Dashboard is now a template

This commit is contained in:
Frédéric Vachon 2015-03-06 17:22:06 -05:00
parent 9c41efbf26
commit e50050941a
4 changed files with 24 additions and 10 deletions

View File

@ -2,7 +2,7 @@
"dashboardConfig": {
"title": "Unhandled service problems",
"refreshInterval": "10000",
"template": "",
"template": "dashboard",
"components" : [
{
"type": "tactical",

View File

@ -15,7 +15,7 @@
<span class="sidebar__category">Shortcut</span>
<ul class="sidebar__sublist" id="shortcutList">
<li class="sidebar__subitem"><a ng-class="getClass('/dashboard')" href="#/dashboard">Dashboard</a></li>
<li class="sidebar__subitem"><a ng-class="getClass('/dashboard?view=dashboardConfig')" href="#/dashboard?view=dashboardConfig">Dashboard</a></li>
<li class="sidebar__subitem"><a ng-class="getClass('/singleTable?view=hostsConfig')" href="#/singleTable?view=hostsConfig">Hosts</a></li>
<li class="sidebar__subitem"><a ng-class="getClass('/singleTable?view=servicesConfig')" href="#/singleTable?view=servicesConfig">Services</a></li>
<li class="sidebar__subitem"><a href="#">Networks parents</a></li>

View File

@ -15,8 +15,8 @@ angular.module('adagios.view.dashboard', ['ngRoute',
});
}])
.controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig', 'TableConfigObj', 'TacticalConfigObj',
function ($scope, dashboardConfig, getServices, tableConfig, TableConfigObj, TacticalConfigObj) {
.controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices', 'tableConfig', 'TableConfigObj', 'TacticalConfigObj',
function ($scope, $routeParams, dashboardConfig, getServices, tableConfig, TableConfigObj, TacticalConfigObj) {
var fields = ['state'],
filters = {'isnot' : { 'state' : ['0'] }},
@ -24,17 +24,25 @@ angular.module('adagios.view.dashboard', ['ngRoute',
components = [],
component,
config,
viewName,
i = 0;
tableConfig.index = 0;
$scope.dashboardTitle = dashboardConfig.data.title;
$scope.dashboardTemplate = dashboardConfig.data.template;
$scope.dashboardRefreshInterval = dashboardConfig.data.refreshInterval;
if (!!$routeParams.view) {
viewName = $routeParams.view;
} else {
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
}
$scope.dashboardTitle = dashboardConfig[viewName].title;
$scope.dashboardTemplate = dashboardConfig[viewName].template;
$scope.dashboardRefreshInterval = dashboardConfig[viewName].refreshInterval;
$scope.dashboardTactical = [];
$scope.dashboardTables = [];
components = dashboardConfig.data.components;
components = dashboardConfig[viewName].components;
for (i = 0; i < components.length; i += 1) {
component = components[i];
@ -54,5 +62,11 @@ angular.module('adagios.view.dashboard', ['ngRoute',
}])
.run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) {
dashboardConfig.data = readConfig.data.dashboardConfig;
var viewsConfig = readConfig.data;
angular.forEach(viewsConfig, function (config, view) {
if (config.template === 'dashboard') {
dashboardConfig[view] = config;
}
});
}]);

View File

@ -38,7 +38,7 @@ angular.module('adagios.view.singleTable', ['ngRoute',
var viewsConfig = readConfig.data;
angular.forEach(viewsConfig, function (config, view) {
if (config.template === "singleTable") {
if (config.template === 'singleTable') {
singleTableConfig[view] = config;
}
});