2019-03-21 05:46:49 +00:00
|
|
|
import _ from 'lodash-es';
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.docker').factory('InfoHelper', [
|
|
|
|
function InfoHelperFactory() {
|
|
|
|
'use strict';
|
2018-04-04 00:31:04 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
var helper = {};
|
2018-04-04 00:31:04 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
helper.determineEndpointMode = function (info, type) {
|
|
|
|
var mode = {
|
|
|
|
provider: '',
|
|
|
|
role: '',
|
|
|
|
agentProxy: false,
|
|
|
|
};
|
2018-05-06 07:15:57 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
if (type === 2 || type === 4) {
|
|
|
|
mode.agentProxy = true;
|
2018-04-04 00:31:04 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
|
|
|
|
if (!info.Swarm || _.isEmpty(info.Swarm.NodeID)) {
|
2020-06-10 19:59:11 +00:00
|
|
|
mode.provider = 'DOCKER_STANDALONE';
|
2018-04-04 00:31:04 +00:00
|
|
|
} else {
|
2020-04-10 21:54:53 +00:00
|
|
|
mode.provider = 'DOCKER_SWARM_MODE';
|
|
|
|
if (info.Swarm.ControlAvailable) {
|
|
|
|
mode.role = 'MANAGER';
|
|
|
|
} else {
|
|
|
|
mode.role = 'WORKER';
|
|
|
|
}
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
return mode;
|
|
|
|
};
|
2018-04-04 00:31:04 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
return helper;
|
|
|
|
},
|
|
|
|
]);
|