From 7eaaf9a2a7dde16499277215a4e99de01ad4819f Mon Sep 17 00:00:00 2001 From: G07cha Date: Tue, 17 Oct 2017 09:56:40 +0300 Subject: [PATCH] feat(container-inspect): add the ability to inspect containers --- app/__module.js | 1 + app/components/container/container.html | 1 + .../containerInspect/containerInspect.html | 19 ++++++++++++++++++ .../containerInspectController.js | 20 +++++++++++++++++++ app/rest/docker/container.js | 3 +++ app/routes.js | 13 ++++++++++++ app/services/docker/containerService.js | 17 +++++----------- 7 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 app/components/containerInspect/containerInspect.html create mode 100644 app/components/containerInspect/containerInspectController.js diff --git a/app/__module.js b/app/__module.js index 843fe2239..45dfe4e31 100644 --- a/app/__module.js +++ b/app/__module.js @@ -20,6 +20,7 @@ angular.module('portainer', [ 'containerConsole', 'containerLogs', 'containerStats', + 'containerInspect', 'serviceLogs', 'containers', 'createContainer', diff --git a/app/components/container/container.html b/app/components/container/container.html index 34590f292..f3dd69639 100644 --- a/app/components/container/container.html +++ b/app/components/container/container.html @@ -83,6 +83,7 @@ Stats Logs Console + Inspect diff --git a/app/components/containerInspect/containerInspect.html b/app/components/containerInspect/containerInspect.html new file mode 100644 index 000000000..200b7cd58 --- /dev/null +++ b/app/components/containerInspect/containerInspect.html @@ -0,0 +1,19 @@ + + + + + Containers > {{ containerInfo.Name|trimcontainername }} > Inspect + + + +
+
+ + + + +
{{ containerInfo|json:4 }}
+
+
+
+
diff --git a/app/components/containerInspect/containerInspectController.js b/app/components/containerInspect/containerInspectController.js new file mode 100644 index 000000000..ae1740630 --- /dev/null +++ b/app/components/containerInspect/containerInspectController.js @@ -0,0 +1,20 @@ +angular.module('containerInspect', []) +.controller('ContainerInspectController', ['$scope', '$transition$', 'Notifications', 'ContainerService', +function ($scope, $transition$, Notifications, ContainerService) { + function initView() { + $('#loadingViewSpinner').show(); + + ContainerService.inspect($transition$.params().id) + .then(function success(d) { + $scope.containerInfo = d; + }) + .catch(function error(e) { + Notifications.error('Failure', e, 'Unable to inspect container'); + }) + .finally(function final() { + $('#loadingViewSpinner').hide(); + }); + } + + initView(); +}]); diff --git a/app/rest/docker/container.js b/app/rest/docker/container.js index d8786cb03..25ab3b2da 100644 --- a/app/rest/docker/container.js +++ b/app/rest/docker/container.js @@ -40,6 +40,9 @@ angular.module('portainer.rest') exec: { method: 'POST', params: {id: '@id', action: 'exec'}, transformResponse: genericHandler + }, + inspect: { + method: 'GET', params: { id: '@id', action: 'json' } } }); }]); diff --git a/app/routes.js b/app/routes.js index 0232c3d6d..87adbf0f6 100644 --- a/app/routes.js +++ b/app/routes.js @@ -105,6 +105,19 @@ function configureRoutes($stateProvider) { } } }) + .state('inspect', { + url: '^/containers/:id/inspect', + views: { + 'content@': { + templateUrl: 'app/components/containerInspect/containerInspect.html', + controller: 'ContainerInspectController' + }, + 'sidebar@': { + templateUrl: 'app/components/sidebar/sidebar.html', + controller: 'SidebarController' + } + } + }) .state('dashboard', { parent: 'root', url: '/dashboard', diff --git a/app/services/docker/containerService.js b/app/services/docker/containerService.js index 33daf016d..4065046b0 100644 --- a/app/services/docker/containerService.js +++ b/app/services/docker/containerService.js @@ -140,18 +140,11 @@ angular.module('portainer.services') }; service.containerTop = function(id) { - var deferred = $q.defer(); - - Container.top({id: id}).$promise - .then(function success(data) { - var containerTop = data; - deferred.resolve(containerTop); - }) - .catch(function error(err) { - deferred.reject(err); - }); - - return deferred.promise; + return Container.top({id: id}).$promise; + }; + + service.inspect = function(id) { + return Container.inspect({id: id}).$promise; }; return service;