Host view uses adg-host directive
This commit is contained in:
parent
5e974cb532
commit
cef8d8c9fd
26
Gruntfile.js
26
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'
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -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',
|
||||
|
@ -0,0 +1,17 @@
|
||||
<article ng-controller="HostCtrl">
|
||||
<section class="main__content tabpanel">
|
||||
<h2 class="main__overview__title">{{hostName}}</h2>
|
||||
<table class="data-table">
|
||||
<tbody >
|
||||
<tr ng-repeat="(key, value) in data.live">
|
||||
<td>{{key}}</td>
|
||||
<td>{{value}}</td>
|
||||
</tr>
|
||||
<tr ng-repeat="(key, value) in data.config">
|
||||
<td>{{key}}</td>
|
||||
<td>{{value}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</article>
|
@ -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('<adg-host> "host-name" and "modules" attributes must be defined');
|
||||
if (!attrs.hostName) {
|
||||
throw new Error('<adg-host> "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);
|
||||
|
@ -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;
|
||||
|
@ -1,17 +1,3 @@
|
||||
<article ng-controller="HostViewCtrl">
|
||||
<section class="main__content tabpanel">
|
||||
<h2 class="main__overview__title">{{hostName}}</h2>
|
||||
<table class="data-table">
|
||||
<tbody >
|
||||
<tr ng-repeat="(key, value) in data.live">
|
||||
<td>{{key}}</td>
|
||||
<td>{{value}}</td>
|
||||
</tr>
|
||||
<tr ng-repeat="(key, value) in data.config">
|
||||
<td>{{key}}</td>
|
||||
<td>{{value}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<adg-host host-name="{{hostName}}"></adg-host>
|
||||
</article>
|
||||
|
@ -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);
|
||||
}]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user