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_hosts_host/cell_hosts_host.js',
|
||||||
'<%= 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 %>/routing_view/routing_view.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: {
|
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_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_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 %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.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' : [
|
'<%= 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_hosts_host/cell_hosts_host.js',
|
||||||
'<%= 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 %>/routing_view/routing_view.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'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -28,8 +28,8 @@ angular.module('adagios', [
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
// Reinitialise objects on url change
|
// Reinitialise objects on url change
|
||||||
.run(['$rootScope', 'reinitTables', function($rootScope, reinitTables) {
|
.run(['$rootScope', 'reinitTables', function ($rootScope, reinitTables) {
|
||||||
$rootScope.$on('$locationChangeStart', function() {
|
$rootScope.$on('$locationChangeStart', function () {
|
||||||
reinitTables();
|
reinitTables();
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
"hostsConfig": {
|
"hostsConfig": {
|
||||||
"title": "Hosts",
|
"title": "Hosts",
|
||||||
"refreshInterval": 0,
|
"refreshInterval": 0,
|
||||||
"template": "singleTable",
|
"template": "single_table",
|
||||||
"components": [
|
"components": [
|
||||||
{
|
{
|
||||||
"type": "table",
|
"type": "table",
|
||||||
@ -180,7 +180,7 @@
|
|||||||
"servicesConfig": {
|
"servicesConfig": {
|
||||||
"title": "Services",
|
"title": "Services",
|
||||||
"refreshInterval": 0,
|
"refreshInterval": 0,
|
||||||
"template": "singleTable",
|
"template": "single_table",
|
||||||
"components": [{
|
"components": [{
|
||||||
"type": "table",
|
"type": "table",
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<ul class="sidebar__sublist collapse in" id="shortcutList">
|
<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('/view?view=dashboardConfig')" href="#/view?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('/view?view=hostsConfig')" href="#/view?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=servicesConfig')" href="#/view?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>
|
||||||
|
@ -16,7 +16,13 @@ angular.module('adagios.view', ['ngRoute',
|
|||||||
.controller('ViewCtrl', ['$scope', '$routeParams', 'viewsTemplate',
|
.controller('ViewCtrl', ['$scope', '$routeParams', 'viewsTemplate',
|
||||||
function ($scope, $routeParams, viewsTemplate) {
|
function ($scope, $routeParams, viewsTemplate) {
|
||||||
var templateName = viewsTemplate[$routeParams.view],
|
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;
|
$scope.templateUrl = templateUrl;
|
||||||
}])
|
}])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<article id="tactical">
|
<article ng-controller="DashboardCtrl" id="tactical">
|
||||||
<header class="main__overview">
|
<header class="main__overview">
|
||||||
<h2 class="main__overview__title">{{dashboardTactical[0].title}}</h2>
|
<h2 class="main__overview__title">{{dashboardTactical[0].title}}</h2>
|
||||||
|
|
@ -8,14 +8,7 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
|||||||
|
|
||||||
.value('dashboardConfig', {})
|
.value('dashboardConfig', {})
|
||||||
|
|
||||||
.config(['$routeProvider', function ($routeProvider) {
|
.controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices',
|
||||||
$routeProvider.when('/dashboard', {
|
|
||||||
templateUrl: 'dashboard/dashboard.html',
|
|
||||||
controller: 'DashboardCtrl'
|
|
||||||
});
|
|
||||||
}])
|
|
||||||
|
|
||||||
.controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices',
|
|
||||||
'TableConfigObj', 'TacticalConfigObj', 'getHostOpenProblems', 'getServiceOpenProblems', 'getHostProblems',
|
'TableConfigObj', 'TacticalConfigObj', 'getHostOpenProblems', 'getServiceOpenProblems', 'getHostProblems',
|
||||||
'getServiceProblems',
|
'getServiceProblems',
|
||||||
function ($scope, $routeParams, dashboardConfig, getServices, TableConfigObj,
|
function ($scope, $routeParams, dashboardConfig, getServices, TableConfigObj,
|
||||||
@ -23,15 +16,9 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
|||||||
var components = [],
|
var components = [],
|
||||||
component,
|
component,
|
||||||
config,
|
config,
|
||||||
viewName,
|
viewName = $scope.viewName,
|
||||||
i = 0;
|
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.dashboardTitle = dashboardConfig[viewName].title;
|
||||||
$scope.dashboardTemplate = dashboardConfig[viewName].template;
|
$scope.dashboardTemplate = dashboardConfig[viewName].template;
|
||||||
$scope.dashboardRefreshInterval = dashboardConfig[viewName].refreshInterval;
|
$scope.dashboardRefreshInterval = dashboardConfig[viewName].refreshInterval;
|
@ -1,4 +1,4 @@
|
|||||||
<article id="tactical">
|
<article ng-controller="SingleTableCtrl" id="tactical">
|
||||||
|
|
||||||
<section class="main__content tabpanel">
|
<section class="main__content tabpanel">
|
||||||
|
|
@ -9,22 +9,9 @@ angular.module('adagios.view.singleTable', ['ngRoute',
|
|||||||
|
|
||||||
.value('singleTableConfig', {})
|
.value('singleTableConfig', {})
|
||||||
|
|
||||||
.config(['$routeProvider', function ($routeProvider) {
|
|
||||||
$routeProvider.when('/singleTable', {
|
|
||||||
templateUrl: 'single_table/single_table.html',
|
|
||||||
controller: 'SingleTableCtrl'
|
|
||||||
});
|
|
||||||
}])
|
|
||||||
|
|
||||||
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'TableConfigObj',
|
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'TableConfigObj',
|
||||||
function ($scope, $routeParams, singleTableConfig, TableConfigObj) {
|
function ($scope, $routeParams, singleTableConfig, TableConfigObj) {
|
||||||
var viewName = "";
|
var viewName = $scope.viewName;
|
||||||
|
|
||||||
if (!!$routeParams.view) {
|
|
||||||
viewName = $routeParams.view;
|
|
||||||
} else {
|
|
||||||
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.tableConfig = new TableConfigObj(singleTableConfig[viewName].components[0].config);
|
$scope.tableConfig = new TableConfigObj(singleTableConfig[viewName].components[0].config);
|
||||||
|
|
||||||
@ -36,7 +23,7 @@ angular.module('adagios.view.singleTable', ['ngRoute',
|
|||||||
var viewsConfig = readConfig.data;
|
var viewsConfig = readConfig.data;
|
||||||
|
|
||||||
angular.forEach(viewsConfig, function (config, view) {
|
angular.forEach(viewsConfig, function (config, view) {
|
||||||
if (config.template === 'singleTable') {
|
if (config.template === 'single_table') {
|
||||||
singleTableConfig[view] = config;
|
singleTableConfig[view] = config;
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user