mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 13:25:45 +02:00
refactor(frontend): os.select, MkSelectのitem指定をオブジェクトによる定義に統一し、型を狭める (#16475)
* refactor(frontend): MkSelectのitem指定をオブジェクトによる定義に統一 * fix * spdx * fix * fix os.select * fix lint * add comment * fix * fix: os.select対応漏れを修正 * fix * fix * fix: MkSelectのmodelに対する型チェックを厳格化 * fix * fix * fix * Update packages/frontend/src/components/MkEmbedCodeGenDialog.vue Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * fix * fix types * fix * fix * Update packages/frontend/src/pages/admin/roles.editor.vue Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * fix: MkSelectに直接配列を指定している場合に正常に型が解決されるように --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
@@ -9,31 +9,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<template #header>Chart</template>
|
||||
<div :class="$style.chart">
|
||||
<div class="selects">
|
||||
<MkSelect v-model="chartSrc" style="margin: 0; flex: 1;">
|
||||
<optgroup v-if="shouldShowFederation" :label="i18n.ts.federation">
|
||||
<option value="federation">{{ i18n.ts._charts.federation }}</option>
|
||||
<option value="ap-request">{{ i18n.ts._charts.apRequest }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="i18n.ts.users">
|
||||
<option value="users">{{ i18n.ts._charts.usersIncDec }}</option>
|
||||
<option value="users-total">{{ i18n.ts._charts.usersTotal }}</option>
|
||||
<option value="active-users">{{ i18n.ts._charts.activeUsers }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="i18n.ts.notes">
|
||||
<option value="notes">{{ i18n.ts._charts.notesIncDec }}</option>
|
||||
<option value="local-notes">{{ i18n.ts._charts.localNotesIncDec }}</option>
|
||||
<option v-if="shouldShowFederation" value="remote-notes">{{ i18n.ts._charts.remoteNotesIncDec }}</option>
|
||||
<option value="notes-total">{{ i18n.ts._charts.notesTotal }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="i18n.ts.drive">
|
||||
<option value="drive-files">{{ i18n.ts._charts.filesIncDec }}</option>
|
||||
<option value="drive">{{ i18n.ts._charts.storageUsageIncDec }}</option>
|
||||
</optgroup>
|
||||
</MkSelect>
|
||||
<MkSelect v-model="chartSpan" style="margin: 0 0 0 10px;">
|
||||
<option value="hour">{{ i18n.ts.perHour }}</option>
|
||||
<option value="day">{{ i18n.ts.perDay }}</option>
|
||||
</MkSelect>
|
||||
<MkSelect v-model="chartSrc" :items="chartSrcDef" style="margin: 0; flex: 1;"></MkSelect>
|
||||
<MkSelect v-model="chartSpan" :items="chartSpanDef" style="margin: 0 0 0 10px;"></MkSelect>
|
||||
</div>
|
||||
<div class="chart _panel">
|
||||
<MkChart :src="chartSrc" :span="chartSpan" :limit="chartLimit" :detailed="true"></MkChart>
|
||||
@@ -43,13 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
<MkFoldableSection class="item">
|
||||
<template #header>Active users heatmap</template>
|
||||
<MkSelect v-model="heatmapSrc" style="margin: 0 0 12px 0;">
|
||||
<option value="active-users">Active users</option>
|
||||
<option value="notes">Notes</option>
|
||||
<option v-if="shouldShowFederation" value="ap-requests-inbox-received">AP Requests: inboxReceived</option>
|
||||
<option v-if="shouldShowFederation" value="ap-requests-deliver-succeeded">AP Requests: deliverSucceeded</option>
|
||||
<option v-if="shouldShowFederation" value="ap-requests-deliver-failed">AP Requests: deliverFailed</option>
|
||||
</MkSelect>
|
||||
<MkSelect v-model="heatmapSrc" :items="heatmapSrcDef" style="margin: 0 0 12px 0;"></MkSelect>
|
||||
<div class="_panel" :class="$style.heatmap">
|
||||
<MkHeatmap :src="heatmapSrc" :label="'Read & Write'"/>
|
||||
</div>
|
||||
@@ -84,10 +55,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref, computed, useTemplateRef } from 'vue';
|
||||
import { onMounted, computed, useTemplateRef } from 'vue';
|
||||
import { Chart } from 'chart.js';
|
||||
import type { HeatmapSource } from '@/components/MkHeatmap.vue';
|
||||
import MkSelect from '@/components/MkSelect.vue';
|
||||
import type { MkSelectItem, ItemOption } from '@/components/MkSelect.vue';
|
||||
import MkChart from '@/components/MkChart.vue';
|
||||
import type { ChartSrc } from '@/components/MkChart.vue';
|
||||
import { useChartTooltip } from '@/composables/use-chart-tooltip.js';
|
||||
@@ -101,15 +72,96 @@ import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import MkRetentionHeatmap from '@/components/MkRetentionHeatmap.vue';
|
||||
import MkRetentionLineChart from '@/components/MkRetentionLineChart.vue';
|
||||
import { initChart } from '@/utility/init-chart.js';
|
||||
import { useMkSelect } from '@/composables/use-mkselect.js';
|
||||
|
||||
initChart();
|
||||
|
||||
const shouldShowFederation = computed(() => instance.federation !== 'none' || $i?.isModerator);
|
||||
|
||||
const chartLimit = 500;
|
||||
const chartSpan = ref<'hour' | 'day'>('hour');
|
||||
const chartSrc = ref<ChartSrc>('active-users');
|
||||
const heatmapSrc = ref<HeatmapSource>('active-users');
|
||||
const {
|
||||
model: chartSpan,
|
||||
def: chartSpanDef,
|
||||
} = useMkSelect({
|
||||
items: [
|
||||
{ value: 'hour', label: i18n.ts.perHour },
|
||||
{ value: 'day', label: i18n.ts.perDay },
|
||||
],
|
||||
initialValue: 'hour',
|
||||
});
|
||||
const {
|
||||
model: chartSrc,
|
||||
def: chartSrcDef,
|
||||
} = useMkSelect({
|
||||
items: computed<MkSelectItem<ChartSrc>[]>(() => {
|
||||
const items: MkSelectItem<ChartSrc>[] = [];
|
||||
|
||||
if (shouldShowFederation.value) {
|
||||
items.push({
|
||||
type: 'group',
|
||||
label: i18n.ts.federation,
|
||||
items: [
|
||||
{ value: 'federation', label: i18n.ts._charts.federation },
|
||||
{ value: 'ap-request', label: i18n.ts._charts.apRequest },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
items.push({
|
||||
type: 'group',
|
||||
label: i18n.ts.users,
|
||||
items: [
|
||||
{ value: 'users', label: i18n.ts._charts.usersIncDec },
|
||||
{ value: 'users-total', label: i18n.ts._charts.usersTotal },
|
||||
{ value: 'active-users', label: i18n.ts._charts.activeUsers },
|
||||
],
|
||||
});
|
||||
|
||||
const notesItems: ItemOption<ChartSrc>[] = [
|
||||
{ value: 'notes', label: i18n.ts._charts.notesIncDec },
|
||||
{ value: 'local-notes', label: i18n.ts._charts.localNotesIncDec },
|
||||
];
|
||||
|
||||
if (shouldShowFederation.value) notesItems.push({ value: 'remote-notes', label: i18n.ts._charts.remoteNotesIncDec });
|
||||
|
||||
notesItems.push(
|
||||
{ value: 'notes-total', label: i18n.ts._charts.notesTotal },
|
||||
);
|
||||
|
||||
items.push({
|
||||
type: 'group',
|
||||
label: i18n.ts.notes,
|
||||
items: notesItems,
|
||||
});
|
||||
|
||||
items.push({
|
||||
type: 'group',
|
||||
label: i18n.ts.drive,
|
||||
items: [
|
||||
{ value: 'drive-files', label: i18n.ts._charts.filesIncDec },
|
||||
{ value: 'drive', label: i18n.ts._charts.storageUsageIncDec },
|
||||
],
|
||||
});
|
||||
|
||||
return items;
|
||||
}),
|
||||
initialValue: 'active-users',
|
||||
});
|
||||
const {
|
||||
model: heatmapSrc,
|
||||
def: heatmapSrcDef,
|
||||
} = useMkSelect({
|
||||
items: computed(() => [
|
||||
{ value: 'active-users' as const, label: 'Active Users' },
|
||||
{ value: 'notes' as const, label: 'Notes' },
|
||||
...(shouldShowFederation.value ? [
|
||||
{ value: 'ap-requests-inbox-received' as const, label: 'AP Requests: inboxReceived' },
|
||||
{ value: 'ap-requests-deliver-succeeded' as const, label: 'AP Requests: deliverSucceeded' },
|
||||
{ value: 'ap-requests-deliver-failed' as const, label: 'AP Requests: deliverFailed' },
|
||||
] : []),
|
||||
]),
|
||||
initialValue: 'active-users',
|
||||
});
|
||||
const subDoughnutEl = useTemplateRef('subDoughnutEl');
|
||||
const pubDoughnutEl = useTemplateRef('pubDoughnutEl');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user