Clean config.js and remove container

Change-Id: Ieeb6980232c02ec72a6a0caa707dddbacb008a6f
This commit is contained in:
Vincent Fournier 2015-08-25 00:38:01 -04:00
parent 5d87fdaacd
commit 844d9e0e6e
58 changed files with 579 additions and 953 deletions

View File

@ -26,11 +26,12 @@ angular.module('bansho', [
}])
// Reinitialise objects on url change
.run(['$rootScope', 'templateManager', 'reinitDrupalTiles', 'reinitDrupalInfo', 'componentsConfig',
function ($rootScope, templateManager, reinitDrupalTiles, reinitDrupalInfo, componentsConfig) {
.run(['$rootScope', 'templateManager', 'sharedData', 'reinitDrupalTiles', 'reinitDrupalInfo', 'componentsConfig',
function ($rootScope, templateManager, sharedData, reinitDrupalTiles, reinitDrupalInfo, componentsConfig) {
componentsConfig.load();
$rootScope.$on('$locationChangeStart', function () {
templateManager.clearIntervals();
sharedData.clear(false);
templateManager.clearIntervals(false);
reinitDrupalTiles();
reinitDrupalInfo();
});

View File

@ -233,42 +233,42 @@
}
},
"inputSource": {
"hostOpenProblems": {
"statusHostsOpenProblems": {
"provider": "status",
"endpoint": "hosts",
"filter": "allHostOpenProblems"
},
"serviceOpenProblems": {
"statusServicesOpenProblems": {
"provider": "status",
"endpoint": "services",
"filter": "allServiceOpenProblems"
},
"serviceOpenProblemsOnly": {
"statusServicesOpenProblemsOnly": {
"provider": "status",
"endpoint": "services",
"filter": "allServiceOpenProblemsOnly"
},
"hostsProblems": {
"statusHostsProblems": {
"provider": "status",
"endpoint": "hosts",
"filter": "allHostsProblems"
},
"servicesProblems": {
"statusServicesProblems": {
"provider": "status",
"endpoint": "services",
"filter": "allServicesProblems"
},
"events": {
"statusEvents": {
"provider": "status",
"endpoint": "events",
"filter": "all"
},
"hosts": {
"statusHosts": {
"provider": "status",
"endpoint": "hosts",
"filter": "all"
},
"services": {
"statusServices": {
"provider": "status",
"endpoint": "services",
"filter": "all"
@ -278,67 +278,67 @@
"endpoint": "services",
"filter": "all"
},
"hostsConfig": {
"configHost": {
"provider": "config",
"endpoint": "hosts",
"filter": "allHostConfigWithoutTemplate"
},
"hostsConfigTemplate": {
"configHostTemplate": {
"provider": "config",
"endpoint": "hosts",
"filter": "allHostConfigTemplate"
},
"commands": {
"configCommands": {
"provider": "config",
"endpoint": "commands",
"filter": "all"
},
"businessImpactModulations": {
"configBusinessImpactModulations": {
"provider": "config",
"endpoint": "businessimpactmodulations",
"filter": "all"
},
"checkModulations": {
"configCheckModulations": {
"provider": "config",
"endpoint": "checkmodulations",
"filter": "all"
},
"contactGroups": {
"configContactGroups": {
"provider": "config",
"endpoint": "contactgroups",
"filter": "all"
},
"contacts": {
"configContacts": {
"provider": "config",
"endpoint": "contacts",
"filter": "all"
},
"hostGroups": {
"configHostGroups": {
"provider": "config",
"endpoint": "hostgroups",
"filter": "all"
},
"macroModulations": {
"configMacroModulations": {
"provider": "config",
"endpoint": "macromodulations",
"filter": "all"
},
"notificationWays": {
"configNotificationWays": {
"provider": "config",
"endpoint": "notificationways",
"filter": "all"
},
"realms": {
"configRealms": {
"provider": "config",
"endpoint": "realms",
"filter": "all"
},
"serviceGroups": {
"configServiceGroups": {
"provider": "config",
"endpoint": "servicegroups",
"filter": "all"
},
"timePeriods": {
"configTimePeriods": {
"provider": "config",
"endpoint": "timeperiods",
"filter": "all"

View File

@ -12,11 +12,11 @@
"navigation": {
"openProblems": {
"title": "Open Problems",
"provider": "nbServicesHostsOpenProblems"
"inputSource": "statusServicesOpenProblems"
},
"allProblems": {
"title": "All Problems",
"provider": "nbServicesHostsProblems"
"inputSource": "statusServicesOpenProblems"
}
}
},
@ -31,8 +31,8 @@
"type": "host-tree",
"attributes": {
"inputSource": [
"hostOpenProblems",
"serviceOpenProblemsOnly"
"statusHostsOpenProblems",
"statusServicesOpenProblemsOnly"
]
}
}
@ -48,7 +48,7 @@
"type": "host-tree",
"attributes": {
"inputSource": [
"servicesProblems"
"statusServicesProblems"
]
}
}
@ -76,11 +76,11 @@
"navigation": {
"openProblems": {
"title": "Open Problems",
"provider": "nbServicesHostsOpenProblems"
"inputSource": "statusServicesOpenProblems"
},
"allProblems": {
"title": "All Problems",
"provider": "nbServicesHostsOpenProblemsDoubleCount"
"inputSource": "statusServicesOpenProblems"
}
}
},
@ -146,14 +146,14 @@
"attributes": {
"title": "Open Hosts Problems",
"item": "host",
"provider": "nbHostsOpenProblems"
"inputSource": "statusHostsOpenProblems"
}
},
{
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "hostOpenProblems",
"inputSource": "statusHostsOpenProblems",
"headerFollow": false,
"isWrappable": false,
"checkColumn": true,
@ -208,14 +208,14 @@
"attributes": {
"title": "Open Service Problems",
"item": "service",
"provider": "nbServicesOpenProblemsOnly"
"inputSource": "statusServicesOpenProblemsOnly"
}
},
{
"type": "table",
"attributes": {
"datasourceId": 1,
"inputSource": "serviceOpenProblemsOnly",
"inputSource": "statusServicesOpenProblemsOnly",
"headerFollow": false,
"isWrappable": true,
"checkColumn": true,
@ -276,8 +276,7 @@
{
"type": "panel",
"attributes": {
"panelId": "allProblems",
"provider": "nbServicesHostsOpenProblems"
"panelId": "allProblems"
},
"components": [
{
@ -335,14 +334,14 @@
"attributes": {
"title": "Hosts Problems",
"item": "host",
"provider": "nbHostsOpenProblems"
"inputSource": "statusHostsProblems"
}
},
{
"type": "table",
"attributes": {
"datasourceId": 2,
"inputSource": "hostsProblems",
"inputSource": "statusHostsProblems",
"headerFollow": false,
"isWrappable": false,
"checkColumn": true,
@ -397,14 +396,14 @@
"attributes": {
"title": "Services Problems",
"item": "service",
"provider": "nbServicesOpenProblems"
"inputSource": "statusServicesProblems"
}
},
{
"type": "table",
"attributes": {
"datasourceId": 3,
"inputSource": "servicesProblems",
"inputSource": "statusServicesProblems",
"headerFollow": false,
"isWrappable": true,
"checkColumn": true,
@ -531,7 +530,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "hosts",
"inputSource": "statusHosts",
"headerFollow": true,
"isWrappable": false,
"noRepeatCell": "",
@ -653,7 +652,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "services",
"inputSource": "statusServices",
"headerFollow": true,
"isWrappable": false,
"checkColumn": true,
@ -766,7 +765,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "events",
"inputSource": "statusEvents",
"headerFollow": true,
"isWrappable": false,
"checkColumn": false,
@ -835,38 +834,32 @@
"type": "panel",
"components": [
{
"type": "container",
"components": [
{
"type": "host-main",
"type": "tile-host-main",
"attributes": {}
},
{
"type": "host-live",
"type": "tile-host-live",
"attributes": {}
},
{
"type": "host-load",
"type": "tile-host-load",
"attributes": {}
},
{
"type": "host-cpu",
"type": "tile-host-cpu",
"attributes": {}
},
{
"type": "host-services-list",
"type": "tile-host-services-list",
"attributes": {}
},
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configHost"
"inputSource": "configHost",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -955,7 +948,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "hostsConfig",
"inputSource": "configHost",
"headerFollow": false,
"isWrappable": false,
"noRepeatCell": "",
@ -1051,7 +1044,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "hostsConfigTemplate",
"inputSource": "configHostTemplate",
"headerFollow": false,
"isWrappable": false,
"noRepeatCell": "",
@ -1123,7 +1116,7 @@
"type": "table",
"attributes": {
"datasourceId": 0,
"inputSource": "commands",
"inputSource": "configCommands",
"headerFollow": true,
"isWrappable": false,
"noRepeatCell": "",
@ -1180,18 +1173,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configCommand"
"inputSource": "configCommands",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1231,7 +1218,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "businessImpactModulations",
"inputSource": "configBusinessImpactModulations",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1289,18 +1276,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configBusinessImpactModulation"
"inputSource": "configBusinessImpactModulations",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1340,7 +1321,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "checkModulations",
"inputSource": "configCheckModulations",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1398,18 +1379,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configCheckModulation"
"inputSource": "configCheckModulations",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1449,7 +1424,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "contactGroups",
"inputSource": "configContactGroups",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1529,18 +1504,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configContactGroup"
"inputSource": "configContactGroups",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1580,7 +1549,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "contacts",
"inputSource": "configContacts",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1668,18 +1637,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configContact"
"inputSource": "configContacts",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1719,7 +1682,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "hostGroups",
"inputSource": "configHostGroups",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1801,18 +1764,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configHostGroup"
"inputSource": "configHostGroups",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1852,7 +1809,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "macroModulations",
"inputSource": "configMacroModulations",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -1901,18 +1858,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configMacroModulation"
"inputSource": "configMacroModulations",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -1952,7 +1903,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "notificationWays",
"inputSource": "configNotificationWays",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -2024,18 +1975,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configNotificationWay"
"inputSource": "configNotificationWays",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -2079,7 +2024,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "realms",
"inputSource": "configRealms",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -2137,18 +2082,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Command": "configRealm"
"inputSource": "configRealms",
"title": "Command"
}
}
}
]
}
]
}
]
@ -2188,7 +2127,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "serviceGroups",
"inputSource": "configServiceGroups",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -2259,18 +2198,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configServiceGroup"
"inputSource": "configServiceGroups",
"title": "Configuration"
}
}
}
]
}
]
}
]
@ -2310,7 +2243,7 @@
"attributes": {
"datasourceId": 0,
"headerFollow": true,
"inputSource": "timePeriods",
"inputSource": "configTimePeriods",
"isWrappable": false,
"noRepeatCell": "",
"checkColumn": false,
@ -2368,18 +2301,12 @@
}
},
{
"type": "container",
"components": [
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Configuration": "configTimePeriod"
"title": "Configuration",
"inputSource": "configTimePeriods"
}
}
}
]
}
]
}
]
@ -2495,34 +2422,28 @@
"type": "panel",
"components": [
{
"type": "container",
"components": [
{
"type": "service-main",
"type": "tile-service-main",
"attributes": {}
},
{
"type": "service-live",
"type": "tile-service-live",
"attributes": {}
},
{
"type": "service-info",
"type": "tile-service-info",
"attributes": {}
},
{
"type": "service-graphs",
"type": "tile-service-metrics",
"attributes": {}
},
{
"type": "info",
"type": "tile-info",
"attributes": {
"inputSource": {
"Service configuration": "configService"
"title": "Service configuration",
"inputSource": "configServices"
}
}
}
]
}
]
}
]

View File

@ -1,6 +0,0 @@
<article>
<section class="main__content tabpanel">
<bansho-components components="components"></bansho-components>
</section>
</article>

View File

@ -1,154 +0,0 @@
'use strict';
angular.module('bansho.container', [])
.directive('banshoContainer', function () {
return {
restrict: 'E',
scope: {
options: '='
},
templateUrl: 'components/custom_directive/container/container.html',
controller: ['$scope', 'templateManager', 'surveilStatus', 'surveilConfig', 'iframeUrl',
function ($scope, templateManager, surveilStatus, surveilConfig, iframeUrl) {
$scope.param = { };
$scope.addDirectiveParamRequirements = function (param) {
if ($scope.param[param] === undefined) {
fillParams[param]();
}
};
var fillParams = {
"configBusinessImpactModulation": function () {
surveilConfig.getBusinessImpactModulation(templateManager.getPageParam('business_impact_modulation_name'))
.then(function (data) {
$scope.param.configBusinessImpactModulation = data[0];
});
},
"configCheckModulation": function () {
surveilConfig.getCheckModulation(templateManager.getPageParam('checkmodulation_name'))
.then(function (data) {
$scope.param.configCheckModulation = data[0];
});
},
"configContactGroup": function () {
surveilConfig.getContactGroup(templateManager.getPageParam('contactgroup_name'))
.then(function (data) {
$scope.param.configContactGroup = data[0];
});
},
"configContact": function () {
surveilConfig.getContact(templateManager.getPageParam('contact_name'))
.then(function (data) {
$scope.param.configContact = data[0];
});
},
"configHostGroup": function () {
surveilConfig.getHostGroup(templateManager.getPageParam('hostgroup_name'))
.then(function (data) {
$scope.param.configHostGroup = data[0];
});
},
"configMacroModulation": function () {
surveilConfig.getMacroModulationName(templateManager.getPageParam('macromodulation_name'))
.then(function (data) {
$scope.param.configMacroModulation = data[0];
});
},
"configNotificationWay": function () {
surveilConfig.getNotificationWay(templateManager.getPageParam('notificationway_name'))
.then(function (data) {
$scope.param.configNotificationWay = data[0];
});
},
"configRealm": function () {
surveilConfig.getRealm(templateManager.getPageParam('realm_name'))
.then(function (data) {
$scope.param.configRealm = data[0];
});
},
"configServiceGroup": function () {
surveilConfig.getServiceGroup(templateManager.getPageParam('servicegroup_name'))
.then(function (data) {
$scope.param.configServiceGroup = data[0];
});
},
"configTimePeriod": function () {
surveilConfig.getTimePeriod(templateManager.getPageParam('timeperiod_name'))
.then(function (data) {
$scope.param.configTimePeriod = data[0];
});
},
"configService": function () {
surveilConfig.getService(templateManager.getPageParam('host_name'),templateManager.getPageParam('service_description'))
.then(function (data) {
$scope.param.configService = data[0];
});
},
"configHost": function () {
surveilConfig.getHost(templateManager.getPageParam('host_name'))
.then(function (data) {
$scope.param.configHost = data[0];
});
},
"configCommand": function () {
surveilConfig.getCommand(templateManager.getPageParam('command_name'))
.then(function (data) {
$scope.param.configCommand = data[0];
});
},
"host": function () {
var hostname = templateManager.getPageParam('host_name');
surveilStatus.getHost(templateManager.getPageParam('host_name')).then(function (data) {
surveilStatus.getService(templateManager.getPageParam('host_name')).then(function (services) {
$scope.param.host = data[0];
$scope.param.host.services = [];
angular.forEach(services, function (service) {
if (service.service_description === 'cpu') {
$scope.param.host.cpu = service;
} else if (service.service_description === 'load') {
$scope.param.host.load = service;
$scope.param.host.load.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", hostname, "load");
} else {
$scope.param.host.services.push(service);
}
});
});
});
},
"hostMetrics": function () {
var hostname = templateManager.getPageParam('host_name');
surveilStatus.getHostMetricNames(hostname).then(function (metrics) {
$scope.param.host.metrics = metrics;
angular.forEach(metrics, function (metric) {
surveilStatus.getHostMetric(hostname, metric).then(function (data) {
// TODO: waiting for ORBER BY DESC support in InfluxDB
});
});
});
},
"service": function () {
var hostname = templateManager.getPageParam('host_name'),
serviceDescription = templateManager.getPageParam('service_description');
surveilStatus.getService(hostname, serviceDescription).then(function (data) {
$scope.param.service = data[0];
surveilStatus.getServiceMetricNames(hostname, serviceDescription).then(function(metric_names) {
$scope.param.service.iframeUrls = {};
angular.forEach(metric_names, function (metricName) {
$scope.param.service.iframeUrls[metricName] = iframeUrl.getIFrameUrl("metric_" + metricName, hostname, serviceDescription);
surveilStatus.getServiceMetric(hostname, serviceDescription).then(function(data) {
// TODO: waiting for ORBER BY DESC support in InfluxDB
});
});
});
});
}
};
$scope.components = $scope.options.components;
}]
};
});

View File

@ -1,15 +0,0 @@
<div data-ng-show="param.host.cpu" class="subcomponent__live subcomponent__small">
<h2>Cpu</h2>
<table class="data-table">
<tbody>
<tr>
<td>State</td>
<td><bansho-service-state-icon state="param.host.cpu.state"></bansho-service-state-icon> {{param.host.cpu.state}}</td>
</tr>
<tr>
<td>Output</td>
<td>{{param.host.cpu.plugin_output}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoHostCpu', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/host_cpu/host_cpu.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('host');
}
};
});

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoHostLive', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/host_live/host_live.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('host');
}
};
});

View File

@ -1,16 +0,0 @@
<div data-ng-show="param.host.load" class="subcomponent__live subcomponent__small">
<h2>Load</h2>
<iframe src="{{param.host.load.iframeUrl}}" width="450" height="200" frameborder="0"></iframe>
<table class="data-table">
<tbody>
<tr>
<td>State</td>
<td><bansho-service-state-icon state="param.host.load.state"></bansho-service-state-icon> {{param.host.load.state}}</td>
</tr>
<tr>
<td>Output</td>
<td>{{param.host.load.plugin_output}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoHostLoad', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/host_load/host_load.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('host');
}
};
});

View File

@ -1,9 +0,0 @@
<div class="subcomponent__live subcomponent__title">
<header class="main__content__header clearfix">
<h1 class="main__content__title">
{{param.host.host_host_name}}
<span class="subtitle" ng-show="param.host.host_config_alias">(param.host.host_config_alias)</span>
<span class="subtitle">{{param.host.host_address}}</span>
</h1>
</header>
</div>

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoHostMain', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/host_main/host_main.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('host');
}
};
});

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoHostServicesList', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/host_services_list/host_services_list.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('host');
}
};
});

View File

@ -1,13 +0,0 @@
<span data-ng-repeat="(key, inputSource) in inputSources">
<div data-ng-show="param[inputSource]" class="subcomponent__live">
<h2>{{key}}</h2>
<table class="data-table">
<tbody data-ng-repeat="(key, value) in param[inputSource]">
<tr>
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
</tbody>
</table>
</div>
</span>

View File

@ -1,21 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/info/info.html',
link: function (scope) {
scope.param = scope.$parent.param;
angular.forEach(scope.components, function(component) {
if (component.type === 'info') {
scope.inputSources = component.attributes.inputSource;
}
});
angular.forEach(scope.inputSources, function (inputSource) {
scope.$parent.addDirectiveParamRequirements(inputSource);
});
}
};
});

View File

@ -1,6 +0,0 @@
<div data-ng-repeat="(metric, iframeUrl) in param.service.iframeUrls" class="subcomponent__live subcomponent__small">
<h2>Graph - {{metric}}</h2>
<iframe src="{{iframeUrl}}" width="450" height="200" frameborder="0"></iframe>
<table class="data-table">
</table>
</div>

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoServiceGraphs', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/service_graphs/service_graphs.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('service');
}
};
});

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoServiceInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/service_info/service_info.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('service');
}
};
});

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoServiceLive', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/service_live/service_live.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('service');
}
};
});

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoServiceMain', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/service_main/service_main.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('service');
}
};
});

View File

@ -1,3 +0,0 @@
<div>
<h2>Metrics</h2>
</div>

View File

@ -1,13 +0,0 @@
'use strict';
angular.module('bansho.container')
.directive('banshoServiceMetrics', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/container/service_metrics/service_metrics.html',
link: function (scope) {
scope.param = scope.$parent.param;
scope.$parent.addDirectiveParamRequirements('service');
}
};
});

View File

@ -2,12 +2,12 @@
angular.module('bansho.customDirective', [
'bansho.actionbar',
'bansho.textArea',
'bansho.container',
'bansho.hostTree',
'bansho.stateIcon',
'bansho.table',
'bansho.tabpanel',
'bansho.tactical',
'bansho.textArea',
'bansho.tile',
'bansho.title'
]);

View File

@ -13,7 +13,7 @@ angular.module('bansho.hostTree', ['bansho.datasource'])
function ($scope, sharedData) {
$scope.sources = {};
angular.forEach($scope.options.attributes.inputSource, function (source) {
$scope.sources[source] = sharedData.getDataFromInputSource(source, function (data) {
$scope.sources[source] = sharedData.getDataFromInputSource(source, false, null, false, function (data) {
$scope.sources[source] = data;
});
});

View File

@ -17,7 +17,7 @@ angular.module('bansho.tabpanel', [])
};
angular.forEach(scope.navigation, function (panel) {
panel.right = sharedData.getData(panel.provider, function (data) {
panel.right = sharedData.getDataFromInputSource(panel.inputSource, true, null, false, function (data) {
panel.right = data;
});
});

View File

@ -50,7 +50,7 @@ angular.module('bansho.table', ['bansho.datasource',
$scope.entries = data;
});
datasource.refreshTableData($scope.datasourceId);
templateManager.addInterval(function refreshTable () {
templateManager.addInterval(false, function refreshTable () {
datasource.refreshTableData($scope.datasourceId);
});

View File

@ -3,7 +3,6 @@
<thead>
<tr>
<th>Current health</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>

View File

@ -7,12 +7,11 @@ angular.module('bansho.tactical.current_health', ['bansho.surveil',
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tactical/current_health/current_health.html',
link: function (scope, element) {
$rootScope.$watch('themeClassSize', function( sizeclass) {
controller: ['$scope', '$element', function (scope, element) {
$rootScope.$watch('themeClassSize', function(sizeclass) {
scope.themeClassSize = sizeclass;
$compile(element.contents())(scope);
//$compile(element.contents())(scope);
});
}
}]
};
}]);

View File

@ -21,20 +21,22 @@ angular.module('bansho.tactical', ['bansho.surveil',
$scope.currentHealth = $scope.options.attributes.currentHealth;
$scope.topAlertProducers = $scope.options.attributes.topAlertProducers;
$scope.totalHosts = sharedData.getData('nbHosts', function (data) {
$scope.totalHosts = sharedData.getDataFromInputSource('statusHosts', true, null, false, function (data) {
$scope.totalHosts = data;
$scope.hostsRatio = ($scope.totalHosts - $scope.hostProblems) / $scope.totalHosts * 100;
});
$scope.hostProblems = sharedData.getData('nbHostsOpenProblems', function (data) {
$scope.hostProblems = sharedData.getDataFromInputSource('statusHostsOpenProblems', true, null, false, function (data) {
$scope.hostProblems = data;
$scope.hostsRatio = ($scope.totalHosts - $scope.hostProblems) / $scope.totalHosts * 100;
});
$scope.totalServices = sharedData.getData('nbServices', function (data) {
$scope.totalServices = sharedData.getDataFromInputSource('statusServices', true, null, false, function (data) {
$scope.totalServices = data;
$scope.servicesRatio = ($scope.totalServices - $scope.serviceProblems) / $scope.totalServices * 100;
});
$scope.serviceProblems = sharedData.getData('nbServicesOpenProblems', function (data) {
$scope.serviceProblems = sharedData.getDataFromInputSource('statusServicesOpenProblems', true, null, false, function (data) {
$scope.serviceProblems = data;
$scope.servicesRatio = ($scope.totalServices - $scope.serviceProblems) / $scope.totalServices * 100;
});

View File

@ -0,0 +1,15 @@
<div data-ng-show="cpu" class="subcomponent__live subcomponent__small">
<h2>Cpu</h2>
<table class="data-table">
<tbody>
<tr>
<td>State</td>
<td><bansho-service-state-icon state="cpu.service_state"></bansho-service-state-icon> {{cpu.service_state}}</td>
</tr>
<tr>
<td>Output</td>
<td>{{cpu.service_plugin_output}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,19 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileHostCpu', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/host_cpu/host_cpu.html',
controller: ['$scope', 'sharedData', 'templateManager', function ($scope, sharedData, templateManager) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (services) {
angular.forEach(services, function (service) {
if (service.service_service_description === 'cpu') {
$scope.cpu = service;
}
});
});
}]
};
});

View File

@ -4,13 +4,13 @@
<tbody>
<tr>
<td>State</td>
<td bansho-host-state-icon state="param.host.host_state">
<span class="data-table__data">{{param.host.host_state}}</span>
<td bansho-host-state-icon state="host[0].host_state">
<span class="data-table__data">{{host[0].host_state}}</span>
</td>
</tr>
<tr>
<td>Output</td>
<td>{{param.host.host_plugin_output}}</td>
<td>{{host[0].host_plugin_output}}</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileHostLive', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/host_live/host_live.html',
controller: ['$scope', 'sharedData', 'templateManager', function (scope, sharedData, templateManager) {
scope.host = sharedData.getDataFromInputSource('statusHosts', false,
templateManager.getAllPageParams(), false, function (host) {
scope.host = host;
});
}]
};
});

View File

@ -0,0 +1,16 @@
<div data-ng-show="load" class="subcomponent__live subcomponent__small">
<h2>Load</h2>
<iframe src="{{iframeUrl}}" width="450" height="200" frameborder="0"></iframe>
<table class="data-table">
<tbody>
<tr>
<td>State</td>
<td><bansho-service-state-icon state="load.service_state"></bansho-service-state-icon> {{load.service_state}}</td>
</tr>
<tr>
<td>Output</td>
<td>{{load.service_plugin_output}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,20 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileHostLoad', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/host_load/host_load.html',
controller: ['$scope', 'sharedData', 'templateManager', 'iframeUrl', function ($scope, sharedData, templateManager, iframeUrl) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (services) {
angular.forEach(services, function (service) {
if (service.service_service_description === 'load') {
$scope.load = service;
$scope.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", service.host_host_name, "load");
}
});
});
}]
};
});

View File

@ -0,0 +1,9 @@
<div class="subcomponent__live subcomponent__title">
<header class="main__content__header clearfix">
<h1 class="main__content__title">
{{host[0].host_host_name}}
<span class="subtitle" data-ng-show="host[0].host_config_alias">(host[0].host_config_alias)</span>
<span class="subtitle">{{host[0].host_address}}</span>
</h1>
</header>
</div>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileHostMain', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/host_main/host_main.html',
controller: ['$scope', 'sharedData', 'templateManager', function (scope, sharedData, templateManager) {
scope.host = sharedData.getDataFromInputSource('statusHosts', false,
templateManager.getAllPageParams(), false, function (host) {
scope.host = host;
});
}]
};
});

View File

@ -1,4 +1,4 @@
<div ng-show="param.host.services.length >= 1" class="subcomponent__live">
<div ng-show="services.length >= 1" class="subcomponent__live">
<h2>Services</h2>
<table class="data-table">
<thead>
@ -9,7 +9,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="service in param.host.services">
<tr ng-repeat="service in services">
<td><a href="#/view?view=service&host_name={{service.service_host_name}}&service_description={{service.service_service_description}}">{{service.service_service_description}}</a>
<td>{{service.service_acknowledged ? "Yes" : "No"}}</td>
<td bansho-service-state-icon state="service.service_state">

View File

@ -0,0 +1,21 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileHostServicesList', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/host_services_list/host_services_list.html',
controller: ['$scope', 'sharedData', 'templateManager', 'iframeUrl', function ($scope, sharedData, templateManager, iframeUrl) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (services) {
$scope.services = [];
angular.forEach(services, function (service) {
if (service.service_service_description !== 'load' &&
service.service_service_description !== 'cpu') {
$scope.services.push(service);
}
});
});
}]
};
});

View File

@ -0,0 +1,11 @@
<div data-ng-show="data[0]" class="subcomponent__live">
<h2>{{title}}</h2>
<table class="data-table">
<tbody data-ng-repeat="(key, value) in data[0]">
<tr>
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,20 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileInfo', function () {
return {
restrict: 'E',
scope: {
options: '='
},
templateUrl: 'components/custom_directive/tile/info/info.html',
controller: ['$scope', 'sharedData', 'templateManager', 'iframeUrl', function ($scope, sharedData, templateManager, iframeUrl) {
$scope.title = $scope.options.attributes.title;
sharedData.getDataFromInputSource($scope.options.attributes.inputSource, false,
templateManager.getAllPageParams(), false, function (data) {
$scope.data = data;
}
);
}]
};
});

View File

@ -4,15 +4,15 @@
<tbody>
<tr>
<td>Last check</td>
<td>{{param.service.service_last_check|timeElapsed}}</td>
<td>{{service[0].service_last_check|timeElapsed}}</td>
</tr>
<tr>
<td>Last state change</td>
<td>{{param.service.service_last_state_change|timeElapsed}}</td>
<td>{{service[0].service_last_state_change|timeElapsed}}</td>
</tr>
<tr>
<td>Acknowledged</td>
<td>{{param.service.service_acknowledged ? "Yes" : "No"}}</td>
<td>{{service[0].service_acknowledged ? "Yes" : "No"}}</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileServiceInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/service_info/service_info.html',
controller: ['$scope', 'sharedData', 'templateManager', function ($scope, sharedData, templateManager, iframeUrl) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (service) {
$scope.service = service;
});
}]
};
});

View File

@ -4,13 +4,13 @@
<tbody>
<tr>
<td>State</td>
<td bansho-service-state-icon state="param.service.service_state">
<span class="data-table__data">{{param.service.service_state}}</span>
<td bansho-service-state-icon state="service[0].service_state">
<span class="data-table__data">{{service[0].service_state}}</span>
</td>
</tr>
<tr>
<td>Output</td>
<td>{{param.service.service_plugin_output}}</td>
<td>{{service[0].service_plugin_output}}</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileServiceLive', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/service_live/service_live.html',
controller: ['$scope', 'sharedData', 'templateManager', function ($scope, sharedData, templateManager, iframeUrl) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (service) {
$scope.service = service;
});
}]
};
});

View File

@ -1,7 +1,7 @@
<div class="subcomponent__live subcomponent__title">
<h1>{{param.service.service_service_description}}
<h1>{{service[0].service_service_description}}
<span class="subtitle">
<a class="data-table__data" href="#/view?view=host&host_name={{param.service.service_host_name}}">{{param.service.host_host_name}}</a>
<a class="data-table__data" href="#/view?view=host&host_name={{service[0].service_host_name}}">{{service[0].host_host_name}}</a>
</span>
</h1>
</div>

View File

@ -0,0 +1,15 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileServiceMain', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/service_main/service_main.html',
controller: ['$scope', 'sharedData', 'templateManager', function ($scope, sharedData, templateManager, iframeUrl) {
sharedData.getDataFromInputSource('statusServices', false,
templateManager.getAllPageParams(), false, function (service) {
$scope.service = service;
});
}]
};
});

View File

@ -0,0 +1,4 @@
<div data-ng-repeat="metric in metrics" class="subcomponent__live subcomponent__small">
<h2>Graph - {{metric.title}}</h2>
<iframe src="{{metric.iframeUrl}}" width="450" height="200" frameborder="0"></iframe>
</div>

View File

@ -0,0 +1,29 @@
'use strict';
angular.module('bansho.tile')
.directive('banshoTileServiceMetrics', function () {
return {
restrict: 'E',
templateUrl: 'components/custom_directive/tile/service_metrics/service_metrics.html',
controller: ['$scope', 'templateManager', 'surveilStatus', 'iframeUrl',
function ($scope, templateManager, surveilStatus, iframeUrl) {
var hostname = templateManager.getPageParam('host_name'),
serviceDescription = templateManager.getPageParam('service_description');
$scope.metrics = [];
surveilStatus.getServiceMetricNames(hostname, serviceDescription).then(function (metricNames) {
angular.forEach(metricNames, function (metricName) {
$scope.metrics.push({
title: metricName,
iframeUrl: iframeUrl.getIFrameUrl("metric_" + metricName, hostname, serviceDescription)
});
surveilStatus.getServiceMetric(hostname, serviceDescription, metricName).then(function (data) {
// TODO: waiting for ORBER BY DESC support in InfluxDB
});
});
});
}]
};
});

View File

@ -0,0 +1 @@
angular.module('bansho.tile', []);

View File

@ -11,7 +11,8 @@ angular.module('bansho.title', [])
link: function (scope) {
if (scope.options.attributes.item) {
scope.item = scope.options.attributes.item;
scope.data = sharedData.getData(scope.options.attributes.provider, function (data) {
scope.data = sharedData.getDataFromInputSource(scope.options.attributes.inputSource, true, null, false, function (data) {
scope.data = data;
});

View File

@ -35,7 +35,7 @@ angular.module('bansho.datasource', ['bansho.surveil'])
filter = componentsConfig.mergeFilters([config[datasourceId].queryFilter, filter]);
}
promise = providerServices[inputSource.provider].getData([], filter, inputSource.endpoint, conf.queryPaging);
promise = providerServices[inputSource.provider].getDataFromInputSource([], inputSource, null, {count: false}, conf.queryPaging);
promise.then(function (newData) {
data[datasourceId] = newData;
@ -132,112 +132,59 @@ angular.module('bansho.datasource', ['bansho.surveil'])
};
}])
.service('sharedData', ['templateManager', 'surveilStatus', 'componentsConfig',
function (templateManager, surveilStatus, componentsConfig) {
var providerServices = {
status: surveilStatus
.service('sharedData', ['templateManager', 'surveilStatus', 'surveilConfig', 'componentsConfig',
function (templateManager, surveilStatus, surveilConfig, componentsConfig) {
var providers = {
status: surveilStatus,
config: surveilConfig
},
sharedData = {},
listeners = {},
providers = {
'nbServicesHostsProblems': function () {
surveilStatus.getNbHostsProblems().then(function (nbHosts) {
surveilStatus.getNbServicesProblems().then(function (nbServices) {
sharedData.nbServicesHostsProblems = nbHosts + nbServices;
notifyListeners('nbServicesHostsProblems');
});
});
},
'nbHostsOpenProblems': function () {
surveilStatus.getNbHostOpenProblems().then(function (nbHostProblems) {
sharedData.nbHostsOpenProblems = nbHostProblems;
notifyListeners('nbHostsOpenProblems');
});
},
'nbServicesOpenProblems': function () {
surveilStatus.getNbServiceOpenProblems().then(function (nbServiceProblems) {
sharedData.nbServicesOpenProblems = nbServiceProblems;
notifyListeners('nbServicesOpenProblems');
});
},
'nbHosts': function () {
surveilStatus.getNbHosts().then(function (nbHosts) {
sharedData.nbHosts = nbHosts;
notifyListeners('nbHosts');
});
},
'nbServices': function () {
surveilStatus.getNbServices().then(function (nbServices) {
sharedData.nbServices = nbServices;
notifyListeners('nbServices');
});
},
'nbServicesOpenProblemsOnly': function () {
surveilStatus.getNbServiceOpenProblemsOnly().then(function (nbServices) {
sharedData.nbServicesOpenProblemsOnly = nbServices;
notifyListeners('nbServicesOpenProblemsOnly');
});
},
'nbServicesHostsOpenProblems': function () {
surveilStatus.getNbHostsProblems().then(function (nbHosts) {
surveilStatus.getNbServiceOpenProblemsOnly().then(function (nbServices) {
sharedData.nbServicesHostsOpenProblems = nbHosts + nbServices;
notifyListeners('nbServicesHostsOpenProblems');
});
});
},
'nbServicesHostsOpenProblemsDoubleCount': function () {
surveilStatus.getNbHostsProblems().then(function (nbHosts) {
surveilStatus.getNbServiceOpenProblems().then(function (nbServices) {
sharedData.nbServicesHostsOpenProblemsDoubleCount = nbHosts + nbServices;
notifyListeners('nbServicesHostsOpenProblemsDoubleCount');
});
});
}
};
data = {};
var notifyListeners = function (key) {
angular.forEach(listeners[key], function (onChange) {
onChange(sharedData[key]);
angular.forEach(data[key].onChange, function (onChange) {
onChange(data[key].value);
});
};
return {
getData: function (key, onChange) {
if (listeners[key] === undefined) {
listeners[key] = [onChange];
templateManager.addInterval(providers[key]);
providers[key]();
} else {
listeners[key].push(onChange);
clear: function (isGlobalCleared) {
angular.forEach(data, function (datasource, key) {
if (!isGlobalCleared && !datasource.isGlobal || isGlobalCleared) {
delete data[key];
}
return sharedData[key];
});
},
getDataFromInputSource: function (source, onChange) {
if (listeners[source] === undefined) {
listeners[source] = [onChange];
getDataFromInputSource: function (source, isCount, keys, isGlobal, onChange) {
var listenerKey = source + isCount + JSON.stringify(keys);
if (data[listenerKey] === undefined) {
data[listenerKey] = {
onChange: [onChange],
isGlobal: isGlobal,
value: null
};
var inputSource = componentsConfig.getInputSource(source);
providers[source] = function () {
providerServices[inputSource.provider].getData([], componentsConfig.getFilter(inputSource.filter).filter, inputSource.endpoint)
var update = function () {
providers[inputSource.provider].getDataFromInputSource([], inputSource, keys, {count: isCount})
.then(function (newData) {
sharedData[source] = newData;
notifyListeners(source);
data[listenerKey].value = newData;
notifyListeners(listenerKey);
}, function (error) {
throw new Error('getTableData : Query failed' + error);
});
};
templateManager.addInterval(providers[source]);
providers[source]();
update();
templateManager.addInterval(isGlobal, update);
} else {
listeners[source].push(onChange);
if (isGlobal) {
data[listenerKey].isGlobal = true;
}
data[listenerKey].onChange.push(onChange);
notifyListeners(listenerKey);
}
return sharedData[source];
return data[listenerKey].value;
}
};
}]);

View File

@ -29,21 +29,21 @@ angular.module('bansho.surveil')
return promise.promise;
};
// All the valid endpoint with their
var validEndpoint = {
"businessimpactmodulations": true,
"checkmodulations": true,
"commands": true,
"contacts": true,
"contactgroups": true,
"hosts": true,
"hostgroups": true,
"macromodulations": true,
"notificationways": true,
"realms": true,
"services": true,
"servicegroups": true,
"timeperiods": true
"businessimpactmodulations": "business_impact_modulation_name",
"checkmodulations": "checkmodulation_name",
"commands": "command_name",
"contacts": "contact_name",
"contactgroups": "contact_group_name",
"hosts": "host_name",
"hostgroups": "hostgroup_name",
"macromodulations": "macromodulations_name",
"notificationways": "notificationway_name",
"realms": "realm_name",
"services": "service_description",
"servicegroups": "servicegroup_name",
"timeperiods": "timeperiods_name"
};
var queryEndpoint = function (endpoint, fields, filters, paging, callback) {
@ -65,113 +65,39 @@ angular.module('bansho.surveil')
return {
getData: getData,
getBusinessImpactModulation: function (businessimpactmodulationName) {
var promise = $q.defer(), query = {"businessimpactmodulations": {"is": {"business_impact_modulation_name": [ businessimpactmodulationName ] } } };
getData([], query, "businessimpactmodulations")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getCheckModulation: function (checkmodulationName) {
var promise = $q.defer(), query = {"checkmodulations": {"is": {"checkmodulation_name": [ checkmodulationName ] } } };
getData([], query, "checkmodulations")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getCommand: function (commandName) {
var promise = $q.defer(), query = {"commands": {"is": {"command_name": [ commandName ] } } };
getData([], query, "commands")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getContactGroup: function (contactgroupName) {
var promise = $q.defer(), query = {"contactgroups": {"is": {"contactgroup_name": [ contactgroupName ] } } };
getData([], query, "contactgroups")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getContact: function (contactName) {
var promise = $q.defer(), query = {"contacts": {"is": {"contact_name": [ contactName ] } } };
getData([], query, "contacts")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getHost: function (hostName) {
var promise = $q.defer(), query = {"hosts": {"is": {"host_name": [ hostName ] } } };
getData([], query, "hosts")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getHostGroup: function (hostgroupName) {
var promise = $q.defer(), query = {"hostgroups": {"is": {"hostgroup_name": [ hostgroupName ] } } };
getData([], query, "hostgroups")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getMacroModulationName: function (macromodulationName) {
var promise = $q.defer(), query = {"macromodulations": {"is": {"macromodulation_name": [ macromodulationName ] } } };
getData([], query, "macromodulations")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getNotificationWay: function (notificationwayName) {
var promise = $q.defer(), query = {"notificationways": {"is": {"notificationway_name": [notificationwayName] } } };
getData([], query, "notificationways")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getRealm: function (realmName) {
var promise = $q.defer(), query = {"realms": {"is": {"realm_name": [realmName] } } };
getData([], query, "realms")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getServiceGroup: function (servicegroupName) {
var promise = $q.defer(), query = {"servicegroups": {"is": {"servicegroup_name": [servicegroupName] } } };
getData([], query, "servicegroups")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getService: function (hostname, serviceDescription) {
var promise = $q.defer(), query = { "hosts": { "is": { "host_name": [hostname] } }, "services": {"is": {"host_name": [hostname] } } };
getDataFromInputSource: function (fields, inputSource, keys, operations, paging) {
// Todo merge filter function
var promise = $q.defer(),
filter = componentsConfig.getFilter(inputSource.filter).filter,
endpoint = inputSource.endpoint;
if (serviceDescription) {
query.services = { "is": { "service_description": [ serviceDescription ] } };
if (endpoint === "services" &&
keys && keys.host_name) {
filter = {
"hosts": {"is": {"host_name": [keys.host_name]}},
"services": {"is": {"host_name": [keys.host_name]}}
};
if (keys.service_description) {
filter.services.is.service_description = [keys.service_description];
}
} else if (keys && keys[validEndpoint[endpoint]]) {
var key = validEndpoint[endpoint],
value = keys[key];
filter = {};
filter[endpoint] = {"is": {}};
filter[endpoint].is[key] = [value];
}
getData([], query, "services")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getTimePeriod: function (timeperiodName) {
var promise = $q.defer(), query = {"timeperiods": {"is": {"timeperiod_name": [timeperiodName] } } };
getData([], query, "timeperiods")
.then(function (data) {
queryEndpoint(endpoint, fields, filter, paging, function (data) {
if (operations && operations.count) {
promise.resolve(data.length);
} else {
promise.resolve(data);
}
});
return promise.promise;
}
};

View File

@ -58,20 +58,6 @@ angular.module('bansho.surveil')
});
};
var getData = function (fields, filters, endpoint, paging) {
var promise = $q.defer();
if (!queryEndpoint[endpoint]) {
throw new Error('getData in surveilStatus : Invalid endpoint ' + endpoint);
}
queryEndpoint[endpoint](fields, filters, paging, function (data) {
promise.resolve(data);
});
return promise.promise;
};
var queryHostsServices = function (fields, filters, paging, callback) {
var hostQuery = surveilQuery(fields, filters.hosts, paging),
serviceQuery = surveilQuery(fields, filters.services, paging);
@ -158,83 +144,50 @@ angular.module('bansho.surveil')
}
};
return {
getData: getData,
getHost: function (hostname) {
var promise = $q.defer(), query = {"hosts": {"is": {"host_name": [ hostname ] } } };
getData([], query, "hosts")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
getNbHosts: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("all").filter, "hosts")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getNbHostOpenProblems: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allHostOpenProblems").filter, "hosts")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getNbHostsProblems: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allHostsProblems").filter, "hosts")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getService: function (hostname, serviceDescription) {
var promise = $q.defer(), query = { "hosts": { "is": { "host_name": [hostname] } }, "services": {"is": {"host_name": [hostname] } } };
var validEndpoint = {
"events": "event_name",
"hosts": "host_name",
"services": "service_description"
};
if (serviceDescription) {
query.services = { "is": { "service_description": [ serviceDescription ] } };
return {
getDataFromInputSource: function (fields, inputSource, keys, operations, paging) {
// Todo merge filter function
var promise = $q.defer(),
filter = componentsConfig.getFilter(inputSource.filter).filter,
endpoint = inputSource.endpoint;
if (endpoint === "services" &&
keys && keys.host_name) {
filter = {
"hosts": {"is": {"host_name": [keys.host_name]}},
"services": {"is": {"host_name": [keys.host_name]}}
};
if (keys.service_description) {
filter.services.is.service_description = [keys.service_description];
}
} else if (keys && keys[validEndpoint[endpoint]]) {
var key = validEndpoint[endpoint],
value = keys[key];
filter = {};
filter[endpoint] = {"is": {}};
filter[endpoint].is[key] = [value];
}
getData([], query, "services")
.then(function (data) {
if (!queryEndpoint[endpoint]) {
throw new Error('getData in surveilStatus : Invalid endpoint ' + endpoint);
}
queryEndpoint[endpoint](fields, filter, paging, function (data) {
if (operations && operations.count) {
promise.resolve(data.length);
} else {
promise.resolve(data);
}
});
return promise.promise;
},
getNbServices: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allServices").filter, "services")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getNbServiceOpenProblems: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allServiceOpenProblems").filter, "services")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getNbServiceOpenProblemsOnly: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allServiceOpenProblemsOnly").filter, "services")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getNbServicesProblems: function () {
var promise = $q.defer();
getData([], componentsConfig.getFilter("allServicesProblems").filter, "services")
.then(function (data) {
promise.resolve(data.length);
});
return promise.promise;
},
getHostMetric: function (host, metric) {

View File

@ -20,7 +20,7 @@
aria-expanded="true"
aria-controls="notificationsPanel">
<span class="visuallyhidden">Voir les notifications</span>
<i class="ico-bell-alt" data-notifications="{{allProblems}}"></i>
<i class="ico-bell-alt" data-notifications="{{nbServices + nbHosts}}"></i>
</button>
<div class="topbar__panel--fromleft collapse" id="notificationsPanel">

View File

@ -21,8 +21,14 @@ angular.module('bansho.topbar', ['bansho.surveil'])
};
authService.registerOnLogin(function () {
$scope.allProblems = sharedData.getData('nbServicesHostsOpenProblems', function (data) {
$scope.allProblems = data;
$scope.nbHosts = sharedData.getDataFromInputSource('statusHostsOpenProblems', true, null, true, function (nbHosts) {
$scope.nbHosts = nbHosts;
$scope.allProblems = $scope.nbServices + $scope.nbHosts;
});
sharedData.getDataFromInputSource('statusServicesOpenProblems', true, null, true, function (nbServices) {
$scope.nbServices = nbServices;
$scope.allProblems = $scope.nbServices + $scope.nbHosts;
});
$scope.components = configManager.getConfigData('topbar').components;

View File

@ -5,7 +5,7 @@
<!--[if gt IE 8]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="X-UA-Compatible" content="IE=edge/>
<title>Bansho</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,400italic' rel='stylesheet' type='text/css'>
@ -95,18 +95,17 @@
<script src="components/custom_directive/tactical/current_health/current_health.js"></script>
<script src="components/custom_directive/tactical/top_alert_producers/top_alert_producers.js"></script>
<script src="components/custom_directive/container/container.js"></script>
<script src="components/custom_directive/container/info/info.js"></script>
<script src="components/custom_directive/container/host_cpu/host_cpu.js"></script>
<script src="components/custom_directive/container/host_load/host_load.js"></script>
<script src="components/custom_directive/container/host_main/host_main.js"></script>
<script src="components/custom_directive/container/host_live/host_live.js"></script>
<script src="components/custom_directive/container/host_services_list/host_services_list.js"></script>
<script src="components/custom_directive/container/service_main/service_main.js"></script>
<script src="components/custom_directive/container/service_live/service_live.js"></script>
<script src="components/custom_directive/container/service_info/service_info.js"></script>
<script src="components/custom_directive/container/service_graphs/service_graphs.js"></script>
<script src="components/custom_directive/container/service_metrics/service_metrics.js"></script>
<script src="components/custom_directive/tile/tile.js"></script>
<script src="components/custom_directive/tile/info/info.js"></script>
<script src="components/custom_directive/tile/host_cpu/host_cpu.js"></script>
<script src="components/custom_directive/tile/host_load/host_load.js"></script>
<script src="components/custom_directive/tile/host_main/host_main.js"></script>
<script src="components/custom_directive/tile/host_live/host_live.js"></script>
<script src="components/custom_directive/tile/host_services_list/host_services_list.js"></script>
<script src="components/custom_directive/tile/service_main/service_main.js"></script>
<script src="components/custom_directive/tile/service_live/service_live.js"></script>
<script src="components/custom_directive/tile/service_info/service_info.js"></script>
<script src="components/custom_directive/tile/service_metrics/service_metrics.js"></script>
<script src="components/custom_directive/actionbar/actionbar.js"></script>
<script src="components/custom_directive/actionbar/component_acknowledge/acknowledge.js"></script>

View File

@ -18,19 +18,24 @@ angular.module('bansho.view')
getLayoutComponents: function () {
return layout.components;
},
addInterval: function (callback) {
addInterval: function (isGlobal, callback) {
if (refreshInterval !== NO_REFRESH) {
intervals.push($interval(callback, refreshInterval * 1000));
intervals.push({isGlobal: isGlobal, interval: $interval(callback, refreshInterval * 1000)});
}
},
clearIntervals: function () {
clearIntervals: function (isGlobalCleared) {
angular.forEach(intervals, function (i) {
$interval.cancel(i);
if (!isGlobalCleared && !i.isGlobal || isGlobalCleared) {
$interval.cancel(i.interval);
}
});
},
setPageParam: function (key, value) {
pageParam[key] = value;
},
getAllPageParams: function () {
return pageParam;
},
getPageParam: function (key) {
if (pageParam[key] === undefined) {
throw new Error("ERROR :'" + key + "' GET parameter must be set in url");