This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 476dd45c9b628fe016ee65a8a542c629f9e8dfa8 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Jul 6 12:28:51 2015 +0200 Category view on dashboard --- app/websocket_func.py | 3 +++ static/js/controllers/dashboardCtrl.js | 47 ++++++++++++++++++++++++++++++++++ static/js/controllers/headCtrl.js | 3 +++ views/dashboard.html | 40 +++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/app/websocket_func.py b/app/websocket_func.py index 4baa086..5455895 100644 --- a/app/websocket_func.py +++ b/app/websocket_func.py @@ -90,6 +90,9 @@ def CALL_FUNC_DB(msg, ws, ml): }}) ws.send(msg) +# asked from dashboard, on category view +def GET_LOADED_MONI_MOD(msg, ws, ml): + ws.send(json.dumps({"RES_GET_LOADED_MONI_MOD": ml.get_info_mod_monitoring()})) # asked from hostpage, at the connection configuration def GET_LOADED_CONN_MOD(msg, ws, ml): diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index a638747..3c841fd 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -269,4 +269,51 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r } } }; + + /*** CATEGORY VIEW FUNCIONS ***/ + + $scope.category_obj = {}; + + $scope.loaded_moni_mod = {}; + + $scope.is_category_in_alert = function (){ + return Object.keys($scope.category_obj).length > 0; + }; + + $scope.get_loaded_moni_mod = function (){ + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_MONI_MOD": null})); + }; + + $scope.$on("resGetLoadedMoniMod", function (event, args) { + $timeout(function () { + $scope.loaded_moni_mod = args; + update_category_obj(); + }, 0); + }); + + var update_category_obj = function (){ + for (var i = 0, l=$scope.items.length; i<l; i++){ + tab_warning = $scope.items[i].warning; + for (var j = 0, l_warn = tab_warning.length; j<l_warn; j++){ + var category = $scope.loaded_moni_mod[tab_warning[j]].block; + if(!$scope.category_obj.hasOwnProperty(category)){ + $scope.category_obj[category] = {}; + $scope.category_obj[category].warning = []; + $scope.category_obj[category].danger = []; + } + $scope.category_obj[category].warning.push($scope.items[i].display_name + " on " + tab_warning[j]); + } + + tab_danger = $scope.items[i].danger; + for (var j = 0, l_dang = tab_danger.length; j<l_dang; j++){ + var category = $scope.loaded_moni_mod[tab_danger[j]].block; + if(!$scope.category_obj.hasOwnProperty(category)){ + $scope.category_obj[category] = {}; + $scope.category_obj[category].warning = []; + $scope.category_obj[category].danger = []; + } + $scope.category_obj[category].danger.push($scope.items[i].display_name + " on " + tab_danger[j]); + } + } + }; }); \ No newline at end of file diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 49a9121..2bb9a71 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -72,6 +72,9 @@ mumApp.controller('headCtrl', function ($scope, $rootScope, toastr, $interval, $ case "RES_REM_HOST": $rootScope.$broadcast("remHost"); break; + case "RES_GET_LOADED_MONI_MOD": + $rootScope.$broadcast("resGetLoadedMoniMod", obj[key]); + break; case "RES_GET_LOADED_CONN_MOD": $rootScope.$broadcast("resGetLoadedConnMod", obj[key]); break; diff --git a/views/dashboard.html b/views/dashboard.html index 96eefcf..2fff242 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -16,6 +16,7 @@ <input type="radio" value="host_view" ng-model="view"> Host view <input type="radio" value="group_view" ng-model="view" ng-click="update_group_obj()"> Group view <input type="radio" value="service_view" ng-model="view" ng-click="update_service_obj()"> Service view + <input type="radio" value="category_view" ng-model="view" ng-click="get_loaded_moni_mod()"> Category view </div> @@ -302,6 +303,45 @@ </div> </div> + <!-- Category View --> + + <div ng-show="view == 'category_view' && items.length > 0"> + <div ng-show="is_category_in_alert()"> + <h2 class="sub-header">Categories in alert...</h2> + + <table class="table table-condensed table-hover"> + <thead> + <tr> + <th>Category</th> + <th>Machines in alert</th> + </tr> + </thead> + + <tbody> + <tr ng-repeat="(cat_name, cat) in category_obj"> + <td> + {{cat_name}} + </td> + <td> + <span ng-repeat="machine in cat.danger" + style="color:red"> + {{machine}} <br/> + </span> + <span ng-repeat="machine in cat.warning" + style="color:orange"> + {{machine}} <br/> + </span> + </td> + </tr> + </tbody> + </table> + </div> + + <div ng-show="!is_category_in_alert()"> + <h2 class="sub-header">No categories in alert at the moment.</h2> + </div> + </div> + <!-- Message when no hosts on monitoring --> <div ng-show="items.length == 0"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.