implemented edit user profile, with images from camera and gallery

This commit is contained in:
arnaucode
2017-01-29 20:54:21 +01:00
parent 70db3f88b9
commit 884a1959ef
19 changed files with 11329 additions and 7 deletions

View File

@@ -8,4 +8,7 @@ server code: https://github.com/arnaucode/carsincommonServer
-page for user to view joins that has done
-allow travel crator to accept join petitions and reject people
-add to travel the date of destination
-user comments and system to profile, to valorate users
-notifications system syncronized
```

View File

@@ -6,6 +6,7 @@
},
"dependencies": {
"angular-material": "^1.1.1",
"ui-leaflet": "^2.0.0"
"ui-leaflet": "^2.0.0",
"ngCordova": "0.1.27-alpha"
}
}

View File

@@ -29,6 +29,12 @@
color: #ffffff;
}
.o_transparentInput{
background: rgba(255, 255, 255, 0);
color: #ffffff;
border: 0px;
width: 80%;
}
.o_userImgCircular {
margin-top: 5%;
background: #ffffff;

View File

@@ -24,6 +24,7 @@
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
<!-- openstreetmaps angular - leaflet -->
@@ -53,6 +54,7 @@
<script src="js/askPackage.js"></script>-->
<script src="js/users.js"></script>
<script src="js/user.js"></script>
<script src="js/editUser.js"></script>
<script src="js/notifications.js"></script>
<script src="js/settings.js"></script>
<script src="js/help.js"></script>

View File

@@ -6,14 +6,15 @@
// 'starter.controllers' is found in controllers.js
var urlapi = "http://localhost:3000/api/";
//var urlapi = "http://localhost:3000/api/";
//var urlapi="https://collectivecar.paas.primustech.io/api/";
//var urlapi="http://147.83.7.158:3000/api/";
var urlapi="http://147.83.7.158:3000/api/";
angular.module('starter', [
'ionic',
'ngMaterial',
'ngCordova',
'pascalprecht.translate',
'app.login',
'app.signup',
@@ -29,6 +30,7 @@ angular.module('starter', [
'app.askPackage',*/
'app.users',
'app.user',
'app.editUser',
'app.notifications',
'app.settings',
'app.help'
@@ -151,6 +153,15 @@ angular.module('starter', [
}
}
})
.state('app.editUser', {
url: '/editUser',
views: {
'menuContent': {
templateUrl: 'templates/editUser.html',
controller: 'EditUserCtrl'
}
}
})
.state('app.notifications', {
url: '/notifications',
views: {

71
www/js/editUser.js Normal file
View File

@@ -0,0 +1,71 @@
angular.module('app.editUser', ['pascalprecht.translate'])
.controller('EditUserCtrl', function($scope, $stateParams, $http, $filter,
$ionicModal, $cordovaCamera, $ionicLoading) {
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
$scope.user=$scope.storageuser;
$scope.selectAvatar = function(){
console.log("img");
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.sourceType,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.user.avatar = "data:image/jpeg;base64," + imageData;
}, function(err) {
console.log(err);
});
};
$scope.selectFaircoinPublicKey = function(){
console.log("img");
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.user.faircoin = "data:image/jpeg;base64," + imageData;
}, function(err) {
console.log(err);
});
};
$scope.update=function(){
$http({
url: urlapi + 'users',
method: "PUT",
data: $scope.user
})
.then(function(data) {
// success
console.log("data: ");
console.log(data.data);
localStorage.setItem("cim_app_userdata", JSON.stringify(data.data));
window.location="#/app/users/" + data.data._id;
},
function(data) { // optional
// failed
$ionicLoading.show({
template: 'Error on update',
noBackdrop: true,
duration: 2000
});
});
};
});

View File

@@ -1,17 +1,27 @@
angular.module('app.user', ['pascalprecht.translate'])
.controller('UserCtrl', function($scope, $stateParams, $http, $filter, $ionicModal) {
.controller('UserCtrl', function($scope, $stateParams, $http,
$ionicLoading, $filter, $ionicModal) {
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
$scope.user={};
$http.get(urlapi + 'users/id/'+$stateParams.userid)
$scope.doRefresh = function(){
$http.get(urlapi + 'users/id/'+$stateParams.userid)
.then(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.user = data.data; // for UI
if($scope.storageuser._id==$scope.user._id)
{
localStorage.setItem("cim_app_userdata", JSON.stringify(data.data));
}
$scope.$broadcast('scroll.refreshComplete');//refresher stop
},function(data, status, headers,config){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
});
};
$scope.doRefresh();

View File

@@ -0,0 +1,55 @@
{
"name": "ngCordova",
"version": "0.1.27-alpha",
"homepage": "http://ngCordova.com/",
"authors": [
"Max Lynch <max@drifty.com>",
"Paolo Bernasconi <paolo.enrico.bernasconi@gmail.com>",
"Chad Campbell <chad.campbell@ecofic.com>"
],
"description": "AngularJS Cordova wrappers for common Cordova plugins.",
"main": [
"./dist/ng-cordova.js"
],
"ignore": [
"**/.*",
"gulpfile.js",
"test",
"src",
"config",
"demo",
"CONTRIBUTING.md",
"CODE_OF_CONDUCT.md"
],
"dependencies": {
"angular": ">= 1.2.23"
},
"keywords": [
"ngCordova",
"ng-cordova",
"ngcordova",
"ng cordova",
"cordova",
"phonegap",
"angular",
"angularjs",
"ionic",
"cordova plugin"
],
"license": "MIT",
"private": false,
"devDependencies": {
"angular": ">= 1.2.23",
"angular-mocks": ">= 1.2.23",
"jquery": "~2.1.1"
},
"_release": "0.1.27-alpha",
"_resolution": {
"type": "version",
"tag": "v0.1.27-alpha",
"commit": "5d0450d887275c70ec227ef9b30e3e3f15646cb9"
},
"_source": "https://github.com/driftyco/ng-cordova.git",
"_target": "0.1.27-alpha",
"_originalSource": "ngCordova"
}

View File

@@ -0,0 +1,7 @@
### 0.1.27-alpha (2016-07-06)
### 0.1.27-alpha (2016-07-06)
Please refer to the [Github ngCordova Releases file](https://github.com/driftyco/ng-cordova/releases) for detailed information.

21
www/lib/ngCordova/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Drifty
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

131
www/lib/ngCordova/README.md Normal file
View File

@@ -0,0 +1,131 @@
[ngCordova](http://ngcordova.com/)
==========
[![Travis](https://img.shields.io/travis/driftyco/ng-cordova.svg?style=flat)](https://travis-ci.org/driftyco/ng-cordova) [![Bower](https://img.shields.io/badge/bower-ngCordova-FFCC2F.svg?style=flat)](http://bower.io/search/?q=ngCordova)
### Cordova with AngularJS Goodness
[<img src="http://ionicframework.com/img/ngcordova-context-logo.png" alt="ngCordova Logo" width="210px" height="210px" />](http://ngcordova.com/)
ngCordova gives you simple AngularJS wrappers for a massive amount of Cordova plugins. Check out the list below for all of the available plugins, and create an issue for a new request.
Created by the [Ionic Framework](http://ionicframework.com/) team and the community.
| RESOURCE | LINK |
|------------|---------|
| **Website** | [ngCordova.com](http://ngcordova.com/) |
| **Docs** | [ngCordova.com/docs](http://ngcordova.com/docs/) |
| **Requirements** | [AngularJS](https://github.com/angular/angular.js), [Cordova](http://cordova.apache.org/) |
| **Install** | `bower install ngCordova` or [download zip file](https://github.com/driftyco/ng-cordova/archive/master.zip) |
| **Custom build** | [ngCordova.com/build](http://ngcordova.com/build/) |
## Installation
Install manually, or from bower:
```bash
$ bower install ngCordova
```
## Plugins `(67+)`
- [Action Sheet](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet)
- [AdMob](https://github.com/floatinghotpot/cordova-plugin-admob) (:warning: share % Ad revenue)
- [App Availability](https://github.com/ohh2ahh/AppAvailability)
- [App Rate](https://github.com/pushandplay/cordova-plugin-apprate)
- [App Version](https://github.com/whiteoctober/cordova-plugin-app-version)
- [Background Geolocation](https://github.com/christocracy/cordova-plugin-background-geolocation)
- [Badge](https://github.com/katzer/cordova-plugin-badge)
- [Barcode Scanner](https://github.com/wildabeast/BarcodeScanner)
- [Battery Status](https://github.com/apache/cordova-plugin-battery-status) *
- [Beacon](https://github.com/petermetz/cordova-plugin-ibeacon)
- [Bluetooth Low Energy](https://github.com/don/cordova-plugin-ble-central)
- [Bluetooth Serial](https://github.com/don/BluetoothSerial)
- [Brightness](https://github.com/fiscal-cliff/phonegap-plugin-brightness)
- [Calendar](https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin)
- [Camera](https://github.com/apache/cordova-plugin-camera) *
- [Clipboard](https://github.com/VersoSolutions/CordovaClipboard)
- [Console](https://github.com/apache/cordova-plugin-console) *
- [Contacts](https://github.com/apache/cordova-plugin-contacts) *
- [Date Picker](https://github.com/VitaliiBlagodir/cordova-plugin-datepicker)
- [Device Motion](https://github.com/apache/cordova-plugin-device-motion) *
- [Device Orientation](https://github.com/apache/cordova-plugin-device-orientation) *
- [Device](https://github.com/apache/cordova-plugin-device) *
- [Dialogs](https://github.com/apache/cordova-plugin-dialogs) *
- [Email Composer](https://github.com/katzer/cordova-plugin-email-composer)
- [Facebook Connect](https://github.com/Wizcorp/phonegap-facebook-plugin)
- [Facebook AudienceNetwork Ads](https://github.com/floatinghotpot/cordova-plugin-facebookads) (:warning: share % Ad revenue)
- [File](https://github.com/apache/cordova-plugin-file) *
- [File Transfer](https://github.com/apache/cordova-plugin-file-transfer) *
- [Flashlight](https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin)
- [Flurry Ads](https://github.com/floatinghotpot/cordova-plugin-flurry) (:warning: share % Ad revenue)
- [Geolocation](https://github.com/apache/cordova-plugin-geolocation) *
- [Globalization](https://github.com/apache/cordova-plugin-globalization) *
- [Google Ads](https://github.com/floatinghotpot/cordova-admob-pro) (:warning: share % Ad revenue)
- [Google Analytics](https://github.com/danwilson/google-analytics-plugin)
- [Google Plus](https://github.com/EddyVerbruggen/cordova-plugin-googleplus)
- [HealthKit for iOS](https://github.com/Telerik-Verified-Plugins/HealthKit)
- [Httpd (Web Server)](https://github.com/floatinghotpot/cordova-httpd)
- [Apple iAd](https://github.com/floatinghotpot/cordova-iad-pro) (:warning: share % Ad revenue)
- [Image Picker](https://github.com/wymsee/cordova-imagePicker)
- [InAppBrowser](https://github.com/apache/cordova-plugin-inappbrowser)*
- [Keyboard](https://github.com/driftyco/ionic-plugin-keyboard)
- [Keychain](https://github.com/shazron/KeychainPlugin)
- [Launch Navigator](https://github.com/dpa99c/phonegap-launch-navigator)
- [Local Notifications](https://github.com/katzer/cordova-plugin-local-notifications/)
- [Media Capture](https://github.com/apache/cordova-plugin-media-capture)
- [Media](https://github.com/apache/cordova-plugin-media) *
- [MillennialMedia Ads](https://github.com/floatinghotpot/cordova-plugin-mmedia) (:warning: share % Ad revenue)
- [MobFox Ads](https://github.com/floatinghotpot/cordova-mobfox-pro) (:warning: share % Ad revenue)
- [MoPub Ads](https://github.com/floatinghotpot/cordova-plugin-mopub) (:warning: share % Ad revenue)
- [Native Audio](https://github.com/SidneyS/cordova-plugin-nativeaudio)
- [Network Information](https://github.com/apache/cordova-plugin-network-information) *
- [Oauth](https://github.com/nraboy/ng-cordova-oauth) (available separately)
- [Pin Dialog](https://github.com/Paldom/PinDialog)
- [Preferences](https://github.com/apla/me.apla.cordova.app-preferences)
- [Printer](https://github.com/katzer/cordova-plugin-printer)
- [Progress Indicator](https://github.com/pbernasconi/cordova-progressIndicator)
- [Push Notifications](https://github.com/phonegap-build/PushPlugin) (**deprecated** - Will be removed in future release)
- [Push Notifications - V5] (https://github.com/phonegap/phonegap-plugin-push)
- [Screenshots](https://github.com/gitawego/cordova-screenshot)
- [Serial](https://github.com/xseignard/cordovarduino)
- [SMS](https://github.com/aharris88/phonegap-sms-plugin)
- [Social Sharing](https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin)
- [Spinner Dialog](https://github.com/Paldom/SpinnerDialog)
- [Splashscreen](https://github.com/apache/cordova-plugin-splashscreen) *
- [SQLite](https://github.com/litehelpers/Cordova-sqlite-storage)
- [StatusBar](https://github.com/apache/cordova-plugin-statusbar) *
- [Toast](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin)
- [Touchid](https://github.com/leecrossley/cordova-plugin-touchid)
- [Vibration](https://github.com/apache/cordova-plugin-vibration) *
- [Video Capture Plus](https://github.com/EddyVerbruggen/VideoCapturePlus-PhoneGap-Plugin) *
- [Zip](https://github.com/MobileChromeApps/cordova-plugin-zip)
`* official Apache Cordova Plugin`
## Authors
#### Max Lynch
- https://twitter.com/maxlynch
- https://github.com/mlynch
#### Paolo Bernasconi
- https://twitter.com/paolobernasconi
- https://github.com/pbernasconi
## Project Maintainer
#### George Stocker
- https://twitter.com/gortok
- https://github.com/gortok
## LICENSE
ngCordova is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.

View File

@@ -0,0 +1,46 @@
{
"name": "ngCordova",
"version": "0.1.27-alpha",
"homepage": "http://ngCordova.com/",
"authors": [
"Max Lynch <max@drifty.com>",
"Paolo Bernasconi <paolo.enrico.bernasconi@gmail.com>",
"Chad Campbell <chad.campbell@ecofic.com>"
],
"description": "AngularJS Cordova wrappers for common Cordova plugins.",
"main": [
"./dist/ng-cordova.js"
],
"ignore": [
"**/.*",
"gulpfile.js",
"test",
"src",
"config",
"demo",
"CONTRIBUTING.md",
"CODE_OF_CONDUCT.md"
],
"dependencies": {
"angular": ">= 1.2.23"
},
"keywords": [
"ngCordova",
"ng-cordova",
"ngcordova",
"ng cordova",
"cordova",
"phonegap",
"angular",
"angularjs",
"ionic",
"cordova plugin"
],
"license": "MIT",
"private": false,
"devDependencies": {
"angular": ">= 1.2.23",
"angular-mocks": ">= 1.2.23",
"jquery": "~2.1.1"
}
}

3486
www/lib/ngCordova/dist/ng-cordova-mocks.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7361
www/lib/ngCordova/dist/ng-cordova.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
{
"name": "ng-cordova",
"private": false,
"main": "dist/ng-cordova",
"version": "0.1.27-alpha",
"repository": {
"url": "git://github.com/driftyco/ng-cordova.git"
},
"devDependencies": {
"gulp": "^3.7.0",
"gulp-concat": "^2.2.0",
"gulp-footer": "^1.0.4",
"gulp-header": "^1.0.2",
"gulp-jscs": "^1.6.0",
"gulp-jshint": "^1.6.1",
"gulp-prettify": "^0.3.0",
"gulp-rename": "^1.2.0",
"gulp-shell": "^0.2.10",
"gulp-uglify": "^0.2.1",
"jasmine-core": "^2.4.1",
"jshint-stylish": "^0.4.0",
"karma": "^0.13.21",
"karma-chrome-launcher": "~0.2.2",
"karma-coverage": "~0.5.3",
"karma-jasmine": "~0.3.7",
"karma-phantomjs-launcher": "~1.0.0",
"minimist": "^0.1.0",
"phantomjs-prebuilt": "^2.1.4"
},
"licenses": [
{
"type": "MIT"
}
],
"scripts": {
"test": "gulp lint && gulp karma --browsers=PhantomJS --reporters=progress"
},
"dependencies": {
"conventional-changelog": "0.0.11",
"fs": "0.0.2",
"gulp-git": "^1.2.4",
"q": "^1.1.2"
}
}

View File

@@ -0,0 +1,44 @@
<ion-view view-title="{{'Edit user' | translate}} {{user.username}}">
<ion-content class="has-footer">
<div class="o_userProfileBackground">
<img ng-src="{{user.avatar}}" class="o_userImgCircular"
ng-click="selectAvatar()"/>
<h3 class="o_text_white">{{user.username}}</h3>
<p>
<input ng-model="user.description" class="o_transparentInput"
placeholder="{{'Description' | translate}}">
</p>
<p>
<input ng-model="user.email" class="o_transparentInput"
placeholder="{{'Email' | translate}}">
</p>
<p ng-show="storageuser._id==user._id">
<md-button class="o_purple300" ng-click="update()">
Update profile
</md-button>
</p>
</div>
<div class="">
<div class="row">
<a class="tab-item">
<i class="icon ion-paper-airplane"></i>
@
<input style="display: inline-block;" type="text" ng-model="user.telegram" placeholder="{{'Telegram' | translate}}">
</a>
<a class="tab-item">
<i class="icon ion-android-car"></i>
{{user.travels.length}} Travels
</a>
<a class="tab-item">
<i class="icon ion-ios-heart"></i>
{{user.favs.length}} favs
</a>
</div>
</div>
<div class="item">
<img src="{{user.faircoin}}" style="width: 100%;"
ng-click="selectFaircoinPublicKey()" />
</div>
</ion-content>
</ion-view>

View File

@@ -1,10 +1,17 @@
<ion-view view-title="{{'User' | translate}} {{user.username}}">
<ion-content class="has-footer">
<ion-refresher
pulling-text="{{'Pull_to_refresh' | translate}}..."
on-refresh="doRefresh()">
</ion-refresher>
<div class="o_userProfileBackground">
<img ng-src="{{user.avatar}}" class="o_userImgCircular" />
<h3 class="o_text_white">{{user.username}}</h3>
<p>{{user.description}}</p>
<p>{{user.email}}</p>
<p ng-show="storageuser._id==user._id">
<md-button class="o_grey500" ng-href="#/app/editUser">Edit profile</md-button>
</p>
</div>
<div class="">
<div class="row">
@@ -38,7 +45,7 @@
</div>
</div>
<div class="item">
<img src="img/faircoinpublickey_sample.png" style="width: 100%;" />
<img src="{{user.faircoin}}" style="width: 100%;" />
</div>
<div class="item item-body">
{{'current_publications_of' | translate}} {{user.username}}: