Integrated dynamic template loading
This commit is contained in:
parent
4bd1253337
commit
ac34be55e8
12
Gruntfile.js
12
Gruntfile.js
@ -109,9 +109,9 @@ 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 %>/dashboard/dashboard.js',
|
||||
'<%= project.app %>/routing_view/routing_view.js',
|
||||
'<%= project.app %>/single_table/single_table.js'
|
||||
'<%= project.app %>/templates/dashboard/dashboard.js',
|
||||
'<%= project.app %>/templates/single_table/single_table.js'
|
||||
]
|
||||
}],
|
||||
options: {
|
||||
@ -143,9 +143,9 @@ 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 %>/dashboard/dashboard.js': '<%= project.app %>/dashboard/dashboard.js',
|
||||
'<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js',
|
||||
'<%= project.build %>/single_table/single_table.js' : '<%= project.app %>/single_table/single_table.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 %>/js/adagios.min.js' : [
|
||||
@ -171,9 +171,9 @@ 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 %>/dashboard/dashboard.js',
|
||||
'<%= project.build %>/routing_view/routing_view.js',
|
||||
'<%= project.build %>/single_table/single_table.js'
|
||||
'<%= project.build %>/templates/dashboard/dashboard.js',
|
||||
'<%= project.build %>/templates/single_table/single_table.js'
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -147,7 +147,7 @@
|
||||
"hostsConfig": {
|
||||
"title": "Hosts",
|
||||
"refreshInterval": 0,
|
||||
"template": "singleTable",
|
||||
"template": "single_table",
|
||||
"components": [
|
||||
{
|
||||
"type": "table",
|
||||
@ -180,7 +180,7 @@
|
||||
"servicesConfig": {
|
||||
"title": "Services",
|
||||
"refreshInterval": 0,
|
||||
"template": "singleTable",
|
||||
"template": "single_table",
|
||||
"components": [{
|
||||
"type": "table",
|
||||
"config": {
|
||||
|
@ -22,9 +22,9 @@
|
||||
</button>
|
||||
|
||||
<ul class="sidebar__sublist collapse in" id="shortcutList">
|
||||
<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 ng-class="getClass('/view?view=dashboardConfig')" href="#/view?view=dashboardConfig">Dashboard</a></li>
|
||||
<li class="sidebar__subitem"><a ng-class="getClass('/view?view=hostsConfig')" href="#/view?view=hostsConfig">Hosts</a></li>
|
||||
<li class="sidebar__subitem"><a ng-class="getClass('/view?view=servicesConfig')" href="#/view?view=servicesConfig">Services</a></li>
|
||||
<li class="sidebar__subitem"><a href="#">Networks parents</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -16,7 +16,13 @@ angular.module('adagios.view', ['ngRoute',
|
||||
.controller('ViewCtrl', ['$scope', '$routeParams', 'viewsTemplate',
|
||||
function ($scope, $routeParams, viewsTemplate) {
|
||||
var templateName = viewsTemplate[$routeParams.view],
|
||||
templateUrl = templateName + '/' + templateName + '.html';
|
||||
templateUrl = 'templates/' + templateName + '/' + templateName + '.html';
|
||||
|
||||
if (!!$routeParams.view) {
|
||||
$scope.viewName = $routeParams.view;
|
||||
} else {
|
||||
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
|
||||
}
|
||||
|
||||
$scope.templateUrl = templateUrl;
|
||||
}])
|
||||
|
@ -1,4 +1,4 @@
|
||||
<article id="tactical">
|
||||
<article ng-controller="DashboardCtrl" id="tactical">
|
||||
<header class="main__overview">
|
||||
<h2 class="main__overview__title">{{dashboardTactical[0].title}}</h2>
|
||||
|
@ -8,13 +8,6 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
|
||||
.value('dashboardConfig', {})
|
||||
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
$routeProvider.when('/dashboard', {
|
||||
templateUrl: 'dashboard/dashboard.html',
|
||||
controller: 'DashboardCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices',
|
||||
'TableConfigObj', 'TacticalConfigObj', 'getHostOpenProblems', 'getServiceOpenProblems', 'getHostProblems',
|
||||
'getServiceProblems',
|
||||
@ -23,15 +16,9 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
var components = [],
|
||||
component,
|
||||
config,
|
||||
viewName,
|
||||
viewName = $scope.viewName,
|
||||
i = 0;
|
||||
|
||||
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;
|
@ -1,4 +1,4 @@
|
||||
<article id="tactical">
|
||||
<article ng-controller="SingleTableCtrl" id="tactical">
|
||||
|
||||
<section class="main__content tabpanel">
|
||||
|
@ -9,22 +9,9 @@ angular.module('adagios.view.singleTable', ['ngRoute',
|
||||
|
||||
.value('singleTableConfig', {})
|
||||
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
$routeProvider.when('/singleTable', {
|
||||
templateUrl: 'single_table/single_table.html',
|
||||
controller: 'SingleTableCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'TableConfigObj',
|
||||
function ($scope, $routeParams, singleTableConfig, TableConfigObj) {
|
||||
var viewName = "";
|
||||
|
||||
if (!!$routeParams.view) {
|
||||
viewName = $routeParams.view;
|
||||
} else {
|
||||
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
|
||||
}
|
||||
var viewName = $scope.viewName;
|
||||
|
||||
$scope.tableConfig = new TableConfigObj(singleTableConfig[viewName].components[0].config);
|
||||
|
||||
@ -36,7 +23,7 @@ angular.module('adagios.view.singleTable', ['ngRoute',
|
||||
var viewsConfig = readConfig.data;
|
||||
|
||||
angular.forEach(viewsConfig, function (config, view) {
|
||||
if (config.template === 'singleTable') {
|
||||
if (config.template === 'single_table') {
|
||||
singleTableConfig[view] = config;
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user