mirror of https://github.com/portainer/portainer
feat(engine-details): replace old node view with a new component
parent
d8d4b38384
commit
08afe4d084
|
@ -238,8 +238,7 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
url: '/:id',
|
url: '/:id',
|
||||||
views: {
|
views: {
|
||||||
'content@': {
|
'content@': {
|
||||||
templateUrl: 'app/docker/views/nodes/edit/node.html',
|
component: 'nodeDetailsView'
|
||||||
controller: 'NodeController'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
|
@ -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>
|
|
@ -0,0 +1,4 @@
|
||||||
|
angular.module('portainer.docker').component('nodeDetailsView', {
|
||||||
|
templateUrl: 'app/docker/views/nodes/node-details/node-details-view.html',
|
||||||
|
controller: 'NodeDetailsViewController'
|
||||||
|
});
|
Loading…
Reference in New Issue