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
1 | 1 | ||
2 | (function() { | 2 | (function() { |
3 | 'use strict' | 3 | 'use strict' |
4 | 4 | ||
5 | angular.module('acufuel') | 5 | angular.module('acufuel') |
6 | .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]); | 6 | .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]); |
7 | 7 | ||
8 | function AccountSettingController($scope, $filter, $rootScope, $state, AccountSettingService) { | 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 | AccountSettingService.getProducts().then(function(result) { | 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 | ||
16 | 63 |
app/partials/accountSetting/accountSetting.Service.js
1 | (function(){ | 1 | (function(){ |
2 | 'use strict'; | 2 | 'use strict'; |
3 | angular.module('acufuel') | 3 | angular.module('acufuel') |
4 | .service('AccountSettingService', ['$rootScope', '$q', '$http', '$state', 'BASE_URL', AccountSettingService]); | 4 | .service('AccountSettingService', ['$rootScope', '$q', '$http', '$state', 'BASE_URL', AccountSettingService]); |
5 | 5 | ||
6 | function AccountSettingService($rootScope, $q, $http, $state, BASE_URL) { | 6 | function AccountSettingService($rootScope, $q, $http, $state, BASE_URL) { |
7 | 7 | ||
8 | this.getProducts = function(data) { | 8 | this.getProducts = function() { |
9 | 9 | ||
10 | var deferred = $q.defer(); | 10 | var deferred = $q.defer(); |
11 | $http({ | 11 | $http({ |
12 | method : 'GET', | 12 | method : 'GET', |
13 | url : BASE_URL.url +'/user/products', | 13 | url : BASE_URL.url +'/user/products', |
14 | headers : {'Content-Type': 'application/json'}, | 14 | headers : {'Content-Type': 'application/json'}, |
15 | }) | 15 | }) |
16 | .then(function (result){ | 16 | .then(function (result){ |
17 | deferred.resolve(result.data); | 17 | deferred.resolve(result.data); |
18 | },function (result){ | 18 | },function (result){ |
19 | //console.log(result.data) | 19 | //console.log(result.data) |
20 | deferred.resolve(result.data); | 20 | deferred.resolve(result.data); |
21 | }) | 21 | }) |
22 | return deferred.promise; | 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 | })(); |
app/partials/accountSetting/accountSetting.html
1 | <div class="col-xs-12 col-md-11"> | 1 | <div class="col-xs-12 col-md-11"> |
2 | <div class="row" style="margin-left:0px"> | 2 | <div class="row" style="margin-left:0px"> |
3 | <div class="col-md-5"> | 3 | <div class="col-md-5"> |
4 | <div class="widget"> | 4 | <div class="widget"> |
5 | <div class="widget-header"> | 5 | <div class="widget-header"> |
6 | <i class="fa fa-user" aria-hidden="true"></i> | 6 | <i class="fa fa-user" aria-hidden="true"></i> |
7 | <h3>Account Sertting</h3> | 7 | <h3>Account Sertting</h3> |
8 | </div> | 8 | </div> |
9 | <!-- /widget-header --> | 9 | <!-- /widget-header --> |
10 | <div class="widget-content"> | 10 | <div class="widget-content"> |
11 | <h3 style="color: #666;margin-left: 10px;">Castle & Cooke FBO</h3></br> | 11 | <h3 style="color: #666;margin-left: 10px;">Castle & Cooke FBO</h3></br> |
12 | <form role="form"> | 12 | <form role="form"> |
13 | <div class="col-sm-6"> | 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> | 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="user.firstName" 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="user.lastName" 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 | </div> | 17 | </div> |
18 | 18 | ||
19 | <div class="col-sm-6"> | 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> | 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="number" ng-model="user.phone" placeholder="Phone" 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="number" ng-model="user.mobile" placeholder="Mobile" 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 | </div> | 23 | </div> |
24 | <div class="col-xs-12"> | 24 | <div class="col-xs-12"> |
25 | <div class="col-xs-12"> | 25 | <div class="col-xs-12"> |
26 | <div class="form-group"> | 26 | <div class="form-group"> |
27 | <div class="row"> | 27 | <div class="row"> |
28 | <div class="col-md-5"> | 28 | <div class="col-md-5"> |
29 | <label class="new-input-label"><b>Fuel Types Offered </b></label> | 29 | <label class="new-input-label"><b>Fuel Types Offered </b></label> |
30 | </div> | 30 | </div> |
31 | <div class="col-md-7"> | 31 | <div class="col-md-7" > |
32 | <input type="checkbox" ng-model="data.baseTenant" name="vehicle" value="Bike"> Jet-A: Full Service<br> | 32 | <label ng-repeat="product in productList" style="width: 100%; font-weight: normal;"> |
33 | <input type="checkbox" ng-model="data.fuelerlinxCustomer" name="vehicle" value="Car" checked> Jet-A: w/Additive<br> | 33 | <!-- <input type="checkbox" ng-model="product.status" ng-click="checkProduct(product)"> {{product.name}}<br> --> |
34 | <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> Jet-A: Self Service <br> | 34 | <input type="checkbox" id="Weekdays" ng-model="product.status" ng-click="checkProduct(productList, product, $index)">{{product.name}} |
35 | <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> 100LL: Full Service <br> | 35 | </label> |
36 | <input type="checkbox" ng-model="data.contractFuelVendor" name="vehicle" value="Car" checked> 100LL: Self Service | ||
37 | </div> | 36 | </div> |
38 | </div> | 37 | </div> |
39 | </div> | 38 | </div> |
40 | </div> | 39 | </div> |
41 | </div> | 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 | </form> | 46 | </form> |
43 | </div> | 47 | </div> |
44 | <!-- /widget-content --> | 48 | <!-- /widget-content --> |
45 | </div> | 49 | </div> |
46 | <!-- /widget --> | 50 | <!-- /widget --> |
47 | </div> | 51 | </div> |
48 | <div class="col-md-7"> | 52 | <div class="col-md-7"> |
49 | <div class="widget"> | 53 | <div class="widget"> |
50 | <div class="widget-header"> | 54 | <div class="widget-header"> |
51 | <i class="fa fa-tasks" aria-hidden="true"></i> | 55 | <i class="fa fa-tasks" aria-hidden="true"></i> |
52 | <h3>Additional User Accounts</h3> | 56 | <h3>Additional User Accounts</h3> |
53 | <div class="pull-right"> | 57 | <div class="pull-right"> |
54 | <button type="submit" style="margin-top: 4px;margin-right: 9px;" data-toggle="modal" data-target="#vendor-modal-3" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Contact</button> | 58 | <button type="submit" style="margin-top: 4px;margin-right: 9px;" data-toggle="modal" data-target="#vendor-modal-3" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Contact</button> |
55 | </div> | 59 | </div> |
56 | <div class="clearfix"></div> | 60 | <div class="clearfix"></div> |
57 | </div> | 61 | </div> |
58 | <!-- /widget-header --> | 62 | <!-- /widget-header --> |
59 | <div class="widget-content"> | 63 | <div class="widget-content"> |
60 | <div class="table-responsive"> | 64 | <div class="table-responsive"> |
61 | <table class="table table-bordered table-hover table-striped"> | 65 | <table class="table table-bordered table-hover table-striped"> |
62 | <thead> | 66 | <thead> |
63 | <tr> | 67 | <tr> |
64 | <th></th> | 68 | <th></th> |
65 | <th>First Name</th> | 69 | <th>First Name</th> |
66 | <th>Last Name</th> | 70 | <th>Last Name</th> |
67 | <th>Email Username</th> | 71 | <th>Email Username</th> |
68 | <th>Password</th> | 72 | <th>Password</th> |
69 | <th>Control</th> | 73 | <th>Control</th> |
70 | </tr> | 74 | </tr> |
71 | </thead> | 75 | </thead> |
72 | <tbody> | 76 | <tbody> |
73 | <tr> | 77 | <tr> |
74 | <td rowspan="2">1</td> | 78 | <td rowspan="2">1</td> |
75 | <td>Mark</td> | 79 | <td>Mark</td> |
76 | <td>Otto</td> | 80 | <td>Otto</td> |
77 | <td>otto@email.com</td> | 81 | <td>otto@email.com</td> |
78 | <td>@otto</td> | 82 | <td>@otto</td> |
79 | <td><input id="toggle-one2" checked type="checkbox" data-size="mini" data-width="55" data-toggle="toggle" data-on="Active" data-off="Deactive"></td> | 83 | <td><input id="toggle-one2" checked type="checkbox" data-size="mini" data-width="55" data-toggle="toggle" data-on="Active" data-off="Deactive"></td> |
80 | </tr> | 84 | </tr> |
81 | </tbody> | 85 | </tbody> |
82 | </table> | 86 | </table> |
83 | </div> | 87 | </div> |
84 | </div> | 88 | </div> |
85 | <!-- /widget-content --> | 89 | <!-- /widget-content --> |
86 | </div> | 90 | </div> |
87 | <!-- /widget --> | 91 | <!-- /widget --> |
88 | </div> | 92 | </div> |
89 | <!-- /span6 --> | 93 | <!-- /span6 --> |
90 | </div> | 94 | </div> |
91 | <!-- /widget --> | 95 | <!-- /widget --> |
92 | </div> | 96 | </div> |
93 | <!-- /container --> | 97 | <!-- /container --> |
94 | <div class="clearfix"></div> | 98 | <div class="clearfix"></div> |
95 | 99 |