improve dashboard

This commit is contained in:
syuilo 2021-10-23 00:04:19 +09:00
parent 0f122884cc
commit 4df409f77b
2 changed files with 64 additions and 5 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="ukygtjoj _block" :class="{ naked, hideHeader: !showHeader, scrollable, closed: !showBody }" v-size="{ max: [380] }"> <div class="ukygtjoj _panel" :class="{ naked, thin, hideHeader: !showHeader, scrollable, closed: !showBody }" v-size="{ max: [380] }">
<header v-if="showHeader" ref="header"> <header v-if="showHeader" ref="header">
<div class="title"><slot name="header"></slot></div> <div class="title"><slot name="header"></slot></div>
<div class="sub"> <div class="sub">
@ -36,6 +36,11 @@ export default defineComponent({
required: false, required: false,
default: true default: true
}, },
thin: {
type: Boolean,
required: false,
default: false
},
naked: { naked: {
type: Boolean, type: Boolean,
required: false, required: false,
@ -226,7 +231,7 @@ export default defineComponent({
} }
} }
&.max-width_380px { &.max-width_380px, &.thin {
> header { > header {
> .title { > .title {
padding: 8px 10px; padding: 8px 10px;

View file

@ -2,7 +2,7 @@
<div> <div>
<MkHeader :info="header"/> <MkHeader :info="header"/>
<div class="edbbcaef"> <div class="edbbcaef" v-size="{ max: [880] }">
<div v-if="stats" class="cfcdecdf" style="margin: var(--margin)"> <div v-if="stats" class="cfcdecdf" style="margin: var(--margin)">
<div class="number _panel"> <div class="number _panel">
<div class="label">Users</div> <div class="label">Users</div>
@ -26,7 +26,18 @@
<MkInstanceStats :chart-limit="500" :detailed="true"/> <MkInstanceStats :chart-limit="500" :detailed="true"/>
</div> </div>
</MkContainer> </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>
<!--<XMetrics/>--> <!--<XMetrics/>-->
<MkFolder style="margin: var(--margin)"> <MkFolder style="margin: var(--margin)">
@ -59,7 +70,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, version as vueVersion } from 'vue'; import { computed, defineComponent, markRaw, version as vueVersion } from 'vue';
import FormKeyValueView from '@client/components/debobigego/key-value-view.vue'; import FormKeyValueView from '@client/components/debobigego/key-value-view.vue';
import MkInstanceStats from '@client/components/instance-stats.vue'; import MkInstanceStats from '@client/components/instance-stats.vue';
import MkButton from '@client/components/ui/button.vue'; import MkButton from '@client/components/ui/button.vue';
@ -67,6 +78,7 @@ import MkSelect from '@client/components/form/select.vue';
import MkNumberDiff from '@client/components/number-diff.vue'; import MkNumberDiff from '@client/components/number-diff.vue';
import MkContainer from '@client/components/ui/container.vue'; import MkContainer from '@client/components/ui/container.vue';
import MkFolder from '@client/components/ui/folder.vue'; import MkFolder from '@client/components/ui/folder.vue';
import MkQueueChart from '@client/components/queue-chart.vue';
import { version, url } from '@client/config'; import { version, url } from '@client/config';
import bytes from '@client/filters/bytes'; import bytes from '@client/filters/bytes';
import number from '@client/filters/number'; import number from '@client/filters/number';
@ -82,6 +94,7 @@ export default defineComponent({
MkInstanceStats, MkInstanceStats,
MkContainer, MkContainer,
MkFolder, MkFolder,
MkQueueChart,
XMetrics, XMetrics,
}, },
@ -108,6 +121,7 @@ export default defineComponent({
notesComparedToThePrevDay: null, notesComparedToThePrevDay: null,
fetchJobs: () => os.api('admin/queue/deliver-delayed', {}), fetchJobs: () => os.api('admin/queue/deliver-delayed', {}),
fetchModLogs: () => os.api('admin/show-moderation-logs', {}), fetchModLogs: () => os.api('admin/show-moderation-logs', {}),
queueStatsConnection: markRaw(os.stream.useChannel('queueStats')),
} }
}, },
@ -133,6 +147,17 @@ export default defineComponent({
os.api('admin/server-info', {}).then(serverInfo => { os.api('admin/server-info', {}).then(serverInfo => {
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
}); });
this.$nextTick(() => {
this.queueStatsConnection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
length: 200
});
});
},
beforeUnmount() {
this.queueStatsConnection.dispose();
}, },
methods: { methods: {
@ -184,5 +209,34 @@ export default defineComponent({
> .charts { > .charts {
margin: var(--margin); margin: var(--margin);
} }
> .queue {
margin: var(--margin);
display: flex;
> .deliver,
> .inbox {
flex: 1;
width: 50%;
&:not(:first-child) {
margin-left: var(--margin);
}
}
}
&.max-width_800px {
> .queue {
display: block;
> .deliver,
> .inbox {
&:not(:first-child) {
margin-top: var(--margin);
margin-left: 0;
}
}
}
}
} }
</style> </style>