mirror of https://github.com/portainer/portainer
fix(app): remove endpoint status update on 502/503 http return
* refactor(app): removing unused dep and functionpull/2629/head
parent
34667bd3b3
commit
c7983d8993
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue