2018-11-02 19:00:23 +01:00
|
|
|
<template>
|
2023-02-14 04:53:39 +01:00
|
|
|
<div :class="$style.root">
|
2023-02-14 04:54:06 +01:00
|
|
|
<MkFolder class="item">
|
2023-02-14 04:53:39 +01:00
|
|
|
<template #header>Chart</template>
|
|
|
|
<div :class="$style.chart">
|
|
|
|
<div class="selects">
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkSelect v-model="chartSrc" style="margin: 0; flex: 1">
|
2023-02-14 04:53:39 +01:00
|
|
|
<optgroup :label="i18n.ts.federation">
|
2023-04-08 02:01:42 +02:00
|
|
|
<option value="federation">
|
|
|
|
{{ i18n.ts._charts.federation }}
|
|
|
|
</option>
|
|
|
|
<option value="ap-request">
|
|
|
|
{{ i18n.ts._charts.apRequest }}
|
|
|
|
</option>
|
2023-02-14 04:53:39 +01:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="i18n.ts.users">
|
2023-04-08 02:01:42 +02:00
|
|
|
<option value="users">
|
|
|
|
{{ i18n.ts._charts.usersIncDec }}
|
|
|
|
</option>
|
|
|
|
<option value="users-total">
|
|
|
|
{{ i18n.ts._charts.usersTotal }}
|
|
|
|
</option>
|
|
|
|
<option value="active-users">
|
|
|
|
{{ i18n.ts._charts.activeUsers }}
|
|
|
|
</option>
|
2023-02-14 04:53:39 +01:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="i18n.ts.notes">
|
2023-04-08 02:01:42 +02:00
|
|
|
<option value="notes">
|
|
|
|
{{ i18n.ts._charts.notesIncDec }}
|
|
|
|
</option>
|
|
|
|
<option value="local-notes">
|
|
|
|
{{ i18n.ts._charts.localNotesIncDec }}
|
|
|
|
</option>
|
|
|
|
<option value="remote-notes">
|
|
|
|
{{ i18n.ts._charts.remoteNotesIncDec }}
|
|
|
|
</option>
|
|
|
|
<option value="notes-total">
|
|
|
|
{{ i18n.ts._charts.notesTotal }}
|
|
|
|
</option>
|
2023-02-14 04:53:39 +01:00
|
|
|
</optgroup>
|
|
|
|
<optgroup :label="i18n.ts.drive">
|
2023-04-08 02:01:42 +02:00
|
|
|
<option value="drive-files">
|
|
|
|
{{ i18n.ts._charts.filesIncDec }}
|
|
|
|
</option>
|
|
|
|
<option value="drive">
|
|
|
|
{{ i18n.ts._charts.storageUsageIncDec }}
|
|
|
|
</option>
|
2023-02-14 04:53:39 +01:00
|
|
|
</optgroup>
|
|
|
|
</MkSelect>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkSelect v-model="chartSpan" style="margin: 0 0 0 10px">
|
2023-02-14 04:53:39 +01:00
|
|
|
<option value="hour">{{ i18n.ts.perHour }}</option>
|
|
|
|
<option value="day">{{ i18n.ts.perDay }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
</div>
|
|
|
|
<div class="chart _panel">
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkChart
|
|
|
|
:src="chartSrc"
|
|
|
|
:span="chartSpan"
|
|
|
|
:limit="chartLimit"
|
|
|
|
:detailed="true"
|
|
|
|
></MkChart>
|
2023-02-14 04:53:39 +01:00
|
|
|
</div>
|
2022-06-29 08:41:06 +02:00
|
|
|
</div>
|
2023-02-14 04:54:06 +01:00
|
|
|
</MkFolder>
|
2023-02-14 04:53:39 +01:00
|
|
|
|
2023-02-14 04:54:06 +01:00
|
|
|
<MkFolder class="item">
|
2023-02-14 04:53:39 +01:00
|
|
|
<template #header>Active users heatmap</template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkSelect v-model="heatmapSrc" style="margin: 0 0 12px 0">
|
2023-02-14 04:53:39 +01:00
|
|
|
<option value="active-users">Active users</option>
|
|
|
|
<option value="notes">Notes</option>
|
2023-04-08 02:01:42 +02:00
|
|
|
<option value="ap-requests-inbox-received">
|
|
|
|
Fediverse Requests: inboxReceived
|
|
|
|
</option>
|
|
|
|
<option value="ap-requests-deliver-succeeded">
|
|
|
|
Fediverse Requests: deliverSucceeded
|
|
|
|
</option>
|
|
|
|
<option value="ap-requests-deliver-failed">
|
|
|
|
Fediverse Requests: deliverFailed
|
|
|
|
</option>
|
2023-02-14 04:53:39 +01:00
|
|
|
</MkSelect>
|
|
|
|
<div class="_panel" :class="$style.heatmap">
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkHeatmap :src="heatmapSrc" />
|
2022-06-29 08:41:06 +02:00
|
|
|
</div>
|
2023-02-14 04:54:06 +01:00
|
|
|
</MkFolder>
|
2023-02-14 04:53:39 +01:00
|
|
|
|
2023-02-14 04:54:06 +01:00
|
|
|
<MkFolder class="item">
|
2023-02-14 04:53:39 +01:00
|
|
|
<template #header>Federation</template>
|
|
|
|
<div :class="$style.federation">
|
|
|
|
<div class="pies">
|
|
|
|
<div class="sub">
|
|
|
|
<div class="title">Sub</div>
|
|
|
|
<canvas ref="subDoughnutEl"></canvas>
|
|
|
|
</div>
|
|
|
|
<div class="pub">
|
|
|
|
<div class="title">Pub</div>
|
|
|
|
<canvas ref="pubDoughnutEl"></canvas>
|
|
|
|
</div>
|
2023-02-14 04:40:31 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-14 04:54:06 +01:00
|
|
|
</MkFolder>
|
2022-01-04 07:36:14 +01:00
|
|
|
</div>
|
2018-11-02 19:00:23 +01:00
|
|
|
</template>
|
|
|
|
|
2022-06-29 08:41:06 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { onMounted } from "vue";
|
|
|
|
import { Chart } from "chart.js";
|
|
|
|
import MkSelect from "@/components/form/select.vue";
|
|
|
|
import MkChart from "@/components/MkChart.vue";
|
|
|
|
import { useChartTooltip } from "@/scripts/use-chart-tooltip";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import MkHeatmap from "@/components/MkHeatmap.vue";
|
|
|
|
import MkFolder from "@/components/MkFolder.vue";
|
|
|
|
import { initChart } from "@/scripts/init-chart";
|
2018-11-02 19:00:23 +01:00
|
|
|
|
2023-02-14 04:53:39 +01:00
|
|
|
initChart();
|
2022-06-29 08:41:06 +02:00
|
|
|
|
2023-02-14 04:53:39 +01:00
|
|
|
const chartLimit = 500;
|
2023-04-08 02:01:42 +02:00
|
|
|
let chartSpan = $ref<"hour" | "day">("hour");
|
|
|
|
let chartSrc = $ref("active-users");
|
|
|
|
let heatmapSrc = $ref("active-users");
|
2023-02-14 04:53:39 +01:00
|
|
|
let subDoughnutEl = $shallowRef<HTMLCanvasElement>();
|
|
|
|
let pubDoughnutEl = $shallowRef<HTMLCanvasElement>();
|
2022-06-29 08:41:06 +02:00
|
|
|
|
2023-02-14 04:40:31 +01:00
|
|
|
const { handler: externalTooltipHandler1 } = useChartTooltip({
|
2023-04-08 02:01:42 +02:00
|
|
|
position: "middle",
|
2023-02-14 04:40:31 +01:00
|
|
|
});
|
|
|
|
const { handler: externalTooltipHandler2 } = useChartTooltip({
|
2023-04-08 02:01:42 +02:00
|
|
|
position: "middle",
|
2023-02-14 04:40:31 +01:00
|
|
|
});
|
2022-06-29 08:41:06 +02:00
|
|
|
|
|
|
|
function createDoughnut(chartEl, tooltip, data) {
|
2022-06-30 15:02:08 +02:00
|
|
|
const chartInstance = new Chart(chartEl, {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "doughnut",
|
2022-06-29 08:41:06 +02:00
|
|
|
data: {
|
2023-04-08 02:01:42 +02:00
|
|
|
labels: data.map((x) => x.name),
|
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
backgroundColor: data.map((x) => x.color),
|
|
|
|
borderColor: getComputedStyle(
|
|
|
|
document.documentElement
|
|
|
|
).getPropertyValue("--panel"),
|
|
|
|
borderWidth: 2,
|
|
|
|
hoverOffset: 0,
|
|
|
|
data: data.map((x) => x.value),
|
|
|
|
},
|
|
|
|
],
|
2020-08-09 08:51:02 +02:00
|
|
|
},
|
2022-06-29 08:41:06 +02:00
|
|
|
options: {
|
2022-07-01 10:08:45 +02:00
|
|
|
maintainAspectRatio: false,
|
2022-06-29 08:41:06 +02:00
|
|
|
layout: {
|
|
|
|
padding: {
|
2022-06-30 13:15:14 +02:00
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
top: 16,
|
|
|
|
bottom: 16,
|
2022-06-29 08:41:06 +02:00
|
|
|
},
|
|
|
|
},
|
2022-06-30 15:02:08 +02:00
|
|
|
onClick: (ev) => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const hit = chartInstance.getElementsAtEventForMode(
|
|
|
|
ev,
|
|
|
|
"nearest",
|
|
|
|
{ intersect: true },
|
|
|
|
false
|
|
|
|
)[0];
|
2022-06-30 15:02:08 +02:00
|
|
|
if (hit && data[hit.index].onClick) {
|
|
|
|
data[hit.index].onClick();
|
|
|
|
}
|
|
|
|
},
|
2022-06-29 08:41:06 +02:00
|
|
|
plugins: {
|
|
|
|
legend: {
|
|
|
|
display: false,
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
enabled: false,
|
2023-04-08 02:01:42 +02:00
|
|
|
mode: "index",
|
2022-06-29 08:41:06 +02:00
|
|
|
animation: {
|
|
|
|
duration: 0,
|
|
|
|
},
|
|
|
|
external: tooltip,
|
|
|
|
},
|
|
|
|
},
|
2020-08-09 08:51:02 +02:00
|
|
|
},
|
2022-06-29 08:41:06 +02:00
|
|
|
});
|
2022-06-30 15:02:08 +02:00
|
|
|
|
|
|
|
return chartInstance;
|
2022-06-29 08:41:06 +02:00
|
|
|
}
|
2018-11-02 19:00:23 +01:00
|
|
|
|
2022-06-29 08:41:06 +02:00
|
|
|
onMounted(() => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.apiGet("federation/stats", { limit: 30 }).then((fedStats) => {
|
|
|
|
createDoughnut(
|
|
|
|
subDoughnutEl,
|
|
|
|
externalTooltipHandler1,
|
|
|
|
fedStats.topSubInstances
|
|
|
|
.map((x) => ({
|
|
|
|
name: x.host,
|
|
|
|
color: x.themeColor,
|
|
|
|
value: x.followersCount,
|
|
|
|
onClick: () => {
|
|
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
|
|
},
|
|
|
|
}))
|
|
|
|
.concat([
|
|
|
|
{
|
|
|
|
name: "(other)",
|
|
|
|
color: "#80808080",
|
|
|
|
value: fedStats.otherFollowersCount,
|
|
|
|
},
|
|
|
|
])
|
|
|
|
);
|
|
|
|
|
|
|
|
createDoughnut(
|
|
|
|
pubDoughnutEl,
|
|
|
|
externalTooltipHandler2,
|
|
|
|
fedStats.topPubInstances
|
|
|
|
.map((x) => ({
|
|
|
|
name: x.host,
|
|
|
|
color: x.themeColor,
|
|
|
|
value: x.followingCount,
|
|
|
|
onClick: () => {
|
|
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
|
|
},
|
|
|
|
}))
|
|
|
|
.concat([
|
|
|
|
{
|
|
|
|
name: "(other)",
|
|
|
|
color: "#80808080",
|
|
|
|
value: fedStats.otherFollowingCount,
|
|
|
|
},
|
|
|
|
])
|
|
|
|
);
|
2022-06-29 08:41:06 +02:00
|
|
|
});
|
2018-11-02 19:00:23 +01:00
|
|
|
});
|
|
|
|
</script>
|
2020-02-16 18:21:27 +01:00
|
|
|
|
2023-02-14 04:53:39 +01:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
|
|
|
&:global {
|
|
|
|
> .item {
|
|
|
|
margin-bottom: 16px;
|
2022-06-29 08:41:06 +02:00
|
|
|
}
|
2022-01-04 07:36:14 +01:00
|
|
|
}
|
2023-02-14 04:53:39 +01:00
|
|
|
}
|
2022-01-04 07:36:14 +01:00
|
|
|
|
2023-02-14 04:53:39 +01:00
|
|
|
.chart {
|
|
|
|
&:global {
|
|
|
|
> .selects {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 12px;
|
2022-06-29 08:41:06 +02:00
|
|
|
}
|
2022-07-01 10:08:45 +02:00
|
|
|
|
2023-02-14 04:53:39 +01:00
|
|
|
> .chart {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.heatmap {
|
|
|
|
padding: 16px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.retention {
|
|
|
|
padding: 16px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.federation {
|
|
|
|
&:global {
|
|
|
|
> .pies {
|
|
|
|
display: flex;
|
|
|
|
gap: 16px;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
> .sub,
|
|
|
|
> .pub {
|
2023-02-14 04:53:39 +01:00
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
position: relative;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
padding: 24px;
|
|
|
|
max-height: 300px;
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
position: absolute;
|
|
|
|
top: 24px;
|
|
|
|
left: 24px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 600px) {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
2022-07-01 10:08:45 +02:00
|
|
|
}
|
2020-02-16 18:21:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|