2017-01-31 23:26:29 +00:00
|
|
|
angular.module('portainer.helpers')
|
|
|
|
.factory('InfoHelper', [function InfoHelperFactory() {
|
|
|
|
'use strict';
|
|
|
|
return {
|
|
|
|
determineEndpointMode: function(info) {
|
|
|
|
var mode = {
|
|
|
|
provider: '',
|
|
|
|
role: ''
|
|
|
|
};
|
|
|
|
if (_.startsWith(info.ServerVersion, 'swarm')) {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.provider = 'DOCKER_SWARM';
|
2017-01-31 23:26:29 +00:00
|
|
|
if (info.SystemStatus[0][1] === 'primary') {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.role = 'PRIMARY';
|
2017-01-31 23:26:29 +00:00
|
|
|
} else {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.role = 'REPLICA';
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!info.Swarm || _.isEmpty(info.Swarm.NodeID)) {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.provider = 'DOCKER_STANDALONE';
|
2017-01-31 23:26:29 +00:00
|
|
|
} else {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.provider = 'DOCKER_SWARM_MODE';
|
2017-01-31 23:26:29 +00:00
|
|
|
if (info.Swarm.ControlAvailable) {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.role = 'MANAGER';
|
2017-01-31 23:26:29 +00:00
|
|
|
} else {
|
2017-05-23 18:56:10 +00:00
|
|
|
mode.role = 'WORKER';
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|