feat(host-details): get info from agent

pull/2255/head
Chaim Lando 2018-09-16 12:38:38 +03:00
parent dc1ab3ffc3
commit 50e6991745
3 changed files with 21 additions and 12 deletions

15
app/agent/rest/host.js Normal file
View File

@ -0,0 +1,15 @@
angular.module('portainer.agent').factory('Host', [
'$resource', 'API_ENDPOINT_ENDPOINTS', 'EndpointProvider',
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
'use strict';
return $resource(
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/host/:action',
{
endpointId: EndpointProvider.endpointID
},
{
info: { method: 'GET', isArray: false, params: { action: 'info' } }
}
);
}
]);

View File

@ -1,20 +1,15 @@
angular.module('portainer.agent').factory('AgentService', [ angular.module('portainer.agent').factory('AgentService', [
'$q', 'Agent', '$q', 'Agent','HttpRequestHelper', 'Host',
function AgentServiceFactory($q, Agent) { function AgentServiceFactory($q, Agent, HttpRequestHelper, Host) {
'use strict'; 'use strict';
var service = {}; var service = {};
service.agents = agents; service.agents = agents;
service.hostInfo = hostInfo; service.hostInfo = hostInfo;
function hostInfo() { function hostInfo(nodeName) {
return $q.when({ HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
PhysicalDeviceVendor: 'hello', return Host.info().$promise;
DeviceVersion: '1.9',
DeviceSerialNumber: '144f',
InstalledPCIDevices: ['usb', 'printer'],
PhysicalDisk: 'none'
});
} }
function agents() { function agents() {

View File

@ -23,8 +23,7 @@ angular.module('portainer.docker').controller('NodeDetailsViewController', [
ctrl.engineDetails = buildEngineDetails(node); ctrl.engineDetails = buildEngineDetails(node);
ctrl.nodeDetails = buildNodeDetails(node); ctrl.nodeDetails = buildNodeDetails(node);
if (ctrl.state.isAgent) { if (ctrl.state.isAgent) {
AgentService.hostInfo(nodeId).then(function onHostInfoLoad(agentHostInfo) { AgentService.hostInfo(node.Hostname).then(function onHostInfoLoad(agentHostInfo) {
console.log(agentHostInfo);
enhanceHostDetails(ctrl.hostDetails, agentHostInfo); enhanceHostDetails(ctrl.hostDetails, agentHostInfo);
}); });
} }