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

195 lines
4.6 KiB
Vue
Raw Normal View History

<template>
2023-02-14 04:48:57 +01:00
<MkSpacer :content-max="1000">
<div ref="rootEl" class="edbbcaef">
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Stats</template>
2023-04-08 02:01:42 +02:00
<XStats />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Active users</template>
2023-04-08 02:01:42 +02:00
<XActiveUsers />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Heatmap</template>
2023-04-08 02:01:42 +02:00
<XHeatmap />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Moderators</template>
2023-04-08 02:01:42 +02:00
<XModerators />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Federation</template>
2023-04-08 02:01:42 +02:00
<XFederation />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Instances</template>
2023-04-08 02:01:42 +02:00
<XInstances />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
2023-02-14 05:25:31 +01:00
<template #header>Fediverse Requests</template>
2023-04-08 02:01:42 +02:00
<XApRequests />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>New users</template>
2023-04-08 02:01:42 +02:00
<XUsers />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Deliver queue</template>
2023-04-08 02:01:42 +02:00
<XQueue domain="deliver" />
2023-02-14 04:54:06 +01:00
</MkFolder>
2023-02-14 04:54:06 +01:00
<MkFolder class="item">
<template #header>Inbox queue</template>
2023-04-08 02:01:42 +02:00
<XQueue domain="inbox" />
2023-02-14 04:54:06 +01:00
</MkFolder>
<!-- <MkFolder class="item">
<template #header>Server metrics</template>
<XMetrics domain="inbox" />
</MkFolder> -->
2021-10-23 21:03:07 +02:00
</div>
2023-02-14 04:48:57 +01:00
</MkSpacer>
</template>
<script lang="ts" setup>
2023-08-27 01:30:30 +02:00
import {
markRaw,
onMounted,
onBeforeUnmount,
nextTick,
shallowRef,
ref,
} from "vue";
2023-04-08 02:01:42 +02:00
import XFederation from "./overview.federation.vue";
import XInstances from "./overview.instances.vue";
import XQueue from "./overview.queue.vue";
import XApRequests from "./overview.ap-requests.vue";
import XUsers from "./overview.users.vue";
import XActiveUsers from "./overview.active-users.vue";
import XStats from "./overview.stats.vue";
import XModerators from "./overview.moderators.vue";
import XHeatmap from "./overview.heatmap.vue";
// import XMetrics from "./overview.metrics.vue";
2023-04-08 02:01:42 +02:00
import * as os from "@/os";
import { stream } from "@/stream";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import MkFolder from "@/components/MkFolder.vue";
const rootEl = shallowRef<HTMLElement>();
const serverInfo = ref<any>(null);
const topSubInstancesForPie = ref<any>(null);
const topPubInstancesForPie = ref<any>(null);
const federationPubActive = ref<number | null>(null);
const federationPubActiveDiff = ref<number | null>(null);
const federationSubActive = ref<number | null>(null);
const federationSubActiveDiff = ref<number | null>(null);
const newUsers = ref(null);
const activeInstances = shallowRef(null);
2023-04-08 02:01:42 +02:00
const queueStatsConnection = markRaw(stream.useChannel("queueStats"));
2022-06-29 14:22:15 +02:00
2022-06-25 16:01:40 +02:00
onMounted(async () => {
/*
const magicGrid = new MagicGrid({
container: rootEl,
static: true,
animate: true,
});
magicGrid.listen();
*/
2023-04-08 02:01:42 +02:00
os.apiGet("charts/federation", { limit: 2, span: "day" }).then((chart) => {
federationPubActive.value = chart.pubActive[0];
federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1];
federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
});
2023-04-08 02:01:42 +02:00
os.apiGet("federation/stats", { limit: 10 }).then((res) => {
topSubInstancesForPie.value = res.topSubInstances
2023-04-08 02:01:42 +02:00
.map((x) => ({
name: x.host,
color: x.themeColor,
value: x.followersCount,
onClick: () => {
os.pageWindow(`/instance-info/${x.host}`);
},
}))
.concat([
{
name: "(other)",
color: "#80808080",
value: res.otherFollowersCount,
},
]);
topPubInstancesForPie.value = res.topPubInstances
2023-04-08 02:01:42 +02:00
.map((x) => ({
name: x.host,
color: x.themeColor,
value: x.followingCount,
onClick: () => {
os.pageWindow(`/instance-info/${x.host}`);
},
}))
.concat([
{
name: "(other)",
color: "#80808080",
value: res.otherFollowingCount,
},
]);
});
2023-04-08 02:01:42 +02:00
os.api("admin/server-info").then((serverInfoResponse) => {
serverInfo.value = serverInfoResponse;
});
2021-10-22 17:04:19 +02:00
2023-04-08 02:01:42 +02:00
os.api("admin/show-users", {
limit: 5,
2023-04-08 02:01:42 +02:00
sort: "+createdAt",
}).then((res) => {
newUsers.value = res;
});
2023-04-08 02:01:42 +02:00
os.api("federation/instances", {
sort: "+latestRequestReceivedAt",
2022-06-29 14:22:15 +02:00
limit: 25,
2023-04-08 02:01:42 +02:00
}).then((res) => {
activeInstances.value = res;
2022-06-29 14:22:15 +02:00
});
nextTick(() => {
2023-04-08 02:01:42 +02:00
queueStatsConnection.send("requestLog", {
id: Math.random().toString().slice(2, 10),
2022-06-26 06:28:47 +02:00
length: 100,
2021-10-22 17:04:19 +02:00
});
});
});
onBeforeUnmount(() => {
queueStatsConnection.dispose();
});
definePageMetadata({
title: i18n.ts.dashboard,
2023-04-08 02:01:42 +02:00
icon: "ph-gauge ph-bold ph-lg",
});
</script>
<style lang="scss" scoped>
.edbbcaef {
2023-02-14 04:48:57 +01:00
display: grid;
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
grid-gap: 16px;
}
</style>