Sharkey/packages/client/src/pages/admin/overview.vue

231 lines
5.6 KiB
Vue
Raw Normal View History

<template>
2021-11-19 12:36:12 +02:00
<div v-size="{ max: [740] }" class="edbbcaef">
2021-10-23 22:03:07 +03:00
<div v-if="stats" class="cfcdecdf" style="margin: var(--margin)">
<div class="number _panel">
<div class="label">Users</div>
<div class="value _monospace">
{{ number(stats.originalUsersCount) }}
2021-11-19 12:36:12 +02:00
<MkNumberDiff v-if="usersComparedToThePrevDay != null" v-tooltip="$ts.dayOverDayChanges" class="diff" :value="usersComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
</div>
</div>
2021-10-23 22:03:07 +03:00
<div class="number _panel">
<div class="label">Notes</div>
<div class="value _monospace">
{{ number(stats.originalNotesCount) }}
2021-11-19 12:36:12 +02:00
<MkNumberDiff v-if="notesComparedToThePrevDay != null" v-tooltip="$ts.dayOverDayChanges" class="diff" :value="notesComparedToThePrevDay"><template #before>(</template><template #after>)</template></MkNumberDiff>
</div>
2021-10-23 22:03:07 +03:00
</div>
</div>
2021-10-22 18:04:19 +03:00
2021-10-23 22:03:07 +03:00
<MkContainer :foldable="true" class="charts">
<template #header><i class="fas fa-chart-bar"></i>{{ $ts.charts }}</template>
2022-01-04 08:36:14 +02:00
<div style="padding: 12px;">
2021-10-23 22:03:07 +03:00
<MkInstanceStats :chart-limit="500" :detailed="true"/>
2021-10-22 18:04:19 +03:00
</div>
2021-10-23 22:03:07 +03:00
</MkContainer>
<div class="queue">
<MkContainer :foldable="true" :thin="true" class="deliver">
<template #header>Queue: deliver</template>
<MkQueueChart :connection="queueStatsConnection" domain="deliver"/>
</MkContainer>
<MkContainer :foldable="true" :thin="true" class="inbox">
<template #header>Queue: inbox</template>
<MkQueueChart :connection="queueStatsConnection" domain="inbox"/>
</MkContainer>
</div>
2021-10-22 18:04:19 +03:00
2021-10-23 22:03:07 +03:00
<!--<XMetrics/>-->
2021-10-23 22:03:07 +03:00
<MkFolder style="margin: var(--margin)">
<template #header><i class="fas fa-info-circle"></i> {{ $ts.info }}</template>
<div class="cfcdecdf">
<div class="number _panel">
<div class="label">Misskey</div>
<div class="value _monospace">{{ version }}</div>
</div>
2021-11-19 12:36:12 +02:00
<div v-if="serverInfo" class="number _panel">
2021-10-23 22:03:07 +03:00
<div class="label">Node.js</div>
<div class="value _monospace">{{ serverInfo.node }}</div>
</div>
2021-11-19 12:36:12 +02:00
<div v-if="serverInfo" class="number _panel">
2021-10-23 22:03:07 +03:00
<div class="label">PostgreSQL</div>
<div class="value _monospace">{{ serverInfo.psql }}</div>
</div>
2021-11-19 12:36:12 +02:00
<div v-if="serverInfo" class="number _panel">
2021-10-23 22:03:07 +03:00
<div class="label">Redis</div>
<div class="value _monospace">{{ serverInfo.redis }}</div>
</div>
<div class="number _panel">
<div class="label">Vue</div>
<div class="value _monospace">{{ vueVersion }}</div>
</div>
</div>
</MkFolder>
</div>
</template>
<script lang="ts">
2021-10-22 18:04:19 +03:00
import { computed, defineComponent, markRaw, version as vueVersion } from 'vue';
2021-11-11 19:02:25 +02:00
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 MkContainer from '@/components/ui/container.vue';
import MkFolder from '@/components/ui/folder.vue';
import MkQueueChart from '@/components/queue-chart.vue';
import { version, url } from '@/config';
import bytes from '@/filters/bytes';
import number from '@/filters/number';
import XMetrics from './metrics.vue';
2021-11-11 19:02:25 +02:00
import * as os from '@/os';
import { stream } from '@/stream';
2021-11-11 19:02:25 +02:00
import * as symbols from '@/symbols';
export default defineComponent({
components: {
MkNumberDiff,
MkInstanceStats,
MkContainer,
2021-10-22 11:15:12 +03:00
MkFolder,
2021-10-22 18:04:19 +03:00
MkQueueChart,
XMetrics,
},
emits: ['info'],
data() {
return {
[symbols.PAGE_INFO]: {
title: this.$ts.dashboard,
2021-10-02 17:11:21 +03:00
icon: 'fas fa-tachometer-alt',
bg: 'var(--bg)',
},
version,
vueVersion,
url,
stats: null,
2021-05-31 06:02:02 +03:00
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 => {
this.usersComparedToThePrevDay = this.stats.originalUsersCount - chart.local.total[1];
});
os.api('charts/notes', { limit: 2, span: 'day' }).then(chart => {
this.notesComparedToThePrevDay = this.stats.originalNotesCount - chart.local.total[1];
});
});
os.api('admin/server-info', {}).then(serverInfo => {
this.serverInfo = serverInfo;
});
2021-10-22 18:04:19 +03:00
this.$nextTick(() => {
this.queueStatsConnection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
length: 200
});
});
},
beforeUnmount() {
this.queueStatsConnection.dispose();
},
methods: {
async showInstanceInfo(q) {
let instance = q;
if (typeof q === 'string') {
instance = await os.api('federation/show-instance', {
host: q
});
}
2022-01-04 08:36:14 +02:00
// TODO
},
bytes,
number,
}
});
</script>
<style lang="scss" scoped>
.edbbcaef {
2021-10-22 11:15:12 +03:00
.cfcdecdf {
display: grid;
grid-gap: 8px;
2021-10-22 08:03:08 +03:00
grid-template-columns: repeat(auto-fill,minmax(150px,1fr));
> .number {
padding: 12px 16px;
> .label {
opacity: 0.7;
font-size: 0.8em;
}
> .value {
font-weight: bold;
font-size: 1.2em;
> .diff {
font-size: 0.8em;
}
}
}
}
> .charts {
margin: var(--margin);
}
2021-10-22 18:04:19 +03:00
> .queue {
margin: var(--margin);
display: flex;
> .deliver,
> .inbox {
flex: 1;
width: 50%;
&:not(:first-child) {
margin-left: var(--margin);
}
}
}
2021-10-23 16:09:48 +03:00
&.max-width_740px {
2021-10-22 18:04:19 +03:00
> .queue {
display: block;
> .deliver,
> .inbox {
2021-10-23 16:09:48 +03:00
width: 100%;
2021-10-22 18:04:19 +03:00
&:not(:first-child) {
margin-top: var(--margin);
margin-left: 0;
}
}
}
}
}
</style>