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 e3a8844d57b7936a7a094f6aa5706b217596c286 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jun 24 14:54:28 2015 +0200 removed profile page and merged with user page --- app/mum.py | 4 - static/js/controllers/profileCtrl.js | 105 ------------------------- static/js/controllers/usersCtrl.js | 31 +++++++- static/js/mumApp.js | 4 - views/index.html | 2 - views/profile.html | 144 ----------------------------------- views/users.html | 51 ++++++++++--- 7 files changed, 70 insertions(+), 271 deletions(-) diff --git a/app/mum.py b/app/mum.py index a426c0c..91a9f06 100755 --- a/app/mum.py +++ b/app/mum.py @@ -30,10 +30,6 @@ def angular(): def angular(): return template('notifications') -@route('/profile.html') -def angular(): - return template('profile') - @route('/scan.html') def angular(): return template('scan') diff --git a/static/js/controllers/profileCtrl.js b/static/js/controllers/profileCtrl.js deleted file mode 100644 index e4dff89..0000000 --- a/static/js/controllers/profileCtrl.js +++ /dev/null @@ -1,105 +0,0 @@ -mumApp.controller('profileCtrl', function ($scope, $rootScope, $route, $modal, $timeout) { - - $scope.users = {}; - - $scope.selected_user = ""; - - $scope.email = ""; - $scope.sms_url = ""; - - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); - - // after calling db functions - $scope.$on("resCall", function (event, args) { - if (args.func == 'get_users') { - $timeout(function () { - $scope.users = args.res; - }, 0); - } - if (args.func == 'get_user_settings') { - $timeout(function () { - $scope.email = args.res.settings.email; - $scope.sms_url = args.res.settings.sms_url; - }, 0); - } - if (args.func == 'update_user_settings') { - $route.reload(); - } - }); - - $scope.get_user_settings = function () { - var args = {}; - if ($scope.selected_user != '') { - args['username'] = $scope.selected_user; - } - - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_settings', 'args': args}})); - }; - - $scope.save_settings = function () { - var args = {}; - args['username'] = $scope.selected_user; - args['settings'] = {}; - args['settings']['email'] = $scope.email; - args['settings']['sms_url'] = $scope.sms_url; - - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_user_settings', 'args': args}})); - }; - - // creation of modals - $scope.open_modal_subscriptions = function () { - var modalInstance = $modal.open({ - templateUrl: 'modal_subscriptions_label.html', - controller: 'ModalSubscriptionsInstanceCtrl', - resolve: { - subs_args: function () { - return {'username': $scope.selected_user}; - } - } - }); - }; -}); - -mumApp.controller('ModalSubscriptionsInstanceCtrl', function ($scope, $rootScope, $modalInstance, $timeout, subs_args) { - $scope.subs_args = subs_args; // { 'username': stringĀ } - - $scope.user_subscriptions = {}; /* - { - 'hosts':{ - addr_host:{ - 'major':{ - notif_mod:{ - 'priority': int, - 'activated': bool - }, ... - } - 'minor':{...} - }, ... - }, - 'groups':{ ... } - } - */ - - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_subscriptions', - 'args': $scope.subs_args['username']}})); - - $scope.$on("resCall", function (event, args) { - if (args.func == 'get_user_subscriptions') { - $timeout(function () { - $scope.user_subscriptions = args.res; - }, 0); - } - }); - - $scope.get_class = function (sub_part, sub_type, target_name, notif_mod) { - var res = ""; - if ($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']) { - res = "success"; - } - return res; - }; - - $scope.close = function () { - $modalInstance.close(); - }; -}); \ No newline at end of file diff --git a/static/js/controllers/usersCtrl.js b/static/js/controllers/usersCtrl.js index 4d616c0..42bb483 100644 --- a/static/js/controllers/usersCtrl.js +++ b/static/js/controllers/usersCtrl.js @@ -3,8 +3,6 @@ mumApp.controller('usersCtrl', function ($scope, $rootScope, $route, $timeout) { $scope.selected_user = ""; - $scope.show_new_user = false; - $scope.new_username = ""; $scope.user_subscriptions = {}; /* @@ -40,6 +38,16 @@ mumApp.controller('usersCtrl', function ($scope, $rootScope, $route, $timeout) { $timeout(function () { $scope.user_subscriptions = args.res; }, 0); + $scope.get_user_settings(); + } + if (args.func == 'get_user_settings') { + $timeout(function () { + $scope.email = args.res.settings.email; + $scope.sms_url = args.res.settings.sms_url; + }, 0); + } + if (args.func == 'update_user_settings') { + $route.reload(); } }); @@ -72,4 +80,23 @@ mumApp.controller('usersCtrl', function ($scope, $rootScope, $route, $timeout) { return res; }; + $scope.get_user_settings = function () { + var args = {}; + if ($scope.selected_user != '') { + args['username'] = $scope.selected_user; + } + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_settings', 'args': args}})); + }; + + $scope.save_settings = function () { + var args = {}; + args['username'] = $scope.selected_user; + args['settings'] = {}; + args['settings']['email'] = $scope.email; + args['settings']['sms_url'] = $scope.sms_url; + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_user_settings', 'args': args}})); + }; + }); \ No newline at end of file diff --git a/static/js/mumApp.js b/static/js/mumApp.js index a1001fc..69f0db7 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -29,10 +29,6 @@ mumApp.config(function ($routeProvider) { templateUrl : 'notifications.html', controller : 'notificationsCtrl' }) - .when('/profile/',{ - templateUrl : 'profile.html', - controller : 'profileCtrl' - }) .when('/scan/',{ templateUrl : 'scan.html', controller : 'scanCtrl' diff --git a/views/index.html b/views/index.html index 9ed3ee7..14dab72 100644 --- a/views/index.html +++ b/views/index.html @@ -38,7 +38,6 @@ <script src="static/js/controllers/hostPageCtrl.js"></script> <script src="static/js/controllers/headCtrl.js"></script> <script src="static/js/controllers/notificationsCtrl.js"></script> - <script src="static/js/controllers/profileCtrl.js"></script> <script src="static/js/controllers/scanCtrl.js"></script> <script src="static/js/controllers/settingsCtrl.js"></script> <script src="static/js/controllers/statsCtrl.js"></script> @@ -85,7 +84,6 @@ </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> - <li><a href="#profile">Profile</a></li> <li><a href="signin.html">Logout</a></li> </ul> </div> diff --git a/views/profile.html b/views/profile.html deleted file mode 100644 index 2c4137a..0000000 --- a/views/profile.html +++ /dev/null @@ -1,144 +0,0 @@ -<div class="col-md-offset-2 main"> - <h1 class="page-header">Your account</h1> - <select class="form-control input-sm" id="usrlist" - ng-model="selected_user" - ng-options="user as user for user in users" - ng-change="get_user_settings()"> - </select> - <button type="button" class="btn btn-primary" - ng-click="open_modal_subscriptions()" - ng-disabled="selected_user==''">See your subscriptions</button> - - <!--<h2 class="sub-header">They will be applied on each new host you will add.</h2>--> - <form ng-show="selected_user!=''"> - <div class="row"> - <div class="col-xs-3"> - <label for="username">Username</label> - <input type="text" class="form-control" id="username" - disabled - ng-model="selected_user"> - </div> - <div class="row"></div> - <div class="col-xs-3"> - <label for="pswd">Change password</label> - <input type="password" class="form-control" id="pswd" disabled> - </div> - <div class="col-xs-3"> - <label for="pswd2">Repeat new password</label> - <input type="password" class="form-control" id="pswd2" disabled> - </div> - <div class="row"></div> - <div class="col-xs-4"> - <label for="mail">Email address</label> - <input type="email" class="form-control" id="mail" ng-model="email"> - </div> - <div class="row"></div> - <div class="col-xs-8"> - <label for="cellphone">SMS URL (put #message# on the message parameter)</label> - <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> - </div> - </div> - - <button type="button" class="btn btn-primary" ng-click="save_settings()">Save changes</button> - <!--<h3>Preferences</h3> - - <div class="checkbox"> - <label for="minornotif">Send minor notifications by :</label> - <label> - <input type="checkbox" value="" id="minornotif"> - Browser notification - </label> - <label> - <input type="checkbox" value=""> - E-mail - </label> - <label> - <input type="checkbox" value=""> - SMS - </label> - </div> - - <div class="checkbox"> - <label for="majornotif">Send major notifications by :</label> - <label> - <input type="checkbox" value="" id="majornotif"> - Browser notification - </label> - <label> - <input type="checkbox" value=""> - E-mail - </label> - <label> - <input type="checkbox" value=""> - SMS - </label> - </div> - - ---> - </form> - - <script type="text/ng-template" id="modal_subscriptions_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Summary of your subscriptions</h3> - </div> - <div class="modal-body"> - <p>Number of notifications between 2 logins</p> - <table class="table table-hover"> - <thead> - <tr> - <th>Host</th> - <th>Notification service</th> - <th>Minor</th> - <th>Major</th> - </tr> - </thead> - <tbody> - <tr ng-repeat-start="(addr_host, host) in user_subscriptions.hosts"> - <td>{{addr_host}}</td> - </tr> - <tr ng-repeat-end - ng-repeat="(notif_mod_name, notif_mod) in host.minor"> - <td></td> - <td>{{notif_mod_name}}</td> - <td class="{{get_class('hosts', 'minor', addr_host, notif_mod_name)}}"> - {{notif_mod.priority}} - </td> - <td class="{{get_class('hosts', 'major', addr_host, notif_mod_name)}}"> - {{user_subscriptions.hosts[addr_host].major[notif_mod_name].priority}} - </td> - </tr> - </tbody> - </table> - <table class="table table-hover"> - <thead> - <tr> - <th>Group</th> - <th>Notification service</th> - <th>Minor</th> - <th>Major</th> - </tr> - </thead> - <tbody> - <tr ng-repeat-start="(grp_name, grp) in user_subscriptions.groups"> - <td>{{grp_name}}</td> - </tr> - <tr ng-repeat-end - ng-repeat="(notif_mod_name, notif_mod) in grp.minor"> - <td></td> - <td>{{notif_mod_name}}</td> - <td class="{{get_class('groups', 'minor', grp_name, notif_mod_name)}}"> - {{notif_mod.priority}} - </td> - <td class="{{get_class('groups', 'major', grp_name, notif_mod_name)}}"> - {{user_subscriptions.groups[grp_name].major[notif_mod_name].priority}} - </td> - </tr> - </tbody> - </table> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> - </div> - </script> -</div> \ No newline at end of file diff --git a/views/users.html b/views/users.html index aeb348c..c289b5d 100644 --- a/views/users.html +++ b/views/users.html @@ -1,5 +1,12 @@ <div class="col-md-offset-2 main"> <h1 class="page-header">Users <small>{{selected_user}}</small></h1> + + <input type="text" ng-model="new_username"> + <button type="button" class="btn btn-primary" + ng-disabled="new_username==''" + ng-click="addUser()">Create user + </button> + <div class="row"> <div class="col-xs-4"> <label for="usrlist">Registered users</label> @@ -9,21 +16,45 @@ ng-change="get_user_subscriptions()"></select> </div> </div> - <button type="button" class="btn btn-primary" data-toggle="popover" - data-placement="bottom" title="Add user..." data-content="ger" - ng-click="show_new_user=!show_new_user">Add user</button> - <input type="text" ng-show="show_new_user" ng-model="new_username"> - <button type="button" class="btn btn-primary" - ng-show="show_new_user && new_username!=''" - ng-click="addUser()">Create user - </button> + <button type="button" class="btn btn-danger" ng-show="selected_user!='' && selected_user!=null" - ng-click="removeUser()">Remove {{selected_user}} + ng-click="removeUser()">Delete {{selected_user}} </button> <div ng-show="selected_user!=''"> - <p>Subscriptions summary:</p> + <div class="row"> + <div class="col-xs-3"> + <label for="username">Username</label> + <input type="text" class="form-control" id="username" + disabled + ng-model="selected_user"> + </div> + <div class="row"></div> + <div class="col-xs-3"> + <label for="pswd">Change password</label> + <input type="password" class="form-control" id="pswd" disabled> + </div> + <div class="col-xs-3"> + <label for="pswd2">Repeat new password</label> + <input type="password" class="form-control" id="pswd2" disabled> + </div> + <div class="row"></div> + <div class="col-xs-4"> + <label for="mail">Email address</label> + <input type="email" class="form-control" id="mail" ng-model="email"> + </div> + <div class="row"></div> + <div class="col-xs-8"> + <label for="cellphone">SMS URL (put #message# on the message parameter)</label> + <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> + </div> + </div> + + <button type="button" class="btn btn-primary" ng-click="save_settings()">Save changes</button> + + <p>This is a summary of this user's subscriptions. You can change the subscriptions on the + dashboard table or a specific host page.</p> <table class="table table-hover"> <thead> <tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.