You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2019/05/29 01:51:13 UTC

[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #3632: Removed restangular from StatusService

mitchell852 commented on a change in pull request #3632: Removed restangular from StatusService
URL: https://github.com/apache/trafficcontrol/pull/3632#discussion_r288366030
 
 

 ##########
 File path: traffic_portal/app/src/common/api/StatusService.js
 ##########
 @@ -17,54 +17,68 @@
  * under the License.
  */
 
-var StatusService = function(Restangular, locationUtils, messageModel) {
+var StatusService = function($http, ENV, locationUtils, messageModel) {
 
     this.getStatuses = function(queryParams) {
-        return Restangular.all('statuses').getList(queryParams);
+        return $http.get(ENV.api['root'] + 'statuses', {params: queryParams}).then(
+            function (result) {
+                return result.data.response;
+            },
+            function (err) {
+                console.error(err);
+            }
+        )
     };
 
     this.getStatus = function(id) {
-        return Restangular.one("statuses", id).get();
+        return $http.get(ENV.api['root'] + 'statuses', {params: {id: id}}).then(
+            function (result) {
+                return result.data.response[0];
+            },
+            function (err) {
+                console.error(err);
+            }
+        )
     };
 
     this.createStatus = function(status) {
-        return Restangular.service('statuses').post(status)
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 'Status created' } ], true);
-                    locationUtils.navigateToPath('/statuses');
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, false);
-                }
-            );
+        return $http.post(ENV.api['root'] + 'statuses', status).then(
+            function(result) {
+                messageModel.setMessages([ { level: 'success', text: 'Status created' } ], true);
+                locationUtils.navigateToPath('/statuses');
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
+            }
+        );
     };
 
     this.updateStatus = function(status) {
-        return status.put()
-            .then(
-            function() {
+        return $http.put(ENV.api['root'] + 'statuses/' + status.id, status).then(
+            function(result) {
                 messageModel.setMessages([ { level: 'success', text: 'Status updated' } ], false);
+                return result;
             },
-            function(fault) {
-                messageModel.setMessages(fault.data.alerts, false);
+            function(err) {
+                messageModel.setMessages(err.data.alerts, false);
             }
         );
     };
 
     this.deleteStatus = function(id) {
-        return Restangular.one("statuses", id).remove()
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 'Status deleted' } ], true);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, true);
-                }
+        return $http.get(ENZ.api['root'] + "statuses/" + id).then(
 
 Review comment:
   typo

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services