This commit is contained in:
ThatOneCalculator 2023-02-13 19:53:39 -08:00
parent 3def9ab3b7
commit 1b69006040
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
1 changed files with 134 additions and 139 deletions

View File

@ -1,122 +1,101 @@
<template> <template>
<div class="zbcjwnqg"> <div :class="$style.root">
<div class="main"> <MkFoldableSection class="item">
<div class="body"> <template #header>Chart</template>
<div class="selects" style="display: flex;"> <div :class="$style.chart">
<MkSelect v-model="chartSrc" style="margin: 0; flex: 1;"> <div class="selects">
<optgroup :label="i18n.ts.federation"> <MkSelect v-model="chartSrc" style="margin: 0; flex: 1;">
<option value="federation">{{ i18n.ts._charts.federation }}</option> <optgroup :label="i18n.ts.federation">
<option value="ap-request">{{ i18n.ts._charts.apRequest }}</option> <option value="federation">{{ i18n.ts._charts.federation }}</option>
</optgroup> <option value="ap-request">{{ i18n.ts._charts.apRequest }}</option>
<optgroup :label="i18n.ts.users"> </optgroup>
<option value="users">{{ i18n.ts._charts.usersIncDec }}</option> <optgroup :label="i18n.ts.users">
<option value="users-total">{{ i18n.ts._charts.usersTotal }}</option> <option value="users">{{ i18n.ts._charts.usersIncDec }}</option>
<option value="active-users">{{ i18n.ts._charts.activeUsers }}</option> <option value="users-total">{{ i18n.ts._charts.usersTotal }}</option>
</optgroup> <option value="active-users">{{ i18n.ts._charts.activeUsers }}</option>
<optgroup :label="i18n.ts.notes"> </optgroup>
<option value="notes">{{ i18n.ts._charts.notesIncDec }}</option> <optgroup :label="i18n.ts.notes">
<option value="local-notes">{{ i18n.ts._charts.localNotesIncDec }}</option> <option value="notes">{{ i18n.ts._charts.notesIncDec }}</option>
<option value="remote-notes">{{ i18n.ts._charts.remoteNotesIncDec }}</option> <option value="local-notes">{{ i18n.ts._charts.localNotesIncDec }}</option>
<option value="notes-total">{{ i18n.ts._charts.notesTotal }}</option> <option value="remote-notes">{{ i18n.ts._charts.remoteNotesIncDec }}</option>
</optgroup> <option value="notes-total">{{ i18n.ts._charts.notesTotal }}</option>
<optgroup :label="i18n.ts.drive"> </optgroup>
<option value="drive-files">{{ i18n.ts._charts.filesIncDec }}</option> <optgroup :label="i18n.ts.drive">
<option value="drive">{{ i18n.ts._charts.storageUsageIncDec }}</option> <option value="drive-files">{{ i18n.ts._charts.filesIncDec }}</option>
</optgroup> <option value="drive">{{ i18n.ts._charts.storageUsageIncDec }}</option>
</MkSelect> </optgroup>
<MkSelect v-model="chartSpan" style="margin: 0 0 0 10px;"> </MkSelect>
<option value="hour">{{ i18n.ts.perHour }}</option> <MkSelect v-model="chartSpan" style="margin: 0 0 0 10px;">
<option value="day">{{ i18n.ts.perDay }}</option> <option value="hour">{{ i18n.ts.perHour }}</option>
</MkSelect> <option value="day">{{ i18n.ts.perDay }}</option>
</div> </MkSelect>
<div class="chart"> </div>
<MkChart :src="chartSrc" :span="chartSpan" :limit="chartLimit" :detailed="detailed"></MkChart> <div class="chart _panel">
</div> <MkChart :src="chartSrc" :span="chartSpan" :limit="chartLimit" :detailed="true"></MkChart>
<div class="item">
<template #header>Active users heatmap</template>
<MkSelect v-model="heatmapSrc" style="margin: 0 0 10px 0;">
<option value="active-users">Active users</option>
<option value="notes">Notes</option>
<option value="ap-requests-inbox-received">AP Requests: inboxReceived</option>
<option value="ap-requests-deliver-succeeded">AP Requests: deliverSucceeded</option>
<option value="ap-requests-deliver-failed">AP Requests: deliverFailed</option>
</MkSelect>
<div class="_panel heatmap">
<MkHeatmap :src="heatmapSrc"/>
</div> </div>
</div> </div>
</div> </MkFoldableSection>
<MkFoldableSection class="item">
<template #header>Active users heatmap</template>
<MkSelect v-model="heatmapSrc" style="margin: 0 0 12px 0;">
<option value="active-users">Active users</option>
<option value="notes">Notes</option>
<option value="ap-requests-inbox-received">AP Requests: inboxReceived</option>
<option value="ap-requests-deliver-succeeded">AP Requests: deliverSucceeded</option>
<option value="ap-requests-deliver-failed">AP Requests: deliverFailed</option>
</MkSelect>
<div class="_panel" :class="$style.heatmap">
<MkHeatmap :src="heatmapSrc"/>
</div>
</MkFoldableSection>
<MkFoldableSection class="item">
<template #header>Retention rate</template>
<div class="_panel" :class="$style.retention">
<MkRetentionHeatmap/>
</div>
</MkFoldableSection>
<MkFoldableSection class="item">
<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>
</div>
</div>
</MkFoldableSection>
</div> </div>
<div class="subpub">
<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>
</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { import { Chart } from 'chart.js';
Chart, import MkSelect from '@/components/MkSelect.vue';
ArcElement,
LineElement,
BarElement,
PointElement,
BarController,
LineController,
CategoryScale,
LinearScale,
TimeScale,
Legend,
Title,
Tooltip,
SubTitle,
Filler,
DoughnutController,
} from 'chart.js';
import MkSelect from '@/components/form/select.vue';
import MkChart from '@/components/MkChart.vue'; import MkChart from '@/components/MkChart.vue';
import MkHeatmap from '@/components/MkHeatmap.vue';
import { useChartTooltip } from '@/scripts/use-chart-tooltip'; import { useChartTooltip } from '@/scripts/use-chart-tooltip';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import MkHeatmap from '@/components/MkHeatmap.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import MkRetentionHeatmap from '@/components/MkRetentionHeatmap.vue';
import { initChart } from '@/scripts/init-chart';
Chart.register( initChart();
ArcElement,
LineElement,
BarElement,
PointElement,
BarController,
LineController,
DoughnutController,
CategoryScale,
LinearScale,
TimeScale,
Legend,
Title,
Tooltip,
SubTitle,
Filler,
);
const props = withDefaults(defineProps<{
chartLimit?: number;
detailed?: boolean;
}>(), {
chartLimit: 90,
});
const chartLimit = 500;
let chartSpan = $ref<'hour' | 'day'>('hour'); let chartSpan = $ref<'hour' | 'day'>('hour');
let chartSrc = $ref('active-users'); let chartSrc = $ref('active-users');
// let heatmapSrc = $ref('active-users'); let heatmapSrc = $ref('active-users');
let subDoughnutEl = $ref<HTMLCanvasElement>(); let subDoughnutEl = $shallowRef<HTMLCanvasElement>();
let pubDoughnutEl = $ref<HTMLCanvasElement>(); let pubDoughnutEl = $shallowRef<HTMLCanvasElement>();
const { handler: externalTooltipHandler1 } = useChartTooltip({ const { handler: externalTooltipHandler1 } = useChartTooltip({
position: 'middle', position: 'middle',
@ -196,47 +175,63 @@ onMounted(() => {
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.zbcjwnqg { .root {
> .main { &:global {
background: var(--panel); > .item {
border-radius: var(--radius); margin-bottom: 16px;
padding: 24px;
margin-bottom: 16px;
> .body {
> .chart {
padding: 8px 0 0 0;
}
> .heatmap {
padding: 12px;
margin-bottom: 12px;
}
} }
} }
}
> .subpub { .chart {
display: flex; &:global {
gap: 16px; > .selects {
display: flex;
> .sub, > .pub { margin-bottom: 12px;
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) { > .chart {
flex-direction: column; padding: 16px;
}
}
}
.heatmap {
padding: 16px;
margin-bottom: 16px;
}
.retention {
padding: 16px;
margin-bottom: 16px;
}
.federation {
&:global {
> .pies {
display: flex;
gap: 16px;
> .sub, > .pub {
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;
}
} }
} }
} }