You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2019/07/26 21:57:14 UTC

[trafficcontrol] branch master updated: Removed restangular from CoordinateService (#3609)

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 d1cc708  Removed restangular from CoordinateService (#3609)
d1cc708 is described below

commit d1cc708596df2e6860b58a9e1bb2ad4f1a62bdcd
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Fri Jul 26 15:57:08 2019 -0600

    Removed restangular from CoordinateService (#3609)
    
    * Removed restangular from ./CoordinateService.js
    
    * Fixed some service methods not throwing in error handlers
---
 .../app/src/common/api/CoordinateService.js        | 88 ++++++++++------------
 1 file changed, 41 insertions(+), 47 deletions(-)

diff --git a/traffic_portal/app/src/common/api/CoordinateService.js b/traffic_portal/app/src/common/api/CoordinateService.js
index ed1fa72..fff1678 100644
--- a/traffic_portal/app/src/common/api/CoordinateService.js
+++ b/traffic_portal/app/src/common/api/CoordinateService.js
@@ -17,66 +17,60 @@
  * under the License.
  */
 
-var CoordinateService = function($http, $q, Restangular, locationUtils, messageModel, ENV) {
+var CoordinateService = function($http, locationUtils, messageModel, ENV) {
 
     this.getCoordinates = function(queryParams) {
-        return Restangular.all('coordinates').getList(queryParams);
+        return $http.get(ENV.api['root'] + 'coordinates', {params: queryParams}).then(
+            function(result) {
+                return result.data.response;
+            },
+            function (err) {
+                throw err;
+            }
+        );
     };
 
     this.createCoordinate = function(coordinate) {
-        var request = $q.defer();
-
-        $http.post(ENV.api['root'] + "coordinates", coordinate)
-            .then(
-                function(response) {
-                    messageModel.setMessages(response.data.alerts, true);
-                    locationUtils.navigateToPath('/coordinates');
-                    request.resolve(response);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false)
-                    request.reject(fault);
-                }
-            );
-
-        return request.promise;
+        return $http.post(ENV.api['root'] + "coordinates", coordinate).then(
+            function(response) {
+                messageModel.setMessages(response.data.alerts, true);
+                locationUtils.navigateToPath('/coordinates');
+                return response;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false)
+                throw err;
+            }
+        );
     };
 
     this.updateCoordinate = function(id, coordinate) {
-        var request = $q.defer();
-
-        $http.put(ENV.api['root'] + "coordinates?id=" + id, coordinate)
-            .then(
-                function(response) {
-                    messageModel.setMessages(response.data.alerts, false);
-                    request.resolve();
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                    request.reject();
-                }
-            );
-        return request.promise;
+        return $http.put(ENV.api['root'] + "coordinates", coordinate, {params: {id: id}}).then(
+            function(response) {
+                messageModel.setMessages(response.data.alerts, false);
+                return response;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
+            }
+        );
     };
 
     this.deleteCoordinate = function(id) {
-        var deferred = $q.defer();
-
-        $http.delete(ENV.api['root'] + "coordinates?id=" + id)
-            .then(
-                function(response) {
-                    messageModel.setMessages(response.data.alerts, true);
-                    deferred.resolve(response);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                    deferred.reject(fault);
-                }
-            );
-        return deferred.promise;
+        return $http.delete(ENV.api['root'] + "coordinates", {params: {id: id}}).then(
+            function(response) {
+                messageModel.setMessages(response.data.alerts, true);
+                return response;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
+            }
+        );
     };
 
 };
 
-CoordinateService.$inject = ['$http', '$q', 'Restangular', 'locationUtils', 'messageModel', 'ENV'];
+CoordinateService.$inject = ['$http', 'locationUtils', 'messageModel', 'ENV'];
 module.exports = CoordinateService;