Commit 47541162edfd61e732f3f09ea6972c70b1ef6e28

Authored by Mr. Hot Foods
1 parent 976f0b4a87
Exists in master

airport upload prgress bar'

app/scripts/config.js
... ... @@ -72,6 +72,154 @@ function config($stateProvider, $urlRouterProvider) {
72 72 angular
73 73 .module('acuefuel')
74 74 .config(config)
75   - .run(function($rootScope, $state) {
  75 + .run(['$rootScope', '$state', 'UpdateAirportService', function($rootScope, $state, UpdateAirportService) {
76 76 $rootScope.$state = $state;
77   - });
78 77 \ No newline at end of file
  78 + $rootScope.record = {}
  79 +
  80 +
  81 + // var progress1 = "";
  82 + // $(document).ready(function() {
  83 + // progress1 = setInterval(function(){
  84 + // progressBar();
  85 + // }, 3000);
  86 +
  87 + // function progressBar(){
  88 + // setInterval (function(){
  89 + // $('.progress .progress-bar').progressbar({
  90 + // display_text: 'none'
  91 + // });
  92 + // },1)
  93 + // }
  94 + // });
  95 +
  96 + getAllUploadProgress();
  97 + function getAllUploadProgress() {
  98 + UpdateAirportService.getAllUploadProgress().then(function(result) {
  99 + console.log("all results ",result)
  100 + for(var i =0 ; i<result.length; i++){
  101 + if(result[i].filetype == 'Airports'){
  102 + $rootScope.record.AirportCount = result[i].progress
  103 + $rootScope.record.AirportStatus = result[i].status
  104 + }
  105 + else if(result[i].filetype == 'Countries'){
  106 + $rootScope.record.CountriesCount = result[i].progress
  107 + $rootScope.record.CountriesStatus = result[i].status
  108 + }
  109 + else if(result[i].filetype == 'SubdivisionStates'){
  110 + $rootScope.record.SubdivisionStatesCount = result[i].progress
  111 + $rootScope.record.SubdivisionStatesStatus = result[i].status
  112 + }
  113 + else if(result[i].filetype == 'FBOHandlerDetail'){
  114 + $rootScope.record.FBOHandlerDetailCount = result[i].progress
  115 + $rootScope.record.FBOHandlerDetailStatus = result[i].status
  116 + }
  117 + else if(result[i].filetype == 'SupplierDetail'){
  118 + $rootScope.record.SupplierDetailCount = result[i].progress
  119 + $rootScope.record.SupplierDetailStatus = result[i].status
  120 +
  121 + }
  122 + }
  123 +
  124 + })
  125 +
  126 + }
  127 +
  128 +
  129 +
  130 + var filetypeA = localStorage.getItem('filetypeA')
  131 + var filetypeC = localStorage.getItem('filetypeC')
  132 + var filetypeSS = localStorage.getItem('filetypeSS')
  133 + var filetypeFBO = localStorage.getItem('filetypeFBO')
  134 + var filetypeSD = localStorage.getItem('filetypeSD')
  135 +
  136 + if(filetypeA != null)
  137 + var uploadStatusA =filetypeA.split(",")[1];
  138 + if(filetypeC != null)
  139 + var uploadStatusC =filetypeC.split(",")[1];
  140 + if(filetypeSS != null)
  141 + var uploadStatusSS =filetypeSS.split(",")[1];
  142 + if(filetypeFBO != null)
  143 + var uploadStatusFBO =filetypeFBO.split(",")[1];
  144 + if(filetypeSD != null)
  145 + var uploadStatusSD =filetypeSD.split(",")[1];
  146 +
  147 +
  148 +
  149 + if(uploadStatusA != 'Completed' || uploadStatusC != 'Completed' || uploadStatusSS != 'Completed' || uploadStatusFBO != 'Completed' || uploadStatusSD != 'Completed'){
  150 + var uploadProgress = setInterval(function(){
  151 + uploadData();
  152 + }, 500);
  153 +
  154 + function uploadData() {
  155 + if(filetypeA != null && filetypeA.split(",")[0] == 'Airports'){
  156 + UpdateAirportService.getUploadProgress(filetypeA.split(",")[0]).then(function(result) {
  157 + if(result != null){
  158 + $rootScope.record.AirportCount = result.progress
  159 + $rootScope.record.AirportStatus = result.status
  160 + if($rootScope.record.AirportStatus == 'Completed' || $rootScope.record.AirportStatus == 'Error'){
  161 + $rootScope.showAirports = true;
  162 + localStorage.removeItem('filetypeA');
  163 + localStorage.removeItem('airportLoader');
  164 + }
  165 + }
  166 + })
  167 + }
  168 + if(filetypeC != null && filetypeC.split(",")[0] == 'Countries'){
  169 + UpdateAirportService.getUploadProgress(filetypeC.split(",")[0]).then(function(result) {
  170 + if(result != null){
  171 + $rootScope.record.CountriesCount = result.progress
  172 + $rootScope.record.CountriesStatus = result.status
  173 + if($rootScope.record.CountriesStatus == 'Completed' || $rootScope.record.CountriesStatus == 'Error'){
  174 + $rootScope.showCountries = true;
  175 + localStorage.removeItem('filetypeC');
  176 + localStorage.removeItem('countryLoader');
  177 + }
  178 +
  179 + }
  180 + })
  181 + }
  182 + if(filetypeSS != null && filetypeSS.split(",")[0] == 'SubdivisionStates'){
  183 + UpdateAirportService.getUploadProgress(filetypeSS.split(",")[0]).then(function(result) {
  184 + if(result != null){
  185 + $rootScope.record.SubdivisionStatesCount = result.progress
  186 + $rootScope.record.SubdivisionStatesStatus = result.status
  187 + if($rootScope.record.SubdivisionStatesStatus == 'Completed' || $rootScope.record.SubdivisionStatesStatus == 'Error'){
  188 + $rootScope.subDivState = true;
  189 + localStorage.removeItem('filetypeSS');
  190 + localStorage.removeItem('subDivStateLoader');
  191 + }
  192 + }
  193 + })
  194 + }
  195 + if(filetypeFBO != null && filetypeFBO.split(",")[0] == 'FBOHandlerDetail'){
  196 + UpdateAirportService.getUploadProgress(filetypeFBO.split(",")[0] ).then(function(result) {
  197 + if(result != null){
  198 + $rootScope.record.FBOHandlerDetailCount = result.progress
  199 + $rootScope.record.FBOHandlerDetailStatus = result.status
  200 + if($rootScope.record.FBOHandlerDetailStatus == 'Completed' || $rootScope.record.FBOHandlerDetailStatus == 'Error'){
  201 + $rootScope.fboHandlerDetail = true;
  202 + localStorage.removeItem('filetypeFBO');
  203 + localStorage.removeItem('fboHandleLoader');
  204 + }
  205 + }
  206 + })
  207 + }
  208 + if(filetypeSD != null && filetypeSD.split(",")[0] == 'SupplierDetail'){
  209 + UpdateAirportService.getUploadProgress(filetypeSD.split(",")[0]).then(function(result) {
  210 + if(result != null){
  211 + $rootScope.record.SupplierDetailCount = result.progress
  212 + $rootScope.record.SupplierDetailStatus = result.status
  213 + if($rootScope.record.SupplierDetailStatus == 'Completed' || $rootScope.record.SupplierDetailStatus == 'Error'){
  214 + $rootScope.suppDetail = true;
  215 + localStorage.removeItem('filetypeSD');
  216 + localStorage.removeItem('suppDetailLoader');
  217 + }
  218 + }
  219 + })
  220 + }
  221 + }
  222 + }else if(uploadStatusA == 'Completed' || uploadStatusC == 'Completed' || uploadStatusSS == 'Completed' || uploadStatusFBO == 'Completed' || uploadStatusSD == 'Completed'){
  223 + clearInterval(uploadProgress);
  224 + }
  225 +
  226 + }]);
79 227 \ No newline at end of file
... ...
app/scripts/constant.js
... ... @@ -4,5 +4,7 @@
4 4 angular.module('acuefuel')
5 5  
6 6 .constant('BE', {
7   - url: 'http://54.149.169.33:8080/ws'
  7 + // url: 'http://54.149.169.33:8080/ws'
  8 + // url: 'http://192.168.1.175:8080/ws'
  9 + url: 'http://192.168.2.137:8080/ws'
8 10 });
... ...
app/views/update-airports/update-airports.html
... ... @@ -13,7 +13,7 @@
13 13 <table class="table table-bordered ">
14 14 <thead>
15 15 <tr class="grad">
16   - <th style="background-color: transparent;" colspan="3">
  16 + <th style="background-color: transparent;" colspan="5">
17 17 <i class="fa fa-list" aria-hidden="true"></i>
18 18 <span style="font-size: 15px;font-weight: initial;margin-left: 5px;">Update Airport Data</span>
19 19 </th>
... ... @@ -22,6 +22,8 @@
22 22 <th style="background-color: transparent;">Table</th>
23 23 <th style="background-color: transparent;">Drop Zone</th>
24 24 <th style="background-color: transparent;">Updated</th>
  25 + <th style="background-color: transparent;">Status</th>
  26 + <th style="background-color: transparent;">Records</th>
25 27 </tr>
26 28 </thead>
27 29 <tbody>
... ... @@ -40,8 +42,11 @@
40 42 <div class="bounce2"></div>
41 43 <div class="bounce3"></div>
42 44 </div>
  45 +
43 46 </td>
44 47 <td>{{newDate}}</td>
  48 + <td>{{record.AirportStatus}}</td>
  49 + <td>{{record.AirportCount}}</td>
45 50 </tr>
46 51 <tr style="background: #fff;">
47 52 <td>Countries</td>
... ... @@ -60,6 +65,8 @@
60 65 </div>
61 66 </td>
62 67 <td>{{newDate}}</td>
  68 + <td>{{record.CountriesStatus}}</td>
  69 + <td>{{record.CountriesCount}}</td>
63 70 </tr>
64 71 <tr style="background: #f9f9f9;">
65 72 <td>FBOHandlerDetail</td>
... ... @@ -78,6 +85,8 @@
78 85 </div>
79 86 </td>
80 87 <td>{{newDate}}</td>
  88 + <td>{{record.FBOHandlerDetailStatus}}</td>
  89 + <td>{{record.FBOHandlerDetailCount}}</td>
81 90 </tr>
82 91 <tr style="background: #fff;">
83 92 <td>SubdivisionStates</td>
... ... @@ -96,6 +105,8 @@
96 105 </div>
97 106 </td>
98 107 <td>{{newDate}}</td>
  108 + <td>{{record.SubdivisionStatesStatus}}</td>
  109 + <td>{{record.SubdivisionStatesCount}}</td>
99 110 </tr>
100 111 <tr style="background: #f9f9f9;">
101 112 <td>SupplierDetail</td>
... ... @@ -114,6 +125,8 @@
114 125 </div>
115 126 </td>
116 127 <td>{{newDate}}</td>
  128 + <td>{{record.SupplierDetailStatus}}</td>
  129 + <td>{{record.SupplierDetailCount}}</td>
117 130 </tr>
118 131 </tbody>
119 132 </table>
... ...
app/views/update-airports/updateAirportController.js
... ... @@ -14,16 +14,19 @@ angular.module(&#39;acuefuel&#39;)
14 14 }else{
15 15 $scope.showAirports = true;
16 16 }
  17 + console.log(localStorage.getItem('countryLoader'))
17 18 if(localStorage.getItem('countryLoader') == 'false'){
18 19 $scope.showCountries = false;
19 20 }else{
20 21 $scope.showCountries = true;
21 22 }
  23 + console.log(localStorage.getItem('fboHandleLoader'))
22 24 if(localStorage.getItem('fboHandleLoader') == 'false'){
23 25 $scope.fboHandlerDetail = false;
24 26 }else{
25 27 $scope.fboHandlerDetail = true;
26 28 }
  29 + console.log(localStorage.getItem('subDivStateLoader'))
27 30 if(localStorage.getItem('subDivStateLoader') == 'false'){
28 31 $scope.subDivState = false;
29 32 }else{
... ... @@ -53,7 +56,7 @@ angular.module(&#39;acuefuel&#39;)
53 56 $scope.importAirportData = function(fileName) {
54 57 $scope.showAirports = false;
55 58 window.localStorage.setItem('airportLoader', false);
56   - console.log(fileName)
  59 + console.log("fileName --- ",fileName)
57 60 if(fileName.name != undefined){
58 61 $scope.dropName = false;
59 62 $scope.selectedFile = fileName;
... ... @@ -66,11 +69,11 @@ angular.module(&#39;acuefuel&#39;)
66 69 var fileCheck = $scope.data.airportFile.name.split('.')[1];
67 70 console.log(fileCheck)
68 71 if(fileCheck == 'csv'){
  72 + $scope.setFileTypeLocal("Airports")
69 73 UpdateAirportService.updateAirportData($scope.data).then(function(result) {
70   - localStorage.removeItem('airportLoader');
  74 + // localStorage.removeItem('airportLoader');
71 75 $scope.showAirports = true;
72   - console.log(result)
73   - toastr.success('Copied', {
  76 + toastr.success('File Upload Successfully', {
74 77 closeButton: true
75 78 })
76 79 }, function (err) {
... ... @@ -109,10 +112,12 @@ angular.module(&#39;acuefuel&#39;)
109 112 var fileCheck = $scope.supplierData.supplierDetailFile.name.split('.')[1];
110 113 console.log(fileCheck)
111 114 if(fileCheck == 'csv'){
  115 + $scope.setFileTypeLocal("SupplierDetail")
112 116 UpdateAirportService.updateSupplierDetail($scope.supplierData).then(function(result) {
113 117 console.log(result)
114 118 $scope.suppDetail = true;
115   - localStorage.removeItem('suppDetailLoader');
  119 + // localStorage.removeItem('suppDetailLoader');
  120 + console.log("row count ",result)
116 121 toastr.success('File Upload Successfully', {
117 122 closeButton: true
118 123 })
... ... @@ -151,10 +156,11 @@ angular.module(&#39;acuefuel&#39;)
151 156 var fileCheck = $scope.countryData.countrieFile.name.split('.')[1];
152 157 console.log(fileCheck)
153 158 if(fileCheck == 'csv'){
  159 + $scope.setFileTypeLocal("Countries")
154 160 UpdateAirportService.updateCountries($scope.countryData).then(function(result) {
155 161 console.log(result)
156 162 $scope.showCountries = true;
157   - localStorage.removeItem('countryLoader');
  163 + // localStorage.removeItem('countryLoader');
158 164 toastr.success('File Upload Successfully', {
159 165 closeButton: true
160 166 })
... ... @@ -193,14 +199,15 @@ angular.module(&#39;acuefuel&#39;)
193 199 var fileCheck = $scope.subDivisionData.subDivisionStateFile.name.split('.')[1];
194 200 console.log(fileCheck)
195 201 if(fileCheck == 'csv'){
  202 + $scope.setFileTypeLocal("SubdivisionStates")
196 203 UpdateAirportService.updateSubDivisionState($scope.subDivisionData).then(function(result) {
197   - console.log(result)
198   - localStorage.removeItem('subDivStateLoader');
  204 + // localStorage.removeItem('subDivStateLoader');
199 205 $scope.subDivState = true;
200 206 toastr.success('File Upload Successfully', {
201 207 closeButton: true
202 208 })
203   - }, function (err) {
  209 + }, function (error) {
  210 + console.log("err",error)
204 211 localStorage.removeItem('subDivStateLoader');
205 212 $scope.subDivState = true;
206 213 toastr.error('Error in uploading', {
... ... @@ -235,9 +242,10 @@ angular.module(&#39;acuefuel&#39;)
235 242 var fileCheck = $scope.fboHandlerData.FBOHandlerFile.name.split('.')[1];
236 243 console.log(fileCheck)
237 244 if(fileCheck == 'csv'){
  245 + $scope.setFileTypeLocal("FBOHandlerDetail")
238 246 UpdateAirportService.updateFBOHandler($scope.fboHandlerData).then(function(result) {
239 247 console.log(result)
240   - localStorage.removeItem('fboHandleLoader');
  248 + // localStorage.removeItem('fboHandleLoader');
241 249 $scope.fboHandlerDetail = true;
242 250 toastr.success('File Upload Successfully', {
243 251 closeButton: true
... ... @@ -258,5 +266,61 @@ angular.module(&#39;acuefuel&#39;)
258 266 })
259 267 }
260 268 }
  269 +
  270 +
  271 + // $scope.getAllUploadProgress = function(){
  272 + // UpdateAirportService.getAllUploadProgress().then(function(result) {
  273 + // console.log("all results ",result)
  274 + // for(var i =0 ; i<result.length; i++){
  275 + // if(result[i].filetype == 'Airports'){
  276 + // $scope.record.AirportCount = result[i].progress
  277 + // $scope.record.AirportStatus = result[i].status
  278 + // }
  279 + // else if(result[i].filetype == 'Countries'){
  280 + // $scope.record.CountriesCount = result[i].progress
  281 + // $scope.record.CountriesStatus = result[i].status
  282 + // }
  283 + // else if(result[i].filetype == 'SubdivisionStates'){
  284 + // $scope.record.SubdivisionStatesCount = result[i].progress
  285 + // $scope.record.SubdivisionStatesStatus = result[i].status
  286 + // }
  287 + // else if(result[i].filetype == 'FBOHandlerDetail'){
  288 + // $scope.record.FBOHandlerDetailCount = result[i].progress
  289 + // $scope.record.FBOHandlerDetailStatus = result[i].status
  290 + // }
  291 + // else if(result[i].filetype == 'SupplierDetail'){
  292 + // $scope.record.SupplierDetailCount = result[i].progress
  293 + // $scope.record.SupplierDetailStatus = result[i].status
  294 +
  295 + // }
  296 + // }
  297 +
  298 + // })
  299 +
  300 + // }
  301 + // $scope.getAllUploadProgress();
  302 +
  303 + $scope.setFileTypeLocal = function(value){
  304 + if(value == 'Airports'){
  305 + window.localStorage.setItem('filetypeA', value+",InProgress")
  306 + }
  307 + else if(value == 'Countries'){
  308 + window.localStorage.setItem('filetypeC', value+",InProgress")
  309 + }
  310 + else if(value == 'SubdivisionStates'){
  311 + window.localStorage.setItem('filetypeSS', value+",InProgress")
  312 + }
  313 + else if(value == 'FBOHandlerDetail'){
  314 + window.localStorage.setItem('filetypeFBO', value+",InProgress")
  315 + }
  316 + else if(value == 'SupplierDetail'){
  317 + window.localStorage.setItem('filetypeSD', value+",InProgress")
  318 + }
  319 +
  320 +
  321 +
  322 + }
  323 +
  324 +
261 325  
262 326 })
263 327 \ No newline at end of file
... ...
app/views/update-airports/updateAirportService.js
... ... @@ -22,10 +22,11 @@
22 22 headers : {'Content-Type': undefined},
23 23 data : fd
24 24 })
25   - .success(function(result) {
  25 + .then(function (result){
  26 + deferred.resolve(result);
  27 + },function (result){
  28 + console.log(result)
26 29 deferred.resolve(result);
27   - }).error(function(error){
28   - deferred.reject(error);
29 30 })
30 31 return deferred.promise;
31 32 }
... ... @@ -46,10 +47,11 @@
46 47 headers : {'Content-Type': undefined},
47 48 data : fd
48 49 })
49   - .success(function(result) {
  50 + .then(function (result){
  51 + deferred.resolve(result);
  52 + },function (result){
  53 + console.log(result)
50 54 deferred.resolve(result);
51   - }).error(function(error){
52   - deferred.reject(error);
53 55 })
54 56 return deferred.promise;
55 57 }
... ... @@ -66,14 +68,15 @@
66 68 $http({
67 69 method : 'POST',
68 70 transformRequest: angular.identity,
69   - url : BE.url +'/airport/upload/updateCountries',
  71 + url : BE.url +'/airport/upload/countries',
70 72 headers : {'Content-Type': undefined},
71 73 data : fd
72 74 })
73   - .success(function(result) {
  75 + .then(function (result){
  76 + deferred.resolve(result);
  77 + },function (result){
  78 + console.log(result)
74 79 deferred.resolve(result);
75   - }).error(function(error){
76   - deferred.reject(error);
77 80 })
78 81 return deferred.promise;
79 82 }
... ... @@ -94,13 +97,16 @@
94 97 headers : {'Content-Type': undefined},
95 98 data : fd
96 99 })
97   - .success(function(result) {
  100 + .then(function (result){
  101 + deferred.resolve(result);
  102 + },function (result){
  103 + console.log(result)
98 104 deferred.resolve(result);
99   - }).error(function(error){
100   - deferred.reject(error);
101 105 })
102 106 return deferred.promise;
103 107 }
  108 +
  109 +
104 110  
105 111 this.updateFBOHandler = function(data) {
106 112  
... ... @@ -118,13 +124,47 @@
118 124 headers : {'Content-Type': undefined},
119 125 data : fd
120 126 })
121   - .success(function(result) {
  127 + .then(function (result){
  128 + deferred.resolve(result);
  129 + },function (result){
  130 + console.log(result)
122 131 deferred.resolve(result);
123   - }).error(function(error){
124   - deferred.reject(error);
125 132 })
126 133 return deferred.promise;
127 134 }
  135 +
  136 + this.getUploadProgress = function(filetype) {
  137 +
  138 + var deferred = $q.defer();
  139 + $http({
  140 + method : 'GET',
  141 + url : BE.url +'/airport/export/records/'+filetype,
  142 + })
  143 + .then(function (result){
  144 + deferred.resolve(result.data);
  145 + },function (result){
  146 + deferred.resolve(result.data);
  147 + })
  148 + return deferred.promise;
  149 + }
  150 +
  151 + this.getAllUploadProgress = function(filetype) {
  152 +
  153 + var deferred = $q.defer();
  154 + $http({
  155 + method : 'GET',
  156 + url : BE.url +'/airport/export/records',
  157 + })
  158 + .then(function (result){
  159 + deferred.resolve(result.data);
  160 + },function (result){
  161 + deferred.resolve(result.data);
  162 + })
  163 + return deferred.promise;
  164 + }
  165 +
  166 +
  167 +
128 168 }
129 169  
130 170 })();
131 171 \ No newline at end of file
... ...