Compare commits

...

1 Commits

Author SHA1 Message Date
baron_l
71aedbbcba fix(endpoints): remove updateEndpoint trigger on status difference 2019-01-18 17:48:27 +01:00
3 changed files with 2 additions and 51 deletions

View File

@@ -1,13 +0,0 @@
angular.module('portainer.docker')
.factory('SystemEndpoint', ['$resource', 'API_ENDPOINT_ENDPOINTS',
function SystemEndpointFactory($resource, API_ENDPOINT_ENDPOINTS) {
'use strict';
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/:action/:subAction', {
name: '@name'
},
{
ping: {
method: 'GET', params: { action: '_ping', endpointId: '@endpointId' }, timeout: 10000
}
});
}]);

View File

@@ -1,5 +1,5 @@
angular.module('portainer.docker')
.factory('SystemService', ['$q', 'System', 'SystemEndpoint', function SystemServiceFactory($q, System, SystemEndpoint) {
.factory('SystemService', ['$q', 'System', function SystemServiceFactory($q, System) {
'use strict';
var service = {};
@@ -20,10 +20,6 @@ angular.module('portainer.docker')
return System.info({}).$promise;
};
service.ping = function(endpointId) {
return SystemEndpoint.ping({endpointId: endpointId}).$promise;
};
service.version = function() {
return System.version({}).$promise;
};

View File

@@ -10,13 +10,7 @@ function ($q, $scope, $state, Authentication, EndpointService, EndpointHelper, G
if (endpoint.Type === 3) {
return switchToAzureEndpoint(endpoint);
}
checkEndpointStatus(endpoint)
.then(function sucess() {
return switchToDockerEndpoint(endpoint);
}).catch(function error(err) {
Notifications.error('Failure', err, 'Unable to verify endpoint status');
});
return switchToDockerEndpoint(endpoint);
};
$scope.dismissImportantInformation = function (hash) {
@@ -36,32 +30,6 @@ function ($q, $scope, $state, Authentication, EndpointService, EndpointHelper, G
});
};
function checkEndpointStatus(endpoint) {
var deferred = $q.defer();
var status = 1;
SystemService.ping(endpoint.Id)
.then(function sucess() {
status = 1;
}).catch(function error() {
status = 2;
}).finally(function () {
if (endpoint.Status === status) {
deferred.resolve(endpoint);
return deferred.promise;
}
EndpointService.updateEndpoint(endpoint.Id, { Status: status })
.then(function sucess() {
deferred.resolve(endpoint);
}).catch(function error(err) {
deferred.reject({msg: 'Unable to update endpoint status', err: err});
});
});
return deferred.promise;
}
function switchToAzureEndpoint(endpoint) {
EndpointProvider.setEndpointID(endpoint.Id);
EndpointProvider.setEndpointPublicURL(endpoint.PublicURL);