refactor
This commit is contained in:
parent
1c966db324
commit
69cdc73f5a
|
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template>
|
||||
<PageWithHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs">
|
||||
<div class="_spacer" style="--MI_SPACER-w: 600px; --MI_SPACER-min: 16px; --MI_SPACER-max: 32px;">
|
||||
<FormSuspense :p="init">
|
||||
<div v-if="tab === 'overview'" class="_gaps_m">
|
||||
<div class="aeakzknw">
|
||||
<MkAvatar class="avatar" :user="user" indicator link preview/>
|
||||
|
|
@ -143,7 +142,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<button v-if="role.target === 'manual'" class="_button" :class="$style.roleUnassign" @click="unassignRole(role, $event)"><i class="ti ti-x"></i></button>
|
||||
<button v-else class="_button" :class="$style.roleUnassign" disabled><i class="ti ti-ban"></i></button>
|
||||
</div>
|
||||
<div v-if="expandedRoles.includes(role.id)" :class="$style.roleItemSub">
|
||||
<div v-if="expandedRoleIds.includes(role.id)" :class="$style.roleItemSub">
|
||||
<div>Assigned: <MkTime :time="info.roleAssigns.find(a => a.roleId === role.id).createdAt" mode="detail"/></div>
|
||||
<div v-if="info.roleAssigns.find(a => a.roleId === role.id).expiresAt">Period: {{ new Date(info.roleAssigns.find(a => a.roleId === role.id).expiresAt).toLocaleString() }}</div>
|
||||
<div v-else>Period: {{ i18n.ts.indefinitely }}</div>
|
||||
|
|
@ -205,7 +204,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkObjectView tall :value="user">
|
||||
</MkObjectView>
|
||||
</div>
|
||||
</FormSuspense>
|
||||
</div>
|
||||
</PageWithHeader>
|
||||
</template>
|
||||
|
|
@ -224,7 +222,6 @@ import MkButton from '@/components/MkButton.vue';
|
|||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
||||
import MkSelect from '@/components/MkSelect.vue';
|
||||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
import * as os from '@/os.js';
|
||||
|
|
@ -232,11 +229,13 @@ import { misskeyApi } from '@/utility/misskey-api.js';
|
|||
import { acct } from '@/filters/user.js';
|
||||
import { definePage } from '@/page.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { iAmAdmin, $i, iAmModerator } from '@/i.js';
|
||||
import { ensureSignin, iAmAdmin, iAmModerator } from '@/i.js';
|
||||
import MkRolePreview from '@/components/MkRolePreview.vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const $i = ensureSignin();
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
userId: string;
|
||||
initialTab?: string;
|
||||
|
|
@ -244,18 +243,19 @@ const props = withDefaults(defineProps<{
|
|||
initialTab: 'overview',
|
||||
});
|
||||
|
||||
const result = await _fetch_();
|
||||
|
||||
const tab = ref(props.initialTab);
|
||||
const chartSrc = ref('per-user-notes');
|
||||
const user = ref<null | Misskey.entities.UserDetailed>();
|
||||
const init = ref<ReturnType<typeof createFetcher>>();
|
||||
const info = ref<any>();
|
||||
const ips = ref<Misskey.entities.AdminGetUserIpsResponse | null>(null);
|
||||
const user = ref(result.user);
|
||||
const info = ref(result.info);
|
||||
const ips = ref(result.ips);
|
||||
const ap = ref<any>(null);
|
||||
const moderator = ref(false);
|
||||
const silenced = ref(false);
|
||||
const suspended = ref(false);
|
||||
const isSystem = ref(false);
|
||||
const moderationNote = ref('');
|
||||
const moderator = ref(info.value.isModerator);
|
||||
const silenced = ref(info.value.isSilenced);
|
||||
const suspended = ref(info.value.isSuspended);
|
||||
const isSystem = ref(user.value.host == null && user.value.username.includes('.'));
|
||||
const moderationNote = ref(info.value.moderationNote);
|
||||
const filesPaginator = markRaw(new Paginator('admin/drive/files', {
|
||||
limit: 10,
|
||||
computedParams: computed(() => ({
|
||||
|
|
@ -272,34 +272,37 @@ const announcementsPaginator = markRaw(new Paginator('admin/announcements/list',
|
|||
status: announcementsStatus.value,
|
||||
})),
|
||||
}));
|
||||
const expandedRoles = ref([]);
|
||||
const expandedRoleIds = ref<(typeof info.value.roles[number]['id'])[]>([]);
|
||||
|
||||
function createFetcher() {
|
||||
return () => Promise.all([misskeyApi('users/show', {
|
||||
function _fetch_() {
|
||||
return Promise.all([misskeyApi('users/show', {
|
||||
userId: props.userId,
|
||||
}), misskeyApi('admin/show-user', {
|
||||
userId: props.userId,
|
||||
}), iAmAdmin ? misskeyApi('admin/get-user-ips', {
|
||||
userId: props.userId,
|
||||
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => {
|
||||
user.value = _user;
|
||||
info.value = _info;
|
||||
ips.value = _ips;
|
||||
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => ({
|
||||
user: _user,
|
||||
info: _info,
|
||||
ips: _ips,
|
||||
}));
|
||||
}
|
||||
|
||||
watch(moderationNote, async () => {
|
||||
await misskeyApi('admin/update-user-note', { userId: user.value.id, text: moderationNote.value });
|
||||
await refreshUser();
|
||||
});
|
||||
|
||||
async function refreshUser() {
|
||||
const result = await _fetch_();
|
||||
user.value = result.user;
|
||||
info.value = result.info;
|
||||
ips.value = result.ips;
|
||||
moderator.value = info.value.isModerator;
|
||||
silenced.value = info.value.isSilenced;
|
||||
suspended.value = info.value.isSuspended;
|
||||
moderationNote.value = info.value.moderationNote;
|
||||
isSystem.value = user.value.host == null && user.value.username.includes('.');
|
||||
|
||||
watch(moderationNote, async () => {
|
||||
await misskeyApi('admin/update-user-note', { userId: user.value.id, text: moderationNote.value });
|
||||
await refreshUser();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refreshUser() {
|
||||
init.value = createFetcher();
|
||||
moderationNote.value = info.value.moderationNote;
|
||||
}
|
||||
|
||||
async function updateRemoteUser() {
|
||||
|
|
@ -456,7 +459,7 @@ async function assignRole() {
|
|||
refreshUser();
|
||||
}
|
||||
|
||||
async function unassignRole(role, ev) {
|
||||
async function unassignRole(role: typeof info.value.roles[number], ev: MouseEvent) {
|
||||
os.popupMenu([{
|
||||
text: i18n.ts.unassign,
|
||||
icon: 'ti ti-x',
|
||||
|
|
@ -468,11 +471,11 @@ async function unassignRole(role, ev) {
|
|||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
function toggleRoleItem(role) {
|
||||
if (expandedRoles.value.includes(role.id)) {
|
||||
expandedRoles.value = expandedRoles.value.filter(x => x !== role.id);
|
||||
function toggleRoleItem(role: typeof info.value.roles[number]) {
|
||||
if (expandedRoleIds.value.includes(role.id)) {
|
||||
expandedRoleIds.value = expandedRoleIds.value.filter(x => x !== role.id);
|
||||
} else {
|
||||
expandedRoles.value.push(role.id);
|
||||
expandedRoleIds.value.push(role.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,12 +496,6 @@ async function editAnnouncement(announcement) {
|
|||
});
|
||||
}
|
||||
|
||||
watch(() => props.userId, () => {
|
||||
init.value = createFetcher();
|
||||
}, {
|
||||
immediate: true,
|
||||
});
|
||||
|
||||
watch(user, () => {
|
||||
misskeyApi('ap/get', {
|
||||
uri: user.value.uri ?? `${url}/users/${user.value.id}`,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkSwitch v-model="statusbar.props.shuffle">
|
||||
<template #label>{{ i18n.ts.shuffle }}</template>
|
||||
</MkSwitch>
|
||||
<MkInput v-model="statusbar.props.refreshIntervalSec" manualSave type="number" min="1">
|
||||
<MkInput v-model="statusbar.props.refreshIntervalSec" manualSave type="number" :min="1">
|
||||
<template #label>{{ i18n.ts.refreshInterval }}</template>
|
||||
</MkInput>
|
||||
<MkRange v-model="statusbar.props.marqueeDuration" :min="5" :max="150" :step="1">
|
||||
|
|
@ -48,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkSwitch>
|
||||
</template>
|
||||
<template v-else-if="statusbar.type === 'federation'">
|
||||
<MkInput v-model="statusbar.props.refreshIntervalSec" manualSave type="number" min="1">
|
||||
<MkInput v-model="statusbar.props.refreshIntervalSec" manualSave type="number" :min="1">
|
||||
<template #label>{{ i18n.ts.refreshInterval }}</template>
|
||||
</MkInput>
|
||||
<MkRange v-model="statusbar.props.marqueeDuration" :min="5" :max="150" :step="1">
|
||||
|
|
@ -104,7 +104,7 @@ const props = defineProps<{
|
|||
userLists: Misskey.entities.UserList[] | null;
|
||||
}>();
|
||||
|
||||
const statusbar = reactive(deepClone(prefer.s.statusbars.find(x => x.id === props._id)));
|
||||
const statusbar = reactive(deepClone(prefer.s.statusbars.find(x => x.id === props._id))!);
|
||||
|
||||
watch(() => statusbar.type, () => {
|
||||
if (statusbar.type === 'rss') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue