1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00
portainer/app/docker/views/host/host-view-controller.js
Chaim Lev-Ari ca08b2fa2a feat(host): replace engine view with host view (#2255)
* feat(engine-details): remove old panels

* feat(engine-details): add basic engine-details-panel component

* feat(engine-details): pass details to the different components

* feat(engine-details): replace host-view with host-overview

* feat(engine-details): add commaseperated filter

* feat(engine-details): add host-view container component

* feat(engine-details): add host-details component

* feat(engine-details): build host details object

* feat(engine-details): format engine version

* feat(engine-details): get details for one node

* feat(engine-details): pass is-agent from view

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

* feat(engine-details): add swarm-node-details component

* feat(engine-details): remove isSwarm binding

* feat(engine-details): remove node-details and include in parent

* feat(engine-details): add labels-table component

* feat(engine-details): add update node service

* feat(engine-details): add update label functionality

* style(engine-details): remove whitespaces

* feat(engine-details): remove old node page

* feat(engine-details): pass is agent to host details

* feat(host-details): hide missing info

* feat(host-details): update node availability

* style(host-details): remove obsolete event object

* feat(host-details): fix labels not sending

* feat(host-details): remove flags for hiding data

* feat(host-details): create mock call to server for agent host info

* style(host-details): fix spelling mistake in filter's name

* feat(host-details): get info from agent

* feat(host-details): hide engine labels when empty

* feat(node-details): move labels table and save button

* feat(host-info): add different urls for refresh

* feat(host-details): show disk/devices info for agent

* feat(host-view): add loading indicator to devices-panel

* feat(host-details): add loading indicator to disks panel

* feat(host-details): show devices/disks on standalone agent

* refactor(host-details): remove default value

* refactor(host-details): remove redundant commaSeperated filter

* refactor(host-details): remove unused functions

* style(host-details): remove whitespace
2018-10-08 11:44:08 +13:00

70 lines
2 KiB
JavaScript

angular.module('portainer.docker').controller('HostViewController', [
'$q', 'SystemService', 'Notifications', 'StateManager', 'AgentService',
function HostViewController($q, SystemService, Notifications, StateManager, AgentService) {
var ctrl = this;
this.$onInit = initView;
ctrl.state = {
isAgent: false
};
this.engineDetails = {};
this.hostDetails = {};
function initView() {
var applicationState = StateManager.getState();
ctrl.state.isAgent = applicationState.endpoint.mode.agentProxy;
$q.all({
version: SystemService.version(),
info: SystemService.info()
})
.then(function success(data) {
ctrl.engineDetails = buildEngineDetails(data);
ctrl.hostDetails = buildHostDetails(data.info);
if (ctrl.state.isAgent) {
return AgentService.hostInfo(data.info.Hostname).then(function onHostInfoLoad(agentHostInfo) {
ctrl.devices = agentHostInfo.PCIDevices;
ctrl.disks = agentHostInfo.PhysicalDisks;
});
}
})
.catch(function error(err) {
Notifications.error(
'Failure',
err,
'Unable to retrieve engine details'
);
});
}
function buildEngineDetails(data) {
var versionDetails = data.version;
var info = data.info;
return {
releaseVersion: versionDetails.Version,
apiVersion: versionDetails.ApiVersion,
rootDirectory: info.DockerRootDir,
storageDriver: info.Driver,
loggingDriver: info.LoggingDriver,
volumePlugins: info.Plugins.Volume,
networkPlugins: info.Plugins.Network
};
}
function buildHostDetails(info) {
return {
os: {
arch: info.Architecture,
type: info.OSType,
name: info.OperatingSystem
},
name: info.Name,
kernelVersion: info.KernelVersion,
totalCPU: info.NCPU,
totalMemory: info.MemTotal
};
}
}
]);