branch develop updated (e5713af -> add9fd1)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from e5713af archiving + stats calculation after a check (except for dict values) + angular-charts bower dependency added as well a sample chart on statistics page new add9fd1 stat page : archived data shown on chart after selection (except dict values) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit add9fd19d7d79065e38a8da300a6062fb9ab2a95 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue May 5 11:25:08 2015 +0200 stat page : archived data shown on chart after selection (except dict values) Summary of changes: app/modules/storage_modules/shelve_db.py | 27 +++++++++++- static/css/dashboard.css | 4 +- static/js/controllers/statsCtrl.js | 70 ++++++++++++++++++++++++-------- views/stats.html | 32 +++++++++++++-- 4 files changed, 110 insertions(+), 23 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 add9fd19d7d79065e38a8da300a6062fb9ab2a95 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue May 5 11:25:08 2015 +0200 stat page : archived data shown on chart after selection (except dict values) --- app/modules/storage_modules/shelve_db.py | 27 +++++++++++- static/css/dashboard.css | 4 +- static/js/controllers/statsCtrl.js | 70 ++++++++++++++++++++++++-------- views/stats.html | 32 +++++++++++++-- 4 files changed, 110 insertions(+), 23 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index de44699..aadd744 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -1,3 +1,5 @@ +# -*- coding: utf8 -*- + __author__ = 'aguilbaud' from datetime import datetime @@ -961,7 +963,6 @@ class shelve_db: date_period_str = dict_archive[period][len(dict_archive[period]) - 1]['date'] date_period = datetime.strptime(date_period_str,'%Y-%m-%d %H:%M:%S.%f') time_diff = date_last_check - date_period - print time_diff if period == 'min' and time_diff.seconds >= 60: dict_archive[period].append(dict_check) if period == 'hour' and time_diff.seconds >= 3600: @@ -1031,6 +1032,30 @@ class shelve_db: 'msg': msg}) return dict_notif + def get_stats(self, args): + """ + Returns the archived data and row statistics concerning a host. + :param args: a dictionary containing: + { + 'addr_host': str + } + :return: a dictionary containing: + { + 'stats': {mod_name: {...}, ...} + 'archive': {mod_name: {...}, ...} + } + """ + res = {} + self.open_db() + try: + res['stats'] = self.db['hosts'][args['addr_host']]['stats'] + res['archive'] = self.db['hosts'][args['addr_host']]['archive'] + except Exception: + print traceback.format_exc() + finally: + self.close_db() + return res + def add_host_list_to_group(self, args): """ Called from the groups page. diff --git a/static/css/dashboard.css b/static/css/dashboard.css index e639ce7..89fc6ad 100644 --- a/static/css/dashboard.css +++ b/static/css/dashboard.css @@ -124,6 +124,6 @@ body { /* For angular charts */ .chart { - width: 500px; - height: 300px; + width: 800px; + height: 500px; } \ No newline at end of file diff --git a/static/js/controllers/statsCtrl.js b/static/js/controllers/statsCtrl.js index 6499b78..46d13ba 100644 --- a/static/js/controllers/statsCtrl.js +++ b/static/js/controllers/statsCtrl.js @@ -1,6 +1,55 @@ -mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout) { +mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) { + $scope.host_list = []; + for(var i = 0; i < DataHosts.Items.length; i++){ + $scope.host_list.push(DataHosts.Items[i]['addr']) + } + + $scope.mod_list = []; + + $scope.selected_host = ''; + + $scope.selected_mod = ''; + + $scope.selected_period = ''; + + $scope.stats = {}; + $scope.archive = {}; + + $scope.get_stats = function(){ + if($scope.selected_host != null && $scope.selected_host != ''){ + var args = {}; + args['addr_host'] = $scope.selected_host; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_stats', 'args': args}})); + } + }; + + $scope.$on("resCall", function (event, args) { + if(args.func == 'get_stats'){ + $scope.stats = args.res.stats; + $scope.archive = args.res.archive; + $scope.mod_list = []; + for(var mod_name in args.res.archive){ + $scope.mod_list.push(mod_name); + } + } + }); + + $scope.refresh_chart_data = function(){ + $scope.config.title = $scope.selected_host; + $scope.data.series = [$scope.selected_mod]; + $scope.data.data = []; + for(var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++){ + $scope.data.data.push({'x': i, + 'y': [$scope.archive[$scope.selected_mod][$scope.selected_period][i].value], + 'tooltip': $scope.archive[$scope.selected_mod][$scope.selected_period][i].value + " @ " + + $scope.archive[$scope.selected_mod][$scope.selected_period][i].date.split('.')[0] + } + ) + } + }; + $scope.config = { - title: 'Products', + title: '', tooltips: true, labels: false, mouseover: function() {}, @@ -14,20 +63,7 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout) { }; $scope.data = { - series: ['Sales', 'Income', 'Expense', 'Laptops', 'Keyboards'], - data: [{ - x: "Laptops", - y: [100, 500, 0], - tooltip: "this is tooltip" - }, { - x: "Desktops", - y: [300, 100, 100] - }, { - x: "Mobiles", - y: [351] - }, { - x: "Tablets", - y: [54, 0, 879] - }] + series: [], + data: [] }; }); \ No newline at end of file diff --git a/views/stats.html b/views/stats.html index 9120281..a375749 100644 --- a/views/stats.html +++ b/views/stats.html @@ -1,14 +1,40 @@ <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <h1 class="page-header">Statistics</h1> - + <select ng-model="selected_host" + ng-options="host for host in host_list" + ng-change="get_stats()"> + </select> + <!-- + <div class="row"> + <div class="col-xs-2" + ng-repeat="(mod, val) in selected_mod"> + {{mod}} <input type="checkbox" ng_model="selected_mod[mod]"> + </div> + </div> + --> + <select ng-model="selected_mod" + ng-options="mod for mod in mod_list" + ng-show="selected_host != ''" + ng-change="selected_period = ''"> + </select> + <select ng-model="selected_period" + ng-show="selected_mod != ''" + ng-change="refresh_chart_data()"> + <option value="min">By minute</option> + <option value="hour">By hour</option> + <option value="day">By day</option> + <option value="week">By week</option> + <option value="month">By month</option> + <option value="year">By year</option> + </select> <div - data-ac-chart="'bar'" + ng-show="selected_period != ''" + data-ac-chart="'line'" data-ac-data="data" data-ac-config="config" class="chart"> </div> - <!--<div class="row placeholders"> <div class="col-xs-6 col-sm-3 placeholder"> <img src="data/index.svg" class="img-responsive" alt="Generic placeholder thumbnail"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm