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 7f6bf28c6712f1dcea71cd66a8ba6b69030a6dd4 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Mar 2 15:03:06 2015 +0100 séparation des controlleurs angular (scanCtrl ajouté) --- app/app.py | 2 +- static/js/controllers/dashboardCtrl.js | 4 ++-- static/js/controllers/headCtrl.js | 25 +++++++++---------------- static/js/controllers/scanCtrl.js | 17 +++++++++++++++++ static/js/mumApp.js | 8 ++++---- views/index.html | 3 ++- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/app/app.py b/app/app.py index c55e720..7805908 100755 --- a/app/app.py +++ b/app/app.py @@ -159,6 +159,6 @@ def receive(ws): if __name__ == '__main__': global wsc wsc = WebSocketContainer(module_loader.load_db()) - process_monitoring.init(module_loader.load_db(), wsc) + #process_monitoring.init(module_loader.load_db(), wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) \ No newline at end of file diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index f649cba..31c9e33 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('dashboardController', function($scope, $filter, $routeParams, DataHosts){ +mumApp.controller('dashboardCtrl', function($scope, $filter, $routeParams, DataHosts){ $scope.param = $routeParams.param; $scope.sort = { @@ -8,7 +8,7 @@ mumApp.controller('dashboardController', function($scope, $filter, $routeParams, $scope.gap = 5; - $scope.items = []; + $scope.items = DataHosts.Items; $scope.$on("hostsUpdate", function (event) { $scope.items = DataHosts.Items; diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 231c143..d5da7ee 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -1,27 +1,17 @@ -mumApp.controller('headController', function($scope, $rootScope, toastr, $interval, $routeParams, $location, DataHosts) { +mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $routeParams, $location, DataHosts) { // init //$scope.master = {}; - $scope.items = []; + $scope.items = DataHosts.Items; $scope.$on("hostsUpdate", function (event) { $scope.items = DataHosts.Items; }); - // Concerning the scan form - - $scope.ip_range = "" // la plage d'ip entree dans le champ - $scope.state = ""; // l'etat general du scan en cours - $scope.validated = false; // pour afficher ou non certaines parties de la page - $scope.scan_is_over = false; // pour afficher ou non certaines parties de la page - $scope.ip_scanned = {}; - - // Concerning the hostpage $scope.host_informations = null; $scope.get_host_informations = function(addr_host){ - alert("jobep"); var request = '{"13" : "'+ addr_host + '"}'; ws.send(request); } @@ -34,6 +24,11 @@ mumApp.controller('headController', function($scope, $rootScope, toastr, $interv ws.send(request); }; + // instructions received from other controllers + // args contains a json formatted string + $scope.$on("sendViaWs", function (event, args) { + ws.send(args); + }); ws.onmessage = function (evt) { // actions effectuees lors de la reception d'un message via la websocket JSON.parse(evt.data, function (key, value) { @@ -61,6 +56,7 @@ mumApp.controller('headController', function($scope, $rootScope, toastr, $interv $scope.$apply(function(){ $scope.state = value; }); + $rootScope.$broadcast("stateUpdate", value); toastr.info(value, "Current status is :"); /* $scope.$apply(function(){ @@ -101,10 +97,7 @@ mumApp.controller('headController', function($scope, $rootScope, toastr, $interv toastr.error(msg, title); }; - $scope.post_val = function(){ //lace la detection apres remplissage du champ et validation du formulaire - var request = '{"10" : "' + $scope.ip_range + '"}'; - ws.send(request); - } + diff --git a/static/js/controllers/scanCtrl.js b/static/js/controllers/scanCtrl.js new file mode 100644 index 0000000..3f40afd --- /dev/null +++ b/static/js/controllers/scanCtrl.js @@ -0,0 +1,17 @@ +mumApp.controller('scanCtrl', function($scope, $rootScope) { + // Concerning the scan form + $scope.ip_range = "" // la plage d'ip entree dans le champ + $scope.state = ""; // l'etat general du scan en cours + + $scope.$on("stateUpdate", function (event, args) { + $scope.state = args; + }); + + $scope.validated = false; // pour afficher ou non certaines parties de la page + $scope.scan_is_over = false; // pour afficher ou non certaines parties de la page + $scope.ip_scanned = {}; + + $scope.post_val = function(){ //lace la detection apres remplissage du champ et validation du formulaire + $rootScope.$broadcast("sendViaWs", JSON.stringify({"10": $scope.ip_range})); + }; +}); \ No newline at end of file diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 3844456..8edd37c 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -8,15 +8,15 @@ mumApp.config(function($routeProvider){ $routeProvider .when('/',{ templateUrl : 'dashboard.html', - controller : 'dashboardController' + controller : 'dashboardCtrl' }) .when('/dashboard',{ templateUrl : 'dashboard.html', - controller : 'dashboardController' + controller : 'dashboardCtrl' }) .when('/dashboard/:param',{ templateUrl : 'dashboard.html', - //controller : 'mainController' + controller : 'dashboardCtrl' }) .when('/groups',{ templateUrl : 'groups.html', @@ -36,7 +36,7 @@ mumApp.config(function($routeProvider){ }) .when('/scan',{ templateUrl : 'scan.html', - //controller : 'mainController' + controller : 'scanCtrl' }) .when('/settings',{ templateUrl : 'settings.html', diff --git a/views/index.html b/views/index.html index 5df1a23..36429c1 100644 --- a/views/index.html +++ b/views/index.html @@ -24,6 +24,7 @@ <script src="static/js/mumApp.js"></script> <script src="static/js/controllers/dashboardCtrl.js"></script> <script src="static/js/controllers/headCtrl.js"></script> + <script src="static/js/controllers/scanCtrl.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]><!-- @@ -36,7 +37,7 @@ <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid"> - <div class="navbar-header" ng-controller="headController"> + <div class="navbar-header" ng-controller="headCtrl"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.