From 6a4574b612f0a729096878158e3c03d753c8200b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 26 Jun 2022 01:45:33 +0900 Subject: [PATCH] enhance(client): tweak control panel dashboard --- .../src/pages/admin/overview.federation.vue | 12 +-- .../src/pages/admin/overview.queue-chart.vue | 2 +- .../client/src/pages/admin/overview.user.vue | 76 +++++++++++++++++ packages/client/src/pages/admin/overview.vue | 81 +++++++++++++++++-- 4 files changed, 158 insertions(+), 13 deletions(-) create mode 100644 packages/client/src/pages/admin/overview.user.vue diff --git a/packages/client/src/pages/admin/overview.federation.vue b/packages/client/src/pages/admin/overview.federation.vue index 6709c30c6..6da1fa4e9 100644 --- a/packages/client/src/pages/admin/overview.federation.vue +++ b/packages/client/src/pages/admin/overview.federation.vue @@ -2,14 +2,14 @@
-
+
- {{ instance.name ?? instance.host }} -

{{ instance.host }}

+
{{ instance.name ?? instance.host }}
+
{{ instance.host }}
-
+
@@ -78,7 +78,7 @@ onUnmounted(() => { color: var(--fg); padding-right: 8px; - > .a { + > .name { display: block; width: 100%; white-space: nowrap; @@ -86,7 +86,7 @@ onUnmounted(() => { text-overflow: ellipsis; } - > p { + > .host { margin: 0; font-size: 75%; opacity: 0.7; diff --git a/packages/client/src/pages/admin/overview.queue-chart.vue b/packages/client/src/pages/admin/overview.queue-chart.vue index e3889e04b..9f23a14b5 100644 --- a/packages/client/src/pages/admin/overview.queue-chart.vue +++ b/packages/client/src/pages/admin/overview.queue-chart.vue @@ -146,7 +146,7 @@ onMounted(() => { }], }, options: { - aspectRatio: 2.5, + aspectRatio: 3, layout: { padding: { left: 0, diff --git a/packages/client/src/pages/admin/overview.user.vue b/packages/client/src/pages/admin/overview.user.vue new file mode 100644 index 000000000..40592b280 --- /dev/null +++ b/packages/client/src/pages/admin/overview.user.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/packages/client/src/pages/admin/overview.vue b/packages/client/src/pages/admin/overview.vue index 22d9d72a7..8e57c7aaf 100644 --- a/packages/client/src/pages/admin/overview.vue +++ b/packages/client/src/pages/admin/overview.vue @@ -34,6 +34,13 @@ +
+
New users
+
+ +
+
+
@@ -75,6 +82,30 @@
+
+
Federation
+
+
+
Sub
+
+ {{ number(federationSubActive) }} + +
+
+
+
Pub
+
+ {{ number(federationPubActive) }} + +
+
+
+
+
+
Recent files
+
+
+
@@ -105,6 +136,7 @@ import MagicGrid from 'magic-grid'; import XMetrics from './metrics.vue'; import XFederation from './overview.federation.vue'; import XQueueChart from './overview.queue-chart.vue'; +import XUser from './overview.user.vue'; import MkInstanceStats from '@/components/instance-stats.vue'; import MkNumberDiff from '@/components/number-diff.vue'; import { version, url } from '@/config'; @@ -141,6 +173,11 @@ let stats: any = $ref(null); let serverInfo: any = $ref(null); let usersComparedToThePrevDay: any = $ref(null); let notesComparedToThePrevDay: any = $ref(null); +let federationPubActive = $ref(null); +let federationPubActiveDiff = $ref(null); +let federationSubActive = $ref(null); +let federationSubActiveDiff = $ref(null); +let newUsers = $ref(null); const queueStatsConnection = markRaw(stream.useChannel('queueStats')); const now = new Date(); let chartInstance: Chart = null; @@ -325,10 +362,24 @@ onMounted(async () => { }); }); + os.apiGet('charts/federation', { limit: 2, span: 'day' }).then(chart => { + federationPubActive = chart.pubActive[0]; + federationPubActiveDiff = chart.pubActive[0] - chart.pubActive[1]; + federationSubActive = chart.subActive[0]; + federationSubActiveDiff = chart.subActive[0] - chart.subActive[1]; + }); + os.api('admin/server-info').then(serverInfoResponse => { serverInfo = serverInfoResponse; }); + os.api('admin/show-users', { + limit: 5, + sort: '+createdAt', + }).then(res => { + newUsers = res; + }); + nextTick(() => { queueStatsConnection.send('requestLog', { id: Math.random().toString().substr(2, 8), @@ -364,12 +415,12 @@ definePageMetadata({ margin: 32px 0; > .title { - font-size: 1.2em; + font-size: 1.1em; font-weight: bold; margin-bottom: 16px; } - &.stats { + &.stats, &.federationStats { > .body { display: grid; grid-gap: 16px; @@ -388,7 +439,7 @@ definePageMetadata({ font-size: 1.5em; > .diff { - font-size: 0.8em; + font-size: 0.7em; } } } @@ -410,7 +461,7 @@ definePageMetadata({ } > .value { - font-size: 1.2em; + font-size: 1.1em; } } } @@ -424,6 +475,21 @@ definePageMetadata({ } } + &.users { + > .body { + background: var(--panel); + border-radius: var(--radius); + + > .user { + padding: 16px 20px; + + &:not(:last-child) { + border-bottom: solid 0.5px var(--divider); + } + } + } + } + &.federation { > .body { background: var(--panel); @@ -434,7 +500,8 @@ definePageMetadata({ &.queue { > .body { - padding: 32px; + position: relative; + padding: 24px; background: var(--panel); border-radius: var(--radius); @@ -443,7 +510,9 @@ definePageMetadata({ } > .title { - + position: absolute; + top: 24px; + left: 24px; } } }