2019-02-22 18:06:48 +00:00
|
|
|
<template>
|
|
|
|
<div class="users-container">
|
2020-04-17 22:27:00 +00:00
|
|
|
<div class="users-header-container">
|
|
|
|
<h1>
|
|
|
|
{{ $t('users.users') }}
|
|
|
|
<span class="user-count">({{ normalizedUsersCount }})</span>
|
|
|
|
</h1>
|
|
|
|
<reboot-button/>
|
|
|
|
</div>
|
2019-06-11 15:13:48 +00:00
|
|
|
<div class="filter-container">
|
2019-03-29 14:25:53 +00:00
|
|
|
<users-filter/>
|
2020-02-23 21:17:24 +00:00
|
|
|
<el-input
|
|
|
|
:placeholder="$t('users.search')"
|
|
|
|
v-model="search"
|
|
|
|
prefix-icon="el-icon-search"
|
|
|
|
class="search"
|
|
|
|
@input="handleDebounceSearchInput"/>
|
2019-03-06 19:44:37 +00:00
|
|
|
</div>
|
2019-06-11 15:13:48 +00:00
|
|
|
<div class="actions-container">
|
2020-01-24 19:43:22 +00:00
|
|
|
<el-button class="actions-button" @click="createAccountDialogOpen = true">
|
|
|
|
<span class="create-account">
|
2019-09-23 19:00:28 +00:00
|
|
|
<i class="el-icon-plus"/>
|
2019-06-11 15:13:48 +00:00
|
|
|
{{ $t('users.createAccount') }}
|
|
|
|
</span>
|
|
|
|
</el-button>
|
|
|
|
<multiple-users-menu
|
|
|
|
:selected-users="selectedUsers"
|
|
|
|
@apply-action="clearSelection"/>
|
|
|
|
</div>
|
|
|
|
<new-account-dialog
|
2019-09-23 19:00:28 +00:00
|
|
|
:dialog-form-visible="createAccountDialogOpen"
|
2019-06-11 15:13:48 +00:00
|
|
|
@createNewAccount="createNewAccount"
|
2019-09-23 19:00:28 +00:00
|
|
|
@closeWindow="createAccountDialogOpen = false"/>
|
2019-05-05 19:52:20 +00:00
|
|
|
<el-table
|
|
|
|
v-loading="loading"
|
|
|
|
ref="usersTable"
|
|
|
|
:data="users"
|
|
|
|
row-key="id"
|
|
|
|
style="width: 100%"
|
2020-06-02 19:52:04 +00:00
|
|
|
@row-click="handleRowClick($event)"
|
2019-05-05 19:52:20 +00:00
|
|
|
@selection-change="handleSelectionChange">
|
|
|
|
<el-table-column
|
|
|
|
v-if="isDesktop"
|
|
|
|
type="selection"
|
|
|
|
reserve-selection
|
|
|
|
width="44"
|
|
|
|
align="center"/>
|
2019-03-22 21:27:31 +00:00
|
|
|
<el-table-column :min-width="width" :label="$t('users.id')" prop="id" />
|
|
|
|
<el-table-column :label="$t('users.name')" prop="nickname">
|
2019-03-22 21:18:57 +00:00
|
|
|
<template slot-scope="scope">
|
2020-06-02 19:52:04 +00:00
|
|
|
{{ scope.row.nickname }}
|
2019-03-22 21:18:57 +00:00
|
|
|
<el-tag v-if="isDesktop" type="info" size="mini">
|
2019-03-22 21:27:31 +00:00
|
|
|
<span>{{ scope.row.local ? $t('users.local') : $t('users.external') }}</span>
|
2019-03-22 21:18:57 +00:00
|
|
|
</el-tag>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2019-03-22 21:27:31 +00:00
|
|
|
<el-table-column :min-width="width" :label="$t('users.status')">
|
2019-02-26 19:50:25 +00:00
|
|
|
<template slot-scope="scope">
|
2019-03-06 19:52:18 +00:00
|
|
|
<el-tag :type="scope.row.deactivated ? 'danger' : 'success'">
|
2019-03-22 21:27:31 +00:00
|
|
|
<span v-if="isDesktop">{{ scope.row.deactivated ? $t('users.deactivated') : $t('users.active') }}</span>
|
2019-03-06 19:52:18 +00:00
|
|
|
<i v-else :class="activationIcon(scope.row.deactivated)"/>
|
|
|
|
</el-tag>
|
2019-03-22 21:18:57 +00:00
|
|
|
<el-tag v-if="scope.row.roles.admin">
|
2019-03-22 21:27:31 +00:00
|
|
|
<span>{{ isDesktop ? $t('users.admin') : getFirstLetter($t('users.admin')) }}</span>
|
2019-03-22 21:18:57 +00:00
|
|
|
</el-tag>
|
|
|
|
<el-tag v-if="scope.row.roles.moderator">
|
2019-03-22 21:27:31 +00:00
|
|
|
<span>{{ isDesktop ? $t('users.moderator') : getFirstLetter($t('users.moderator')) }}</span>
|
2019-03-22 21:18:57 +00:00
|
|
|
</el-tag>
|
2019-11-19 11:15:15 +00:00
|
|
|
<el-tooltip :content="$t('users.unconfirmedEmail')" effect="dark">
|
|
|
|
<el-tag v-if="scope.row.confirmation_pending" type="info">
|
|
|
|
{{ isDesktop ? $t('users.unconfirmed') : getFirstLetter($t('users.unconfirmed')) }}
|
|
|
|
</el-tag>
|
|
|
|
</el-tooltip>
|
2020-08-05 22:53:23 +00:00
|
|
|
<el-tooltip :content="$t('users.unapprovedAccount')" effect="dark">
|
|
|
|
<el-tag v-if="scope.row.approval_pending" type="info">
|
|
|
|
{{ isDesktop ? $t('users.unapproved') : getFirstLetter($t('users.unapproved')) }}
|
|
|
|
</el-tag>
|
|
|
|
</el-tooltip>
|
|
|
|
<div v-if="pendingView && isDesktop" class="reason-text">
|
|
|
|
"{{ scope.row.registration_reason | truncate(100, '...') }}"
|
|
|
|
</div>
|
2019-02-26 19:50:25 +00:00
|
|
|
</template>
|
2020-08-05 22:53:23 +00:00
|
|
|
|
2019-02-26 19:50:25 +00:00
|
|
|
</el-table-column>
|
2019-03-22 21:27:31 +00:00
|
|
|
<el-table-column :label="$t('users.actions')" fixed="right">
|
2019-02-26 19:50:25 +00:00
|
|
|
<template slot-scope="scope">
|
2020-01-28 16:38:56 +00:00
|
|
|
<moderation-dropdown
|
2020-06-06 19:16:25 +00:00
|
|
|
v-if="propertyExists(scope.row, 'nickname')"
|
2020-01-28 16:38:56 +00:00
|
|
|
:user="scope.row"
|
|
|
|
:page="'users'"
|
|
|
|
@open-reset-token-dialog="openResetPasswordDialog"/>
|
2020-06-06 19:16:25 +00:00
|
|
|
<el-button v-else type="text" disabled>
|
|
|
|
{{ $t('users.moderation') }}
|
|
|
|
<i v-if="isDesktop" class="el-icon-arrow-down el-icon--right"/>
|
|
|
|
</el-button>
|
2019-02-24 22:31:05 +00:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
2020-05-20 19:40:25 +00:00
|
|
|
<reset-password-dialog
|
|
|
|
:reset-password-dialog-open="resetPasswordDialogOpen"
|
|
|
|
@close-reset-token-dialog="closeResetPasswordDialog"/>
|
2019-02-27 22:13:20 +00:00
|
|
|
<div v-if="!loading" class="pagination">
|
|
|
|
<el-pagination
|
|
|
|
:total="usersCount"
|
2019-03-03 20:46:14 +00:00
|
|
|
:current-page="currentPage"
|
|
|
|
:page-size="pageSize"
|
2020-06-19 22:25:59 +00:00
|
|
|
hide-on-single-page
|
2019-02-27 22:13:20 +00:00
|
|
|
layout="prev, pager, next"
|
2019-03-01 17:32:03 +00:00
|
|
|
@current-change="handlePageChange"
|
|
|
|
/>
|
2019-02-27 22:13:20 +00:00
|
|
|
</div>
|
2019-02-22 18:06:48 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-01 17:32:03 +00:00
|
|
|
import debounce from 'lodash.debounce'
|
2019-05-05 21:51:52 +00:00
|
|
|
import numeral from 'numeral'
|
2019-03-29 14:25:53 +00:00
|
|
|
import UsersFilter from './components/UsersFilter'
|
2019-06-11 15:13:48 +00:00
|
|
|
import MultipleUsersMenu from './components/MultipleUsersMenu'
|
|
|
|
import NewAccountDialog from './components/NewAccountDialog'
|
2020-01-27 12:05:51 +00:00
|
|
|
import ModerationDropdown from './components/ModerationDropdown'
|
2020-04-17 22:27:00 +00:00
|
|
|
import RebootButton from '@/components/RebootButton'
|
2020-05-20 19:40:25 +00:00
|
|
|
import ResetPasswordDialog from './components/ResetPasswordDialog'
|
2019-02-23 21:40:26 +00:00
|
|
|
|
2019-02-22 18:06:48 +00:00
|
|
|
export default {
|
|
|
|
name: 'Users',
|
2019-03-29 14:25:53 +00:00
|
|
|
components: {
|
2020-01-27 12:05:51 +00:00
|
|
|
NewAccountDialog,
|
|
|
|
ModerationDropdown,
|
2019-06-11 15:13:48 +00:00
|
|
|
MultipleUsersMenu,
|
2020-04-17 22:27:00 +00:00
|
|
|
RebootButton,
|
2020-05-20 19:40:25 +00:00
|
|
|
ResetPasswordDialog,
|
2020-01-27 12:05:51 +00:00
|
|
|
UsersFilter
|
2019-03-29 14:25:53 +00:00
|
|
|
},
|
2020-08-05 22:53:23 +00:00
|
|
|
filters: {
|
|
|
|
truncate: function(text, length, suffix) {
|
|
|
|
if (text.length > length) {
|
|
|
|
return text.substring(0, length) + suffix
|
|
|
|
} else {
|
|
|
|
return text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-05-21 19:24:48 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2019-06-11 15:13:48 +00:00
|
|
|
search: '',
|
|
|
|
selectedUsers: [],
|
2019-09-23 19:00:28 +00:00
|
|
|
createAccountDialogOpen: false,
|
|
|
|
resetPasswordDialogOpen: false
|
2019-05-21 19:24:48 +00:00
|
|
|
}
|
|
|
|
},
|
2019-02-24 22:31:05 +00:00
|
|
|
computed: {
|
|
|
|
loading() {
|
|
|
|
return this.$store.state.users.loading
|
|
|
|
},
|
2019-05-05 21:51:52 +00:00
|
|
|
normalizedUsersCount() {
|
|
|
|
return numeral(this.$store.state.users.totalUsersCount).format('0a')
|
|
|
|
},
|
2019-02-27 22:13:20 +00:00
|
|
|
pageSize() {
|
|
|
|
return this.$store.state.users.pageSize
|
2019-03-03 20:46:14 +00:00
|
|
|
},
|
|
|
|
currentPage() {
|
|
|
|
return this.$store.state.users.currentPage
|
2019-03-06 19:44:37 +00:00
|
|
|
},
|
2019-03-06 19:52:18 +00:00
|
|
|
isDesktop() {
|
|
|
|
return this.$store.state.app.device === 'desktop'
|
|
|
|
},
|
|
|
|
isMobile() {
|
|
|
|
return this.$store.state.app.device === 'mobile'
|
|
|
|
},
|
2020-05-18 17:07:26 +00:00
|
|
|
users() {
|
|
|
|
return this.$store.state.users.fetchedUsers
|
|
|
|
},
|
|
|
|
usersCount() {
|
|
|
|
return this.$store.state.users.totalUsersCount
|
|
|
|
},
|
2020-08-05 22:53:23 +00:00
|
|
|
pendingView() {
|
|
|
|
return this.$store.state.users.filters['needApproval']
|
|
|
|
},
|
2019-03-06 19:52:18 +00:00
|
|
|
width() {
|
2019-03-22 21:18:57 +00:00
|
|
|
return this.isMobile ? 55 : false
|
2019-02-22 18:06:48 +00:00
|
|
|
}
|
2019-02-23 21:40:26 +00:00
|
|
|
},
|
2019-03-01 17:32:03 +00:00
|
|
|
created() {
|
|
|
|
this.handleDebounceSearchInput = debounce((query) => {
|
2019-03-03 21:25:25 +00:00
|
|
|
this.$store.dispatch('SearchUsers', { query, page: 1 })
|
2019-03-01 17:32:03 +00:00
|
|
|
}, 500)
|
|
|
|
},
|
2019-02-23 21:40:26 +00:00
|
|
|
mounted: function() {
|
2020-04-17 22:27:00 +00:00
|
|
|
this.$store.dispatch('NeedReboot')
|
2019-03-03 21:25:25 +00:00
|
|
|
this.$store.dispatch('FetchUsers', { page: 1 })
|
2019-02-24 22:31:05 +00:00
|
|
|
},
|
2020-05-18 19:50:32 +00:00
|
|
|
destroyed() {
|
|
|
|
this.$store.dispatch('ClearUsersState')
|
|
|
|
},
|
2019-02-24 22:31:05 +00:00
|
|
|
methods: {
|
2019-05-16 15:16:53 +00:00
|
|
|
activationIcon(status) {
|
|
|
|
return status ? 'el-icon-error' : 'el-icon-success'
|
|
|
|
},
|
2019-05-16 17:59:25 +00:00
|
|
|
clearSelection() {
|
|
|
|
this.$refs.usersTable.clearSelection()
|
|
|
|
},
|
2020-01-28 16:38:56 +00:00
|
|
|
closeResetPasswordDialog() {
|
|
|
|
this.resetPasswordDialogOpen = false
|
|
|
|
this.$store.dispatch('RemovePasswordToken')
|
|
|
|
},
|
2019-09-23 19:00:28 +00:00
|
|
|
async createNewAccount(accountData) {
|
2019-10-24 21:15:40 +00:00
|
|
|
await this.$store.dispatch('CreateNewAccount', accountData)
|
|
|
|
this.createAccountDialogOpen = false
|
2019-06-11 15:13:48 +00:00
|
|
|
},
|
2019-05-16 15:16:53 +00:00
|
|
|
getFirstLetter(str) {
|
|
|
|
return str.charAt(0).toUpperCase()
|
|
|
|
},
|
2019-02-27 22:13:20 +00:00
|
|
|
handlePageChange(page) {
|
2019-03-03 20:01:00 +00:00
|
|
|
const searchQuery = this.$store.state.users.searchQuery
|
|
|
|
if (searchQuery === '') {
|
2019-03-03 21:25:25 +00:00
|
|
|
this.$store.dispatch('FetchUsers', { page })
|
2019-03-03 20:01:00 +00:00
|
|
|
} else {
|
2019-03-03 21:25:25 +00:00
|
|
|
this.$store.dispatch('SearchUsers', { query: searchQuery, page })
|
2019-03-03 20:01:00 +00:00
|
|
|
}
|
|
|
|
},
|
2020-06-02 19:52:04 +00:00
|
|
|
handleRowClick(row) {
|
|
|
|
if (row.id) {
|
|
|
|
this.$router.push({ name: 'UsersShow', params: { id: row.id }})
|
|
|
|
}
|
|
|
|
},
|
2019-05-03 23:12:48 +00:00
|
|
|
handleSelectionChange(value) {
|
|
|
|
this.$data.selectedUsers = value
|
|
|
|
},
|
2020-01-28 16:38:56 +00:00
|
|
|
openResetPasswordDialog() {
|
|
|
|
this.resetPasswordDialogOpen = true
|
2019-09-23 19:00:28 +00:00
|
|
|
},
|
2020-06-06 19:16:25 +00:00
|
|
|
propertyExists(account, property) {
|
|
|
|
return account[property]
|
|
|
|
},
|
2019-05-16 15:16:53 +00:00
|
|
|
showDeactivatedButton(id) {
|
|
|
|
return this.$store.state.user.id !== id
|
2019-02-24 22:31:05 +00:00
|
|
|
}
|
2019-02-22 18:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2019-09-23 19:00:28 +00:00
|
|
|
<style rel='stylesheet/scss' lang='scss'>
|
2019-06-11 15:13:48 +00:00
|
|
|
.actions-button {
|
|
|
|
text-align: left;
|
|
|
|
width: 350px;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
|
|
|
.actions-container {
|
|
|
|
display: flex;
|
|
|
|
height: 36px;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin: 0 15px 10px 15px;
|
2020-04-17 22:27:00 +00:00
|
|
|
.el-dropdown {
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
2019-06-11 15:13:48 +00:00
|
|
|
}
|
2019-03-29 14:25:53 +00:00
|
|
|
.active-tag {
|
|
|
|
color: #409EFF;
|
|
|
|
font-weight: 700;
|
|
|
|
.el-icon-check {
|
|
|
|
color: #409EFF;
|
|
|
|
float: right;
|
|
|
|
margin: 7px 0 0 15px;
|
|
|
|
}
|
|
|
|
}
|
2019-05-06 15:49:03 +00:00
|
|
|
.el-dropdown-link:hover {
|
2019-06-11 15:13:48 +00:00
|
|
|
cursor: pointer;
|
|
|
|
color: #409EFF;
|
|
|
|
}
|
2020-01-24 19:43:22 +00:00
|
|
|
.create-account > .el-icon-plus {
|
2019-06-11 15:13:48 +00:00
|
|
|
margin-right: 5px;
|
|
|
|
}
|
2019-09-23 19:00:28 +00:00
|
|
|
.password-reset-token {
|
|
|
|
margin: 0 0 14px 0;
|
|
|
|
}
|
|
|
|
.password-reset-token-dialog {
|
|
|
|
width: 50%
|
|
|
|
}
|
|
|
|
.reset-password-link {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
2020-05-20 20:10:32 +00:00
|
|
|
.users-header-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
2019-02-24 22:31:05 +00:00
|
|
|
.users-container {
|
|
|
|
h1 {
|
2020-03-18 18:09:25 +00:00
|
|
|
margin: 10px 0 0 15px;
|
2020-04-17 22:27:00 +00:00
|
|
|
height: 40px;
|
2019-02-24 22:31:05 +00:00
|
|
|
}
|
2020-06-02 19:52:04 +00:00
|
|
|
.el-table__row:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2019-02-27 22:13:20 +00:00
|
|
|
.pagination {
|
2019-03-03 20:01:00 +00:00
|
|
|
margin: 25px 0;
|
2019-02-27 22:13:20 +00:00
|
|
|
text-align: center;
|
|
|
|
}
|
2020-04-17 22:27:00 +00:00
|
|
|
.reboot-button {
|
|
|
|
margin: 0 15px 0 0;
|
|
|
|
padding: 10px;
|
|
|
|
width: 145px;
|
|
|
|
}
|
2019-03-01 17:32:03 +00:00
|
|
|
.search {
|
2019-03-29 14:25:53 +00:00
|
|
|
width: 350px;
|
2019-03-01 17:32:03 +00:00
|
|
|
float: right;
|
2020-04-17 22:27:00 +00:00
|
|
|
margin-left: 10px;
|
2019-03-01 17:32:03 +00:00
|
|
|
}
|
2019-06-11 15:13:48 +00:00
|
|
|
.filter-container {
|
2019-03-06 19:44:37 +00:00
|
|
|
display: flex;
|
2019-03-29 14:25:53 +00:00
|
|
|
height: 36px;
|
2019-03-06 19:44:37 +00:00
|
|
|
justify-content: space-between;
|
2019-03-29 14:25:53 +00:00
|
|
|
align-items: center;
|
2020-04-17 22:27:00 +00:00
|
|
|
margin: 15px
|
2019-03-06 19:44:37 +00:00
|
|
|
}
|
2019-05-05 21:51:52 +00:00
|
|
|
.user-count {
|
|
|
|
color: gray;
|
|
|
|
font-size: 28px;
|
2019-03-06 19:44:37 +00:00
|
|
|
}
|
2020-08-05 22:53:23 +00:00
|
|
|
.reason-text {
|
|
|
|
word-break: normal;
|
|
|
|
}
|
2019-03-01 17:32:03 +00:00
|
|
|
}
|
2020-02-26 23:18:47 +00:00
|
|
|
|
|
|
|
@media only screen and (max-width:480px) {
|
2019-09-23 19:00:28 +00:00
|
|
|
.password-reset-token-dialog {
|
|
|
|
width: 85%
|
|
|
|
}
|
2019-03-06 19:52:18 +00:00
|
|
|
.users-container {
|
|
|
|
h1 {
|
2020-04-17 22:27:00 +00:00
|
|
|
margin: 0;
|
2019-03-06 19:52:18 +00:00
|
|
|
}
|
2020-01-24 19:43:22 +00:00
|
|
|
.actions-button {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2019-06-11 15:13:48 +00:00
|
|
|
.actions-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
margin: 0 10px 7px 10px
|
|
|
|
}
|
2019-03-22 21:18:57 +00:00
|
|
|
.el-icon-arrow-down {
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
2019-03-06 19:52:18 +00:00
|
|
|
.search {
|
2019-03-29 14:25:53 +00:00
|
|
|
width: 100%;
|
2020-04-17 22:27:00 +00:00
|
|
|
margin-left: 0;
|
2019-03-06 19:52:18 +00:00
|
|
|
}
|
2019-06-11 15:13:48 +00:00
|
|
|
.filter-container {
|
2019-03-06 19:52:18 +00:00
|
|
|
display: flex;
|
2019-03-29 14:25:53 +00:00
|
|
|
height: 82px;
|
|
|
|
flex-direction: column;
|
2019-06-11 15:13:48 +00:00
|
|
|
margin: 0 10px
|
2019-03-06 19:52:18 +00:00
|
|
|
}
|
2020-07-28 18:32:40 +00:00
|
|
|
.el-table__row {
|
|
|
|
.el-tag {
|
|
|
|
width: 30px;
|
|
|
|
display: inline-block;
|
|
|
|
margin-bottom: 4px;
|
|
|
|
font-weight: bold;
|
|
|
|
&.el-tag--success {
|
|
|
|
padding-left: 8px;
|
|
|
|
}
|
|
|
|
&.el-tag--danger {
|
|
|
|
padding-left: 8px;
|
|
|
|
}
|
2019-03-22 21:18:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 22:27:00 +00:00
|
|
|
.reboot-button {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
.users-header-container {
|
|
|
|
margin: 7px 10px 12px 10px;
|
|
|
|
}
|
|
|
|
.user-count {
|
|
|
|
color: gray;
|
|
|
|
font-size: 22px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width:801px) and (min-width: 481px) {
|
|
|
|
.actions-button {
|
|
|
|
width: 49%;
|
|
|
|
}
|
|
|
|
.search {
|
|
|
|
width: 49%;
|
2019-03-06 19:52:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-24 22:31:05 +00:00
|
|
|
</style>
|