Merge "Config host and config Template pages"

This commit is contained in:
Jenkins 2015-08-10 16:44:06 +00:00 committed by Gerrit Code Review
commit cd297b3d0e
23 changed files with 369 additions and 35 deletions

View File

@ -55,14 +55,14 @@ angular.module('bansho.authentication', [])
}])
.factory('authService', [ '$http', '$location', '$rootScope', 'session', 'configManager', 'themeManager', 'surveilConfig',
function ($http, $location, $rootScope, session, configManager, themeManager, surveilConfig) {
.factory('authService', [ '$http', '$location', '$rootScope', 'session', 'configManager', 'themeManager', 'surveilApiConfig',
function ($http, $location, $rootScope, session, configManager, themeManager, surveilApiConfig) {
var authService = {},
onLogin = [];
authService.login = function (credentials) {
return $http
.post(surveilConfig.getAuthUrl() + '/tokens/', credentials)
.post(surveilApiConfig.getAuthUrl() + '/tokens/', credentials)
.success(function (data) {
$rootScope.isAuthenticated = true;

View File

@ -198,6 +198,30 @@
}
}
},
"allHostConfigTemplate": {
"name": "Host config template",
"filter": {
"hosts": {
"is": {
"register": [
"0"
]
}
}
}
},
"allHostConfigWithoutTemplate": {
"name": "Host config without template",
"filter": {
"hosts": {
"isnot": {
"register": [
"0"
]
}
}
}
},
"all": {
"name": "All",
"filter": {
@ -247,6 +271,16 @@
"provider": "status",
"endpoint": "services",
"filter": "all"
},
"hostsConfig": {
"provider": "config",
"endpoint": "hosts",
"filter": "allHostConfigWithoutTemplate"
},
"hostsConfigTemplate": {
"provider": "config",
"endpoint": "hosts",
"filter": "allHostConfigTemplate"
}
}
}

View File

@ -114,8 +114,8 @@ angular.module('bansho.config', [])
};
}])
.service('configManager', ['$http', '$q', 'componentsConfig', 'surveilConfig',
function ($http, $q, componentsConfig, surveilConfig) {
.service('configManager', ['$http', '$q', 'componentsConfig', 'surveilApiConfig',
function ($http, $q, componentsConfig, surveilApiConfig) {
var layoutConfig = {},
config = {};
@ -125,8 +125,8 @@ angular.module('bansho.config', [])
$http.get('components/config/config.json')
.success(function (c) {
config = c;
surveilConfig.setSurveilApiUrl(c.surveilApiUrl);
surveilConfig.setAuthUrl(c.surveilAuthUrl);
surveilApiConfig.setSurveilApiUrl(c.surveilApiUrl);
surveilApiConfig.setAuthUrl(c.surveilAuthUrl);
promise.resolve();
})
.error(function() {
@ -185,7 +185,7 @@ angular.module('bansho.config', [])
var saveLayoutConfig = function () {
var responsePromise = $q.defer();
$http.post(surveilConfig.endpoint('appConfig'), JSON.stringify(layoutConfig.data))
$http.post(surveilApiConfig.endpoint('appConfig'), JSON.stringify(layoutConfig.data))
.success(function () {
responsePromise.resolve();
})
@ -201,14 +201,14 @@ angular.module('bansho.config', [])
componentsConfig.load();
$http.get(surveilConfig.endpoint('appConfig'))
$http.get(surveilApiConfig.endpoint('appConfig'))
.success(function (conf) {
if (!useStoredConfig || jQuery.isEmptyObject(conf)) {
$http.get('components/config/defaultLayoutConfig.json')
.success(function (conf) {
layoutConfig.data = conf;
$http.post(surveilConfig.endpoint('appConfig'), JSON.stringify(conf))
$http.post(surveilApiConfig.endpoint('appConfig'), JSON.stringify(conf))
.success(function () {
responsePromise.resolve();
})

View File

@ -692,5 +692,158 @@
},
"config": {
"template": "config"
},
"configHosts": {
"template": "page",
"components": [
{
"type": "panel",
"components": [
{
"type": "title",
"attributes": {
"title": "ConfigHosts"
}
},
{
"type": "actionbar",
"attributes": {
"tableId": [
0
]
},
"components": [
{
"type": "actionbar-filter",
"attributes": {
"filters": [
{
"location": "componentsConfig",
"content": "all"
},
{
"location": "componentsConfig",
"content": "hostOk"
},
{
"location": "componentsConfig",
"content": "hostNotOk"
}
]
}
},
{
"type": "actionbar-more",
"attributes": {}
},
{
"type": "actionbar-search-filter",
"attributes": {}
}
]
},
{
"type": "table",
"attributes": {
"tableId": 0,
"refreshInterval": 30,
"cells": {
"text": [
"Host",
"Address",
"Use",
"Enable"
],
"name": [
"config_host",
"config_host_address",
"config_host_use",
"config_host_register"
]
},
"headerFollow": false,
"inputSource": "hostsConfig",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false
}
}
]
}
]
},
"configHostsTemplate": {
"template": "page",
"components": [
{
"type": "panel",
"components": [
{
"type": "title",
"attributes": {
"title": "Hosts Template"
}
},
{
"type": "actionbar",
"attributes": {
"tableId": [
0
]
},
"components": [
{
"type": "actionbar-filter",
"attributes": {
"filters": [
{
"location": "componentsConfig",
"content": "all"
},
{
"location": "componentsConfig",
"content": "hostOk"
},
{
"location": "componentsConfig",
"content": "hostNotOk"
}
]
}
},
{
"type": "actionbar-more",
"attributes": {}
},
{
"type": "actionbar-search-filter",
"attributes": {}
}
]
},
{
"type": "table",
"attributes": {
"tableId": 0,
"cells": {
"text": [
"Template",
"Use"
],
"name": [
"config_host_name",
"config_host_use"
]
},
"headerFollow": false,
"inputSource": "hostsConfigTemplate",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false
}
}
]
}
]
}
}

View File

@ -3,10 +3,11 @@
angular.module('bansho.datasource', ['bansho.surveil'])
.value('tableGlobalConfig', {'cellToFieldsMap': {}, 'cellWrappableField': {}})
.service('datasource', ['$filter', 'surveilStatus', 'surveilQuery', 'componentsConfig', 'tableGlobalConfig',
function ($filter, surveilStatus, surveilQuery, componentsConfig, tableGlobalConfig) {
.service('datasource', ['$filter', 'surveilStatus', 'surveilConfig', 'surveilQuery', 'componentsConfig', 'tableGlobalConfig',
function ($filter, surveilStatus, surveilConfig, surveilQuery, componentsConfig, tableGlobalConfig) {
var providerServices = {
status: surveilStatus
status: surveilStatus,
config: surveilConfig
},
config = [],
data = [],

View File

@ -0,0 +1,3 @@
<td class="data-table__host {{entry[cell_name + '_additionnalClass']}}" ng-controller="CellConfigHostCtrl">
<a class="data-table__data" href="#/view?view=host&host_name={{entry.host_name}}">{{entry.host_name}}</a>
</td>

View File

@ -0,0 +1,12 @@
'use strict';
angular.module('bansho.table.cell_config_host', ['bansho.table'])
.controller('CellConfigHostCtrl', ['$scope', function ($scope) {
$scope.cell_name = 'host';
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host = ['host_name'];
tableGlobalConfig.cellWrappableField.config_host = 'host_name';
}]);

View File

@ -0,0 +1,3 @@
<td class="data-table__hostaddress">
<span class="data-table__data">{{entry.address}}</span>
</td>

View File

@ -0,0 +1,11 @@
'use strict';
angular.module('bansho.table.cell_config_host_address', ['bansho.table'])
.controller('CellConfigHostAddressCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_address = ['address'];
}]);

View File

@ -0,0 +1,3 @@
<td class="data-table__hostname">
<span class="data-table__data">{{entry.name}}</span>
</td>

View File

@ -0,0 +1,11 @@
'use strict';
angular.module('bansho.table.cell_config_host_name', ['bansho.table'])
.controller('CellConfigHostNameCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_use = ['name'];
}]);

View File

@ -0,0 +1,3 @@
<td class="data-table__hostregister" data-ng-controller="CellConfigHostRegisterCtrl">
<span class="data-table__data fa {{activityClass}}"></span>
</td>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.table.cell_config_host_register', ['bansho.table'])
.controller('CellConfigHostRegisterCtrl', ['$scope', function ($scope) {
if ($scope.register === 0) {
$scope.activityClass = 'fa-times-circle-o';
} else {
$scope.activityClass = 'fa-check-circle-o';
}
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_register = ['register'];
}]);

View File

@ -0,0 +1,3 @@
<td class="data-table__hostuse">
<span class="data-table__data">{{entry.use}}</span>
</td>

View File

@ -0,0 +1,11 @@
'use strict';
angular.module('bansho.table.cell_config_host_use', ['bansho.table'])
.controller('CellConfigHostUseCtrl', [function () {
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.config_host_use = ['use'];
}]);

View File

@ -1,3 +1,3 @@
<td class="data-table__event_output" ng-controller="CellStatusEventOutputCtrl">
<td class="data-table__event_output">
<p class="data-table__data">{{entry.event_output}}</p>
</td>

View File

@ -8,4 +8,4 @@ angular.module('bansho.table.cell_status_host_status', ['bansho.table'])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.status_host_status = ['state', 'last_check', 'parents'];
}]);
}]);

View File

@ -5,15 +5,12 @@ angular.module('bansho.table', ['bansho.datasource',
'bansho.filters',
'bansho.table.cell_status_host',
'bansho.table.cell_status_event',
'bansho.table.cell_status_event_event_type',
'bansho.table.cell_status_event_output',
'bansho.table.cell_status_event_host_name',
'bansho.table.cell_status_event_service',
'bansho.table.cell_status_duration',
'bansho.table.cell_status_service_check',
'bansho.table.cell_status_last_check',
'bansho.table.cell_status_host_address',
'bansho.table.cell_status_host_status',
'bansho.table.cell_config_host',
'bansho.table.cell_config_host_register',
'ngMaterial'
])

View File

@ -27,6 +27,20 @@
<li class="sidebar__subitem"><a href="#">Networks parents</a></li>
</ul>
</li>
<li class="sidebar__item">
<button class="sidebar__category"
data-toggle="collapse"
data-target="#reportsList"
aria-expanded="true"
aria-controls="reportsList">Config Objects</button>
<button class="sidebar__customize ico-cog">
<span class="visuallyhidden">Customize the config objects category</span>
</button>
<ul class="sidebar__sublist collapse in" id="configList">
<li class="sidebar__subitem"><a href="#/view?view=configHosts">Host</a></li>
<li class="sidebar__subitem"><a href="#/view?view=configHostsTemplate">Templates</a></li>
</ul>
</li>
<li class="sidebar__item">
<button class="sidebar__category"
data-toggle="collapse"

View File

@ -0,0 +1,55 @@
/*global jQuery */
'use strict';
angular.module('bansho.surveil')
.service('surveilConfig', ['$http', '$q','surveilQuery', 'componentsConfig', 'surveilApiConfig',
function ($http, $q, surveilQuery, componentsConfig, surveilApiConfig) {
var executeQuery = function (url, method, query) {
return $http({
url: url,
method: method,
data: query
}).error(function () {
throw new Error('executeQuery : ' + method + ' Request failed');
});
};
var getData = function (fields, filters, endpoint) {
var promise = $q.defer();
if (!queryEndpoint[endpoint]) {
throw new Error('getData in surveilConfig : Invalid endpoint ' + endpoint);
}
queryEndpoint[endpoint](fields, filters, function (data) {
promise.resolve(data);
});
return promise.promise;
};
var queryEndpoint = {
"hosts": function (fields, filters, callback) {
var hostQuery = surveilQuery(fields, filters.hosts),
method = 'POST',
hostUrl = surveilApiConfig.endpoint('config') + '/hosts/';
executeQuery(hostUrl, method, hostQuery)
.success(function (hosts) {
var response = [];
angular.forEach(hosts, function (host) {
response.push(host);
});
callback(response);
});
}
};
return {
getData: getData
};
}]);

View File

@ -3,10 +3,10 @@
'use strict';
angular.module('bansho.surveil')
.service('surveilStatus', ['$http', '$q', 'surveilQuery', 'componentsConfig', 'surveilConfig',
function ($http, $q, surveilQuery, componentsConfig, surveilConfig) {
.service('surveilStatus', ['$http', '$q', 'surveilQuery', 'componentsConfig', 'surveilApiConfig',
function ($http, $q, surveilQuery, componentsConfig, surveilApiConfig) {
var getMetric = function (host, service, metric) {
var url = surveilConfig.endpoint('status') + '/hosts/' + host,
var url = surveilApiConfig.endpoint('status') + '/hosts/' + host,
responsePromise = $q.defer();
if (service !== undefined) {
@ -25,7 +25,7 @@ angular.module('bansho.surveil')
};
var getMetricNames = function (host, service) {
var url = surveilConfig.endpoint('status') + '/hosts/' + host,
var url = surveilApiConfig.endpoint('status') + '/hosts/' + host,
responsePromise = $q.defer();
if (service !== undefined) {
@ -76,9 +76,9 @@ angular.module('bansho.surveil')
var hostQuery = surveilQuery(fields, filters.hosts),
serviceQuery = surveilQuery(fields, filters.services);
executeQuery(surveilConfig.endpoint('status') + '/hosts/', 'POST', hostQuery)
executeQuery(surveilApiConfig.endpoint('status') + '/hosts/', 'POST', hostQuery)
.success(function (hosts) {
executeQuery(surveilConfig.endpoint('status') + '/services/', 'POST', serviceQuery)
executeQuery(surveilApiConfig.endpoint('status') + '/services/', 'POST', serviceQuery)
.success(function (services) {
callback(hosts, services);
});
@ -127,12 +127,7 @@ angular.module('bansho.surveil')
"hosts": function (fields, filters, callback) {
var hostQuery = surveilQuery(fields, filters.hosts),
method = 'POST',
hostUrl = surveilConfig.endpoint('status') + '/hosts/';
if (filters.hosts && filters.hosts.is && filters.hosts.is.host_name) {
hostUrl += filters.hosts.is.host_name;
method = 'GET';
}
hostUrl = surveilApiConfig.endpoint('status') + '/hosts/';
executeQuery(hostUrl, method, hostQuery)
.success(function (hosts) {
@ -149,7 +144,7 @@ angular.module('bansho.surveil')
"events": function (fields, filters, callback) {
var query = surveilQuery(fields, filters.events);
executeQuery(surveilConfig.endpoint('status') + '/events/', 'POST', query)
executeQuery(surveilApiConfig.endpoint('status') + '/events/', 'POST', query)
.success(function (events) {
angular.forEach(events, function (event) {
angular.forEach(event, function (value, attr) {

View File

@ -1,5 +1,5 @@
angular.module('bansho.surveil', [])
.service('surveilConfig', function () {
.service('surveilApiConfig', function () {
var apiUrl,
authUrl,
surveilEndpoints = {};
@ -10,6 +10,7 @@ angular.module('bansho.surveil', [])
surveilEndpoints = {
status: apiUrl + '/status',
actions: apiUrl + '/actions',
config: apiUrl + '/config',
appConfig: apiUrl + '/bansho/config'
};
},

View File

@ -11,6 +11,7 @@
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,400italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="assets/css/app.css">
<!-- build:css assets/css/app_ext_css.css -->
<link href="bower_components/fontawesome/css/font-awesome.min.css" media="all" rel="stylesheet" type="text/css">
<link href="bower_components/pnotify/pnotify.core.css" media="all" rel="stylesheet" type="text/css" />
<link href="bower_components/pnotify/pnotify.buttons.css" media="all" rel="stylesheet" type="text/css" />
<link href="bower_components/pnotify/pnotify.history.css" media="all" rel="stylesheet" type="text/css" />
@ -49,6 +50,7 @@
<script src="components/surveil/surveil.js"></script>
<script src="components/surveil/status.js"></script>
<script src="components/surveil/actions.js"></script>
<script src="components/surveil/config.js"></script>
<script src="components/surveil/query.js"></script>
<script src="components/authentication/authentication.js"></script>
@ -69,6 +71,7 @@
<script src="components/directive/tabpanel/tabpanel.js"></script>
<!-- Table components -->
<script src="components/directive/actionbar/actionbar.js"></script>
<script src="components/directive/actionbar/component_acknowledge/acknowledge.js"></script>
<script src="components/directive/actionbar/component_downtime/downtime.js"></script>
@ -79,6 +82,12 @@
<script src="components/directive/table/table.js"></script>
<script src="components/directive/table/cell_status_duration/cell_status_duration.js"></script>
<script src="components/directive/table/cell_config_host/cell_config_host.js"></script>
<script src="components/directive/table/cell_config_host_address/cell_config_host_address.js"></script>
<script src="components/directive/table/cell_config_host_name/cell_config_host_name.js"></script>
<script src="components/directive/table/cell_config_host_register/cell_config_host_register.js"></script>
<script src="components/directive/table/cell_config_host_use/cell_config_host_use.js"></script>
<script src="components/directive/table/cell_status_event/cell_status_event.js"></script>
<script src="components/directive/table/cell_status_event_event_type/cell_status_event_event_type.js"></script>
<script src="components/directive/table/cell_status_event_output/cell_status_event_output.js"></script>
@ -134,7 +143,7 @@
<bansho-topbar ng-show="isAuthenticated"></bansho-topbar>
</div>
<div ng-view id="page" class="main" role="main"></div>
<main ng-view id="page" class="main" role="main"></main>
<footer class="footer" role="contentinfo"></footer>
</div>
</div>