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', [
'$q', 'Agent',
function AgentServiceFactory($q, Agent) {
'$q', 'Agent','HttpRequestHelper', 'Host',
function AgentServiceFactory($q, Agent, HttpRequestHelper, Host) {
'use strict';
var service = {};
service.agents = agents;
service.hostInfo = hostInfo;
function hostInfo() {
return $q.when({
PhysicalDeviceVendor: 'hello',
DeviceVersion: '1.9',
DeviceSerialNumber: '144f',
InstalledPCIDevices: ['usb', 'printer'],
PhysicalDisk: 'none'
});
function hostInfo(nodeName) {
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
return Host.info().$promise;
}
function agents() {

View File

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