From a01622130c7d49ddb871ff67a4392c4b8168c261 Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt Date: Thu, 20 Aug 2015 11:41:24 -0300 Subject: [PATCH 1/6] Changes to user administration --- .../admin/users/adminUserChannels.coffee | 10 +++++++- .../views/admin/users/adminUserChannels.html | 2 +- client/views/admin/users/adminUserInfo.coffee | 12 +++++++--- client/views/admin/users/adminUsers.coffee | 24 ++++--------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/client/views/admin/users/adminUserChannels.coffee b/client/views/admin/users/adminUserChannels.coffee index 55c4b5d448c8b..f7f5520e92150 100644 --- a/client/views/admin/users/adminUserChannels.coffee +++ b/client/views/admin/users/adminUserChannels.coffee @@ -1,3 +1,11 @@ Template.adminUserChannels.helpers type: -> - return if @t is 'd' then 'at' else if @t is 'p' then 'lock' else 'hash' \ No newline at end of file + return if @t is 'd' then 'at' else if @t is 'p' then 'lock' else 'hash' + route: -> + return switch @t + when 'd' + FlowRouter.path('direct', {username: @name}) + when 'p' + FlowRouter.path('group', {name: @name}) + when 'c' + FlowRouter.path('channel', {name: @name}) diff --git a/client/views/admin/users/adminUserChannels.html b/client/views/admin/users/adminUserChannels.html index 468a4951e92c0..a2f020d077f56 100644 --- a/client/views/admin/users/adminUserChannels.html +++ b/client/views/admin/users/adminUserChannels.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/client/views/admin/users/adminUserInfo.coffee b/client/views/admin/users/adminUserInfo.coffee index 75caa12027edc..07621a4efbc93 100644 --- a/client/views/admin/users/adminUserInfo.coffee +++ b/client/views/admin/users/adminUserInfo.coffee @@ -20,21 +20,27 @@ Template.adminUserInfo.helpers return "UTC #{@utcOffset}" Template.adminUserInfo.events - 'click .deactivate': -> + 'click .deactivate': (e) -> + e.stopPropagation() + e.preventDefault() Meteor.call 'setUserActiveStatus', Template.currentData()._id, false, (error, result) -> if result toastr.success t('User_has_been_deactivated') if error toastr.error error.reason - 'click .activate': -> + 'click .activate': (e) -> + e.stopPropagation() + e.preventDefault() Meteor.call 'setUserActiveStatus', Template.currentData()._id, true, (error, result) -> if result toastr.success t('User_has_been_activated') if error toastr.error error.reason - 'click .delete': -> + 'click .delete': (e) -> + e.stopPropagation() + e.preventDefault() _id = Template.currentData()._id swal { title: t('Are_you_sure') diff --git a/client/views/admin/users/adminUsers.coffee b/client/views/admin/users/adminUsers.coffee index cf7eb79298dfe..bb9828828e3fc 100644 --- a/client/views/admin/users/adminUsers.coffee +++ b/client/views/admin/users/adminUsers.coffee @@ -12,7 +12,7 @@ Template.adminUsers.helpers userData: -> return Meteor.users.findOne Session.get 'adminUsersSelected' userChannels: -> - return ChatSubscription.find({ "u._id": Session.get 'settingsUsersSelected' }, { fields: { rid: 1, name: 1, t: 1 }, sort: { t: 1, name: 1 } }).fetch() + return ChatSubscription.find({ "u._id": Session.get 'adminUsersSelected' }, { fields: { rid: 1, name: 1, t: 1 }, sort: { t: 1, name: 1 } }).fetch() isLoading: -> return 'btn-loading' unless Template.instance().ready?.get() hasMore: -> @@ -47,7 +47,7 @@ Template.adminUsers.onCreated -> @autorun -> if Session.get 'adminUsersSelected' - channelSubscription = instance.subscribe 'userChannels', Session.get 'settingsUsersSelected' + channelSubscription = instance.subscribe 'userChannels', Session.get 'adminUsersSelected' @users = -> filter = _.trim instance.filter?.get() @@ -57,7 +57,7 @@ Template.adminUsers.onCreated -> else query = {} - return Meteor.users.find(query, { limit: instance.limit?.get(), sort: { username: 1 } }).fetch() + return Meteor.users.find(query, { limit: instance.limit?.get(), sort: { username: 1, name: 1 } }).fetch() Template.adminUsers.onRendered -> Tracker.afterFlush -> @@ -86,25 +86,11 @@ Template.adminUsers.events Session.set 'adminUsersSelected', $(e.currentTarget).data('id') Session.set 'flexOpened', true - 'click .user-info-tabs a': (e) -> + 'click .info-tabs a': (e) -> e.preventDefault() - $('.user-info-tabs a').removeClass 'active' + $('.info-tabs a').removeClass 'active' $(e.currentTarget).addClass 'active' - 'click .deactivate': -> - Meteor.call 'setUserActiveStatus', Session.get('adminUsersSelected'), false, (error, result) -> - if result - toastr.success t('User_has_been_deactivated') - if error - toastr.error error.reason - - 'click .activate': -> - Meteor.call 'setUserActiveStatus', Session.get('adminUsersSelected'), true, (error, result) -> - if result - toastr.success t('User_has_been_activated') - if error - toastr.error error.reason - $('.user-info-content').hide() $($(e.currentTarget).attr('href')).show() From ec2c31cbdeea7fbe78fdce1a1c9b848a3b8a072d Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt Date: Thu, 20 Aug 2015 13:36:22 -0300 Subject: [PATCH 2/6] Button to make or remove user as admin --- client/views/admin/users/adminUserInfo.coffee | 18 ++++++++++++++++++ client/views/admin/users/adminUserInfo.html | 5 +++++ i18n/en.i18n.json | 2 ++ 3 files changed, 25 insertions(+) diff --git a/client/views/admin/users/adminUserInfo.coffee b/client/views/admin/users/adminUserInfo.coffee index 07621a4efbc93..2124f0de09622 100644 --- a/client/views/admin/users/adminUserInfo.coffee +++ b/client/views/admin/users/adminUserInfo.coffee @@ -37,6 +37,24 @@ Template.adminUserInfo.events toastr.success t('User_has_been_activated') if error toastr.error error.reason + + 'click .make-admin': (e) -> + e.stopPropagation() + e.preventDefault() + Meteor.call 'setAdminStatus', Template.currentData()._id, true, (error, result) -> + if result + toastr.success t('User_is_now_an_admin') + if error + toastr.error error.reason + + 'click .remove-admin': (e) -> + e.stopPropagation() + e.preventDefault() + Meteor.call 'setAdminStatus', Template.currentData()._id, false, (error, result) -> + if result + toastr.success t('User_is_no_longer_an_admin') + if error + toastr.error error.reason 'click .delete': (e) -> e.stopPropagation() diff --git a/client/views/admin/users/adminUserInfo.html b/client/views/admin/users/adminUserInfo.html index 693a24683eb8d..4c133d2412891 100644 --- a/client/views/admin/users/adminUserInfo.html +++ b/client/views/admin/users/adminUserInfo.html @@ -13,6 +13,11 @@

{{name}}