diff --git a/app/components/authentication/authentication.js b/app/components/authentication/authentication.js index 526f628..d592be8 100644 --- a/app/components/authentication/authentication.js +++ b/app/components/authentication/authentication.js @@ -56,7 +56,8 @@ angular.module('bansho.authentication', []) .factory('authService', [ '$http', '$location', '$rootScope', 'session', 'configManager', 'themeManager', 'surveilConfig', function ($http, $location, $rootScope, session, configManager, themeManager, surveilConfig) { - var authService = {}; + var authService = {}, + onLogin = []; authService.login = function (credentials) { return $http @@ -70,6 +71,10 @@ angular.module('bansho.authentication', []) configManager.fetchLayoutConfig(configManager.getConfig().useStoredConfig).then(function () { themeManager.setTheme(configManager.getTheme()); $location.path('/view'); + + angular.forEach(onLogin, function (f) { + f(); + }); }, function (message) { throw new Error(message); }); @@ -95,6 +100,10 @@ angular.module('bansho.authentication', []) themeManager.switchTheme(); }; + authService.registerOnLogin = function (f) { + onLogin.push(f); + }; + return authService; }]) diff --git a/app/components/config/defaultLayoutConfig.json b/app/components/config/defaultLayoutConfig.json index a246e71..2d96cca 100644 --- a/app/components/config/defaultLayoutConfig.json +++ b/app/components/config/defaultLayoutConfig.json @@ -2,6 +2,63 @@ "banshoConfig": { "theme": "dark" }, + "topbar": { + "template": "page", + "components": [ + { + "type": "tabpanel", + "attributes": { + "navigation": [ + { + "title": "Open problems", + "panelId": "openProblems", + "provider": "nbServicesHostsOpenProblems" + }, + { + "title": "All problems", + "panelId": "allProblems", + "provider": "nbServicesHostsProblems" + } + ] + }, + "components": [ + { + "type": "panel", + "attributes": { + "panelId": "openProblems" + }, + "components": [ + { + "type": "host-tree", + "attributes": { + "inputSource": [ + "hostOpenProblems", + "serviceOpenProblemsOnly" + ] + } + } + ] + }, + { + "type": "panel", + "attributes": { + "panelId": "openProblems" + }, + "components": [ + { + "type": "host-tree", + "attributes": { + "inputSource": [ + "servicesProblems" + ] + } + } + ] + } + ] + } + ] + }, "dashboardConfig": { "template": "page", "components": [ diff --git a/app/components/datasource/datasource.js b/app/components/datasource/datasource.js index ab24a4b..c16cf7a 100644 --- a/app/components/datasource/datasource.js +++ b/app/components/datasource/datasource.js @@ -96,11 +96,22 @@ angular.module('bansho.datasource', ['bansho.surveil']) }; }]) - .service('sharedData', ['templateManager', 'surveilStatus', - function (templateManager, surveilStatus) { - var sharedData = {}, + .service('sharedData', ['templateManager', 'surveilStatus', 'componentsConfig', + function (templateManager, surveilStatus, componentsConfig) { + var providerServices = { + status: surveilStatus + }, + 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; @@ -167,6 +178,30 @@ angular.module('bansho.datasource', ['bansho.surveil']) } return sharedData[key]; + }, + getDataFromInputSource: function (source, onChange) { + if (listeners[source] === undefined) { + listeners[source] = [onChange]; + + var inputSource = componentsConfig.getInputSource(source); + + providers[source] = function () { + providerServices[inputSource.provider].getData([], componentsConfig.getFilter(inputSource.filter).filter, inputSource.endpoint) + .then(function (newData) { + sharedData[source] = newData; + notifyListeners(source); + }, function (error) { + throw new Error('getTableData : Query failed' + error); + }); + }; + + templateManager.addInterval(providers[source]); + providers[source](); + } else { + listeners[source].push(onChange); + } + + return sharedData[source]; } }; }]); diff --git a/app/components/directive/directive.js b/app/components/directive/directive.js index a784062..414810f 100644 --- a/app/components/directive/directive.js +++ b/app/components/directive/directive.js @@ -3,6 +3,7 @@ angular.module('bansho.directive', [ 'bansho.actionbar', 'bansho.host', + 'bansho.hostTree', 'bansho.service', 'bansho.table', 'bansho.tabpanel', diff --git a/app/components/directive/host/host_live/host_live.html b/app/components/directive/host/host_live/host_live.html index 82ba2f9..1355169 100644 --- a/app/components/directive/host/host_live/host_live.html +++ b/app/components/directive/host/host_live/host_live.html @@ -2,14 +2,16 @@

Live status

- - - - - - - - + + + + + + + +
State {{param.host.host_state}}
Output{{param.host.host_plugin_output}}
State + {{param.host.host_state}} +
Output{{param.host.host_plugin_output}}
diff --git a/app/components/directive/host/host_services_list/host_services_list.html b/app/components/directive/host/host_services_list/host_services_list.html index 7f7121f..a6a8079 100644 --- a/app/components/directive/host/host_services_list/host_services_list.html +++ b/app/components/directive/host/host_services_list/host_services_list.html @@ -12,7 +12,9 @@ {{service.service_service_description}} {{service.service_acknowledged ? "Yes" : "No"}} - {{service.service_state}} + + {{service.service_state}} + diff --git a/app/components/directive/hostTree/hostTree.html b/app/components/directive/hostTree/hostTree.html new file mode 100644 index 0000000..08d920d --- /dev/null +++ b/app/components/directive/hostTree/hostTree.html @@ -0,0 +1,22 @@ +
    + + +
  1. + + {{key}} + +
    + +
    + + {{service.service_service_description}} + + 2 days, 8 hours +
    +
    {{service.service_plugin_output}}
    +
    +
    +
  2. +
    +
    +
diff --git a/app/components/directive/hostTree/hostTree.js b/app/components/directive/hostTree/hostTree.js new file mode 100644 index 0000000..11c7a8d --- /dev/null +++ b/app/components/directive/hostTree/hostTree.js @@ -0,0 +1,23 @@ +'use strict'; + +angular.module('bansho.hostTree', ['bansho.datasource']) + + .directive('banshoHostTree', function () { + return { + restrict: 'E', + scope: { + options: '=' + }, + templateUrl: 'components/directive/hostTree/hostTree.html', + controller: ['$scope', 'sharedData', + function ($scope, sharedData) { + $scope.sources = {}; + angular.forEach($scope.options.attributes.inputSource, function (source) { + $scope.sources[source] = sharedData.getDataFromInputSource(source, function (data) { + $scope.sources[source] = data; + }); + }); + $scope.components = $scope.options.components; + }] + }; + }); diff --git a/app/components/directive/service/service_live/service_live.html b/app/components/directive/service/service_live/service_live.html index fea7d5e..990a7b2 100644 --- a/app/components/directive/service/service_live/service_live.html +++ b/app/components/directive/service/service_live/service_live.html @@ -4,7 +4,9 @@ State - {{param.service.service_state}} + + {{param.service.service_state}} + Output diff --git a/app/components/directive/state_icon/state_icon.js b/app/components/directive/state_icon/state_icon.js new file mode 100644 index 0000000..fda65a5 --- /dev/null +++ b/app/components/directive/state_icon/state_icon.js @@ -0,0 +1,48 @@ +'use strict'; + +angular.module('bansho.table') + .directive('banshoHostStateIcon', function () { + return { + restrict: 'EA', + scope: { + state: '=' + }, + link: function (scope, element) { + scope.$watch('state', function () { + element.removeClass('state--ok'); + element.removeClass('state--warning'); + element.removeClass('state--error'); + + if (scope.state === 'UP') { + element.addClass('state--ok'); + } else if (scope.state === 'DOWN' || scope.state === 'UNREACHABLE') { + element.addClass('state--error'); + } + }); + } + }; + }) + + .directive('banshoServiceStateIcon', function () { + return { + restrict: 'EA', + scope: { + state: '=' + }, + link: function (scope, element) { + scope.$watch('state', function () { + element.removeClass('state--ok'); + element.removeClass('state--warning'); + element.removeClass('state--error'); + + if (scope.state === 'OK') { + element.addClass('state--ok'); + } else if (scope.state === 'WARNING') { + element.addClass('state--warning'); + } else if (scope.state === 'CRITICAL' || scope.state === 'UNKNOWN') { + element.addClass('state--error'); + } + }); + } + }; + }); diff --git a/app/components/directive/table/cell_status_host_status/cell_status_host_status.html b/app/components/directive/table/cell_status_host_status/cell_status_host_status.html index 5cdaf16..5aa753f 100644 --- a/app/components/directive/table/cell_status_host_status/cell_status_host_status.html +++ b/app/components/directive/table/cell_status_host_status/cell_status_host_status.html @@ -1,3 +1,3 @@ - {{entry.host_state}} + {{entry.host_state}} diff --git a/app/components/directive/table/state_icon/state_icon.html b/app/components/directive/table/state_icon/state_icon.html deleted file mode 100644 index 84529f7..0000000 --- a/app/components/directive/table/state_icon/state_icon.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/components/directive/table/state_icon/state_icon.js b/app/components/directive/table/state_icon/state_icon.js deleted file mode 100644 index b120ae1..0000000 --- a/app/components/directive/table/state_icon/state_icon.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -angular.module('bansho.table') - .directive('banshoHostStateIcon', function () { - return { - restrict: 'E', - scope: { - state: '=' - }, - templateUrl: 'components/directive/table/state_icon/state_icon.html', - controller: ['$scope', function ($scope) { - $scope.$watch('state', function (newValue) { - if ($scope.state === 'UP') { - $scope.stateClass = 'state--ok'; - } else if ($scope.state === 'WARNING') { - $scope.stateClass = 'state--warning'; - } else if ($scope.state === '') { - $scope.stateClass = ''; - } else { - $scope.stateClass = 'state--error'; - } - }); - }] - }; - }) - - .directive('banshoServiceStateIcon', function () { - return { - restrict: 'E', - scope: { - state: '=' - }, - templateUrl: 'components/directive/table/state_icon/state_icon.html', - controller: ['$scope', function ($scope) { - $scope.$watch('state', function (newValue) { - if ($scope.state === 'OK') { - $scope.stateClass = 'state--ok'; - } else if ($scope.state === 'WARNING') { - $scope.state = 'state--warning'; - } else if ($scope.state === '') { - $scope.stateClass = ''; - } else { - $scope.stateClass = 'state--error'; - } - }); - }] - }; - }); diff --git a/app/components/surveil/status.js b/app/components/surveil/status.js index 316b2f5..0c6e15c 100644 --- a/app/components/surveil/status.js +++ b/app/components/surveil/status.js @@ -236,6 +236,14 @@ angular.module('bansho.surveil') }); 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) { return getMetric(host, undefined, metric); }, diff --git a/app/components/topbar/topbar.html b/app/components/topbar/topbar.html index 5d5dba2..687a31d 100644 --- a/app/components/topbar/topbar.html +++ b/app/components/topbar/topbar.html @@ -17,96 +17,17 @@ type="button" data-toggle="collapse" data-target="#notificationsPanel" - aria-expanded="false" + aria-expanded="true" aria-controls="notificationsPanel"> Voir les notifications
-
- - -
-
-
    -
  1. - localhost - -
    -
    - Root partition - 2 days, 8 hours -
    -
    Disk warning - free space : / 673 MB (12% inode = 59%)
    -
    -
  2. -
  3. - www.theatlantic.com - -
    -
    - HTTP www.theatlantic.com - 6 days, 5 hours -
    -
    Check_http: invalid onedirection - $
    -
    -
  4. -
  5. - www.savoirfairelinux.com - -
    -
    - Verbis se superiores opere enim - 8 days, 5 hours -
    -
    Check_http: invalid onedirection option - $
    - -
    - CPU utilization - 1 days, 3 hours -
    -
    NRPE: Command checkCPU not defined
    - -
    - Runnning services - 1 days, 12 hours -
    -
    Levandi amicitias se fere - $
    -
    -
  6. -
- - -
- -
- ALL PROBLEMS -
-
+
+
- +