Repository: incubator-ignite Updated Branches: refs/heads/ignite-843 28fcb5d00 -> c93a720a5
# IGNITE-843 Fix broken admin page. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c93a720a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c93a720a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c93a720a Branch: refs/heads/ignite-843 Commit: c93a720a509059b456e96236a7ce93e547d7da03 Parents: 28fcb5d Author: sevdokimov <sergey.evdoki...@jetbrains.com> Authored: Thu Jul 9 10:42:44 2015 +0300 Committer: sevdokimov <sergey.evdoki...@jetbrains.com> Committed: Thu Jul 9 10:42:44 2015 +0300 ---------------------------------------------------------------------- .../nodejs/controllers/admin-controller.js | 8 ++- .../web-control-center/nodejs/routes/admin.js | 12 ++--- .../nodejs/views/admin/index.jade | 21 -------- .../nodejs/views/admin/userList.jade | 54 ++++++++++++++++++++ .../nodejs/views/admin/users.jade | 35 ------------- 5 files changed, 66 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c93a720a/modules/web-control-center/nodejs/controllers/admin-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/controllers/admin-controller.js b/modules/web-control-center/nodejs/controllers/admin-controller.js index 8ee89ee..425ec3e 100644 --- a/modules/web-control-center/nodejs/controllers/admin-controller.js +++ b/modules/web-control-center/nodejs/controllers/admin-controller.js @@ -34,7 +34,7 @@ controlCenterModule.controller('adminController', ['$scope', '$alert', '$http', if (!confirm("You are going to delete user " + user.username + ". Please, confirm it.")) return false; - $http.post('admin/remove', {params: {userId: user._id}}).success( + $http.post('admin/remove', {userId: user._id}).success( function (data) { $scope.alertStr = "User has been removed: " + user.username; $scope.alertType = 'success'; @@ -53,11 +53,15 @@ controlCenterModule.controller('adminController', ['$scope', '$alert', '$http', user.adminChanging = true; - $http.post('admin/save', {params: {userId: user._id, adminFlag: user.admin}}).success( + $http.post('admin/save', {userId: user._id, adminFlag: user.admin}).success( function (data) { reload(); + + adminChanging = false; }).error(function (err) { $scope.alertStr = "Failed to update user: " + err; + + adminChanging = false; }); } }]); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c93a720a/modules/web-control-center/nodejs/routes/admin.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/routes/admin.js b/modules/web-control-center/nodejs/routes/admin.js index b15443e..e67f306 100644 --- a/modules/web-control-center/nodejs/routes/admin.js +++ b/modules/web-control-center/nodejs/routes/admin.js @@ -20,7 +20,7 @@ var db = require('../db'); var uiUtils = require('../helpers/ui-utils'); router.get('/', function(req, res) { - res.render('admin/index'); + res.render('admin/userList'); }); /** @@ -42,7 +42,7 @@ router.post('/list', function(req, res) { }); router.post('/remove', function(req, res) { - var userId = req.query.userId; + var userId = req.body.userId; db.Account.findByIdAndRemove(userId, function(err) { if (!err) @@ -53,8 +53,8 @@ router.post('/remove', function(req, res) { }); router.post('/save', function(req, res) { - var userId = req.query.userId; - var adminFlag = req.query.adminFlag; + var userId = req.body.userId; + var adminFlag = req.body.adminFlag; db.Account.findByIdAndUpdate(userId, {admin: adminFlag}, function(err) { if (!err) @@ -64,8 +64,8 @@ router.post('/save', function(req, res) { }); }); -router.post('/become', function(req, res) { - var viewedUserId = req.body.viewedUserId; +router.get('/become', function(req, res) { + var viewedUserId = req.query.viewedUserId; if (!viewedUserId) { req.session.viewedUser = null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c93a720a/modules/web-control-center/nodejs/views/admin/index.jade ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/views/admin/index.jade b/modules/web-control-center/nodejs/views/admin/index.jade deleted file mode 100644 index 099d2b7..0000000 --- a/modules/web-control-center/nodejs/views/admin/index.jade +++ /dev/null @@ -1,21 +0,0 @@ -//- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -extends ../templates/layout - -append scripts - script(src='/admin-controller.js') - script(src='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js') - -block container - include users http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c93a720a/modules/web-control-center/nodejs/views/admin/userList.jade ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/views/admin/userList.jade b/modules/web-control-center/nodejs/views/admin/userList.jade new file mode 100644 index 0000000..d3cd122 --- /dev/null +++ b/modules/web-control-center/nodejs/views/admin/userList.jade @@ -0,0 +1,54 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +extends ../templates/layout + +append scripts + script(src='/admin-controller.js') + +block container + .row(ng-controller='adminController') + .docs-content + .docs-header + h1 Users + p List of registered users + hr + .docs-body + div(ng-class='{alert: true, "alert-danger": alertType == danger, "alert-success": alertType == "success"}' ng-show='alertStr') {{alertStr}} + table.table.table-striped(st-table='userListDisplay' st-safe-src='userList') + thead + tr + th(colspan='5') + input.form-control(type='text' st-search='' class='' placeholder='Search ...') + tr + th(st-sort='username') User name + th(st-sort='email') Email + th(st-sort='lastLogin') Last login + th(st-sort='lastLogin') Admin + th(colspan='2') Actions + tbody + tr(ng-repeat='user in userListDisplay') + td {{user.username}} + td + a(ng-href='mailto:{{user.email}}') {{user.email}} + td + span.small {{user.lastLogin | date:'medium'}} + td + input(type='checkbox' ng-disabled='user.adminChanging' ng-model='user.admin' + ng-change='toggleAdmin(user)') + td(width='1%') + a(ng-click='removeUser(user)' ng-show='user._id != loggedInUser._id' title='Remove user') + span.glyphicon.glyphicon-remove(style='color: red') + td(width='1%') + a(ng-href='admin/become?viewedUserId={{user._id}}' ng-show='user._id != loggedInUser._id' title='View user\'s configurations') + span.glyphicon.glyphicon-eye-open http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c93a720a/modules/web-control-center/nodejs/views/admin/users.jade ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/views/admin/users.jade b/modules/web-control-center/nodejs/views/admin/users.jade deleted file mode 100644 index 58c46c1..0000000 --- a/modules/web-control-center/nodejs/views/admin/users.jade +++ /dev/null @@ -1,35 +0,0 @@ -.row(ng-controller='adminController') - .docs-content - .docs-header - h1 Users - p List of registered users - hr - .docs-body - div(ng-class='{alert: true, "alert-danger": alertType == danger, "alert-success": alertType == "success"}' ng-show='alertStr') {{alertStr}} - table.table.table-striped(st-table='userListDisplay' st-safe-src='userList') - thead - tr - th(colspan='5') - input.form-control(type='text' st-search='' class='' placeholder='Search ...') - tr - th(st-sort='username') User name - th(st-sort='email') Email - th(st-sort='lastLogin') Last login - th(st-sort='lastLogin') Admin - th(colspan='2') Actions - tbody - tr(ng-repeat='user in userListDisplay') - td {{user.username}} - td - a(ng-href='mailto:{{user.email}}') {{user.email}} - td - span.small {{user.lastLogin | date:'medium'}} - td - input(type='checkbox' ng-disabled='user.adminChanging' ng-model='user.admin' - ng-change='toggleAdmin(user)') - td(width='1%') - a(ng-click='removeUser(user)' ng-show='user._id != loggedInUser._id' title='Remove user') - span.glyphicon.glyphicon-remove(style='color: red') - td(width='1%') - a(ng-href='become?viewedUserId={{user._id}}' ng-show='user._id != loggedInUser._id' title='View user\'s configurations') - span.glyphicon.glyphicon-eye-open