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/06/04 15:38:02 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #3633: Removed restangular from TenantService

ocket8888 commented on a change in pull request #3633: Removed restangular from TenantService
URL: https://github.com/apache/trafficcontrol/pull/3633#discussion_r290363109
 
 

 ##########
 File path: traffic_portal/app/src/common/api/TenantService.js
 ##########
 @@ -17,53 +17,70 @@
  * under the License.
  */
 
-var TenantService = function(Restangular, messageModel) {
+var TenantService = function($http, ENV, messageModel) {
 
     this.getTenants = function(queryParams) {
-        return Restangular.all('tenants').getList(queryParams);
+        return $http.get(ENV.api['root'] + 'tenants', {params: queryParams}).then(
+            function (result) {
+                return result.data.response;
+            },
+            function (err) {
+                throw err;
+            }
+        )
     };
 
     this.getTenant = function(id) {
-        return Restangular.one("tenants", id).get();
+        return $http.get(ENV.api['root'] + 'tenants', {params: {id: id}}).then(
+            function (result) {
+                return result.data.response[0];
+            },
+            function (err) {
+                throw err;
+            }
+        )
     };
 
     this.createTenant = function(tenant) {
-        return Restangular.service('tenants').post(tenant)
-            .then(
-                function() {
-                    messageModel.setMessages([ { level: 'success', text: 'Tenant created' } ], true);
-                },
-                function(fault) {
-                    messageModel.setMessages(fault.data.alerts, true);
-                }
+        return $http.post(ENV.api['root'] + 'tenants', tenant).then(
+            function(result) {
+                messageModel.setMessages([ { level: 'success', text: 'Tenant created' } ], true);
+                return result;
+            },
+            function(err) {
+                messageModel.setMessages(err.data.alerts, true);
 
 Review comment:
   yeah. I just copied what was there, but you're right - what was there was wrong.

----------------------------------------------------------------
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