Commit bb639860c4afc574f05cabbc136e08d944ee42ad
1 parent
28af27a3fe
Exists in
master
account setting page implementation with api
Showing
3 changed files
with
119 additions
and
15 deletions
Show diff stats
app/partials/accountSetting/accountSetting.Controller.js
... | ... | @@ -6,10 +6,57 @@ |
6 | 6 | .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]); |
7 | 7 | |
8 | 8 | function AccountSettingController($scope, $filter, $rootScope, $state, AccountSettingService) { |
9 | - | |
9 | + $scope.addArray = []; | |
10 | + $scope.userData = {}; | |
11 | + $scope.userid = JSON.parse(localStorage.getItem('userProfileId')); | |
12 | + if($scope.userid && $scope.userid != null && $scope.userid != undefined){ | |
13 | + var id = $scope.userid; | |
14 | + AccountSettingService.loginUserData(id).then(function(result) { | |
15 | + $scope.userData = result; | |
16 | + $scope.userData.status = $scope.userData.account.user.status.toLowerCase(); | |
17 | + $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); | |
18 | + }) | |
19 | + } | |
20 | + | |
10 | 21 | AccountSettingService.getProducts().then(function(result) { |
11 | - | |
22 | + $scope.productList = result; | |
23 | + for(var i=0;i<$scope.productList.length;i++){ | |
24 | + var obj = { | |
25 | + id : $scope.productList[i].id, | |
26 | + name : $scope.productList[i].name, | |
27 | + status : $scope.productList[i].status | |
28 | + } | |
29 | + $scope.addArray.push(obj); | |
30 | + } | |
12 | 31 | }) |
32 | + | |
33 | + $scope.productData = {}; | |
34 | + $scope.productData.productList = []; | |
35 | + | |
36 | + $scope.checkProduct = function(productlist, product, index){ | |
37 | + $scope.addArray[index].id = productlist[index].id; | |
38 | + $scope.addArray[index].name = productlist[index].name; | |
39 | + $scope.addArray[index].status = productlist[index].status; | |
40 | + $scope.productData.productList = $scope.addArray; | |
41 | + console.log($scope.productData) | |
42 | + } | |
43 | + | |
44 | + $scope.updateUser = function(){ | |
45 | + | |
46 | + var updateData = "companyName=" + $scope.userData.companyName + "&username=" + $scope.userData.username + "&firstName=" + $scope.userData.firstName | |
47 | + + "&lastName=" + $scope.userData.lastName + "&phone=" + $scope.userData.phone + "&mobile=" + $scope.userData.mobile | |
48 | + + "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid; | |
49 | + | |
50 | + AccountSettingService.updateUserProfile(updateData).then(function(result) { | |
51 | + | |
52 | + AccountSettingService.updateProducts($scope.productData).then(function(result) { | |
53 | + toastr.success(''+result.success+'', { | |
54 | + closeButton: true | |
55 | + }) | |
56 | + }) | |
57 | + | |
58 | + }) | |
59 | + } | |
13 | 60 | } |
14 | 61 | })(); |
15 | 62 | ... | ... |
app/partials/accountSetting/accountSetting.Service.js
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | |
6 | 6 | function AccountSettingService($rootScope, $q, $http, $state, BASE_URL) { |
7 | 7 | |
8 | - this.getProducts = function(data) { | |
8 | + this.getProducts = function() { | |
9 | 9 | |
10 | 10 | var deferred = $q.defer(); |
11 | 11 | $http({ |
... | ... | @@ -22,6 +22,59 @@ |
22 | 22 | return deferred.promise; |
23 | 23 | } |
24 | 24 | |
25 | + this.updateProducts = function(data) { | |
26 | + | |
27 | + var deferred = $q.defer(); | |
28 | + $http({ | |
29 | + method : 'PUT', | |
30 | + url : BASE_URL.url +'/fuelPricing/product', | |
31 | + data : data, | |
32 | + headers : {'Content-Type': 'application/json'}, | |
33 | + }) | |
34 | + .then(function (result){ | |
35 | + deferred.resolve(result.data); | |
36 | + },function (result){ | |
37 | + //console.log(result.data) | |
38 | + deferred.resolve(result.data); | |
39 | + }) | |
40 | + return deferred.promise; | |
41 | + } | |
42 | + | |
43 | + this.loginUserData = function(id) { | |
44 | + | |
45 | + var deferred = $q.defer(); | |
46 | + $http({ | |
47 | + method : 'GET', | |
48 | + url : BASE_URL.url +'/account/user/'+id, | |
49 | + headers : {'Content-Type': 'application/json'}, | |
50 | + }) | |
51 | + .then(function (result){ | |
52 | + deferred.resolve(result.data); | |
53 | + },function (result){ | |
54 | + //console.log(result.data) | |
55 | + deferred.resolve(result.data); | |
56 | + }) | |
57 | + return deferred.promise; | |
58 | + } | |
59 | + | |
60 | + this.updateUserProfile = function(data) { | |
61 | + | |
62 | + var deferred = $q.defer(); | |
63 | + $http({ | |
64 | + method : 'PUT', | |
65 | + url : BASE_URL.url +'/account/updateProfile', | |
66 | + headers : {'Content-Type': 'application/x-www-form-urlencoded'}, | |
67 | + data: data | |
68 | + }) | |
69 | + .then(function (result){ | |
70 | + deferred.resolve(result.data); | |
71 | + },function (result){ | |
72 | + //console.log(result.data) | |
73 | + deferred.resolve(result.data); | |
74 | + }) | |
75 | + return deferred.promise; | |
76 | + } | |
77 | + | |
25 | 78 | } |
26 | 79 | |
27 | 80 | })(); |
28 | 81 | \ No newline at end of file | ... | ... |
app/partials/accountSetting/accountSetting.html
... | ... | @@ -11,15 +11,15 @@ |
11 | 11 | <h3 style="color: #666;margin-left: 10px;">Castle & Cooke FBO</h3></br> |
12 | 12 | <form role="form"> |
13 | 13 | <div class="col-sm-6"> |
14 | - <div class="form-group"><label>Username</label> <input type="email" placeholder="Username" ng-model="user.email" class="form-control"></div> | |
15 | - <div class="form-group"><label>First Name</label> <input type="text" placeholder="First Name" ng-model="user.firstName" class="form-control"></div> | |
16 | - <div class="form-group"><label>Last Name</label> <input type="text" placeholder="Last Name" ng-model="user.lastName" class="form-control"></div> | |
14 | + <div class="form-group"><label>Username</label> <input type="email" placeholder="Username" ng-model="userData.email" class="form-control"></div> | |
15 | + <div class="form-group"><label>First Name</label> <input type="text" placeholder="First Name" ng-model="userData.firstName" class="form-control"></div> | |
16 | + <div class="form-group"><label>Last Name</label> <input type="text" placeholder="Last Name" ng-model="userData.lastName" class="form-control"></div> | |
17 | 17 | </div> |
18 | 18 | |
19 | 19 | <div class="col-sm-6"> |
20 | - <div class="form-group"><label>Password</label> <input type="password" ng-model="user.password" placeholder="Password" class="form-control"></div> | |
21 | - <div class="form-group"><label>Phone</label> <input type="number" ng-model="user.phone" placeholder="Phone" class="form-control"></div> | |
22 | - <div class="form-group"><label>Mobile</label> <input type="number" ng-model="user.mobile" placeholder="Mobile" class="form-control"></div> | |
20 | + <!-- <div class="form-group"><label>Password</label> <input type="password" ng-model="userData.password" placeholder="Password" class="form-control"></div> --> | |
21 | + <div class="form-group"><label>Phone</label> <input type="tel" ng-model="userData.phone" placeholder="Phone" class="form-control"></div> | |
22 | + <div class="form-group"><label>Mobile</label> <input type="tel" ng-model="userData.mobile" placeholder="Mobile" class="form-control"></div> | |
23 | 23 | </div> |
24 | 24 | <div class="col-xs-12"> |
25 | 25 | <div class="col-xs-12"> |
... | ... | @@ -28,17 +28,21 @@ |
28 | 28 | <div class="col-md-5"> |
29 | 29 | <label class="new-input-label"><b>Fuel Types Offered </b></label> |
30 | 30 | </div> |
31 | - <div class="col-md-7"> | |
32 | - <input type="checkbox" ng-model="data.baseTenant" name="vehicle" value="Bike"> Jet-A: Full Service<br> | |
33 | - <input type="checkbox" ng-model="data.fuelerlinxCustomer" name="vehicle" value="Car" checked> Jet-A: w/Additive<br> | |
34 | - <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> Jet-A: Self Service <br> | |
35 | - <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> 100LL: Full Service <br> | |
36 | - <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> 100LL: Self Service | |
31 | + <div class="col-md-7" > | |
32 | + <label ng-repeat="product in productList" style="width: 100%; font-weight: normal;"> | |
33 | + <!-- <input type="checkbox" ng-model="product.status" ng-click="checkProduct(product)"> {{product.name}}<br> --> | |
34 | + <input type="checkbox" id="Weekdays" ng-model="product.status" ng-click="checkProduct(productList, product, $index)">{{product.name}} | |
35 | + </label> | |
37 | 36 | </div> |
38 | 37 | </div> |
39 | 38 | </div> |
40 | 39 | </div> |
41 | 40 | </div> |
41 | + <div class="clearfix"></div> | |
42 | + <div class="row" style="text-align: center;"> | |
43 | + <button type="button" class="btn btn-primary" ng-click="updateUser()">Save</button> | |
44 | + <button type="button" class="btn btn-default">Cancel</button> | |
45 | + </div> | |
42 | 46 | </form> |
43 | 47 | </div> |
44 | 48 | <!-- /widget-content --> | ... | ... |