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/09/18 21:00:04 UTC
[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request
#3617: Removed restangular from DivisionService
mitchell852 commented on a change in pull request #3617: Removed restangular from DivisionService
URL: https://github.com/apache/trafficcontrol/pull/3617#discussion_r325889761
##########
File path: traffic_portal/app/src/common/api/DivisionService.js
##########
@@ -17,54 +17,70 @@
* under the License.
*/
-var DivisionService = function(Restangular, locationUtils, messageModel) {
+var DivisionService = function($http, ENV, locationUtils, messageModel) {
this.getDivisions = function(queryParams) {
- return Restangular.all('divisions').getList(queryParams);
+ return $http.get(ENV.api['root'] + 'divisions', {params: queryParams}).then(
+ function(result) {
+ return result.data.response;
+ },
+ function(err) {
+ throw err;
+ }
+ );
};
this.getDivision = function(id) {
- return Restangular.one("divisions", id).get();
+ return $http.get(ENV.api['root'] + 'divisions', {params: {id: id}}).then(
+ function(result) {
+ return result.data.response[0];
+ },
+ function(err) {
+ throw err;
+ }
+ );
};
this.createDivision = function(division) {
- return Restangular.service('divisions').post(division)
- .then(
- function() {
- messageModel.setMessages([ { level: 'success', text: 'Division created' } ], true);
- locationUtils.navigateToPath('/divisions');
- },
- function(fault) {
- messageModel.setMessages(fault.data.alerts, false);
- }
- );
+ return $http.post(ENV.api['root'] + 'divisions', division).then(
+ function(result) {
+ messageModel.setMessages(result.data.alerts, true);
+ locationUtils.navigateToPath('/divisions');
+ return result;
+ },
+ function(err) {
+ messageModel.setMessages(err.data.alerts, false);
+ throw err;
+ }
+ );
};
this.updateDivision = function(division) {
- return division.put()
- .then(
- function() {
- messageModel.setMessages([ { level: 'success', text: 'Division updated' } ], false);
- },
- function(fault) {
- messageModel.setMessages(fault.data.alerts, false);
- }
- );
+ return $http.put(ENV.api['root'] + 'divisions/' + division.id).then(
Review comment:
I think you missed something here. The division object is not being sent. I think you need to send it as the 2nd argument to put()
----------------------------------------------------------------
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