trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mitchell...@apache.org
Subject [trafficcontrol] branch master updated: Removed restangular from TrafficPortalService (#3634)
Date Fri, 07 Jun 2019 19:42:25 GMT
This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new d9ff3be  Removed restangular from TrafficPortalService (#3634)
d9ff3be is described below

commit d9ff3be61caa5ee70abf7451707a422ae148fde2
Author: ocket8888 <ocket8888@gmail.com>
AuthorDate: Fri Jun 7 13:42:19 2019 -0600

    Removed restangular from TrafficPortalService (#3634)
    
    * Removed restangular from ./TrafficPortalService.js
    
    * Fixed some service methods not throwing in error handlers
---
 .../app/src/common/api/TrafficPortalService.js     | 66 ++++++++++------------
 1 file changed, 31 insertions(+), 35 deletions(-)

diff --git a/traffic_portal/app/src/common/api/TrafficPortalService.js b/traffic_portal/app/src/common/api/TrafficPortalService.js
index 11b5cbc..cec27e6 100644
--- a/traffic_portal/app/src/common/api/TrafficPortalService.js
+++ b/traffic_portal/app/src/common/api/TrafficPortalService.js
@@ -17,33 +17,28 @@
  * under the License.
  */
 
-var TrafficPortalService = function($http, $q, messageModel, ENV) {
+var TrafficPortalService = function($http, messageModel, ENV) {
 
     this.getReleaseVersionInfo = function() {
-        var deferred = $q.defer();
-        $http.get('traffic_portal_release.json')
-            .then(
-                function(result) {
-                    deferred.resolve(result);
-                },
-                function(fault) {
-                    deferred.reject(fault);
-                }
-            );
-
-        return deferred.promise;
+        return $http.get('traffic_portal_release.json').then(
+            function(result) {
+                return result;
+            },
+            function(err) {
+                throw err;
+            }
+        );
     };
 
     this.getProperties = function() {
-        var deferred = $q.defer();
-        $http.get('traffic_portal_properties.json')
-            .then(
-                function(result) {
-                    deferred.resolve(result.data.properties);
-                }
-            );
-
-        return deferred.promise;
+        return $http.get('traffic_portal_properties.json').then(
+            function(result) {
+                return result.data.properties;
+            },
+            function (err) {
+                throw err;
+            }
+        );
     };
 
     this.dbDump = function() {
@@ -51,22 +46,23 @@ var TrafficPortalService = function($http, $q, messageModel, ENV) {
         responseType=arraybuffer is important if you want to create a blob of your data
         See: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
         */
-        $http.get(ENV.api['root'] + 'dbdump', { responseType:'arraybuffer' } )
-            .then(
-                function(result) {
-                    download(result.data, moment().format() + '.pg_dump');
-                },
-                function(fault) {
-                    if (fault && fault.alerts && fault.alerts.length >
0) {
-                        messageModel.setMessages(fault.alerts, false);
-                    } else {
-                        messageModel.setMessages([ { level: 'error', text: fault.status.toString()
+ ': ' + fault.statusText } ], false);
-                    }
+        return $http.get(ENV.api['root'] + 'dbdump', { responseType:'arraybuffer' } ).then(
+            function(result) {
+                download(result.data, moment().format() + '.pg_dump');
+                return result;
+            },
+            function(err) {
+                if (err && err.alerts && err.alerts.length > 0) {
+                    messageModel.setMessages(err.alerts, false);
+                } else {
+                    messageModel.setMessages([ { level: 'error', text: err.status.toString()
+ ': ' + err.statusText } ], false);
                 }
-            );
+                throw err;
+            }
+        );
     };
 
 };
 
-TrafficPortalService.$inject = ['$http', '$q', 'messageModel', 'ENV'];
+TrafficPortalService.$inject = ['$http', 'messageModel', 'ENV'];
 module.exports = TrafficPortalService;


Mime
View raw message