Skip to content

Commit

Permalink
Update locations services to account changes in the locations rest API
Browse files Browse the repository at this point in the history
Update repositories controller according to changes in the backend API for locations/activate endpoint.
  • Loading branch information
Svilen Velikov committed Sep 11, 2019
1 parent 7050ede commit 08bcca5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
13 changes: 5 additions & 8 deletions src/js/angular/repositories/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/js/angular/repositories/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions test/repositories/controllers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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']});
Expand All @@ -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();
Expand Down

0 comments on commit 08bcca5

Please sign in to comment.