mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
918 lines
28 KiB
918 lines
28 KiB
4 years ago
|
<template>
|
||
|
<div class="h-100">
|
||
3 years ago
|
<v-toolbar flat height="38" class="mt-5">
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="query"
|
||
4 years ago
|
style="max-width: 300px"
|
||
|
dense
|
||
|
flat
|
||
3 years ago
|
solo
|
||
4 years ago
|
class="search-field caption"
|
||
3 years ago
|
hide-details
|
||
|
placeholder="Filter by email"
|
||
4 years ago
|
@keypress.enter="loadUsers"
|
||
3 years ago
|
>
|
||
|
<template #prepend-inner>
|
||
3 years ago
|
<v-icon small class="mt-1">
|
||
|
search
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-text-field>
|
||
3 years ago
|
<v-spacer />
|
||
|
|
||
3 years ago
|
<!-- tooltip="Reload roles" -->
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="['roles', 'reload']"
|
||
3 years ago
|
outlined
|
||
3 years ago
|
:tooltip="$t('activity.reloadRoles')"
|
||
3 years ago
|
color="primary"
|
||
|
small
|
||
|
:disabled="loading"
|
||
3 years ago
|
@click="clickReload"
|
||
3 years ago
|
@click.prevent
|
||
|
>
|
||
3 years ago
|
<v-icon small left>
|
||
|
refresh
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
3 years ago
|
{{ $t("general.reload") }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<!-- tooltip="Add new role" -->
|
||
4 years ago
|
<x-btn
|
||
|
v-if="_isUIAllowed('newUser')"
|
||
3 years ago
|
v-ge="['roles', 'add new']"
|
||
3 years ago
|
class="nc-new-user"
|
||
3 years ago
|
outlined
|
||
3 years ago
|
:tooltip="$t('tooltip.addRole')"
|
||
4 years ago
|
color="primary"
|
||
|
small
|
||
|
:disabled="loading"
|
||
|
@click="addUser"
|
||
3 years ago
|
>
|
||
3 years ago
|
<v-icon small left>
|
||
|
mdi-plus
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- New User -->
|
||
3 years ago
|
{{ $t("activity.newUser") }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
|
||
3 years ago
|
<v-card style="height: calc(100% - 38px)" class="elevation-0">
|
||
4 years ago
|
<v-container style="height: 100%" fluid>
|
||
3 years ago
|
<v-row style="height: 100%">
|
||
4 years ago
|
<v-col cols="12" class="h-100">
|
||
|
<v-card class="h-100 elevation-0">
|
||
3 years ago
|
<v-row style="height: 100%">
|
||
|
<v-col
|
||
|
offset="2"
|
||
|
:cols="8"
|
||
|
class="h-100"
|
||
|
style="overflow-y: auto"
|
||
|
>
|
||
3 years ago
|
<v-data-table
|
||
|
v-if="users"
|
||
|
dense
|
||
3 years ago
|
:headers="[{}, {}, {}, {}]"
|
||
3 years ago
|
hide-default-header
|
||
|
:hide-default-footer="count < limit"
|
||
|
:options.sync="options"
|
||
|
:items="users"
|
||
|
:items-per-page.sync="limit"
|
||
|
:server-items-length="count"
|
||
|
>
|
||
|
<template #header>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr class="text-left">
|
||
|
<!-- <th>#</th>-->
|
||
|
<th class="font-weight-regular caption">
|
||
3 years ago
|
<v-icon small>
|
||
|
mdi-email-outline
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- Email -->
|
||
3 years ago
|
{{ $t("labels.email") }}
|
||
3 years ago
|
</th>
|
||
|
<th class="font-weight-regular caption">
|
||
3 years ago
|
<v-icon small>
|
||
|
mdi-drama-masks
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- Roles -->
|
||
3 years ago
|
{{ $t("objects.roles") }}
|
||
3 years ago
|
</th>
|
||
|
<th class="font-weight-regular caption">
|
||
|
<!-- <v-icon small class="mt-n1">mdi-cursor-default-outline</v-icon>-->
|
||
3 years ago
|
<!-- Actions -->
|
||
3 years ago
|
{{ $t("labels.actions") }}
|
||
3 years ago
|
</th>
|
||
|
</tr>
|
||
4 years ago
|
</thead>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<template #item="{ item }">
|
||
4 years ago
|
<tr @click="selectedUser = item">
|
||
|
<td>{{ item.email }}</td>
|
||
|
<td>
|
||
|
<!-- {{ item.roles }}-->
|
||
|
|
||
3 years ago
|
<v-chip
|
||
3 years ago
|
v-if="item.roles"
|
||
3 years ago
|
class="mr-1"
|
||
3 years ago
|
:color="rolesColors[getRole(item.roles)]"
|
||
3 years ago
|
>
|
||
3 years ago
|
{{ getRole(item.roles) }}
|
||
4 years ago
|
</v-chip>
|
||
|
</td>
|
||
|
<td>
|
||
3 years ago
|
<!-- tooltip="Edit User" -->
|
||
3 years ago
|
<x-icon
|
||
3 years ago
|
v-if="item.project_id"
|
||
3 years ago
|
:tooltip="$t('activity.editUser')"
|
||
3 years ago
|
icon-class=""
|
||
|
color="primary"
|
||
|
small
|
||
3 years ago
|
@click.prevent.stop="
|
||
|
invite_token = null;
|
||
|
selectedUser = item;
|
||
|
userEditDialog = true;
|
||
|
"
|
||
3 years ago
|
>
|
||
|
mdi-pencil-outline
|
||
4 years ago
|
</x-icon>
|
||
3 years ago
|
<span v-if="!item.project_id">
|
||
|
<x-icon
|
||
|
tooltip="Add user to project"
|
||
|
color="primary"
|
||
|
small
|
||
3 years ago
|
@click="inviteUser(item)"
|
||
3 years ago
|
>
|
||
|
mdi-plus
|
||
|
</x-icon>
|
||
|
</span>
|
||
4 years ago
|
<x-icon
|
||
|
v-else
|
||
3 years ago
|
:tooltip="$t('activity.deleteUser')"
|
||
3 years ago
|
class="ml-2"
|
||
|
color="error"
|
||
|
small
|
||
3 years ago
|
@click.prevent.stop="clickDeleteUser(item.id)"
|
||
3 years ago
|
>
|
||
|
mdi-delete-outline
|
||
4 years ago
|
</x-icon>
|
||
3 years ago
|
|
||
3 years ago
|
<!-- tooltip="Resend invite email" -->
|
||
3 years ago
|
<x-icon
|
||
|
v-if="item.invite_token"
|
||
3 years ago
|
:tooltip="$t('activity.resendInvite')"
|
||
3 years ago
|
icon-class="mt-n1"
|
||
|
color="primary"
|
||
|
small
|
||
3 years ago
|
@click.prevent.stop="resendInvite(item.id)"
|
||
3 years ago
|
>
|
||
|
mdi-email-send-outline
|
||
4 years ago
|
</x-icon>
|
||
|
|
||
3 years ago
|
<!-- tooltip="Copy invite url" -->
|
||
3 years ago
|
<x-icon
|
||
|
v-if="item.invite_token"
|
||
3 years ago
|
:tooltip="$t('activity.copyInviteURL')"
|
||
3 years ago
|
icon-class=""
|
||
|
color="primary"
|
||
|
small
|
||
3 years ago
|
@click.prevent.stop="
|
||
|
clipboard(getInviteUrl(item.invite_token));
|
||
|
$toast
|
||
|
.success('Invite url copied to clipboard')
|
||
|
.goAway(3000);
|
||
|
"
|
||
3 years ago
|
>
|
||
|
mdi-content-copy
|
||
4 years ago
|
</x-icon>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
|
</v-data-table>
|
||
3 years ago
|
<!-- tooltip="Add new user" -->
|
||
3 years ago
|
<!-- <div class="mt-10 text-center">
|
||
4 years ago
|
<x-btn
|
||
|
v-if="_isUIAllowed('newUser')"
|
||
3 years ago
|
v-ge="['roles','add new']"
|
||
|
outlined
|
||
3 years ago
|
:tooltip="$t('msg.info.addUser')"
|
||
4 years ago
|
color="primary"
|
||
|
small
|
||
|
:disabled="loading"
|
||
|
@click="addUser"
|
||
3 years ago
|
>
|
||
|
<v-icon small left>
|
||
|
mdi-plus
|
||
|
</v-icon>
|
||
3 years ago
|
<!– New User –>
|
||
3 years ago
|
{{ $t('activity.newUser') }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
</div>-->
|
||
3 years ago
|
|
||
|
<feedback-form class="mx-auto mt-6" />
|
||
4 years ago
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
|
||
3 years ago
|
<table
|
||
|
v-if="false"
|
||
|
class="mx-auto users-table"
|
||
|
style="min-width: 700px"
|
||
|
>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
|
<th />
|
||
|
<th>Email</th>
|
||
|
<th>Roles</th>
|
||
|
<th />
|
||
|
</tr>
|
||
4 years ago
|
</thead>
|
||
|
<tbody>
|
||
3 years ago
|
<tr v-for="user in users" :key="user.email">
|
||
|
<td>
|
||
3 years ago
|
<v-icon x-large>
|
||
|
mdi-account-outline
|
||
|
</v-icon>
|
||
3 years ago
|
</td>
|
||
|
<td class="px-1 py-1" align="top">
|
||
|
<v-text-field
|
||
|
solo
|
||
|
class="elevation-0"
|
||
|
disabled
|
||
|
:value="user.email"
|
||
|
hide-details
|
||
|
dense
|
||
|
/>
|
||
|
</td>
|
||
|
<td class="px-1 py-1">
|
||
|
<set-list-checkbox-cell v-model="user.roles" :values="roles" />
|
||
|
</td>
|
||
|
<td align="middle">
|
||
3 years ago
|
<v-icon large>
|
||
|
mdi-close
|
||
|
</v-icon>
|
||
|
<v-icon large>
|
||
|
mdi-save
|
||
|
</v-icon>
|
||
3 years ago
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
3 years ago
|
<v-icon x-large>
|
||
|
mdi-account-outline
|
||
|
</v-icon>
|
||
3 years ago
|
</td>
|
||
|
<td class="px-1 py-1" align="top">
|
||
3 years ago
|
<v-text-field solo class="elevation-0" hide-details dense />
|
||
3 years ago
|
</td>
|
||
|
<td class="px-1 py-1">
|
||
|
<set-list-checkbox-cell :values="roles" />
|
||
|
</td>
|
||
|
<td align="middle">
|
||
3 years ago
|
<v-icon large>
|
||
|
mdi-account-plus
|
||
|
</v-icon>
|
||
3 years ago
|
</td>
|
||
|
</tr>
|
||
4 years ago
|
</tbody>
|
||
|
</table>
|
||
|
</v-container>
|
||
|
</v-card>
|
||
|
|
||
|
<dlg-label-submit-cancel
|
||
|
type="primary"
|
||
|
:actions-mtd="confirmDelete"
|
||
3 years ago
|
:heading="dialogMessage"
|
||
4 years ago
|
:dialog-show="showConfirmDlg"
|
||
3 years ago
|
/>
|
||
4 years ago
|
|
||
3 years ago
|
<!-- todo: move to a separate component-->
|
||
3 years ago
|
<v-dialog
|
||
|
v-model="userEditDialog"
|
||
|
:width="invite_token ? 700 : 700"
|
||
|
@close="invite_token = null"
|
||
|
>
|
||
3 years ago
|
<v-card v-if="selectedUser" style="min-height: 100%" class="elevation-0">
|
||
3 years ago
|
<v-card-title>
|
||
3 years ago
|
{{ $t("activity.share") }} :
|
||
|
{{ $store.getters["project/GtrProjectName"] }}
|
||
3 years ago
|
|
||
|
<div class="nc-header-border" />
|
||
|
</v-card-title>
|
||
|
|
||
|
<v-card-text>
|
||
|
<div>
|
||
3 years ago
|
<v-icon small>
|
||
|
mdi-account-outline
|
||
|
</v-icon>
|
||
|
<template v-if="invite_token">
|
||
|
Copy Invite Token
|
||
|
</template>
|
||
|
<template v-else-if="selectedUser.id">
|
||
|
Edit User
|
||
|
</template>
|
||
3 years ago
|
<template v-else>
|
||
3 years ago
|
<!-- Invite Team -->
|
||
3 years ago
|
{{ $t("activity.inviteTeam") }}
|
||
3 years ago
|
</template>
|
||
|
</div>
|
||
|
<div class="pa-4 nc-invite-container">
|
||
3 years ago
|
<div v-if="invite_token" class="mt-6 align-center">
|
||
3 years ago
|
<v-alert
|
||
|
v-ripple
|
||
|
type="success"
|
||
|
outlined
|
||
|
class="pointer"
|
||
3 years ago
|
@click="
|
||
|
clipboard(inviteUrl);
|
||
|
$toast.success('Copied invite url to clipboard').goAway(3000);
|
||
|
"
|
||
3 years ago
|
>
|
||
|
<template #append>
|
||
3 years ago
|
<v-icon color="green" class="ml-2">
|
||
|
mdi-content-copy
|
||
|
</v-icon>
|
||
3 years ago
|
</template>
|
||
|
<div class="ellipsis d-100">
|
||
|
{{ inviteUrl }}
|
||
|
</div>
|
||
|
</v-alert>
|
||
|
|
||
|
<p class="caption grey--text mt-3">
|
||
3 years ago
|
<!-- Looks like you have not configured mailer yet! <br> Please copy above invite link and send it to -->
|
||
|
<pre>{{ $t('msg.info.userInviteNoSMTP') }} {{ invite_token && (invite_token.email || invite_token.emails && invite_token.emails.join(', ')) }}.</pre>
|
||
3 years ago
|
</p>
|
||
|
|
||
|
<div class="text-right">
|
||
3 years ago
|
<!--tooltip="Invite more users"-->
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
:tooltip="$t('tooltip.inviteMore')"
|
||
3 years ago
|
small
|
||
|
outlined
|
||
|
btn.class="grey--text"
|
||
3 years ago
|
@click="clickInviteMore"
|
||
3 years ago
|
>
|
||
3 years ago
|
<v-icon small color="grey" class="mr-1">
|
||
|
mdi-account-multiple-plus-outline
|
||
3 years ago
|
</v-icon>
|
||
3 years ago
|
<!--Invite more-->
|
||
3 years ago
|
{{ $t("activity.inviteMore") }}
|
||
3 years ago
|
</x-btn>
|
||
|
</div>
|
||
|
|
||
|
<!-- todo: show error message if failed-->
|
||
4 years ago
|
</div>
|
||
3 years ago
|
<template v-else>
|
||
|
<v-form ref="form" v-model="valid" @submit.prevent="saveUser">
|
||
|
<v-row class="my-0">
|
||
|
<v-col cols="8" class="py-0">
|
||
3 years ago
|
<!--hint="You can add multiple comma(,) separated emails"-->
|
||
3 years ago
|
<v-text-field
|
||
|
ref="email"
|
||
|
v-model="selectedUser.email"
|
||
|
:disabled="!!selectedUser.id"
|
||
|
dense
|
||
|
validate-on-blur
|
||
|
outlined
|
||
3 years ago
|
:rules="emailRules"
|
||
3 years ago
|
class="caption"
|
||
3 years ago
|
:hint="$t('msg.info.addMultipleUsers')"
|
||
3 years ago
|
label="Email"
|
||
3 years ago
|
@input="edited = true"
|
||
3 years ago
|
>
|
||
|
<template #label>
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Email -->
|
||
3 years ago
|
{{ $t("labels.email") }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
</template>
|
||
|
</v-text-field>
|
||
|
</v-col>
|
||
|
<v-col cols="4" class="py-0">
|
||
3 years ago
|
<!--label="Select User Role"-->
|
||
3 years ago
|
<v-combobox
|
||
|
v-model="selectedRoles"
|
||
|
outlined
|
||
3 years ago
|
:rules="roleRules"
|
||
3 years ago
|
class="role-select caption"
|
||
|
hide-details="auto"
|
||
|
:items="roles"
|
||
3 years ago
|
:label="$t('labels.selectUserRole')"
|
||
3 years ago
|
dense
|
||
|
deletable-chips
|
||
|
@change="edited = true"
|
||
|
>
|
||
3 years ago
|
<template #selection="{ item }">
|
||
3 years ago
|
<v-chip small :color="rolesColors[item]">
|
||
|
{{ item }}
|
||
|
</v-chip>
|
||
|
</template>
|
||
3 years ago
|
<template #item="{ item }">
|
||
3 years ago
|
<div>
|
||
|
<div>{{ item }}</div>
|
||
|
<div class="mb-2 caption grey--text">
|
||
|
{{ roleDescriptions[item] }}
|
||
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
3 years ago
|
</v-combobox>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-form>
|
||
|
<div class="text-center mt-0">
|
||
|
<x-btn
|
||
3 years ago
|
v-ge="['rows', 'save']"
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
3 years ago
|
color="primary"
|
||
|
btn.class="nc-invite-or-save-btn"
|
||
|
@click="saveUser"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small left>
|
||
3 years ago
|
{{ selectedUser.id ? "save" : "mdi-send" }}
|
||
3 years ago
|
</v-icon>
|
||
3 years ago
|
{{
|
||
|
selectedUser.id ? $t("general.save") : $t("activity.invite")
|
||
|
}}
|
||
3 years ago
|
</x-btn>
|
||
|
</div>
|
||
|
</template>
|
||
|
<!-- </v-card-actions>-->
|
||
|
</div>
|
||
|
</v-card-text>
|
||
3 years ago
|
<v-card-text>
|
||
|
<share-base />
|
||
|
</v-card-text>
|
||
4 years ago
|
</v-card>
|
||
|
</v-dialog>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import FeedbackForm from '~/components/FeedbackForm'
|
||
|
import SetListCheckboxCell from '~/components/project/spreadsheet/components/editableCell/SetListCheckboxCell'
|
||
|
import { enumColor } from '@/components/project/spreadsheet/helpers/colors'
|
||
|
import DlgLabelSubmitCancel from '~/components/utils/DlgLabelSubmitCancel'
|
||
|
import { isEmail } from '@/helpers'
|
||
|
import ShareBase from '~/components/base/ShareBase'
|
||
|
import XBtn from '~/components/global/XBtn'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'UserManagement',
|
||
3 years ago
|
components: {
|
||
|
XBtn,
|
||
|
ShareBase,
|
||
|
FeedbackForm,
|
||
|
DlgLabelSubmitCancel,
|
||
3 years ago
|
SetListCheckboxCell
|
||
3 years ago
|
},
|
||
4 years ago
|
data: () => ({
|
||
3 years ago
|
validate: false,
|
||
4 years ago
|
deleteItem: null,
|
||
|
invite_token: null,
|
||
|
userEditDialog: false,
|
||
|
limit: 10,
|
||
|
showConfirmDlg: false,
|
||
|
users: null,
|
||
|
count: 0,
|
||
|
options: {},
|
||
|
loading: false,
|
||
|
selectedUser: null,
|
||
|
roles: [],
|
||
3 years ago
|
query: '',
|
||
4 years ago
|
deleteId: null,
|
||
|
edited: false,
|
||
|
valid: null,
|
||
|
emailRules: [
|
||
3 years ago
|
v => !!v || 'E-mail is required',
|
||
3 years ago
|
(v) => {
|
||
3 years ago
|
const invalidEmails = (v || '')
|
||
3 years ago
|
.split(/\s*,\s*/)
|
||
3 years ago
|
.filter(e => !isEmail(e))
|
||
3 years ago
|
return (
|
||
|
!invalidEmails.length ||
|
||
3 years ago
|
`"${invalidEmails.join(', ')}" - invalid email`
|
||
|
)
|
||
|
}
|
||
4 years ago
|
],
|
||
3 years ago
|
roleRules: [
|
||
3 years ago
|
v => !!v || 'User Role is required',
|
||
|
v =>
|
||
|
['creator', 'editor', 'commenter', 'viewer'].includes(v) ||
|
||
|
'invalid user role'
|
||
3 years ago
|
],
|
||
3 years ago
|
userList: [],
|
||
3 years ago
|
roleDescriptions: {},
|
||
3 years ago
|
deleteUserType: '' // [DELETE_FROM_PROJECT, DELETE_FROM_NOCODB]
|
||
4 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
3 years ago
|
roleNames() {
|
||
3 years ago
|
return this.roles.map(r => r.title)
|
||
3 years ago
|
},
|
||
3 years ago
|
inviteUrl() {
|
||
3 years ago
|
return this.invite_token
|
||
|
? `${location.origin}${location.pathname}#/user/authentication/signup/${this.invite_token.invite_token}`
|
||
3 years ago
|
: null
|
||
3 years ago
|
},
|
||
3 years ago
|
rolesColors() {
|
||
3 years ago
|
const colors = this.$store.state.settings.darkTheme
|
||
3 years ago
|
? enumColor.dark
|
||
3 years ago
|
: enumColor.light
|
||
3 years ago
|
return ['owner'].concat(this.roles).reduce((o, r, i) => {
|
||
3 years ago
|
o[r] = colors[i % colors.length]
|
||
|
return o
|
||
|
}, {})
|
||
3 years ago
|
},
|
||
|
selectedRoles: {
|
||
3 years ago
|
get() {
|
||
3 years ago
|
return (
|
||
|
this.selectedUser && this.selectedUser.roles
|
||
3 years ago
|
? this.selectedUser.roles.split(',')
|
||
3 years ago
|
: []
|
||
|
).sort(
|
||
|
(a, b) => this.roleNames.indexOf(a) - this.roleNames.indexOf(a)
|
||
3 years ago
|
)[0]
|
||
3 years ago
|
},
|
||
3 years ago
|
set(roles) {
|
||
3 years ago
|
if (this.selectedUser) {
|
||
3 years ago
|
this.selectedUser.roles = roles // .filter(Boolean).join(',')
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
selectedUserIndex: {
|
||
3 years ago
|
get() {
|
||
3 years ago
|
return this.users
|
||
3 years ago
|
? this.users.findIndex(u => u.email === this.selectedUser.email)
|
||
|
: -1
|
||
3 years ago
|
},
|
||
3 years ago
|
set(i) {
|
||
3 years ago
|
this.selectedUser = this.users[i]
|
||
|
}
|
||
3 years ago
|
},
|
||
|
dialogMessage() {
|
||
3 years ago
|
let msg = 'Do you want to remove the user'
|
||
|
if (this.deleteUserType === 'DELETE_FROM_PROJECT') {
|
||
|
msg += ' from Project'
|
||
|
} else if (this.deleteUserType === 'DELETE_FROM_NOCODB') {
|
||
|
msg += ' from NocoDB'
|
||
3 years ago
|
}
|
||
3 years ago
|
msg += '?'
|
||
|
return msg
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
watch: {
|
||
|
options: {
|
||
3 years ago
|
async handler() {
|
||
3 years ago
|
await this.loadUsers()
|
||
3 years ago
|
},
|
||
3 years ago
|
deep: true
|
||
3 years ago
|
},
|
||
3 years ago
|
userEditDialog(v) {
|
||
3 years ago
|
// if (!v) { this.validate = false }
|
||
3 years ago
|
if (v && this.selectedUser && !this.selectedUser.id) {
|
||
3 years ago
|
this.$nextTick(() => {
|
||
|
setTimeout(() => {
|
||
3 years ago
|
this.$refs.email.$el.querySelector('input').focus()
|
||
|
}, 100)
|
||
|
})
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
this.$eventBus.$on('show-add-user', this.addUser)
|
||
|
await this.loadUsers()
|
||
|
await this.loadRoles()
|
||
3 years ago
|
},
|
||
3 years ago
|
beforeDestroy() {
|
||
3 years ago
|
this.$eventBus.$off('show-add-user', this.addUser)
|
||
4 years ago
|
},
|
||
4 years ago
|
methods: {
|
||
3 years ago
|
clickReload() {
|
||
3 years ago
|
this.loadUsers()
|
||
|
this.$e('a:user:reload')
|
||
3 years ago
|
},
|
||
|
clickDeleteUser(id) {
|
||
3 years ago
|
this.$e('c:user:delete')
|
||
|
this.deleteId = id
|
||
|
this.deleteItem = id
|
||
|
this.showConfirmDlg = true
|
||
|
this.deleteUserType = 'DELETE_FROM_PROJECT'
|
||
3 years ago
|
},
|
||
|
clickInviteMore() {
|
||
3 years ago
|
this.$e('c:user:invite-more')
|
||
|
this.invite_token = null
|
||
|
this.selectedUser = { roles: 'editor' }
|
||
3 years ago
|
},
|
||
3 years ago
|
getRole(roles) {
|
||
3 years ago
|
return (roles ? roles.split(',') : []).sort(
|
||
3 years ago
|
(a, b) => this.roleNames.indexOf(a) - this.roleNames.indexOf(a)
|
||
3 years ago
|
)[0]
|
||
3 years ago
|
},
|
||
3 years ago
|
simpleAnim() {
|
||
3 years ago
|
const count = 30
|
||
3 years ago
|
const defaults = {
|
||
|
origin: { y: 0.7 },
|
||
3 years ago
|
zIndex: 9999999
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
function fire(particleRatio, opts) {
|
||
3 years ago
|
window.confetti(
|
||
|
Object.assign({}, defaults, opts, {
|
||
3 years ago
|
particleCount: Math.floor(count * particleRatio)
|
||
3 years ago
|
})
|
||
3 years ago
|
)
|
||
4 years ago
|
}
|
||
|
|
||
|
fire(0.25, {
|
||
|
spread: 26,
|
||
3 years ago
|
startVelocity: 55
|
||
|
})
|
||
4 years ago
|
fire(0.2, {
|
||
3 years ago
|
spread: 60
|
||
|
})
|
||
4 years ago
|
fire(0.35, {
|
||
|
spread: 100,
|
||
|
decay: 0.91,
|
||
3 years ago
|
scalar: 0.8
|
||
|
})
|
||
4 years ago
|
fire(0.1, {
|
||
|
spread: 120,
|
||
|
startVelocity: 25,
|
||
|
decay: 0.92,
|
||
3 years ago
|
scalar: 1.2
|
||
|
})
|
||
4 years ago
|
fire(0.1, {
|
||
|
spread: 120,
|
||
3 years ago
|
startVelocity: 45
|
||
|
})
|
||
4 years ago
|
},
|
||
3 years ago
|
getInviteUrl(token) {
|
||
3 years ago
|
return token
|
||
|
? `${location.origin}${location.pathname}#/user/authentication/signup/${token}`
|
||
3 years ago
|
: null
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
clipboard(str) {
|
||
3 years ago
|
const el = document.createElement('textarea')
|
||
|
el.addEventListener('focusin', e => e.stopPropagation())
|
||
|
el.value = str
|
||
|
document.body.appendChild(el)
|
||
|
el.select()
|
||
|
document.execCommand('copy')
|
||
|
document.body.removeChild(el)
|
||
|
|
||
|
this.$e('c:user:copy-url')
|
||
4 years ago
|
},
|
||
3 years ago
|
async resendInvite(id) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$api.auth.projectUserResendInvite(this.$route.params.project_id, id)
|
||
3 years ago
|
this.$toast.success('Invite email sent successfully').goAway(3000)
|
||
|
await this.loadUsers()
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.response.data.msg).goAway(3000)
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:user:resend-invite')
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadUsers() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
const { page = 1, itemsPerPage = 20 } = this.options
|
||
3 years ago
|
// const data = (await this.$axios.get('/admin', {
|
||
|
// headers: {
|
||
|
// 'xc-auth': this.$store.state.users.token
|
||
|
// },
|
||
|
// params: {
|
||
|
// limit: itemsPerPage,
|
||
|
// offset: (page - 1) * itemsPerPage,
|
||
|
// query: this.query,
|
||
|
// project_id: this.$route.params.project_id
|
||
|
// }
|
||
|
// })).data
|
||
|
|
||
3 years ago
|
const userData = await this.$api.auth.projectUserList(
|
||
|
this.$store.state.project.projectId,
|
||
|
{
|
||
|
query: {
|
||
|
limit: itemsPerPage,
|
||
|
offset: (page - 1) * itemsPerPage,
|
||
3 years ago
|
query: this.query
|
||
|
}
|
||
4 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
|
||
3 years ago
|
this.count = userData.users.pageInfo.totalRows
|
||
|
this.users = userData.users.list
|
||
4 years ago
|
if (!this.selectedUser && this.users && this.users[0]) {
|
||
3 years ago
|
this.selectedUserIndex = 0
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadRoles() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.roles = ['creator', 'editor', 'commenter', 'viewer']
|
||
3 years ago
|
|
||
|
// todo:
|
||
|
// (await this.$axios.get('/admin/roles', {
|
||
|
// headers: {
|
||
|
// 'xc-auth': this.$store.state.users.token
|
||
|
// },
|
||
|
// params: {
|
||
|
// project_id: this.$route.params.project_id
|
||
|
// }
|
||
|
// })).data.map((role) => {
|
||
|
// this.roleDescriptions[role.title] = role.description
|
||
|
// return role.title
|
||
|
// }).filter(role => role !== 'guest')
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteUser(id, type) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$api.auth.projectUserRemove(
|
||
|
this.$route.params.project_id,
|
||
|
id
|
||
3 years ago
|
)
|
||
3 years ago
|
this.$toast
|
||
|
.success(
|
||
|
`Successfully removed the user from ${
|
||
3 years ago
|
type === 'DELETE_FROM_PROJECT' ? 'project' : 'NocoDB'
|
||
3 years ago
|
}`
|
||
|
)
|
||
3 years ago
|
.goAway(3000)
|
||
|
await this.loadUsers()
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.response.data.msg).goAway(3000)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async confirmDelete(hideDialog) {
|
||
4 years ago
|
if (hideDialog) {
|
||
3 years ago
|
this.showConfirmDlg = false
|
||
|
return
|
||
4 years ago
|
}
|
||
3 years ago
|
await this.deleteUser(this.deleteId, this.deleteUserType)
|
||
|
this.showConfirmDlg = false
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:user:delete')
|
||
4 years ago
|
},
|
||
3 years ago
|
addUser() {
|
||
3 years ago
|
this.invite_token = null
|
||
4 years ago
|
this.selectedUser = {
|
||
3 years ago
|
roles: 'editor'
|
||
|
}
|
||
|
this.userEditDialog = true
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('c:user:add')
|
||
4 years ago
|
},
|
||
3 years ago
|
async inviteUser(item) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$api.auth.projectUserAdd(
|
||
|
this.$route.params.project_id,
|
||
|
item
|
||
3 years ago
|
)
|
||
|
this.$toast.success('Successfully added user to project').goAway(3000)
|
||
|
await this.loadUsers()
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.response.data.msg).goAway(3000)
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:user:add')
|
||
4 years ago
|
},
|
||
3 years ago
|
async saveUser() {
|
||
3 years ago
|
this.validate = true
|
||
|
await this.$nextTick()
|
||
3 years ago
|
if (this.loading || !this.$refs.form.validate() || !this.selectedUser) {
|
||
3 years ago
|
return
|
||
4 years ago
|
}
|
||
3 years ago
|
this.$e('a:user:invite', { role: this.selectedUser.roles })
|
||
4 years ago
|
|
||
|
if (!this.edited) {
|
||
3 years ago
|
this.userEditDialog = false
|
||
4 years ago
|
}
|
||
|
|
||
|
try {
|
||
3 years ago
|
let data
|
||
4 years ago
|
if (this.selectedUser.id) {
|
||
3 years ago
|
await this.$api.auth.projectUserUpdate(
|
||
|
this.$route.params.project_id,
|
||
|
this.selectedUser.id,
|
||
|
{
|
||
|
roles: this.selectedUser.roles,
|
||
|
email: this.selectedUser.email,
|
||
|
project_id: this.$route.params.project_id,
|
||
3 years ago
|
projectName: this.$store.getters['project/GtrProjectName']
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
data = await this.$api.auth.projectUserAdd(
|
||
|
this.$route.params.project_id,
|
||
|
{
|
||
|
...this.selectedUser,
|
||
|
project_id: this.$route.params.project_id,
|
||
3 years ago
|
projectName: this.$store.getters['project/GtrProjectName']
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.$toast
|
||
3 years ago
|
.success('Successfully updated the user details')
|
||
|
.goAway(3000)
|
||
|
await this.loadUsers()
|
||
3 years ago
|
if (data && data.invite_token) {
|
||
3 years ago
|
this.invite_token = data
|
||
|
this.simpleAnim()
|
||
|
return
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.response.data.msg).goAway(3000)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
await this.loadUsers()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
|
.v-alert__wrapper > .v-icon {
|
||
|
align-self: center;
|
||
|
}
|
||
|
|
||
|
tbody tr:nth-of-type(odd) {
|
||
|
background-color: transparent;
|
||
|
}
|
||
|
|
||
3 years ago
|
.search-field.v-text-field > .v-input__control,
|
||
|
.search-field.v-text-field > .v-input__control > .v-input__slot {
|
||
4 years ago
|
min-height: auto;
|
||
|
}
|
||
|
|
||
|
.role-select {
|
||
|
.v-select__selections {
|
||
|
//padding-bottom: 0 !important;
|
||
|
min-height: auto !important;
|
||
|
|
||
|
.v-chip {
|
||
|
margin-top: 6px;
|
||
|
margin-bottom: 2px;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.users-table {
|
||
|
td:first-child {
|
||
3 years ago
|
width: 50px;
|
||
4 years ago
|
}
|
||
|
|
||
|
td:last-child {
|
||
3 years ago
|
width: 50px;
|
||
4 years ago
|
}
|
||
|
}
|
||
3 years ago
|
|
||
|
::v-deep .nc-invite-container {
|
||
|
border-radius: 4px;
|
||
|
border: 2px solid var(--v-backgroundColor-base);
|
||
|
background: var(--v-backgroundColor-base);
|
||
|
|
||
|
.v-input .v-input__slot {
|
||
|
background: var(--v-backgroundColorDefault-base);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.nc-header-border {
|
||
|
width: 100%;
|
||
|
border-bottom: 2px solid var(--v-backgroundColor-base);
|
||
|
margin-bottom: 10px;
|
||
|
}
|
||
4 years ago
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
3 years ago
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|