2017-01-31 23:26:29 +00:00
|
|
|
angular.module('portainer.helpers')
|
|
|
|
.factory('NodeHelper', [function NodeHelperFactory() {
|
|
|
|
'use strict';
|
|
|
|
return {
|
|
|
|
nodeToConfig: function(node) {
|
|
|
|
return {
|
|
|
|
Name: node.Spec.Name,
|
|
|
|
Role: node.Spec.Role,
|
|
|
|
Labels: node.Spec.Labels,
|
|
|
|
Availability: node.Spec.Availability
|
|
|
|
};
|
2017-03-28 13:12:54 +00:00
|
|
|
},
|
|
|
|
getManagerIP: function(nodes) {
|
|
|
|
var managerIp;
|
|
|
|
for (var n in nodes) {
|
2017-05-23 18:56:10 +00:00
|
|
|
if (undefined === nodes[n].ManagerStatus || nodes[n].ManagerStatus.Reachability !== 'reachable') {
|
2017-03-28 13:12:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
managerIp = nodes[n].ManagerStatus.Addr.split(':')[0];
|
2017-03-28 13:12:54 +00:00
|
|
|
}
|
|
|
|
return managerIp;
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|