2023-07-26 22:31:52 -07:00
|
|
|
<!--
|
2024-02-13 07:59:27 -08:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-26 22:31:52 -07:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2022-06-25 07:01:40 -07:00
|
|
|
<template>
|
2022-12-22 22:21:55 -08:00
|
|
|
<div>
|
2022-06-25 07:01:40 -07:00
|
|
|
<MkLoading v-if="fetching"/>
|
2022-12-22 22:21:55 -08:00
|
|
|
<div v-show="!fetching" :class="$style.root">
|
|
|
|
<div v-if="topSubInstancesForPie && topPubInstancesForPie" class="pies">
|
|
|
|
<div class="pie deliver _panel">
|
|
|
|
<div class="title">Sub</div>
|
|
|
|
<XPie :data="topSubInstancesForPie" class="chart"/>
|
|
|
|
<div class="subTitle">Top 10</div>
|
2022-06-25 07:01:40 -07:00
|
|
|
</div>
|
2022-12-22 22:21:55 -08:00
|
|
|
<div class="pie inbox _panel">
|
|
|
|
<div class="title">Pub</div>
|
|
|
|
<XPie :data="topPubInstancesForPie" class="chart"/>
|
|
|
|
<div class="subTitle">Top 10</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="!fetching" class="items">
|
|
|
|
<div class="item _panel sub">
|
|
|
|
<div class="icon"><i class="ti ti-world-download"></i></div>
|
|
|
|
<div class="body">
|
|
|
|
<div class="value">
|
|
|
|
{{ number(federationSubActive) }}
|
|
|
|
<MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="federationSubActiveDiff"></MkNumberDiff>
|
|
|
|
</div>
|
|
|
|
<div class="label">Sub</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="item _panel pub">
|
|
|
|
<div class="icon"><i class="ti ti-world-upload"></i></div>
|
|
|
|
<div class="body">
|
|
|
|
<div class="value">
|
|
|
|
{{ number(federationPubActive) }}
|
|
|
|
<MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="federationPubActiveDiff"></MkNumberDiff>
|
|
|
|
</div>
|
|
|
|
<div class="label">Pub</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-25 07:01:40 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-06 21:42:09 -08:00
|
|
|
import { onMounted, ref } from 'vue';
|
2023-12-25 21:19:35 -08:00
|
|
|
import XPie, { type InstanceForPie } from './overview.pie.vue';
|
2023-09-19 00:37:43 -07:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 01:32:46 -08:00
|
|
|
import { misskeyApiGet } from '@/scripts/misskey-api.js';
|
2023-09-19 00:37:43 -07:00
|
|
|
import number from '@/filters/number.js';
|
2022-12-22 22:21:55 -08:00
|
|
|
import MkNumberDiff from '@/components/MkNumberDiff.vue';
|
2023-09-19 00:37:43 -07:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2023-12-25 21:19:35 -08:00
|
|
|
const topSubInstancesForPie = ref<InstanceForPie[] | null>(null);
|
|
|
|
const topPubInstancesForPie = ref<InstanceForPie[] | null>(null);
|
2023-12-06 21:42:09 -08:00
|
|
|
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 fetching = ref(true);
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
const { handler: externalTooltipHandler } = useChartTooltip();
|
2023-07-07 15:08:16 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
onMounted(async () => {
|
2024-01-04 01:32:46 -08:00
|
|
|
const chart = await misskeyApiGet('charts/federation', { limit: 2, span: 'day' });
|
2023-12-06 21:42:09 -08:00
|
|
|
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];
|
2022-12-22 22:21:55 -08:00
|
|
|
|
2024-01-04 01:32:46 -08:00
|
|
|
misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
|
2023-12-25 21:19:35 -08:00
|
|
|
topSubInstancesForPie.value = [
|
|
|
|
...res.topSubInstances.map(x => ({
|
|
|
|
name: x.host,
|
|
|
|
color: x.themeColor,
|
|
|
|
value: x.followersCount,
|
|
|
|
onClick: () => {
|
|
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
|
|
},
|
|
|
|
})),
|
|
|
|
{ name: '(other)', color: '#80808080', value: res.otherFollowersCount },
|
|
|
|
];
|
|
|
|
topPubInstancesForPie.value = [
|
|
|
|
...res.topPubInstances.map(x => ({
|
|
|
|
name: x.host,
|
|
|
|
color: x.themeColor,
|
|
|
|
value: x.followingCount,
|
|
|
|
onClick: () => {
|
|
|
|
os.pageWindow(`/instance-info/${x.host}`);
|
|
|
|
},
|
|
|
|
})),
|
|
|
|
{ name: '(other)', color: '#80808080', value: res.otherFollowingCount },
|
|
|
|
];
|
2022-06-25 07:01:40 -07:00
|
|
|
});
|
2022-12-22 22:21:55 -08:00
|
|
|
|
2023-12-06 21:42:09 -08:00
|
|
|
fetching.value = false;
|
2022-06-25 07:01:40 -07:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
&:global {
|
|
|
|
> .pies {
|
|
|
|
display: grid;
|
2022-12-24 22:36:03 -08:00
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
2022-12-24 22:43:46 -08:00
|
|
|
grid-gap: 12px;
|
|
|
|
margin-bottom: 12px;
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
> .pie {
|
|
|
|
position: relative;
|
|
|
|
padding: 12px;
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
> .title {
|
|
|
|
position: absolute;
|
|
|
|
top: 20px;
|
|
|
|
left: 20px;
|
|
|
|
font-size: 90%;
|
|
|
|
}
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
> .chart {
|
|
|
|
max-height: 150px;
|
2022-06-25 07:01:40 -07:00
|
|
|
}
|
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
> .subTitle {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 20px;
|
|
|
|
right: 20px;
|
|
|
|
font-size: 85%;
|
2022-06-25 07:01:40 -07:00
|
|
|
}
|
|
|
|
}
|
2022-12-22 22:21:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
> .items {
|
|
|
|
display: grid;
|
2022-12-24 22:36:03 -08:00
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
2022-12-24 22:43:46 -08:00
|
|
|
grid-gap: 12px;
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
> .item {
|
|
|
|
display: flex;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 12px;
|
2022-06-25 07:01:40 -07:00
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
> .icon {
|
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
height: 100%;
|
|
|
|
aspect-ratio: 1;
|
|
|
|
margin-right: 12px;
|
|
|
|
background: var(--accentedBg);
|
|
|
|
color: var(--accent);
|
|
|
|
border-radius: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.sub {
|
|
|
|
> .icon {
|
|
|
|
background: #d5ba0026;
|
|
|
|
color: #dfc300;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.pub {
|
|
|
|
> .icon {
|
|
|
|
background: #00cf2326;
|
|
|
|
color: #00cd5b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
2022-12-24 22:36:03 -08:00
|
|
|
padding: 2px 0;
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
> .value {
|
2023-01-01 16:21:44 -08:00
|
|
|
font-size: 1.2em;
|
2022-12-22 22:21:55 -08:00
|
|
|
font-weight: bold;
|
|
|
|
|
|
|
|
> .diff {
|
|
|
|
font-size: 0.65em;
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
font-size: 0.8em;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
2022-06-25 07:01:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
2022-12-22 22:21:55 -08:00
|
|
|
|