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 7f8f904  Removed restangular from ./ASNService.js (#3600)
7f8f904 is described below

commit 7f8f9044d4a19468c7e999c4d8f2ef986fe2945d
Author: ocket8888 <[email protected]>
AuthorDate: Tue May 28 19:05:58 2019 -0600

    Removed restangular from ./ASNService.js (#3600)
---
 traffic_portal/app/src/common/api/ASNService.js | 73 ++++++++++++++++---------
 1 file changed, 47 insertions(+), 26 deletions(-)

diff --git a/traffic_portal/app/src/common/api/ASNService.js 
b/traffic_portal/app/src/common/api/ASNService.js
index 664c9af..9b7ed24 100644
--- a/traffic_portal/app/src/common/api/ASNService.js
+++ b/traffic_portal/app/src/common/api/ASNService.js
@@ -17,54 +17,75 @@
  * under the License.
  */
 
-var ASNService = function(Restangular, locationUtils, messageModel) {
+var ASNService = function($http, $q, locationUtils, messageModel, ENV) {
 
     this.getASNs = function(queryParams) {
-        return Restangular.all('asns').getList(queryParams);
+        return $http.get(ENV.api['root'] + 'asns', {params: queryParams}).then(
+            function(result) {
+                return result.data.response;
+            },
+            function(err) {
+                console.error(err);
+                throw err;
+            }
+        );
     };
 
     this.getASN = function(id) {
-        return Restangular.one("asns", id).get();
+        return $http.get(ENV.api['root'] + 'asns', {params: {'id': id}}).then(
+            function(result) {
+                return result.data.response[0];
+            },
+            function(err) {
+                console.error(err);
+                throw err;
+            }
+        );
     };
 
     this.createASN = function(asn) {
-        return Restangular.service('asns').post(asn)
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 'ASN 
created' } ], true);
-                    locationUtils.navigateToPath('/asns');
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                }
-            );
+        return $http.post(ENV.api['root'] + 'asns', asn).then(
+            function(result) {
+                messageModel.setMessages([{level: 'success', text: 'ASN 
created' }], true);
+                console.info("created new ASN: ", result.data.response);
+                locationUtils.navigateToPath('/asns');
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
+            }
+        );
     };
 
     this.updateASN = function(asn) {
-        return asn.put()
-            .then(
-            function() {
-                messageModel.setMessages([ { level: 'success', text: 'ASN 
updated' } ], false);
+        return $http.put(ENV.api['root'] + 'asns/' + asn.id, asn).then(
+            function(result) {
+                messageModel.setMessages([{level: 'success', text: 'ASN 
updated'}], false);
+                console.info('updated ASN: ', result.data.response);
+                return result;
             },
-            function(fault) {
-                messageModel.setMessages(fault.data.alerts, false);
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+                throw err;
             }
         );
     };
 
     this.deleteASN = function(id) {
-        return Restangular.one("asns", id).remove()
-            .then(
-            function() {
-                messageModel.setMessages([ { level: 'success', text: 'ASN 
deleted' } ], true);
+        return $http.delete(ENV.api['root'] + 'asns/' + id).then(
+            function(result) {
+                messageModel.setMessages(result.data.alerts, true);
+                return result;
             },
-            function(fault) {
-                messageModel.setMessages(fault.data.alerts, true);
+            function(err) {
+                messageModel.setMessages(err.data.alerts, true);
+                throw err;
             }
         );
     };
 
 };
 
-ASNService.$inject = ['Restangular', 'locationUtils', 'messageModel'];
+ASNService.$inject = ['$http', '$q', 'locationUtils', 'messageModel', 'ENV'];
 module.exports = ASNService;

Reply via email to