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 455c1b7 Removed restangular from CapabilityService (#3607)
455c1b7 is described below
commit 455c1b78dba43b9006bb3f6cd9d12258015ee0d6
Author: ocket8888 <[email protected]>
AuthorDate: Fri Jul 26 15:57:50 2019 -0600
Removed restangular from CapabilityService (#3607)
* Removed restangular from ./CapabilityService.js
* Fixed some service methods not throwing in error handlers
---
.../app/src/common/api/CapabilityService.js | 91 +++++++++++-----------
1 file changed, 45 insertions(+), 46 deletions(-)
diff --git a/traffic_portal/app/src/common/api/CapabilityService.js
b/traffic_portal/app/src/common/api/CapabilityService.js
index 9d0855c..73c873e 100644
--- a/traffic_portal/app/src/common/api/CapabilityService.js
+++ b/traffic_portal/app/src/common/api/CapabilityService.js
@@ -17,68 +17,67 @@
* under the License.
*/
-var CapabilityService = function(Restangular, $q, $http, messageModel, ENV) {
+var CapabilityService = function($http, messageModel, ENV) {
this.getCapabilities = function(queryParams) {
- return Restangular.all('capabilities').getList(queryParams);
+ return $http.get(ENV.api['root'] + 'capabilities', {params:
queryParams}).then(
+ function(result) {
+ return result.data.response;
+ },
+ function(err) {
+ throw err;
+ }
+ );
};
this.getCapability = function(name) {
- return Restangular.one("capabilities", name).get();
+ return $http.get(ENV.api['root'] + 'capabilities/' + name).then(
+ function(result) {
+ return result.data.response[0];
+ },
+ function(err) {
+ throw err;
+ }
+ );
};
this.createCapability = function(cap) {
- var request = $q.defer();
-
- $http.post(ENV.api['root'] + "capabilities", cap)
- .then(
- function(result) {
- request.resolve(result.data);
- },
- function(fault) {
-
messageModel.setMessages(fault.data.alerts, false);
- request.reject(fault);
- }
- );
-
- return request.promise;
+ return $http.post(ENV.api['root'] + "capabilities", cap).then(
+ function(result) {
+ return result.data;
+ },
+ function(err) {
+ messageModel.setMessages(err.data.alerts,
false);
+ throw err;
+ }
+ );
};
this.updateCapability = function(cap) {
- var request = $q.defer();
-
- $http.put(ENV.api['root'] + "capabilities/" + cap.name, cap)
- .then(
- function(result) {
- request.resolve(result.data);
- },
- function(fault) {
-
messageModel.setMessages(fault.data.alerts, false);
- request.reject();
- }
- );
-
- return request.promise;
+ return $http.put(ENV.api['root'] + "capabilities/" + cap.name,
cap).then(
+ function(result) {
+ return result.data;
+ },
+ function(err) {
+ messageModel.setMessages(err.data.alerts,
false);
+ throw err;
+ }
+ );
};
this.deleteCapability = function(cap) {
- var request = $q.defer();
-
- $http.delete(ENV.api['root'] + "capabilities/" + cap.name)
- .then(
- function(result) {
- request.resolve(result.data);
- },
- function(fault) {
-
messageModel.setMessages(fault.data.alerts, false);
- request.reject(fault);
- }
- );
-
- return request.promise;
+ return $http.delete(ENV.api['root'] + "capabilities/" +
cap.name).then(
+ function(result) {
+ return result.data;
+ },
+ function(err) {
+ messageModel.setMessages(err.data.alerts,
false);
+ throw err;
+ }
+ );
};
};
-CapabilityService.$inject = ['Restangular', '$q', '$http', 'messageModel',
'ENV'];
+CapabilityService.$inject = ['$http', 'messageModel', 'ENV'];
module.exports = CapabilityService;