feat(engine-details): replace old node view with a new component

pull/2255/head
Chaim Lando 2018-09-05 18:08:06 +03:00
parent d8d4b38384
commit 08afe4d084
4 changed files with 78 additions and 2 deletions

View File

@ -238,8 +238,7 @@ angular.module('portainer.docker', ['portainer.app'])
url: '/:id',
views: {
'content@': {
templateUrl: 'app/docker/views/nodes/edit/node.html',
controller: 'NodeController'
component: 'nodeDetailsView'
}
}
};

View File

@ -0,0 +1,66 @@
angular.module('portainer.docker').controller('NodeDetailsViewController', [
'$stateParams',
'NodeService',
function NodeDetailsViewController($stateParams, NodeService) {
var ctrl = this;
ctrl.$onInit = initView;
function initView() {
NodeService.node($stateParams.id).then(function(node) {
console.log(node)
ctrl.hostDetails = buildHostDetails(node);
ctrl.engineDetails = buildEngineDetails(node);
ctrl.nodeDetails = buildNodeDetails(node);
});
}
function buildHostDetails(node) {
return {
os: {
arch: node.PlatformArchitecture,
type: node.PlatformOS
// name: node.OperatingSystem TODO
},
name: node.Hostname,
// kernelVersion: node.KernelVersion,
totalCPU: node.CPUs / 1e9,
totalMemory: node.Memory
};
}
function buildEngineDetails(node) {
return {
releaseVersion: node.EngineVersion,
// apiVersion: versionDetails.ApiVersion, TODO
// rootDirectory: node.DockerRootDir, TODO
// storageDriver: node.Driver,
// loggingDriver: node.LoggingDriver,
volumePlugins: getPlugins(node.Plugins, 'Volume'),
networkPlugins: getPlugins(node.Plugins, 'Network')
};
}
function buildNodeDetails(node) {
return {
name: node.Name,
role: node.Role,
managerAddress: node.ManagerAddr,
availability: node.Availability,
status: node.Status,
engineLabels: node.EngineLabels,
nodeLabels: node.Labels
};
}
function getPlugins(pluginsList, type) {
return pluginsList
.filter(function(plugin) {
return plugin.Type === type;
})
.map(function(plugin) {
return plugin.Name;
});
}
}
]);

View File

@ -0,0 +1,7 @@
<host-overview
is-swarm="true"
is-agent="$ctrl.state.isAgent"
host-details="$ctrl.hostDetails"
engine-details="$ctrl.engineDetails"
node-details="$ctrl.nodeDetails"
></host-overview>

View File

@ -0,0 +1,4 @@
angular.module('portainer.docker').component('nodeDetailsView', {
templateUrl: 'app/docker/views/nodes/node-details/node-details-view.html',
controller: 'NodeDetailsViewController'
});