fix(app): remove endpoint status update on 502/503 http return

* refactor(app): removing unused dep and function
pull/2629/head
baron_l 2019-01-15 19:58:35 +01:00 committed by Anthony Lapenna
parent 34667bd3b3
commit c7983d8993
2 changed files with 1 additions and 9 deletions

View File

@ -1,5 +1,5 @@
angular.module('portainer.app')
.factory('EndpointStatusInterceptor', ['$q', '$injector', 'EndpointProvider', function ($q, $injector, EndpointProvider) {
.factory('EndpointStatusInterceptor', ['$q', 'EndpointProvider', function ($q, EndpointProvider) {
'use strict';
var interceptor = {};
@ -18,21 +18,17 @@ angular.module('portainer.app')
}
function responseInterceptor(response) {
var EndpointService = $injector.get('EndpointService');
var url = response.config.url;
if (response.status === 200 && canBeOffline(url) && EndpointProvider.offlineMode()) {
EndpointProvider.setOfflineMode(false);
EndpointService.updateEndpoint(EndpointProvider.endpointID(), {Status: EndpointProvider.endpointStatusFromOfflineMode(false)});
}
return response || $q.when(response);
}
function responseErrorInterceptor(rejection) {
var EndpointService = $injector.get('EndpointService');
var url = rejection.config.url;
if ((rejection.status === 502 || rejection.status === 503 || rejection.status === -1) && canBeOffline(url) && !EndpointProvider.offlineMode()) {
EndpointProvider.setOfflineMode(true);
EndpointService.updateEndpoint(EndpointProvider.endpointID(), {Status: EndpointProvider.endpointStatusFromOfflineMode(true)});
}
return $q.reject(rejection);
}

View File

@ -64,10 +64,6 @@ angular.module('portainer.app')
return endpoint.OfflineMode;
};
service.endpointStatusFromOfflineMode = function(isOffline) {
return isOffline ? 2 : 1;
};
service.setOfflineMode = function(isOffline) {
endpoint.OfflineMode = isOffline;
LocalStorage.storeOfflineMode(isOffline);