From 08bcca53b1d1c05e0c7d4b3148ae66e1a897f510 Mon Sep 17 00:00:00 2001 From: Svilen Velikov Date: Thu, 5 Sep 2019 15:00:20 +0300 Subject: [PATCH] Update locations services to account changes in the locations rest API Update repositories controller according to changes in the backend API for locations/activate endpoint. --- src/js/angular/repositories/controllers.js | 13 +++++-------- src/js/angular/repositories/services.js | 4 ++-- test/repositories/controllers.spec.js | 15 ++++----------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/js/angular/repositories/controllers.js b/src/js/angular/repositories/controllers.js index 12e86db56..92a8c780f 100644 --- a/src/js/angular/repositories/controllers.js +++ b/src/js/angular/repositories/controllers.js @@ -83,7 +83,7 @@ define(['angular/core/services', 'angular/repositories/services'], $scope.addLocationHttp = function (dataAddLocation) { $scope.loader = true; - $http.put('rest/locations', dataAddLocation) + $http.post('rest/locations', dataAddLocation) .success(function (data, status, headers, config) { $scope.locations = data; //Reload locations and repositories @@ -118,7 +118,7 @@ define(['angular/core/services', 'angular/repositories/services'], //Edit location $scope.editLocationHttp = function (dataEditLocation) { $scope.loader = true; - $http.post('rest/locations', dataEditLocation).success(function (data, status, headers, config) { + $http.put('rest/locations', dataEditLocation).success(function (data, status, headers, config) { $scope.locations = data; //Reload locations and repositories $repositories.init(); @@ -148,13 +148,10 @@ define(['angular/core/services', 'angular/repositories/services'], }; $scope.activateLocationRequest = function (location) { - var data = { - "uri": location.uri, - "username": location.username, - "password": location.password, - "active": false - }; $scope.loader = true; + let data = { + 'uri': location.uri + }; $http.post('rest/locations/activate', data).success(function (data, status, headers, config) { $repositories.setRepository(''); $repositories.init(); diff --git a/src/js/angular/repositories/services.js b/src/js/angular/repositories/services.js index e5a57fad8..a377f8cb4 100644 --- a/src/js/angular/repositories/services.js +++ b/src/js/angular/repositories/services.js @@ -232,9 +232,9 @@ define(['angular/core/services', 'angular/security/services'], } var that = this; $http({ - url: 'rest/locations/default-repository', + url: 'rest/locations/active/default-repository', method: 'POST', - data: {repository: id} + data: {defaultRepository: id} }) .success(function (data, status, headers, config) { // XXX maybe we should reload the active location but oh well diff --git a/test/repositories/controllers.spec.js b/test/repositories/controllers.spec.js index 2c6b13b20..5614368c6 100644 --- a/test/repositories/controllers.spec.js +++ b/test/repositories/controllers.spec.js @@ -92,7 +92,7 @@ define(["angular/repositories/services", $repositories.init = function () { test = true }; - $httpBackend.expectPUT('rest/locations', {}).respond(200, ''); + $httpBackend.expectPOST('rest/locations', {}).respond(200, ''); $scope.addLocationHttp({}); $httpBackend.flush(); expect(test).toBeTruthy(); @@ -106,7 +106,7 @@ define(["angular/repositories/services", $repositories.init = function () { test = true }; - $httpBackend.expectPOST('rest/locations', {}).respond(200, {locations: ['some new location']}); + $httpBackend.expectPUT('rest/locations', {}).respond(200, {locations: ['some new location']}); $scope.editLocationHttp({}); $httpBackend.flush(); expect($scope.locations).toEqual({locations: ['some new location']}); @@ -125,16 +125,9 @@ define(["angular/repositories/services", $repositories.setRepository = function (id) { repository = id }; - $httpBackend.expectPOST('rest/locations/activate', { - "uri": 'uri', - "username": 'username', - "password": 'password', - "active": false - }).respond(200, ''); + $httpBackend.expectPOST('rest/locations/activate').respond(200, ''); $scope.activateLocationRequest({ - "uri": 'uri', - "username": 'username', - "password": 'password' + 'uri': 'uri' }); $httpBackend.flush(); expect(init).toBeTruthy();