2020-06-11 19:13:21 +02:00
|
|
|
<template>
|
2022-09-20 16:53:26 +02:00
|
|
|
<div v-if="user">
|
2022-01-10 15:19:16 +01:00
|
|
|
<breadcrumbs-nav
|
|
|
|
:links="[
|
2022-07-12 10:55:28 +02:00
|
|
|
{ name: RouteName.ADMIN, text: t('Admin') },
|
2022-01-10 15:19:16 +01:00
|
|
|
{
|
|
|
|
name: RouteName.USERS,
|
2022-07-12 10:55:28 +02:00
|
|
|
text: t('Users'),
|
2022-01-10 15:19:16 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: RouteName.ADMIN_USER_PROFILE,
|
|
|
|
params: { id: user.id },
|
|
|
|
text: user.email,
|
|
|
|
},
|
|
|
|
]"
|
|
|
|
/>
|
|
|
|
|
2022-01-13 15:04:43 +01:00
|
|
|
<section>
|
2022-07-12 10:55:28 +02:00
|
|
|
<h2 class="text-lg font-bold mb-3">{{ t("Details") }}</h2>
|
2022-01-13 15:04:43 +01:00
|
|
|
<div class="flex flex-col">
|
2022-09-20 16:53:26 +02:00
|
|
|
<div class="overflow-x-auto">
|
2022-01-14 18:10:50 +01:00
|
|
|
<div class="inline-block py-2 min-w-full sm:px-2">
|
2022-01-13 15:04:43 +01:00
|
|
|
<div class="overflow-hidden shadow-md sm:rounded-lg">
|
2022-09-20 16:53:26 +02:00
|
|
|
<table v-if="metadata.length > 0" class="table w-full">
|
2022-01-13 15:04:43 +01:00
|
|
|
<tbody>
|
|
|
|
<tr
|
2022-08-26 16:08:58 +02:00
|
|
|
class="border-b"
|
2022-07-12 10:55:28 +02:00
|
|
|
v-for="{ key, value, type } in metadata"
|
2022-01-13 15:04:43 +01:00
|
|
|
:key="key"
|
|
|
|
>
|
2022-01-14 18:10:50 +01:00
|
|
|
<td class="py-4 px-2 whitespace-nowrap align-middle">
|
2022-01-13 15:04:43 +01:00
|
|
|
{{ key }}
|
|
|
|
</td>
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-01-13 15:04:43 +01:00
|
|
|
<td
|
2022-07-12 10:55:28 +02:00
|
|
|
v-if="type === 'ip'"
|
2022-01-14 18:10:50 +01:00
|
|
|
class="py-4 px-2 whitespace-nowrap"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-01-14 18:10:50 +01:00
|
|
|
<code>{{ value }}</code>
|
2022-01-13 15:04:43 +01:00
|
|
|
</td>
|
|
|
|
<td
|
2022-01-14 18:10:50 +01:00
|
|
|
v-else-if="type === 'role'"
|
|
|
|
class="py-4 px-2 whitespace-nowrap"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-01-14 18:10:50 +01:00
|
|
|
<span
|
|
|
|
:class="{
|
|
|
|
'bg-red-100 text-red-800':
|
|
|
|
user.role == ICurrentUserRole.ADMINISTRATOR,
|
|
|
|
'bg-yellow-100 text-yellow-800':
|
|
|
|
user.role == ICurrentUserRole.MODERATOR,
|
|
|
|
'bg-blue-100 text-blue-800':
|
|
|
|
user.role == ICurrentUserRole.USER,
|
|
|
|
}"
|
|
|
|
class="text-sm font-medium mr-2 px-2.5 py-0.5 rounded"
|
|
|
|
>
|
|
|
|
{{ value }}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td v-else class="py-4 px-2 align-middle">
|
|
|
|
{{ value }}
|
2022-01-13 15:04:43 +01:00
|
|
|
</td>
|
|
|
|
<td
|
2022-01-14 18:10:50 +01:00
|
|
|
v-if="type === 'email'"
|
2022-07-12 10:55:28 +02:00
|
|
|
class="py-4 px-2 whitespace-nowrap flex flex flex-col items-start gap-2"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
|
|
|
size="small"
|
2022-01-14 18:10:50 +01:00
|
|
|
v-if="!user.disabled"
|
|
|
|
@click="isEmailChangeModalActive = true"
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2022-01-14 18:10:50 +01:00
|
|
|
icon-left="pencil"
|
2022-07-12 10:55:28 +02:00
|
|
|
>{{ t("Change email") }}</o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
tag="router-link"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.USERS,
|
|
|
|
query: { emailFilter: `@${userEmailDomain}` },
|
|
|
|
}"
|
2022-07-12 10:55:28 +02:00
|
|
|
size="small"
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2022-01-14 18:10:50 +01:00
|
|
|
icon-left="magnify"
|
|
|
|
>{{
|
2022-07-12 10:55:28 +02:00
|
|
|
t("Other users with the same email domain")
|
|
|
|
}}</o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
>
|
2022-01-13 15:04:43 +01:00
|
|
|
</td>
|
|
|
|
<td
|
2022-01-14 18:10:50 +01:00
|
|
|
v-else-if="type === 'confirmed'"
|
|
|
|
class="py-4 px-2 whitespace-nowrap flex items-center"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
|
|
|
size="small"
|
2022-04-03 17:41:16 +02:00
|
|
|
v-if="!user.confirmedAt || user.disabled"
|
2022-01-14 18:10:50 +01:00
|
|
|
@click="isConfirmationModalActive = true"
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2022-01-14 18:10:50 +01:00
|
|
|
icon-left="check"
|
2022-07-12 10:55:28 +02:00
|
|
|
>{{ t("Confirm user") }}</o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
>
|
2022-01-13 15:04:43 +01:00
|
|
|
</td>
|
|
|
|
<td
|
2022-01-14 18:10:50 +01:00
|
|
|
v-else-if="type === 'role'"
|
|
|
|
class="py-4 px-2 whitespace-nowrap flex items-center"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
|
|
|
size="small"
|
2022-01-14 18:10:50 +01:00
|
|
|
v-if="!user.disabled"
|
|
|
|
@click="isRoleChangeModalActive = true"
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2022-01-14 18:10:50 +01:00
|
|
|
icon-left="chevron-double-up"
|
2022-07-12 10:55:28 +02:00
|
|
|
>{{ t("Change role") }}</o-button
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
|
|
|
</td>
|
|
|
|
<td
|
2022-01-14 18:10:50 +01:00
|
|
|
v-else-if="type === 'ip' && user.currentSignInIp"
|
|
|
|
class="py-4 px-2 whitespace-nowrap flex items-center"
|
2022-01-13 15:04:43 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
tag="router-link"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.USERS,
|
|
|
|
query: { ipFilter: user.currentSignInIp },
|
|
|
|
}"
|
2022-07-12 10:55:28 +02:00
|
|
|
size="small"
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2022-01-14 18:10:50 +01:00
|
|
|
icon-left="web"
|
|
|
|
>{{
|
2022-07-12 10:55:28 +02:00
|
|
|
t("Other users with the same IP address")
|
|
|
|
}}</o-button
|
2022-01-14 18:10:50 +01:00
|
|
|
>
|
2022-01-13 15:04:43 +01:00
|
|
|
</td>
|
2022-01-14 18:10:50 +01:00
|
|
|
<td v-else></td>
|
2022-01-13 15:04:43 +01:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section class="my-4">
|
2022-07-12 10:55:28 +02:00
|
|
|
<h2 class="text-lg font-bold mb-3">{{ t("Profiles") }}</h2>
|
2022-01-14 18:10:50 +01:00
|
|
|
<div
|
|
|
|
class="flex flex-wrap justify-center sm:justify-start gap-4"
|
2022-07-12 10:55:28 +02:00
|
|
|
v-if="profiles && profiles.length > 0"
|
2022-01-14 18:10:50 +01:00
|
|
|
>
|
2022-01-13 15:04:43 +01:00
|
|
|
<router-link
|
|
|
|
v-for="profile in profiles"
|
|
|
|
:key="profile.id"
|
|
|
|
:to="{ name: RouteName.ADMIN_PROFILE, params: { id: profile.id } }"
|
|
|
|
>
|
|
|
|
<actor-card
|
|
|
|
:actor="profile"
|
|
|
|
:full="true"
|
|
|
|
:popover="false"
|
2022-01-14 18:10:50 +01:00
|
|
|
:limit="true"
|
2022-01-13 15:04:43 +01:00
|
|
|
/>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
2022-07-12 10:55:28 +02:00
|
|
|
<empty-content v-else-if="!loadingUser" :inline="true" icon="account">
|
|
|
|
{{ t("This user doesn't have any profiles") }}
|
2022-01-14 18:10:50 +01:00
|
|
|
</empty-content>
|
2022-01-13 15:04:43 +01:00
|
|
|
</section>
|
2022-01-14 18:10:50 +01:00
|
|
|
<section class="my-4">
|
2022-07-12 10:55:28 +02:00
|
|
|
<h2 class="text-lg font-bold mb-3">{{ t("Actions") }}</h2>
|
2022-01-14 18:10:50 +01:00
|
|
|
<div class="buttons" v-if="!user.disabled">
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button @click="suspendAccount" variant="danger">{{
|
|
|
|
t("Suspend")
|
|
|
|
}}</o-button>
|
2022-01-14 18:10:50 +01:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="p-4 mb-4 text-sm text-red-700 bg-red-100 rounded-lg"
|
|
|
|
role="alert"
|
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
{{ t("The user has been disabled") }}
|
2022-01-14 18:10:50 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-modal
|
|
|
|
v-model:active="isEmailChangeModalActive"
|
2022-01-14 18:10:50 +01:00
|
|
|
trap-focus
|
|
|
|
:destroy-on-hide="false"
|
|
|
|
aria-role="dialog"
|
2022-07-12 10:55:28 +02:00
|
|
|
:aria-label="t('Edit user email')"
|
|
|
|
:close-button-aria-label="t('Close')"
|
2022-01-14 18:10:50 +01:00
|
|
|
aria-modal
|
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<form @submit.prevent="updateUserEmail">
|
|
|
|
<div class="" style="width: auto">
|
|
|
|
<header class="">
|
|
|
|
<h2>{{ t("Change user email") }}</h2>
|
|
|
|
</header>
|
|
|
|
<section class="">
|
|
|
|
<o-field :label="t('Previous email')">
|
2022-08-26 16:08:58 +02:00
|
|
|
<o-input type="email" v-model="user.email" disabled />
|
2022-07-12 10:55:28 +02:00
|
|
|
</o-field>
|
|
|
|
<o-field :label="t('New email')">
|
|
|
|
<o-input
|
|
|
|
type="email"
|
|
|
|
v-model="newUser.email"
|
|
|
|
:placeholder="t(`new{'@'}email.com`)"
|
|
|
|
required
|
|
|
|
>
|
|
|
|
</o-input>
|
|
|
|
</o-field>
|
|
|
|
<o-checkbox v-model="newUser.notify">{{
|
|
|
|
t("Notify the user of the change")
|
|
|
|
}}</o-checkbox>
|
|
|
|
</section>
|
|
|
|
<footer class="mt-2 flex gap-2">
|
2022-08-26 16:08:58 +02:00
|
|
|
<o-button outlined @click="isEmailChangeModalActive = false">{{
|
2022-07-12 10:55:28 +02:00
|
|
|
t("Close")
|
|
|
|
}}</o-button>
|
|
|
|
<o-button native-type="submit" variant="primary">{{
|
|
|
|
t("Change email")
|
|
|
|
}}</o-button>
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</o-modal>
|
|
|
|
<o-modal
|
|
|
|
v-model:active="isRoleChangeModalActive"
|
2022-01-14 18:10:50 +01:00
|
|
|
has-modal-card
|
|
|
|
trap-focus
|
|
|
|
:destroy-on-hide="false"
|
|
|
|
aria-role="dialog"
|
2022-07-12 10:55:28 +02:00
|
|
|
:aria-label="t('Edit user email')"
|
|
|
|
:close-button-aria-label="t('Close')"
|
2022-01-14 18:10:50 +01:00
|
|
|
aria-modal
|
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<form @submit.prevent="updateUserRole">
|
2022-09-20 16:53:26 +02:00
|
|
|
<header>
|
|
|
|
<h2>{{ t("Change user role") }}</h2>
|
|
|
|
</header>
|
|
|
|
<section>
|
|
|
|
<o-field>
|
|
|
|
<o-radio
|
|
|
|
v-model="newUser.role"
|
|
|
|
:native-value="ICurrentUserRole.ADMINISTRATOR"
|
|
|
|
>
|
|
|
|
{{ t("Administrator") }}
|
|
|
|
</o-radio>
|
|
|
|
</o-field>
|
|
|
|
<o-field>
|
|
|
|
<o-radio
|
|
|
|
v-model="newUser.role"
|
|
|
|
:native-value="ICurrentUserRole.MODERATOR"
|
|
|
|
>
|
|
|
|
{{ t("Moderator") }}
|
|
|
|
</o-radio>
|
|
|
|
</o-field>
|
|
|
|
<o-field>
|
|
|
|
<o-radio
|
|
|
|
v-model="newUser.role"
|
|
|
|
:native-value="ICurrentUserRole.USER"
|
|
|
|
>
|
|
|
|
{{ t("User") }}
|
|
|
|
</o-radio>
|
|
|
|
</o-field>
|
|
|
|
<o-checkbox v-model="newUser.notify">{{
|
|
|
|
t("Notify the user of the change")
|
|
|
|
}}</o-checkbox>
|
|
|
|
</section>
|
|
|
|
<footer class="mt-2 flex gap-2">
|
|
|
|
<o-button @click="isRoleChangeModalActive = false" outlined>{{
|
|
|
|
t("Close")
|
|
|
|
}}</o-button>
|
|
|
|
<o-button native-type="submit" variant="primary">{{
|
|
|
|
t("Change role")
|
|
|
|
}}</o-button>
|
|
|
|
</footer>
|
2022-07-12 10:55:28 +02:00
|
|
|
</form>
|
|
|
|
</o-modal>
|
|
|
|
<o-modal
|
|
|
|
v-model:active="isConfirmationModalActive"
|
2022-01-14 18:10:50 +01:00
|
|
|
has-modal-card
|
|
|
|
trap-focus
|
|
|
|
:destroy-on-hide="false"
|
|
|
|
aria-role="dialog"
|
2022-07-12 10:55:28 +02:00
|
|
|
:aria-label="t('Edit user email')"
|
|
|
|
:close-button-aria-label="t('Close')"
|
2022-01-14 18:10:50 +01:00
|
|
|
aria-modal
|
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<form @submit.prevent="confirmUser">
|
2022-09-20 16:53:26 +02:00
|
|
|
<header>
|
|
|
|
<h2>{{ t("Confirm user") }}</h2>
|
|
|
|
</header>
|
|
|
|
<section>
|
|
|
|
<o-checkbox v-model="newUser.notify">{{
|
|
|
|
t("Notify the user of the change")
|
|
|
|
}}</o-checkbox>
|
|
|
|
</section>
|
|
|
|
<footer>
|
|
|
|
<o-button @click="isConfirmationModalActive = false">{{
|
|
|
|
t("Close")
|
|
|
|
}}</o-button>
|
|
|
|
<o-button native-type="submit" variant="primary">{{
|
|
|
|
t("Confirm user")
|
|
|
|
}}</o-button>
|
|
|
|
</footer>
|
2022-07-12 10:55:28 +02:00
|
|
|
</form>
|
|
|
|
</o-modal>
|
2020-06-11 19:13:21 +02:00
|
|
|
</div>
|
2022-07-12 10:55:28 +02:00
|
|
|
<empty-content v-else-if="!loadingUser" icon="account">
|
|
|
|
{{ t("This user was not found") }}
|
2021-12-13 17:33:10 +01:00
|
|
|
<template #desc>
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-button
|
2022-08-26 16:08:58 +02:00
|
|
|
variant="text"
|
2021-12-13 17:33:10 +01:00
|
|
|
tag="router-link"
|
|
|
|
:to="{ name: RouteName.USERS }"
|
2022-07-12 10:55:28 +02:00
|
|
|
>{{ t("Back to user list") }}</o-button
|
2021-12-13 17:33:10 +01:00
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</empty-content>
|
2020-06-11 19:13:21 +02:00
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
2020-11-23 16:58:50 +01:00
|
|
|
import { formatBytes } from "@/utils/datetime";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { ICurrentUserRole } from "@/types/enums";
|
2020-08-18 17:21:58 +02:00
|
|
|
import { GET_USER, SUSPEND_USER } from "../../graphql/user";
|
2020-06-11 19:13:21 +02:00
|
|
|
import RouteName from "../../router/name";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { IUser } from "../../types/current-user.model";
|
2021-12-13 17:33:10 +01:00
|
|
|
import EmptyContent from "../../components/Utils/EmptyContent.vue";
|
2022-01-13 15:04:43 +01:00
|
|
|
import ActorCard from "../../components/Account/ActorCard.vue";
|
2022-01-14 18:10:50 +01:00
|
|
|
import { ADMIN_UPDATE_USER, LANGUAGES_CODES } from "@/graphql/admin";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { useMutation, useQuery } from "@vue/apollo-composable";
|
|
|
|
import { ILanguage } from "@/types/admin.model";
|
|
|
|
import { computed, inject, reactive, ref, watch } from "vue";
|
|
|
|
import { useHead } from "@vueuse/head";
|
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
import { formatDateTimeString } from "@/filters/datetime";
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
import { IPerson } from "@/types/actor";
|
|
|
|
import { Dialog } from "@/plugins/dialog";
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = defineProps<{ id: string }>();
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { result: userResult, loading: loadingUser } = useQuery<{ user: IUser }>(
|
|
|
|
GET_USER,
|
|
|
|
() => ({
|
|
|
|
id: props.id,
|
|
|
|
})
|
|
|
|
);
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const user = computed(() => userResult.value?.user);
|
2022-01-13 15:04:43 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const languageCode = computed(() => user.value?.locale);
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { result: languagesResult } = useQuery<{ languages: ILanguage[] }>(
|
|
|
|
LANGUAGES_CODES,
|
|
|
|
() => ({
|
|
|
|
codes: languageCode.value,
|
|
|
|
}),
|
|
|
|
() => ({
|
|
|
|
enabled: languageCode.value !== undefined,
|
|
|
|
})
|
|
|
|
);
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const languages = computed(() => languagesResult.value?.languages);
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { t } = useI18n({ useScope: "global" });
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
useHead({
|
|
|
|
title: computed(() => user.value?.email ?? ""),
|
|
|
|
});
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const isEmailChangeModalActive = ref(false);
|
|
|
|
const isRoleChangeModalActive = ref(false);
|
|
|
|
const isConfirmationModalActive = ref(false);
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const newUser = reactive({
|
|
|
|
email: "",
|
|
|
|
role: user.value?.role,
|
|
|
|
confirm: false,
|
|
|
|
notify: true,
|
|
|
|
});
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const metadata = computed(
|
|
|
|
(): Array<{ key: string; value: string; type?: string }> => {
|
|
|
|
if (!user.value) return [];
|
2020-06-11 19:13:21 +02:00
|
|
|
return [
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Email"),
|
|
|
|
value: user.value.email,
|
2022-01-14 18:10:50 +01:00
|
|
|
type: "email",
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Language"),
|
|
|
|
value: languages.value ? languages.value[0].name : t("Unknown"),
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Role"),
|
|
|
|
value: roleName(user.value.role),
|
2022-01-14 18:10:50 +01:00
|
|
|
type: "role",
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Login status"),
|
|
|
|
value: user.value.disabled ? t("Disabled") : t("Activated"),
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Confirmed"),
|
|
|
|
value: user.value.confirmedAt
|
|
|
|
? formatDateTimeString(user.value.confirmedAt)
|
|
|
|
: t("Not confirmed"),
|
2022-01-14 18:10:50 +01:00
|
|
|
type: "confirmed",
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
2020-08-31 16:57:13 +02:00
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Last sign-in"),
|
|
|
|
value: user.value.currentSignInAt
|
|
|
|
? formatDateTimeString(user.value.currentSignInAt)
|
|
|
|
: t("Unknown"),
|
2020-08-31 16:57:13 +02:00
|
|
|
},
|
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Last IP adress"),
|
|
|
|
value: user.value.currentSignInIp || t("Unknown"),
|
|
|
|
type: user.value.currentSignInIp ? "ip" : undefined,
|
2020-08-31 16:57:13 +02:00
|
|
|
},
|
2020-06-11 19:13:21 +02:00
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Total number of participations"),
|
|
|
|
value: user.value.participations.total.toString(),
|
2020-06-11 19:13:21 +02:00
|
|
|
},
|
2020-11-23 16:58:50 +01:00
|
|
|
{
|
2022-07-12 10:55:28 +02:00
|
|
|
key: t("Uploaded media total size"),
|
2022-09-20 16:53:26 +02:00
|
|
|
value: formatBytes(user.value.mediaSize),
|
2020-11-23 16:58:50 +01:00
|
|
|
},
|
2020-06-11 19:13:21 +02:00
|
|
|
];
|
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
);
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const roleName = (role: ICurrentUserRole): string => {
|
|
|
|
switch (role) {
|
|
|
|
case ICurrentUserRole.ADMINISTRATOR:
|
|
|
|
return t("Administrator");
|
|
|
|
case ICurrentUserRole.MODERATOR:
|
|
|
|
return t("Moderator");
|
|
|
|
case ICurrentUserRole.USER:
|
|
|
|
default:
|
|
|
|
return t("User");
|
2020-06-11 19:13:21 +02:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
};
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const router = useRouter();
|
2020-06-11 19:13:21 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { mutate: suspendUser } = useMutation<
|
|
|
|
{ suspendProfile: { id: string } },
|
|
|
|
{ userId: string }
|
|
|
|
>(SUSPEND_USER);
|
2022-01-13 15:04:43 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const dialog = inject<Dialog>("dialog");
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const suspendAccount = async (): Promise<void> => {
|
|
|
|
dialog?.confirm({
|
|
|
|
title: t("Suspend the account?"),
|
|
|
|
message: t(
|
|
|
|
"Do you really want to suspend this account? All of the user's profiles will be deleted."
|
|
|
|
),
|
|
|
|
confirmText: t("Suspend the account"),
|
|
|
|
cancelText: t("Cancel"),
|
2022-08-26 16:08:58 +02:00
|
|
|
variant: "danger",
|
2022-07-12 10:55:28 +02:00
|
|
|
onConfirm: async () => {
|
|
|
|
suspendUser({
|
|
|
|
userId: props.id,
|
|
|
|
});
|
|
|
|
return router.push({ name: RouteName.USERS });
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const profiles = computed((): IPerson[] | undefined => {
|
|
|
|
return user.value?.actors;
|
|
|
|
});
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const confirmUser = async () => {
|
|
|
|
isConfirmationModalActive.value = false;
|
|
|
|
await updateUser({
|
|
|
|
id: props.id,
|
|
|
|
confirmed: true,
|
|
|
|
notify: newUser.notify,
|
|
|
|
});
|
|
|
|
};
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const updateUserRole = async () => {
|
|
|
|
isRoleChangeModalActive.value = false;
|
|
|
|
await updateUser({
|
|
|
|
id: props.id,
|
|
|
|
role: newUser.role,
|
|
|
|
notify: newUser.notify,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const updateUserEmail = async () => {
|
|
|
|
isEmailChangeModalActive.value = false;
|
|
|
|
await updateUser({
|
|
|
|
id: props.id,
|
|
|
|
email: newUser.email,
|
|
|
|
notify: newUser.notify,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const { mutate: updateUser } = useMutation<
|
|
|
|
{ adminUpdateUser: IUser },
|
|
|
|
{
|
|
|
|
id: string;
|
2022-01-14 18:10:50 +01:00
|
|
|
email?: string;
|
|
|
|
notify: boolean;
|
|
|
|
confirmed?: boolean;
|
|
|
|
role?: ICurrentUserRole;
|
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
>(ADMIN_UPDATE_USER);
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
watch(user, (updatedUser: IUser | undefined, oldUser: IUser | undefined) => {
|
|
|
|
if (updatedUser?.role !== oldUser?.role) {
|
|
|
|
newUser.role = updatedUser?.role;
|
2022-01-14 18:10:50 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
});
|
2022-01-14 18:10:50 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const userEmailDomain = computed((): string | undefined => {
|
|
|
|
if (user.value?.email) {
|
|
|
|
return user.value?.email.split("@")[1];
|
2022-01-14 18:10:50 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
return undefined;
|
|
|
|
});
|
2022-01-13 15:04:43 +01:00
|
|
|
</script>
|