mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-02 20:53:08 +02:00
a6a91fec3a
* add: safeFloatParserを追加 * fix: 欠けていた型を追加 * refactor: pageBlockTypesをjson-schemaに移植 * refactor: components/global内の型エラーが出ている箇所を修正 * lint: fix null check style * refactor: fix type error * refactor: fix some type errors * fix: 翻訳が抜けていた箇所を修正 * refactor: getJsonSchemaで正しいスキーマが返されるように修正 * fix: MkChartの型エラーとbytesオプションが機能していない問題を修正 * fix(misskey-js): `drive`->`folderUpdated`のpayloadの型が間違っていたのを修正 * refactor: fix some type errors * change: Captcha読み込み中の文言をLoadingに変更 * refactor(backend/misskey-js): MainEventの型を改善 * refactor: chartjs-plugin-gradientが二重でpluginに登録されていたのを修正 * update: misskey-js.api.md * refactor: fix some type errors * fix: backendのtypecheckが落ちていたのを修正 * update: misskey-js.api.md * add: json-schemaのnoteにpollの型定義を追加 * refactor: noteのjson-schemaの型を改善 * refactor: MkPoll * refactor: fix some type errors * change: UserLiteにisLockedを持たせるように * fix: notificationスキーマにroleが含まれていないのを修正 * Revert "change: UserLiteにisLockedを持たせるように" This reverts commit 1bb0c8e7a9b19a4e9f21bf7381712b98f27672a5. * fix: フォロー通知から鍵垢へのフォローを行うと処理中のまま止まってしまう問題を修正 * refactor: noteスキーマのvisibilityにenumを追加 * change: deepCloneのCloneableTypeにundefinedを追加 * refactor: fix some type errors * refactor: `allowEmpty: false`を使用していた箇所を`minLength: 1`に置き換え * enhance: API 'retension' のresponseの型を追加 * fix: Chart関連のtooltipが正しい位置に表示されない問題を修正 * refactor: fix some type errors * fix: 型情報が不足していたのを修正 * enhance: announcementスキーマにenumを追加 * enhance: ロールポリシーの型定義をRoleServiceからjson-schemaに移植 * refactor: policiesを`ref: RolePolicies`に統一 * fix: API `meta` のレスポンスの型にpoliciesが含まれていないのを修正 * refactor: fix some type errors * fix: backendのlintが落ちているのを修正 * fix: MkFoldableSectionの開閉時のanimationが適用されていない問題を修正 * fix: backendのtypecheckが落ちているのを修正 * update: run build-misskey-js-with-types * fix: MkDialogのmount時に文字数制限の判定が行われない問題を修正 * update: CHANGELOG.md * refactor: MkUserSelectDialogの型を改善 * fix: deepCloneでundefinedはcloneしないように (#9207) * change: frontendのcloneをbackend側にも反映 * update: CHANGELOG.md * fix: RoleServiceからPackを通して型RolePoliciesに依存させないように * Update packages/frontend/src/scripts/get-note-summary.ts * revert RoleService.ts changes * change: optional chaining -> non-null assertion * remove: unused import * fix: propsで渡されたuserがUserLiteの場合に意図しない動作になってしまうのを修正 * change: fix null check style * refactor: fix type error * change: fix null check style * Update packages/frontend/src/components/MkDrive.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * refactor: css moduleでglobalを使わないように * refactor: roleのiconUrlは必ず存在するものとして扱うように * enhance: MenuButtonのactiveにcomputedを受け付けられるように * Update packages/frontend/src/components/MkNotePreview.vue * Update MkWindow.vue * refactor: notification.noteは必ず存在するものとして扱うように * Update packages/frontend/src/components/MkNotification.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * fix: MkSignupDialogでdoneのemit時にresを含んでいなかったのを修正 * Update packages/frontend/src/scripts/clone.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * refactor: 不要な返り値の型を削除 * refactor: 不要なnullチェックを削除 * update: misskey-js-autogen * update: clone.ts * refactor * Update MkNotification.vue * Update MkNotification.vue * ✌️ * Update MkNotification.vue * Update MkNotification.vue * Update MkNotification.vue * Update MkNotifications.vue * Update MkUserSetupDialog.Profile.vue * Update MkUserCardMini.vue * ✌️ * Update MkMenu.vue --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
277 lines
7 KiB
Vue
277 lines
7 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<div :class="$style.root">
|
|
<MkFoldableSection class="item">
|
|
<template #header>Chart</template>
|
|
<div :class="$style.chart">
|
|
<div class="selects">
|
|
<MkSelect v-model="chartSrc" style="margin: 0; flex: 1;">
|
|
<optgroup :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 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>
|
|
</div>
|
|
<div class="chart _panel">
|
|
<MkChart :src="chartSrc" :span="chartSpan" :limit="chartLimit" :detailed="true"></MkChart>
|
|
</div>
|
|
</div>
|
|
</MkFoldableSection>
|
|
|
|
<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 value="ap-requests-inbox-received">AP Requests: inboxReceived</option>
|
|
<option value="ap-requests-deliver-succeeded">AP Requests: deliverSucceeded</option>
|
|
<option value="ap-requests-deliver-failed">AP Requests: deliverFailed</option>
|
|
</MkSelect>
|
|
<div class="_panel" :class="$style.heatmap">
|
|
<MkHeatmap :src="heatmapSrc" :label="'Read & Write'"/>
|
|
</div>
|
|
</MkFoldableSection>
|
|
|
|
<MkFoldableSection class="item">
|
|
<template #header>Retention rate</template>
|
|
<div class="_panel" :class="$style.retentionHeatmap">
|
|
<MkRetentionHeatmap/>
|
|
</div>
|
|
<div class="_panel" :class="$style.retentionLine">
|
|
<MkRetentionLineChart/>
|
|
</div>
|
|
</MkFoldableSection>
|
|
|
|
<MkFoldableSection class="item">
|
|
<template #header>Federation</template>
|
|
<div :class="$style.federation">
|
|
<div class="pies">
|
|
<div class="sub">
|
|
<div class="title">Sub</div>
|
|
<canvas ref="subDoughnutEl"></canvas>
|
|
</div>
|
|
<div class="pub">
|
|
<div class="title">Pub</div>
|
|
<canvas ref="pubDoughnutEl"></canvas>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</MkFoldableSection>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref, shallowRef } from 'vue';
|
|
import { Chart } from 'chart.js';
|
|
import MkSelect from '@/components/MkSelect.vue';
|
|
import MkChart from '@/components/MkChart.vue';
|
|
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
|
|
import * as os from '@/os.js';
|
|
import { misskeyApiGet } from '@/scripts/misskey-api.js';
|
|
import { i18n } from '@/i18n.js';
|
|
import MkHeatmap, { type HeatmapSource } from '@/components/MkHeatmap.vue';
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
|
import MkRetentionHeatmap from '@/components/MkRetentionHeatmap.vue';
|
|
import MkRetentionLineChart from '@/components/MkRetentionLineChart.vue';
|
|
import { initChart } from '@/scripts/init-chart.js';
|
|
|
|
initChart();
|
|
|
|
const chartLimit = 500;
|
|
const chartSpan = ref<'hour' | 'day'>('hour');
|
|
const chartSrc = ref('active-users');
|
|
const heatmapSrc = ref<HeatmapSource>('active-users');
|
|
const subDoughnutEl = shallowRef<HTMLCanvasElement>();
|
|
const pubDoughnutEl = shallowRef<HTMLCanvasElement>();
|
|
|
|
const { handler: externalTooltipHandler1 } = useChartTooltip({
|
|
position: 'middle',
|
|
});
|
|
const { handler: externalTooltipHandler2 } = useChartTooltip({
|
|
position: 'middle',
|
|
});
|
|
|
|
function createDoughnut(chartEl, tooltip, data) {
|
|
const chartInstance = new Chart(chartEl, {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: data.map(x => x.name),
|
|
datasets: [{
|
|
backgroundColor: data.map(x => x.color),
|
|
borderColor: getComputedStyle(document.documentElement).getPropertyValue('--panel'),
|
|
borderWidth: 2,
|
|
hoverOffset: 0,
|
|
data: data.map(x => x.value),
|
|
}],
|
|
},
|
|
options: {
|
|
maintainAspectRatio: false,
|
|
layout: {
|
|
padding: {
|
|
left: 16,
|
|
right: 16,
|
|
top: 16,
|
|
bottom: 16,
|
|
},
|
|
},
|
|
onClick: (ev) => {
|
|
if (ev.native == null) return;
|
|
const hit = chartInstance.getElementsAtEventForMode(ev.native, 'nearest', { intersect: true }, false)[0];
|
|
if (hit && data[hit.index].onClick) {
|
|
data[hit.index].onClick();
|
|
}
|
|
},
|
|
plugins: {
|
|
legend: {
|
|
display: false,
|
|
},
|
|
tooltip: {
|
|
enabled: false,
|
|
mode: 'index',
|
|
animation: {
|
|
duration: 0,
|
|
},
|
|
external: tooltip,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return chartInstance;
|
|
}
|
|
|
|
onMounted(() => {
|
|
misskeyApiGet('federation/stats', { limit: 30 }).then(fedStats => {
|
|
type ChartData = {
|
|
name: string,
|
|
color: string | null,
|
|
value: number,
|
|
onClick?: () => void,
|
|
}[];
|
|
|
|
const subs: ChartData = fedStats.topSubInstances.map(x => ({
|
|
name: x.host,
|
|
color: x.themeColor,
|
|
value: x.followersCount,
|
|
onClick: () => {
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
},
|
|
}));
|
|
|
|
subs.push({
|
|
name: '(other)',
|
|
color: '#80808080',
|
|
value: fedStats.otherFollowersCount,
|
|
});
|
|
|
|
createDoughnut(subDoughnutEl.value, externalTooltipHandler1, subs);
|
|
|
|
const pubs: ChartData = fedStats.topPubInstances.map(x => ({
|
|
name: x.host,
|
|
color: x.themeColor,
|
|
value: x.followingCount,
|
|
onClick: () => {
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
},
|
|
}));
|
|
|
|
pubs.push({
|
|
name: '(other)',
|
|
color: '#80808080',
|
|
value: fedStats.otherFollowingCount,
|
|
});
|
|
|
|
createDoughnut(pubDoughnutEl.value, externalTooltipHandler2, pubs);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
&:global {
|
|
> .item {
|
|
margin-bottom: 16px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.chart {
|
|
&:global {
|
|
> .selects {
|
|
display: flex;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
> .chart {
|
|
padding: 16px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.heatmap {
|
|
padding: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.retentionHeatmap {
|
|
padding: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.retentionLine {
|
|
padding: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.federation {
|
|
&:global {
|
|
> .pies {
|
|
display: flex;
|
|
gap: 16px;
|
|
|
|
> .sub, > .pub {
|
|
flex: 1;
|
|
min-width: 0;
|
|
position: relative;
|
|
background: var(--panel);
|
|
border-radius: var(--radius);
|
|
padding: 24px;
|
|
max-height: 300px;
|
|
|
|
> .title {
|
|
position: absolute;
|
|
top: 24px;
|
|
left: 24px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|