Files
portainer/app/docker/views/host/host-view-controller.js
T
Chaim Lev-Ari 9813099aa4 feat(app): toggle features based on agent API version (#2378)
* feat(agent): get agent's version from ping

* feat(agent): add version to api url

* feat(agent): query agent with api version

* feat(agent): rename agent api version name on state

* feat(agent): disable feature based on agent's api version

* style(agent): rename ping rest service + remove whitespaces

* style(state): remove whitespace

* style(agent): add whitespace

* fix(agent): remove check for error status 403

* refactor(agent): rename ping file name

* refactor(agent): move old services to v1 folder

* refactor(agent): turn ping service to usual pattern

* refactor(agent): change version to a global variable

* refactor(agent): move ping to version2

* refactor(agent): restore ping to use root ping

* fix(volumes): add volumeID to browse api path

* feat(volume): add upload button to volume browser
2018-10-26 16:16:29 +13:00

75 lines
2.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 = {};
this.devices = null;
this.disks = null;
function initView() {
var applicationState = StateManager.getState();
ctrl.state.isAgent = applicationState.endpoint.mode.agentProxy;
var agentApiVersion = applicationState.endpoint.agentApiVersion;
ctrl.state.agentApiVersion = agentApiVersion;
$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 && agentApiVersion > 1) {
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
};
}
}
]);