Sharkey/packages/frontend/src/pages/admin/index.vue

349 lines
8.3 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
2021-11-19 12:36:12 +02:00
<div ref="el" class="hiyeyicy" :class="{ wide: !narrow }">
<div v-if="!narrow || currentPage?.route.name == null" class="nav">
2023-05-19 14:52:15 +03:00
<MkSpacer :contentMax="700" :marginMin="16">
2021-10-24 14:16:55 +03:00
<div class="lxpfedzu">
<div class="banner">
2023-04-01 07:46:04 +03:00
<img :src="instance.iconUrl || '/favicon.ico'" alt="" class="icon"/>
2021-10-24 14:16:55 +03:00
</div>
2021-10-10 11:48:07 +03:00
2022-07-20 16:24:26 +03:00
<MkInfo v-if="thereIsUnresolvedAbuseReport" warn class="info">{{ i18n.ts.thereIsUnresolvedAbuseReportWarning }} <MkA to="/admin/abuses" class="_link">{{ i18n.ts.check }}</MkA></MkInfo>
<MkInfo v-if="noMaintainerInformation" warn class="info">{{ i18n.ts.noMaintainerInformationWarning }} <MkA to="/admin/settings" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
<MkInfo v-if="noBotProtection" warn class="info">{{ i18n.ts.noBotProtectionWarning }} <MkA to="/admin/security" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
<MkInfo v-if="noEmailServer" warn class="info">{{ i18n.ts.noEmailServerWarning }} <MkA to="/admin/email-settings" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
2021-10-10 11:48:07 +03:00
<MkSuperMenu :def="menuDef" :grid="narrow"></MkSuperMenu>
2021-10-24 14:16:55 +03:00
</div>
</MkSpacer>
</div>
2023-01-03 02:19:54 +02:00
<div v-if="!(narrow && currentPage?.route.name == null)" class="main">
<RouterView/>
</div>
</div>
</template>
<script lang="ts" setup>
import { onActivated, onMounted, onUnmounted, provide, watch } from 'vue';
2021-11-11 19:02:25 +02:00
import { i18n } from '@/i18n';
import MkSuperMenu from '@/components/MkSuperMenu.vue';
import MkInfo from '@/components/MkInfo.vue';
2021-11-11 19:02:25 +02:00
import { instance } from '@/instance';
import * as os from '@/os';
import { lookupUser } from '@/scripts/lookup-user';
import { useRouter } from '@/router';
import { definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata';
2020-02-16 19:21:27 +02:00
const isEmpty = (x: string | null) => x == null || x === '';
const router = useRouter();
2021-10-23 22:03:07 +03:00
const indexInfo = {
title: i18n.ts.controlPanel,
icon: 'ti ti-settings',
hideHeader: true,
};
provide('shouldOmitHeaderTitle', false);
2021-10-10 09:19:16 +03:00
let INFO = $ref(indexInfo);
let childInfo = $ref(null);
let narrow = $ref(false);
let view = $ref(null);
let el = $ref(null);
let pageProps = $ref({});
let noMaintainerInformation = isEmpty(instance.maintainerName) || isEmpty(instance.maintainerEmail);
let noBotProtection = !instance.disableRegistration && !instance.enableHcaptcha && !instance.enableRecaptcha && !instance.enableTurnstile;
let noEmailServer = !instance.enableEmail;
let thereIsUnresolvedAbuseReport = $ref(false);
let currentPage = $computed(() => router.currentRef.value.child);
os.api('admin/abuse-user-reports', {
state: 'unresolved',
limit: 1,
}).then(reports => {
if (reports.length > 0) thereIsUnresolvedAbuseReport = true;
});
2021-10-10 09:19:16 +03:00
const NARROW_THRESHOLD = 600;
const ro = new ResizeObserver((entries, observer) => {
if (entries.length === 0) return;
narrow = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
});
2021-10-10 09:19:16 +03:00
const menuDef = $computed(() => [{
title: i18n.ts.quickAction,
items: [{
type: 'button',
icon: 'ti ti-search',
text: i18n.ts.lookup,
action: lookup,
}, ...(instance.disableRegistration ? [{
type: 'button',
icon: 'ti ti-user-plus',
enhance: 招待機能の改善 (#11195) * refactor(backend): 招待機能を改修 * feat(backend): 招待コードのcreate/delete/listエンドポイントを追加 * add(misskey-js): エンドポイントと型を追加 * change(backend): metaでinvite関連の情報も返すように * add(misskey-js): エンドポイントと型を追加 * add(backend): `/endpoints/invite/limit`を追加 * fix: createdByがnullableではなかったのを修正 * fix: relationが取得できていなかった問題を修正 * fix: パラメータを間違えていたのを修正 * feat(client): 招待ページを実装 * change(client): インスタンスメニューの「招待」押した場合に招待ページに飛ぶように変更 * feat: 招待コードをコピーできるように * change(backend): metaに招待コード発行に関する情報を持たせるのをやめる * feat: ロールごとに招待コードの発行上限数などを設定できるように * change(client): 招待コードをコピーしたときにダイアログを出すように * add: 招待に関する管理者用のエンドポイントを追加 * change(backend): モデレーターであれば作成者以外でも招待コードを削除できるように * change(backend): admin/invite/listはオフセットでページネーションするように * feat(client): 招待コードの管理ページを追加 * feat(client): 招待コードのリストをソートできるように * change: `admin/invite/create`のレスポンスを修正 * fix(client): 有効期限を指定できていなかった問題を修正 * refactor: 必要のない箇所を削除 * perf(backend): use limit() instead of take() * change(client): 作成ボタンを見た目を変更 * refactor: 招待コードの生成部分を共通化し、コード内に"01OI"のいずれかの文字を含まないように * fix(client): paginationの仕様が変わっていたので修正 * change(backend): expiresAtパラメータのnullを許容 * change(client): 有効期限を設けないときは日付の入力欄を非表示に * fix: 自身のポリシーよりもインスタンス側のポリシーが優先表示される問題を修正 * fix: n時間のときに「n時間間」となってしまうのを修正 * fix(backend): ポリシーが途中で変更されたときに作成可能数がマイナス表記になってしまうのを修正 * change(client): 招待コードのユーザー名が不明な理由を表示するように * update: CHANGELOG.md * lint * refactor * refactor * tweak ui * :art: * :art: * add(backend): indexを追加 * change(backend): indexの追加に伴う変更 * change(client): インスタンスメニューの「招待」の場所を変更 * add(frontend): MkInviteCode用のstorybookを追加 * Update misskey-js.api.md * fix(misskey-js): InviteのcreatedByの型が間違っていたのを修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
2023-07-15 03:57:58 +03:00
text: i18n.ts.createInviteCode,
action: invite,
}] : [])],
}, {
title: i18n.ts.administration,
items: [{
icon: 'ti ti-dashboard',
text: i18n.ts.dashboard,
to: '/admin/overview',
active: currentPage?.route.name === 'overview',
}, {
icon: 'ti ti-users',
text: i18n.ts.users,
to: '/admin/users',
active: currentPage?.route.name === 'users',
enhance: 招待機能の改善 (#11195) * refactor(backend): 招待機能を改修 * feat(backend): 招待コードのcreate/delete/listエンドポイントを追加 * add(misskey-js): エンドポイントと型を追加 * change(backend): metaでinvite関連の情報も返すように * add(misskey-js): エンドポイントと型を追加 * add(backend): `/endpoints/invite/limit`を追加 * fix: createdByがnullableではなかったのを修正 * fix: relationが取得できていなかった問題を修正 * fix: パラメータを間違えていたのを修正 * feat(client): 招待ページを実装 * change(client): インスタンスメニューの「招待」押した場合に招待ページに飛ぶように変更 * feat: 招待コードをコピーできるように * change(backend): metaに招待コード発行に関する情報を持たせるのをやめる * feat: ロールごとに招待コードの発行上限数などを設定できるように * change(client): 招待コードをコピーしたときにダイアログを出すように * add: 招待に関する管理者用のエンドポイントを追加 * change(backend): モデレーターであれば作成者以外でも招待コードを削除できるように * change(backend): admin/invite/listはオフセットでページネーションするように * feat(client): 招待コードの管理ページを追加 * feat(client): 招待コードのリストをソートできるように * change: `admin/invite/create`のレスポンスを修正 * fix(client): 有効期限を指定できていなかった問題を修正 * refactor: 必要のない箇所を削除 * perf(backend): use limit() instead of take() * change(client): 作成ボタンを見た目を変更 * refactor: 招待コードの生成部分を共通化し、コード内に"01OI"のいずれかの文字を含まないように * fix(client): paginationの仕様が変わっていたので修正 * change(backend): expiresAtパラメータのnullを許容 * change(client): 有効期限を設けないときは日付の入力欄を非表示に * fix: 自身のポリシーよりもインスタンス側のポリシーが優先表示される問題を修正 * fix: n時間のときに「n時間間」となってしまうのを修正 * fix(backend): ポリシーが途中で変更されたときに作成可能数がマイナス表記になってしまうのを修正 * change(client): 招待コードのユーザー名が不明な理由を表示するように * update: CHANGELOG.md * lint * refactor * refactor * tweak ui * :art: * :art: * add(backend): indexを追加 * change(backend): indexの追加に伴う変更 * change(client): インスタンスメニューの「招待」の場所を変更 * add(frontend): MkInviteCode用のstorybookを追加 * Update misskey-js.api.md * fix(misskey-js): InviteのcreatedByの型が間違っていたのを修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
2023-07-15 03:57:58 +03:00
}, {
icon: 'ti ti-user-plus',
text: i18n.ts.invite,
to: '/admin/invites',
active: currentPage?.route.name === 'invites',
2023-01-13 01:16:45 +02:00
}, {
icon: 'ti ti-badges',
text: i18n.ts.roles,
to: '/admin/roles',
active: currentPage?.route.name === 'roles',
}, {
2022-12-31 13:36:49 +02:00
icon: 'ti ti-icons',
text: i18n.ts.customEmojis,
to: '/admin/emojis',
active: currentPage?.route.name === 'emojis',
}, {
icon: 'ti ti-whirl',
text: i18n.ts.federation,
2023-01-09 03:07:37 +02:00
to: '/admin/federation',
active: currentPage?.route.name === 'federation',
}, {
2022-12-20 08:15:34 +02:00
icon: 'ti ti-clock-play',
text: i18n.ts.jobQueue,
to: '/admin/queue',
active: currentPage?.route.name === 'queue',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.files,
to: '/admin/files',
active: currentPage?.route.name === 'files',
}, {
icon: 'ti ti-speakerphone',
text: i18n.ts.announcements,
to: '/admin/announcements',
active: currentPage?.route.name === 'announcements',
}, {
icon: 'ti ti-ad',
text: i18n.ts.ads,
to: '/admin/ads',
active: currentPage?.route.name === 'ads',
}, {
icon: 'ti ti-exclamation-circle',
text: i18n.ts.abuseReports,
to: '/admin/abuses',
active: currentPage?.route.name === 'abuses',
}],
}, {
title: i18n.ts.settings,
items: [{
icon: 'ti ti-settings',
text: i18n.ts.general,
to: '/admin/settings',
active: currentPage?.route.name === 'settings',
}, {
icon: 'ti ti-paint',
text: i18n.ts.branding,
to: '/admin/branding',
active: currentPage?.route.name === 'branding',
2023-03-13 10:37:22 +02:00
}, {
icon: 'ti ti-shield',
text: i18n.ts.moderation,
to: '/admin/moderation',
active: currentPage?.route.name === 'moderation',
}, {
icon: 'ti ti-mail',
text: i18n.ts.emailServer,
to: '/admin/email-settings',
active: currentPage?.route.name === 'email-settings',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.objectStorage,
to: '/admin/object-storage',
active: currentPage?.route.name === 'object-storage',
}, {
icon: 'ti ti-lock',
text: i18n.ts.security,
to: '/admin/security',
active: currentPage?.route.name === 'security',
}, {
icon: 'ti ti-planet',
text: i18n.ts.relays,
to: '/admin/relays',
active: currentPage?.route.name === 'relays',
}, {
icon: 'ti ti-ban',
text: i18n.ts.instanceBlocking,
to: '/admin/instance-block',
active: currentPage?.route.name === 'instance-block',
}, {
2022-12-20 01:35:49 +02:00
icon: 'ti ti-ghost',
text: i18n.ts.proxyAccount,
to: '/admin/proxy-account',
active: currentPage?.route.name === 'proxy-account',
}, {
icon: 'ti ti-adjustments',
text: i18n.ts.other,
to: '/admin/other-settings',
active: currentPage?.route.name === 'other-settings',
}],
}, {
title: i18n.ts.info,
items: [{
icon: 'ti ti-database',
text: i18n.ts.database,
to: '/admin/database',
active: currentPage?.route.name === 'database',
}],
}]);
watch(narrow, () => {
if (currentPage?.route.name == null && !narrow) {
router.push('/admin/overview');
}
});
onMounted(() => {
ro.observe(el);
narrow = el.offsetWidth < NARROW_THRESHOLD;
if (currentPage?.route.name == null && !narrow) {
router.push('/admin/overview');
}
});
onActivated(() => {
narrow = el.offsetWidth < NARROW_THRESHOLD;
if (currentPage?.route.name == null && !narrow) {
router.push('/admin/overview');
}
});
onUnmounted(() => {
ro.disconnect();
});
watch(router.currentRef, (to) => {
2023-04-01 07:46:04 +03:00
if (to.route.path === '/admin' && to.child?.route.name == null && !narrow) {
router.replace('/admin/overview');
}
});
provideMetadataReceiver((info) => {
if (info == null) {
childInfo = null;
} else {
childInfo = info;
}
});
const invite = () => {
enhance: 招待機能の改善 (#11195) * refactor(backend): 招待機能を改修 * feat(backend): 招待コードのcreate/delete/listエンドポイントを追加 * add(misskey-js): エンドポイントと型を追加 * change(backend): metaでinvite関連の情報も返すように * add(misskey-js): エンドポイントと型を追加 * add(backend): `/endpoints/invite/limit`を追加 * fix: createdByがnullableではなかったのを修正 * fix: relationが取得できていなかった問題を修正 * fix: パラメータを間違えていたのを修正 * feat(client): 招待ページを実装 * change(client): インスタンスメニューの「招待」押した場合に招待ページに飛ぶように変更 * feat: 招待コードをコピーできるように * change(backend): metaに招待コード発行に関する情報を持たせるのをやめる * feat: ロールごとに招待コードの発行上限数などを設定できるように * change(client): 招待コードをコピーしたときにダイアログを出すように * add: 招待に関する管理者用のエンドポイントを追加 * change(backend): モデレーターであれば作成者以外でも招待コードを削除できるように * change(backend): admin/invite/listはオフセットでページネーションするように * feat(client): 招待コードの管理ページを追加 * feat(client): 招待コードのリストをソートできるように * change: `admin/invite/create`のレスポンスを修正 * fix(client): 有効期限を指定できていなかった問題を修正 * refactor: 必要のない箇所を削除 * perf(backend): use limit() instead of take() * change(client): 作成ボタンを見た目を変更 * refactor: 招待コードの生成部分を共通化し、コード内に"01OI"のいずれかの文字を含まないように * fix(client): paginationの仕様が変わっていたので修正 * change(backend): expiresAtパラメータのnullを許容 * change(client): 有効期限を設けないときは日付の入力欄を非表示に * fix: 自身のポリシーよりもインスタンス側のポリシーが優先表示される問題を修正 * fix: n時間のときに「n時間間」となってしまうのを修正 * fix(backend): ポリシーが途中で変更されたときに作成可能数がマイナス表記になってしまうのを修正 * change(client): 招待コードのユーザー名が不明な理由を表示するように * update: CHANGELOG.md * lint * refactor * refactor * tweak ui * :art: * :art: * add(backend): indexを追加 * change(backend): indexの追加に伴う変更 * change(client): インスタンスメニューの「招待」の場所を変更 * add(frontend): MkInviteCode用のstorybookを追加 * Update misskey-js.api.md * fix(misskey-js): InviteのcreatedByの型が間違っていたのを修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
2023-07-15 03:57:58 +03:00
os.api('admin/invite/create').then(x => {
os.alert({
type: 'info',
enhance: 招待機能の改善 (#11195) * refactor(backend): 招待機能を改修 * feat(backend): 招待コードのcreate/delete/listエンドポイントを追加 * add(misskey-js): エンドポイントと型を追加 * change(backend): metaでinvite関連の情報も返すように * add(misskey-js): エンドポイントと型を追加 * add(backend): `/endpoints/invite/limit`を追加 * fix: createdByがnullableではなかったのを修正 * fix: relationが取得できていなかった問題を修正 * fix: パラメータを間違えていたのを修正 * feat(client): 招待ページを実装 * change(client): インスタンスメニューの「招待」押した場合に招待ページに飛ぶように変更 * feat: 招待コードをコピーできるように * change(backend): metaに招待コード発行に関する情報を持たせるのをやめる * feat: ロールごとに招待コードの発行上限数などを設定できるように * change(client): 招待コードをコピーしたときにダイアログを出すように * add: 招待に関する管理者用のエンドポイントを追加 * change(backend): モデレーターであれば作成者以外でも招待コードを削除できるように * change(backend): admin/invite/listはオフセットでページネーションするように * feat(client): 招待コードの管理ページを追加 * feat(client): 招待コードのリストをソートできるように * change: `admin/invite/create`のレスポンスを修正 * fix(client): 有効期限を指定できていなかった問題を修正 * refactor: 必要のない箇所を削除 * perf(backend): use limit() instead of take() * change(client): 作成ボタンを見た目を変更 * refactor: 招待コードの生成部分を共通化し、コード内に"01OI"のいずれかの文字を含まないように * fix(client): paginationの仕様が変わっていたので修正 * change(backend): expiresAtパラメータのnullを許容 * change(client): 有効期限を設けないときは日付の入力欄を非表示に * fix: 自身のポリシーよりもインスタンス側のポリシーが優先表示される問題を修正 * fix: n時間のときに「n時間間」となってしまうのを修正 * fix(backend): ポリシーが途中で変更されたときに作成可能数がマイナス表記になってしまうのを修正 * change(client): 招待コードのユーザー名が不明な理由を表示するように * update: CHANGELOG.md * lint * refactor * refactor * tweak ui * :art: * :art: * add(backend): indexを追加 * change(backend): indexの追加に伴う変更 * change(client): インスタンスメニューの「招待」の場所を変更 * add(frontend): MkInviteCode用のstorybookを追加 * Update misskey-js.api.md * fix(misskey-js): InviteのcreatedByの型が間違っていたのを修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
2023-07-15 03:57:58 +03:00
text: x?.[0].code,
});
}).catch(err => {
os.alert({
type: 'error',
text: err,
});
});
};
const lookup = (ev) => {
os.popupMenu([{
text: i18n.ts.user,
icon: 'ti ti-user',
action: () => {
lookupUser();
},
}, {
text: i18n.ts.note,
icon: 'ti ti-pencil',
action: () => {
alert('TODO');
},
}, {
text: i18n.ts.file,
icon: 'ti ti-cloud',
action: () => {
alert('TODO');
},
}, {
text: i18n.ts.instance,
icon: 'ti ti-planet',
action: () => {
alert('TODO');
},
}], ev.currentTarget ?? ev.target);
};
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata(INFO);
defineExpose({
header: {
title: i18n.ts.controlPanel,
},
});
</script>
<style lang="scss" scoped>
.hiyeyicy {
&.wide {
display: flex;
margin: 0 auto;
height: 100%;
> .nav {
width: 32%;
2021-10-10 09:19:16 +03:00
max-width: 280px;
box-sizing: border-box;
border-right: solid 0.5px var(--divider);
overflow: auto;
2021-10-10 09:19:16 +03:00
height: 100%;
}
2020-08-13 17:02:43 +03:00
> .main {
flex: 1;
min-width: 0;
}
}
2021-10-10 09:19:16 +03:00
> .nav {
2021-10-24 14:16:55 +03:00
.lxpfedzu {
> .info {
margin: 16px 0;
}
2021-10-24 14:16:55 +03:00
> .banner {
margin: 16px;
2021-10-24 14:16:55 +03:00
> .icon {
display: block;
margin: auto;
height: 42px;
border-radius: 8px;
}
}
}
}
}
</style>