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 1a02d1d  Removed restangular from PhysLocationService (#3624)
1a02d1d is described below

commit 1a02d1dc1b6638f68f1981868ad4934b98f4debf
Author: ocket8888 <[email protected]>
AuthorDate: Wed Aug 21 13:26:57 2019 -0600

    Removed restangular from PhysLocationService (#3624)
    
    * Removed restangular from ./PhysLocationService.js
    
    * Fixed some service methods not throwing in error handlers
---
 .../app/src/common/api/PhysLocationService.js      | 82 +++++++++++++---------
 1 file changed, 49 insertions(+), 33 deletions(-)

diff --git a/traffic_portal/app/src/common/api/PhysLocationService.js 
b/traffic_portal/app/src/common/api/PhysLocationService.js
index 13729c5..e9924de 100644
--- a/traffic_portal/app/src/common/api/PhysLocationService.js
+++ b/traffic_portal/app/src/common/api/PhysLocationService.js
@@ -17,55 +17,71 @@
  * under the License.
  */
 
-var PhysLocationService = function(Restangular, locationUtils, messageModel) {
+var PhysLocationService = function($http, ENV, locationUtils, messageModel) {
 
     this.getPhysLocations = function(queryParams) {
-        return Restangular.all('phys_locations').getList(queryParams);
+        return $http.get(ENV.api['root'] + 'phys_locations', {params: 
queryParams}).then(
+            function (result) {
+                return result.data.response;
+            },
+            function (err) {
+                throw err;
+            }
+        );
     };
 
     this.getPhysLocation = function(id) {
-        return Restangular.one("phys_locations", id).get();
+        return $http.get(ENV.api['root'] + 'phys_locations', {params: {id: 
id}}).then(
+            function(result) {
+                return result.data.response[0];
+            },
+            function(err) {
+                throw err;
+            }
+        );
     };
 
     this.createPhysLocation = function(physLocation) {
-        return Restangular.service('phys_locations').post(physLocation)
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 
'Physical location created' } ], true);
-                    locationUtils.navigateToPath('/phys-locations');
-
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                }
-            );
+        return $http.post(ENV.api['root'] + 'phys_locations', 
physLocation).then(
+            function(result) {
+                messageModel.setMessages([ { level: 'success', text: 'Physical 
location created' } ], true);
+                locationUtils.navigateToPath('/phys-locations');
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
+            }
+        );
     };
 
     this.updatePhysLocation = function(physLocation) {
-        return physLocation.put()
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 
'Physical location updated' } ], false);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                }
-            );
+        return $http.put(ENV.api['root'] + 'phys_locations/' + 
physLocation.id, physLocation).then(
+            function(result) {
+                messageModel.setMessages([ { level: 'success', text: 'Physical 
location updated' } ], false);
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
+            }
+        );
     };
 
     this.deletePhysLocation = function(id) {
-        return Restangular.one("phys_locations", id).remove()
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 
'Physical location deleted' } ], true);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, true);
-                }
-            );
+        return $http.delete(ENV.api['root'] + 'phys_locations/' + id).then(
+            function(result) {
+                messageModel.setMessages([ { level: 'success', text: 'Physical 
location deleted' } ], true);
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, true);
+                throw err;
+            }
+        );
     };
 
 };
 
-PhysLocationService.$inject = ['Restangular', 'locationUtils', 'messageModel'];
+PhysLocationService.$inject = ['$http', 'ENV', 'locationUtils', 
'messageModel'];
 module.exports = PhysLocationService;

Reply via email to