Added custom tables support

This commit is contained in:
Frédéric Vachon 2015-02-10 12:22:28 -05:00
parent 81f7b4980d
commit 7fead8c0d9
5 changed files with 65 additions and 2 deletions

View File

@ -20,7 +20,8 @@ angular.module('adagios', [
'adagios.config',
'adagios.view.dashboard',
'adagios.view.hosts',
'adagios.view.services'
'adagios.view.services',
'adagios.view.custom'
])
.config(['$routeProvider', function ($routeProvider) {

View File

@ -13,5 +13,17 @@
"cells": ["host", "service_check", "duration", "last_check"],
"apiName": "services",
"filters": {}
},
"customViewsConfig": {
"customView1": {
"cells": ["hosts_host", "host_address", "duration", "last_check", "host_status"],
"apiName": "hosts",
"filters": {}
},
"customView2": {
"cells": ["host", "service_check", "duration", "last_check"],
"apiName": "services",
"filters": {}
}
}
}

View File

@ -0,0 +1,7 @@
<div ng-controller="CustomViewsCtrl" id="tactical">
<h2>Custom View</h2>
<adg-table cells="{{customViewCells}}" api-name="{{customViewApiName}}" filters="{{customViewFilters}}"></adg-table>
</div>

View File

@ -0,0 +1,42 @@
'use strict';
angular.module('adagios.view.custom', ['ngRoute',
'adagios.tactical.status_overview',
'adagios.tactical.current_health',
'adagios.tactical.top_alert_producers',
'adagios.table'
])
.value('customViewsConfig', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/customViews', {
templateUrl: 'custom_views/custom_views.html',
controller: 'CustomViewsCtrl'
});
}])
.controller('CustomViewsCtrl', [ '$scope', '$routeParams', 'customViewsConfig',
function ($scope, $routeParams, customViewsConfig) {
var viewName = "";
if (!!$routeParams.view) {
viewName = $routeParams.view;
} else {
console.log("ERROR : 'view' GET parameter must be the custom view name");
return;
}
$scope.customViewCells = customViewsConfig[viewName].cells.join();
$scope.customViewApiName = customViewsConfig[viewName].apiName;
$scope.customViewFilters = customViewsConfig[viewName].filters;
}])
.run(['readConfig', 'customViewsConfig', function (readConfig, customViewsConfig) {
var viewsConfig = readConfig.data.customViewsConfig;
angular.forEach(viewsConfig, function(config, view) {
customViewsConfig[view] = config;
});
}]);

View File

@ -55,6 +55,7 @@
<script src="dashboard/dashboard.js"></script>
<script src="hosts/hosts.js"></script>
<script src="services/services.js"></script>
<script src="custom_views/custom_views.js"></script>
</head>
<body class="layout color-scheme--dark">