2023-01-12 14:02:26 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="700">
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkButton primary rounded @click="create"><i class="ti ti-plus"></i> {{ i18n.ts._role.new }}</MkButton>
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role.baseRole }}</template>
|
2023-01-19 03:39:23 +02:00
|
|
|
<div class="_gaps_s">
|
2023-01-15 09:52:12 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.rateLimitFactor }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ Math.floor(policies.rateLimitFactor * 100) }}%</template>
|
|
|
|
<MkRange :model-value="policies.rateLimitFactor * 100" :min="30" :max="300" :step="10" :text-converter="(v) => `${v}%`" @update:model-value="v => policies.rateLimitFactor = (v / 100)">
|
2023-01-15 09:52:12 +02:00
|
|
|
<template #caption>{{ i18n.ts._role._options.descriptionOfRateLimitFactor }}</template>
|
|
|
|
</MkRange>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-12 14:02:26 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.gtlAvailable }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.gtlAvailable ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.gtlAvailable">
|
2023-01-12 14:02:26 +02:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.ltlAvailable }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.ltlAvailable ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.ltlAvailable">
|
2023-01-12 14:02:26 +02:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.canPublicNote }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.canPublicNote ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canPublicNote">
|
2023-01-12 14:02:26 +02:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-13 07:22:53 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.canInvite }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.canInvite ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canInvite">
|
2023-01-13 07:22:53 +02:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-13 07:58:27 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.canManageCustomEmojis }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.canManageCustomEmojis ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canManageCustomEmojis">
|
2023-01-13 07:58:27 +02:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-12 14:02:26 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.driveCapacityMb }}MB</template>
|
|
|
|
<MkInput v-model="policies.driveCapacityMb" type="number">
|
2023-01-12 14:02:26 +02:00
|
|
|
<template #suffix>MB</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-14 11:04:56 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.pinMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.pinLimit }}</template>
|
|
|
|
<MkInput v-model="policies.pinLimit" type="number">
|
2023-01-14 11:04:56 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-12 14:02:26 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.antennaMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.antennaLimit }}</template>
|
|
|
|
<MkInput v-model="policies.antennaLimit" type="number">
|
2023-01-12 14:02:26 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
2023-01-14 01:04:38 +02:00
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.wordMuteMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.wordMuteLimit }}</template>
|
|
|
|
<MkInput v-model="policies.wordMuteLimit" type="number">
|
2023-01-14 01:04:38 +02:00
|
|
|
<template #suffix>chars</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-14 03:48:11 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.webhookMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.webhookLimit }}</template>
|
|
|
|
<MkInput v-model="policies.webhookLimit" type="number">
|
2023-01-14 03:48:11 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-14 09:14:24 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.clipMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.clipLimit }}</template>
|
|
|
|
<MkInput v-model="policies.clipLimit" type="number">
|
2023-01-14 09:14:24 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.noteEachClipsMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.noteEachClipsLimit }}</template>
|
|
|
|
<MkInput v-model="policies.noteEachClipsLimit" type="number">
|
2023-01-14 09:14:24 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-14 10:38:16 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.userListMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.userListLimit }}</template>
|
|
|
|
<MkInput v-model="policies.userListLimit" type="number">
|
2023-01-14 10:38:16 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.userEachUserListsMax }}</template>
|
2023-01-15 13:52:53 +02:00
|
|
|
<template #suffix>{{ policies.userEachUserListsLimit }}</template>
|
|
|
|
<MkInput v-model="policies.userEachUserListsLimit" type="number">
|
2023-01-14 10:38:16 +02:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-16 04:21:04 +02:00
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role._options.canHideAds }}</template>
|
|
|
|
<template #suffix>{{ policies.canHideAds ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canHideAds">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-12 14:02:26 +02:00
|
|
|
<MkButton primary rounded @click="updateBaseRole">{{ i18n.ts.save }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<MkRolePreview v-for="role in roles" :key="role.id" :role="role"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-01-15 13:52:53 +02:00
|
|
|
import { computed, reactive } from 'vue';
|
2023-01-12 14:02:26 +02:00
|
|
|
import XHeader from './_header_.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-15 09:52:12 +02:00
|
|
|
import MkRange from '@/components/MkRange.vue';
|
2023-01-12 14:02:26 +02:00
|
|
|
import MkRolePreview from '@/components/MkRolePreview.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { instance } from '@/instance';
|
|
|
|
import { useRouter } from '@/router';
|
|
|
|
|
2023-01-15 13:52:53 +02:00
|
|
|
const ROLE_POLICIES = [
|
|
|
|
'gtlAvailable',
|
|
|
|
'ltlAvailable',
|
|
|
|
'canPublicNote',
|
|
|
|
'canInvite',
|
|
|
|
'canManageCustomEmojis',
|
2023-01-16 04:21:04 +02:00
|
|
|
'canHideAds',
|
2023-01-15 13:52:53 +02:00
|
|
|
'driveCapacityMb',
|
|
|
|
'pinLimit',
|
|
|
|
'antennaLimit',
|
|
|
|
'wordMuteLimit',
|
|
|
|
'webhookLimit',
|
|
|
|
'clipLimit',
|
|
|
|
'noteEachClipsLimit',
|
|
|
|
'userListLimit',
|
|
|
|
'userEachUserListsLimit',
|
|
|
|
'rateLimitFactor',
|
|
|
|
] as const;
|
|
|
|
|
2023-01-12 14:02:26 +02:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const roles = await os.api('admin/roles/list');
|
|
|
|
|
2023-01-15 13:52:53 +02:00
|
|
|
const policies = reactive<Record<typeof ROLE_POLICIES[number], any>>({});
|
|
|
|
for (const ROLE_POLICY of ROLE_POLICIES) {
|
|
|
|
policies[ROLE_POLICY] = instance.policies[ROLE_POLICY];
|
|
|
|
}
|
2023-01-12 14:02:26 +02:00
|
|
|
|
|
|
|
async function updateBaseRole() {
|
2023-01-15 13:52:53 +02:00
|
|
|
await os.apiWithDialog('admin/roles/update-default-policies', {
|
|
|
|
policies,
|
2023-01-12 14:02:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
router.push('/admin/roles/new');
|
|
|
|
}
|
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.roles,
|
|
|
|
icon: 'ti ti-badges',
|
|
|
|
})));
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
|
|
|
|
</style>
|