single_table template

This commit is contained in:
Frédéric Vachon 2015-03-06 16:42:55 -05:00
parent 00437462c1
commit 144490eba2
13 changed files with 114 additions and 238 deletions

View File

@ -110,9 +110,7 @@ module.exports = function (grunt) {
'<%= project.app %>/components/table/cell_host_address/cell_host_address.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/table/cell_host_status/cell_host_status.js',
'<%= project.app %>/dashboard/dashboard.js', '<%= project.app %>/dashboard/dashboard.js',
'<%= project.app %>/hosts/hosts.js', '<%= project.app %>/single_table/single_table.js'
'<%= project.app %>/services/services.js',
'<%= project.app %>/custom_views/custom_views.js'
] ]
}], }],
options: { options: {
@ -145,9 +143,7 @@ module.exports = function (grunt) {
'<%= 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_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/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js',
'<%= project.build %>/dashboard/dashboard.js': '<%= project.app %>/dashboard/dashboard.js', '<%= project.build %>/dashboard/dashboard.js': '<%= project.app %>/dashboard/dashboard.js',
'<%= project.build %>/hosts/hosts.js': '<%= project.app %>/hosts/hosts.js', '<%= project.build %>/single_table/single_table.js' : '<%= project.app %>/single_table/single_table.js'
'<%= project.build %>/services/services.js': '<%= project.app %>/services/services.js',
'<%= project.build %>/custom_views/custom_views.js' : '<%= project.app %>/custom_views/custom_views.js'
}, },
{ {
'<%= project.build %>/js/adagios.min.js' : [ '<%= project.build %>/js/adagios.min.js' : [
@ -174,9 +170,7 @@ module.exports = function (grunt) {
'<%= project.build %>/components/table/cell_host_address/cell_host_address.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/table/cell_host_status/cell_host_status.js',
'<%= project.build %>/dashboard/dashboard.js', '<%= project.build %>/dashboard/dashboard.js',
'<%= project.build %>/hosts/hosts.js', '<%= project.build %>/single_table/single_table.js'
'<%= project.build %>/services/services.js',
'<%= project.build %>/custom_views/custom_views.js'
] ]
} }
], ],

View File

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

View File

@ -16,8 +16,8 @@
<ul class="sidebar__sublist" id="shortcutList"> <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')" href="#/dashboard">Dashboard</a></li>
<li class="sidebar__subitem"><a ng-class="getClass('/hosts')" href="#/hosts">Hosts</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('/services')" href="#/services">Services</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> <li class="sidebar__subitem"><a href="#">Networks parents</a></li>
</ul> </ul>
</li> </li>

View File

@ -6,7 +6,7 @@ angular.module('adagios.sidebar', [])
$scope.getClass = function (path) { $scope.getClass = function (path) {
var class_name = ""; var class_name = "";
if ($location.path().substr(0, path.length) === path) { if ($location.url().substr(0, path.length) === path) {
class_name = "state--current"; class_name = "state--current";
} }

View File

@ -12,7 +12,7 @@ angular.module('adagios.table', ['adagios.live',
'adagios.table.cell_host_status' 'adagios.table.cell_host_status'
]) ])
.value('tableConfig', { 'cellToFieldsMap': {}, 'cellWrappableField': {}, 'index': 0}) .value('tableConfig', {'cellToFieldsMap': {}, 'cellWrappableField': {}, 'index': 0})
.controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat', .controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat',
function ($scope, $interval, getServices, tableConfig, processColumnRepeat) { function ($scope, $interval, getServices, tableConfig, processColumnRepeat) {

View File

@ -1,56 +0,0 @@
'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', 'tableConfig',
function ($scope, $routeParams, customViewsConfig, tableConfig) {
var viewName = "";
tableConfig.index = 0;
if (!!$routeParams.view) {
viewName = $routeParams.view;
} else {
console.error("ERROR : 'view' GET parameter must be the custom view name");
return;
}
function TableConfig(config) {
this.title = config.title;
this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join();
this.ApiName = config.apiName;
this.Filters = config.filters;
this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell;
}
$scope.tableConfig = new TableConfig(customViewsConfig[viewName].components[0].config);
$scope.singleTableTitle = customViewsConfig[viewName].title;
$scope.singleTableRefreshInterval = customViewsConfig[viewName].refreshInterval;
}])
.run(['readConfig', 'customViewsConfig', function (readConfig, customViewsConfig) {
var viewsConfig = readConfig.data;
angular.forEach(viewsConfig, function (config, view) {
if (config.template === "singleTable") {
customViewsConfig[view] = config;
}
});
}]);

View File

@ -16,60 +16,60 @@ angular.module('adagios.view.dashboard', ['ngRoute',
}]) }])
.controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig', .controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig',
function ($scope, dashboardConfig, getServices, tableConfig) { function ($scope, dashboardConfig, getServices, tableConfig) {
var fields = ['state'], var fields = ['state'],
filters = {'isnot' : { 'state' : ['0'] }}, filters = {'isnot' : { 'state' : ['0'] }},
apiName = 'hosts', apiName = 'hosts',
components = [], components = [],
component, component,
config, config,
i = 0; i = 0;
tableConfig.index = 0; tableConfig.index = 0;
$scope.dashboardTitle = dashboardConfig.data.title; $scope.dashboardTitle = dashboardConfig.data.title;
$scope.dashboardTemplate = dashboardConfig.data.template; $scope.dashboardTemplate = dashboardConfig.data.template;
$scope.dashboardRefreshInterval = dashboardConfig.data.refreshInterval; $scope.dashboardRefreshInterval = dashboardConfig.data.refreshInterval;
$scope.dashboardTactical = []; $scope.dashboardTactical = [];
$scope.dashboardTables = []; $scope.dashboardTables = [];
components = dashboardConfig.data.components; components = dashboardConfig.data.components;
function TableConfig(config) { function TableConfig(config) {
this.title = config.title; this.title = config.title;
this.CellsText = config.cells.text.join(); this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join(); this.CellsName = config.cells.name.join();
this.ApiName = config.apiName; this.ApiName = config.apiName;
this.Filters = config.filters; this.Filters = config.filters;
this.IsWrappable = config.isWrappable; this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell; this.NoRepeatCell = config.noRepeatCell;
}
function TacticalConfig(config) {
this.title = config.title;
this.statusOverview = config.components.statusOverview;
this.currentHealth = config.components.currentHealth;
this.topAlertProducers = config.components.topAlertProducers;
}
for (i = 0; i < components.length; i += 1) {
component = components[i];
config = component.config;
if (component.type === 'table') {
$scope.dashboardTables.push(new TableConfig(config));
} else if (component.type === 'tactical') {
$scope.dashboardTactical.push(new TacticalConfig(config));
console.log($scope.dashboardTactical[0].statusOverview);
} }
}
getServices(fields, filters, apiName) function TacticalConfig(config) {
.success(function (data) { this.title = config.title;
$scope.nbHostProblems = data.length; this.statusOverview = config.components.statusOverview;
}); this.currentHealth = config.components.currentHealth;
}]) this.topAlertProducers = config.components.topAlertProducers;
}
for (i = 0; i < components.length; i += 1) {
component = components[i];
config = component.config;
if (component.type === 'table') {
$scope.dashboardTables.push(new TableConfig(config));
} else if (component.type === 'tactical') {
$scope.dashboardTactical.push(new TacticalConfig(config));
console.log($scope.dashboardTactical[0].statusOverview);
}
}
getServices(fields, filters, apiName)
.success(function (data) {
$scope.nbHostProblems = data.length;
});
}])
.run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) { .run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) {
dashboardConfig.data = readConfig.data.dashboardConfig; dashboardConfig.data = readConfig.data.dashboardConfig;

View File

@ -1,22 +0,0 @@
<article ng-controller="HostsCtrl" id="tactical">
<section class="main__content tabpanel">
<div class="tab-content">
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{hostsTitle}}</h2>
</header>
</div>
</div>
<adg-table cells-name="{{hostsCellsName}}"
cells-text="{{hostsCellsText}}"
api-name="{{hostsApiName}}"
filters="{{hostsFilters}}"
is-wrappable="{{hostsIsWrappable}}"
no-repeat-cell="{{hostsNoRepeatCell}}"
refresh-interval="{{hostsRefreshInterval}}"></adg-table>
</section>
</article>

View File

@ -1,35 +0,0 @@
'use strict';
angular.module('adagios.view.hosts', ['ngRoute',
'adagios.table'
])
.value('hostsConfig', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/hosts', {
templateUrl: 'hosts/hosts.html',
controller: 'HostsCtrl'
});
}])
.controller('HostsCtrl', ['$scope', 'hostsConfig', function ($scope, hostsConfig) {
$scope.hostsTitle = hostsConfig.title;
$scope.hostsCellsText = hostsConfig.cellsText.join();
$scope.hostsCellsName = hostsConfig.cellsName.join();
$scope.hostsApiName = hostsConfig.apiName;
$scope.hostsFilters = hostsConfig.filters;
$scope.hostsIsWrappable = hostsConfig.isWrappable;
$scope.hostsRefreshInterval = hostsConfig.refreshInterval;
}])
.run(['readConfig', 'hostsConfig', function (readConfig, hostsConfig) {
hostsConfig.title = readConfig.data.hostsConfig.title;
hostsConfig.cellsText = readConfig.data.hostsConfig.cells.text;
hostsConfig.cellsName = readConfig.data.hostsConfig.cells.name;
hostsConfig.apiName = readConfig.data.hostsConfig.apiName;
hostsConfig.filters = readConfig.data.hostsConfig.filters;
hostsConfig.isWrappable = readConfig.data.hostsConfig.isWrappable;
hostsConfig.noRepeatCell = readConfig.data.hostsConfig.noRepeatCell;
hostsConfig.refreshInterval = readConfig.data.hostsConfig.refreshInterval;
}]);

View File

@ -1,22 +0,0 @@
<article ng-controller="ServicesCtrl" id="tactical">
<section class="main__content tabpanel">
<div class="tab-content">
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{servicesTitle}}</h2>
</header>
</div>
</div>
<adg-table cells-name="{{servicesCellsName}}"
cells-text="{{servicesCellsText}}"
api-name="{{servicesApiName}}"
filters="{{servicesFilters}}"
is-wrappable="{{servicesIsWrappable}}"
no-repeat-cell="{{servicesNoRepeatCell}}"
refresh-interval="{{servicesRefreshInterval}}"></adg-table>
</section>
</article>

View File

@ -1,36 +0,0 @@
'use strict';
angular.module('adagios.view.services', ['ngRoute',
'adagios.table'
])
.value('servicesConfig', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/services', {
templateUrl: 'services/services.html',
controller: 'ServicesCtrl'
});
}])
.controller('ServicesCtrl', ['$scope', 'servicesConfig', function ($scope, servicesConfig) {
$scope.servicesTitle = servicesConfig.title;
$scope.servicesCellsText = servicesConfig.cellsText.join();
$scope.servicesCellsName = servicesConfig.cellsName.join();
$scope.servicesApiName = servicesConfig.apiName;
$scope.servicesFilters = servicesConfig.filters;
$scope.servicesIsWrappable = servicesConfig.isWrappable;
$scope.servicesNoRepeatCell = servicesConfig.noRepeatCell;
$scope.servicesRefreshInterval = servicesConfig.refreshInterval;
}])
.run(['readConfig', 'servicesConfig', function (readConfig, servicesConfig) {
servicesConfig.title = readConfig.data.servicesConfig.title;
servicesConfig.cellsText = readConfig.data.servicesConfig.cells.text;
servicesConfig.cellsName = readConfig.data.servicesConfig.cells.name;
servicesConfig.apiName = readConfig.data.servicesConfig.apiName;
servicesConfig.filters = readConfig.data.servicesConfig.filters;
servicesConfig.isWrappable = readConfig.data.servicesConfig.isWrappable;
servicesConfig.noRepeatCell = readConfig.data.servicesConfig.noRepeatCell;
servicesConfig.refreshInterval = readConfig.data.servicesConfig.refreshInterval;
}]);

View File

@ -1,7 +1,7 @@
<article ng-controller="CustomViewsCtrl" id="tactical"> <article id="tactical">
<section class="main__content tabpanel"> <section class="main__content tabpanel">
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="problems tab-pane active" id="openProblems"> <div role="tabpanel" class="problems tab-pane active" id="openProblems">
<header class="main__content__header clearfix"> <header class="main__content__header clearfix">
@ -12,7 +12,7 @@
<adg-table cells-name="{{tableConfig.CellsName}}" <adg-table cells-name="{{tableConfig.CellsName}}"
cells-text="{{tableConfig.CellsText}}" cells-text="{{tableConfig.CellsText}}"
api-name="{{tableConfig.ApiName}}" api-name="{{tableConfig.ApiName}}"
filters="{{tableConfig.Filters}}" filters="{{tableConfig.Filters}}"
is-wrappable="{{tableConfig.IsWrappable}}" is-wrappable="{{tableConfig.IsWrappable}}"
no-repeat-cell="{{tableConfig.NoRepeatCell}}" no-repeat-cell="{{tableConfig.NoRepeatCell}}"

View File

@ -0,0 +1,55 @@
'use strict';
angular.module('adagios.view.singleTable', ['ngRoute',
'adagios.tactical.status_overview',
'adagios.tactical.current_health',
'adagios.tactical.top_alert_producers',
'adagios.table'
])
.value('singleTableConfig', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/singleTable', {
templateUrl: 'single_table/single_table.html',
controller: 'SingleTableCtrl'
});
}])
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'tableConfig',
function ($scope, $routeParams, singleTableConfig, tableConfig) {
var viewName = "";
tableConfig.index = 0;
if (!!$routeParams.view) {
viewName = $routeParams.view;
} else {
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
}
function TableConfig(config) {
this.title = config.title;
this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join();
this.ApiName = config.apiName;
this.Filters = config.filters;
this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell;
}
$scope.tableConfig = new TableConfig(singleTableConfig[viewName].components[0].config);
$scope.singleTableTitle = singleTableConfig[viewName].title;
$scope.singleTableRefreshInterval = singleTableConfig[viewName].refreshInterval;
}])
.run(['readConfig', 'singleTableConfig', function (readConfig, singleTableConfig) {
var viewsConfig = readConfig.data;
angular.forEach(viewsConfig, function (config, view) {
if (config.template === "singleTable") {
singleTableConfig[view] = config;
}
});
}]);