mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-26 03:47:40 -07:00
Refactor admin/overview to use Composition API (#8674)
* refactor(client): refactor admin/overview to use Composition API * fix(client): apply review suggestions
This commit is contained in:
parent
4633b7547e
commit
1a2447d38c
1 changed files with 38 additions and 80 deletions
|
@ -5,20 +5,20 @@
|
||||||
<div class="label">Users</div>
|
<div class="label">Users</div>
|
||||||
<div class="value _monospace">
|
<div class="value _monospace">
|
||||||
{{ number(stats.originalUsersCount) }}
|
{{ number(stats.originalUsersCount) }}
|
||||||
<MkNumberDiff v-if="usersComparedToThePrevDay != null" v-tooltip="$ts.dayOverDayChanges" class="diff" :value="usersComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
|
<MkNumberDiff v-if="usersComparedToThePrevDay != null" v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="usersComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="number _panel">
|
<div class="number _panel">
|
||||||
<div class="label">Notes</div>
|
<div class="label">Notes</div>
|
||||||
<div class="value _monospace">
|
<div class="value _monospace">
|
||||||
{{ number(stats.originalNotesCount) }}
|
{{ number(stats.originalNotesCount) }}
|
||||||
<MkNumberDiff v-if="notesComparedToThePrevDay != null" v-tooltip="$ts.dayOverDayChanges" class="diff" :value="notesComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
|
<MkNumberDiff v-if="notesComparedToThePrevDay != null" v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="notesComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MkContainer :foldable="true" class="charts">
|
<MkContainer :foldable="true" class="charts">
|
||||||
<template #header><i class="fas fa-chart-bar"></i>{{ $ts.charts }}</template>
|
<template #header><i class="fas fa-chart-bar"></i>{{ i18n.ts.charts }}</template>
|
||||||
<div style="padding: 12px;">
|
<div style="padding: 12px;">
|
||||||
<MkInstanceStats :chart-limit="500" :detailed="true"/>
|
<MkInstanceStats :chart-limit="500" :detailed="true"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<!--<XMetrics/>-->
|
<!--<XMetrics/>-->
|
||||||
|
|
||||||
<MkFolder style="margin: var(--margin)">
|
<MkFolder style="margin: var(--margin)">
|
||||||
<template #header><i class="fas fa-info-circle"></i> {{ $ts.info }}</template>
|
<template #header><i class="fas fa-info-circle"></i> {{ i18n.ts.info }}</template>
|
||||||
<div class="cfcdecdf">
|
<div class="cfcdecdf">
|
||||||
<div class="number _panel">
|
<div class="number _panel">
|
||||||
<div class="label">Misskey</div>
|
<div class="label">Misskey</div>
|
||||||
|
@ -65,103 +65,61 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { computed, defineComponent, markRaw, version as vueVersion } from 'vue';
|
import { markRaw, version as vueVersion, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
||||||
import MkInstanceStats from '@/components/instance-stats.vue';
|
import MkInstanceStats from '@/components/instance-stats.vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
|
||||||
import MkSelect from '@/components/form/select.vue';
|
|
||||||
import MkNumberDiff from '@/components/number-diff.vue';
|
import MkNumberDiff from '@/components/number-diff.vue';
|
||||||
import MkContainer from '@/components/ui/container.vue';
|
import MkContainer from '@/components/ui/container.vue';
|
||||||
import MkFolder from '@/components/ui/folder.vue';
|
import MkFolder from '@/components/ui/folder.vue';
|
||||||
import MkQueueChart from '@/components/queue-chart.vue';
|
import MkQueueChart from '@/components/queue-chart.vue';
|
||||||
import { version, url } from '@/config';
|
import { version, url } from '@/config';
|
||||||
import bytes from '@/filters/bytes';
|
|
||||||
import number from '@/filters/number';
|
import number from '@/filters/number';
|
||||||
import XMetrics from './metrics.vue';
|
import XMetrics from './metrics.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { stream } from '@/stream';
|
import { stream } from '@/stream';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
let stats: any = $ref(null);
|
||||||
components: {
|
let serverInfo: any = $ref(null);
|
||||||
MkNumberDiff,
|
let usersComparedToThePrevDay: any = $ref(null);
|
||||||
MkInstanceStats,
|
let notesComparedToThePrevDay: any = $ref(null);
|
||||||
MkContainer,
|
const queueStatsConnection = markRaw(stream.useChannel('queueStats'));
|
||||||
MkFolder,
|
|
||||||
MkQueueChart,
|
|
||||||
XMetrics,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
onMounted(async () => {
|
||||||
|
os.api('stats', {}).then(statsResponse => {
|
||||||
data() {
|
stats = statsResponse;
|
||||||
return {
|
|
||||||
[symbols.PAGE_INFO]: {
|
|
||||||
title: this.$ts.dashboard,
|
|
||||||
icon: 'fas fa-tachometer-alt',
|
|
||||||
bg: 'var(--bg)',
|
|
||||||
},
|
|
||||||
version,
|
|
||||||
vueVersion,
|
|
||||||
url,
|
|
||||||
stats: null,
|
|
||||||
meta: null,
|
|
||||||
serverInfo: null,
|
|
||||||
usersComparedToThePrevDay: null,
|
|
||||||
notesComparedToThePrevDay: null,
|
|
||||||
fetchJobs: () => os.api('admin/queue/deliver-delayed', {}),
|
|
||||||
fetchModLogs: () => os.api('admin/show-moderation-logs', {}),
|
|
||||||
queueStatsConnection: markRaw(stream.useChannel('queueStats')),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async mounted() {
|
|
||||||
os.api('meta', { detail: true }).then(meta => {
|
|
||||||
this.meta = meta;
|
|
||||||
});
|
|
||||||
|
|
||||||
os.api('stats', {}).then(stats => {
|
|
||||||
this.stats = stats;
|
|
||||||
|
|
||||||
os.api('charts/users', { limit: 2, span: 'day' }).then(chart => {
|
os.api('charts/users', { limit: 2, span: 'day' }).then(chart => {
|
||||||
this.usersComparedToThePrevDay = this.stats.originalUsersCount - chart.local.total[1];
|
usersComparedToThePrevDay = stats.originalUsersCount - chart.local.total[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
os.api('charts/notes', { limit: 2, span: 'day' }).then(chart => {
|
os.api('charts/notes', { limit: 2, span: 'day' }).then(chart => {
|
||||||
this.notesComparedToThePrevDay = this.stats.originalNotesCount - chart.local.total[1];
|
notesComparedToThePrevDay = stats.originalNotesCount - chart.local.total[1];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
os.api('admin/server-info', {}).then(serverInfo => {
|
os.api('admin/server-info').then(serverInfoResponse => {
|
||||||
this.serverInfo = serverInfo;
|
serverInfo = serverInfoResponse;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$nextTick(() => {
|
nextTick(() => {
|
||||||
this.queueStatsConnection.send('requestLog', {
|
queueStatsConnection.send('requestLog', {
|
||||||
id: Math.random().toString().substr(2, 8),
|
id: Math.random().toString().substr(2, 8),
|
||||||
length: 200
|
length: 200
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
|
|
||||||
beforeUnmount() {
|
onBeforeUnmount(() => {
|
||||||
this.queueStatsConnection.dispose();
|
queueStatsConnection.dispose();
|
||||||
},
|
});
|
||||||
|
|
||||||
methods: {
|
defineExpose({
|
||||||
async showInstanceInfo(q) {
|
[symbols.PAGE_INFO]: {
|
||||||
let instance = q;
|
title: i18n.ts.dashboard,
|
||||||
if (typeof q === 'string') {
|
icon: 'fas fa-tachometer-alt',
|
||||||
instance = await os.api('federation/show-instance', {
|
bg: 'var(--bg)',
|
||||||
host: q
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO
|
|
||||||
},
|
|
||||||
|
|
||||||
bytes,
|
|
||||||
|
|
||||||
number,
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue