From cef8d8c9fd5cb8a1a41ec8372b1b1b9e50248ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Thu, 26 Mar 2015 16:17:08 -0400 Subject: [PATCH] Host view uses adg-host directive --- Gruntfile.js | 26 +++++++++++++++++++++++--- app/app.js | 5 +++-- app/components/host/host.html | 17 +++++++++++++++++ app/components/host/host.js | 28 +++++++++++++++++++--------- app/components/live/get_objects.js | 11 ++--------- app/templates/host/host.html | 16 +--------------- app/templates/host/host.js | 10 +--------- 7 files changed, 66 insertions(+), 47 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0315f9b..9cb1ba2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -109,10 +109,16 @@ module.exports = function (grunt) { '<%= project.app %>/components/table/cell_hosts_host/cell_hosts_host.js', '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', + '<%= project.app %>/components/host/host.js', + '<%= project.app %>/components/host/host_cpu/host_cpu.js', + '<%= project.app %>/components/host/host_info/host_info.js', + '<%= project.app %>/components/host/host_load/host_load.js', + '<%= project.app %>/components/host/host_main/host_main.js', + '<%= project.app %>/components/host/host_services_list/host_services_list.js', '<%= project.app %>/routing_view/routing_view.js', '<%= project.app %>/templates/dashboard/dashboard.js', '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.app %>/templates/host/host.js', + '<%= project.app %>/templates/host/host.js' ] }], options: { @@ -144,10 +150,18 @@ module.exports = function (grunt) { '<%= project.build %>/components/table/cell_hosts_host/cell_hosts_host.js': '<%= project.app %>/components/table/cell_hosts_host/cell_hosts_host.js', '<%= project.build %>/components/table/cell_host_address/cell_host_address.js': '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', '<%= project.build %>/components/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', + + '<%= project.build %>/components/host/host.js': '<%= project.app %>/components/host/host.js', + '<%= project.build %>/components/host/host_cpu/host_cpu.js': '<%= project.app %>/components/host/host_cpu/host_cpu.js', + '<%= project.build %>/components/host/host_info/host_info.js': '<%= project.app %>/components/host/host_info/host_info.js', + '<%= project.build %>/components/host/host_load/host_load.js': '<%= project.app %>/components/host/host_load/host_load.js', + '<%= project.build %>/components/host/host_main/host_main.js': '<%= project.app %>/components/host/host_main/host_main.js', + '<%= project.build %>/components/host/host_services_list/host_services_list.js': '<%= project.app %>/components/host/host_services_list/host_services_list.js', + '<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js', '<%= project.build %>/templates/dashboard/dashboard.js': '<%= project.app %>/templates/dashboard/dashboard.js', '<%= project.build %>/templates/single_table/single_table.js' : '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js' : '<%= project.app %>/templates/host/host.js', + '<%= project.build %>/templates/host/host.js' : '<%= project.app %>/templates/host/host.js' }, { '<%= project.build %>/js/adagios.min.js' : [ @@ -173,10 +187,16 @@ module.exports = function (grunt) { '<%= project.build %>/components/table/cell_hosts_host/cell_hosts_host.js', '<%= project.build %>/components/table/cell_host_address/cell_host_address.js', '<%= project.build %>/components/table/cell_host_status/cell_host_status.js', + '<%= project.build %>/components/host/host.js', + '<%= project.build %>/components/host/host_cpu/host_cpu.js', + '<%= project.build %>/components/host/host_info/host_info.js', + '<%= project.build %>/components/host/host_load/host_load.js', + '<%= project.build %>/components/host/host_main/host_main.js', + '<%= project.build %>/components/host/host_services_list/host_services_list.js', '<%= project.build %>/routing_view/routing_view.js', '<%= project.build %>/templates/dashboard/dashboard.js', '<%= project.build %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js', + '<%= project.build %>/templates/host/host.js' ] } ], diff --git a/app/app.js b/app/app.js index d1b7bd5..2e5ae44 100644 --- a/app/app.js +++ b/app/app.js @@ -15,9 +15,10 @@ angular.element(document).ready(function () { angular.module('adagios', [ 'ngRoute', - 'adagios.sidebar', - 'adagios.topbar', 'adagios.config', + 'adagios.topbar', + 'adagios.sidebar', + 'adagios.host', 'adagios.view', 'adagios.view.dashboard', 'adagios.view.singleTable', diff --git a/app/components/host/host.html b/app/components/host/host.html index e69de29..d60ba5d 100644 --- a/app/components/host/host.html +++ b/app/components/host/host.html @@ -0,0 +1,17 @@ +
+
+

{{hostName}}

+ + + + + + + + + + + +
{{key}}{{value}}
{{key}}{{value}}
+
+
diff --git a/app/components/host/host.js b/app/components/host/host.js index 42d6abf..8e7bf04 100644 --- a/app/components/host/host.js +++ b/app/components/host/host.js @@ -1,25 +1,35 @@ 'use strict'; -angular.module('adagios.host', []) +angular.module('adagios.host', ['adagios.live']) - .controller('TableCtrl', ['$scope', function ($scope) { - angular.noop(); + .value('hostConfig', {}) + + .controller('HostCtrl', ['$scope', 'hostConfig', 'addObjectToScope', function ($scope, hostConfig, addObjectToScope) { + var objectType = 'host', + objectIdentifier = {}; + + objectIdentifier.host_name = hostConfig.hostName; + $scope.data = {}; + + addObjectToScope(objectType, objectIdentifier, $scope); }]) - .directive('adgHost', ['$http', '$compile', - function ($http, $compile) { + .directive('adgHost', ['$http', '$compile', 'hostConfig', + function ($http, $compile, hostConfig) { return { restrict: 'E', compile: function () { return function (scope, element, attrs) { - var template = 'components/host/host.html', - conf; + var template = 'components/host/host.html'; - if (!attrs.hostName || !attrs.modules) { - throw new Error(' "host-name" and "modules" attributes must be defined'); + if (!attrs.hostName) { + throw new Error(' "host-name" attribute must be defined'); } + hostConfig.hostName = {}; + hostConfig.hostName = attrs.hostName; + $http.get(template, { cache: true }) .success(function (data) { var elem = $compile(data)(scope); diff --git a/app/components/live/get_objects.js b/app/components/live/get_objects.js index 651547e..4a2483c 100644 --- a/app/components/live/get_objects.js +++ b/app/components/live/get_objects.js @@ -173,18 +173,11 @@ angular.module('adagios.live') "service" : "services" }; - if (objectType === "host") { - objectIdentifier.host_name = objectIdentifier.host_name; - } else if (objectType === "service") { - objectIdentifier.host_name = objectIdentifier.host_name; - objectIdentifier.description = objectIdentifier.description; - } - url += endpoints[objectType]; url += "/?"; - angular.forEach(objectIdentifier, function (value, key){ - if(!firstParameter){ + angular.forEach(objectIdentifier, function (value, key) { + if (!firstParameter) { url += "&"; } url += key + "=" + value; diff --git a/app/templates/host/host.html b/app/templates/host/host.html index e1854c5..f683b11 100644 --- a/app/templates/host/host.html +++ b/app/templates/host/host.html @@ -1,17 +1,3 @@
-
-

{{hostName}}

- - - - - - - - - - - -
{{key}}{{value}}
{{key}}{{value}}
-
+
diff --git a/app/templates/host/host.js b/app/templates/host/host.js index 9dfce6a..b6c6224 100644 --- a/app/templates/host/host.js +++ b/app/templates/host/host.js @@ -1,20 +1,12 @@ - 'use strict'; angular.module('adagios.view.host', ['adagios.live']) .controller('HostViewCtrl', ['$http', '$scope', '$routeParams', 'getObjectId', 'getObjectById', 'addObjectToScope', function ($http, $scope, $routeParams, getObjectId, getObjectById, addObjectToScope) { - - var objectIdentifier = {}, - objectType = 'host'; - if (!!$routeParams.host_name) { - objectIdentifier.host_name = $routeParams.host_name; + $scope.hostName = $routeParams.host_name; } else { throw new Error("ERROR :'host_name' GET parameter must be set"); } - - $scope.data = {}; - addObjectToScope(objectType, objectIdentifier, $scope); }]);