2022-06-25 23:01:40 +09:00
|
|
|
<template>
|
|
|
|
<div class="wbrkwale">
|
|
|
|
<MkLoading v-if="fetching"/>
|
|
|
|
<transition-group v-else tag="div" :name="$store.state.animation ? 'chart' : ''" class="instances">
|
2022-06-26 01:45:33 +09:00
|
|
|
<MkA v-for="(instance, i) in instances" :key="instance.id" :to="`/instance-info/${instance.host}`" class="instance">
|
2022-06-25 23:01:40 +09:00
|
|
|
<img v-if="instance.iconUrl" :src="instance.iconUrl" alt=""/>
|
|
|
|
<div class="body">
|
2022-06-26 01:45:33 +09:00
|
|
|
<div class="name">{{ instance.name ?? instance.host }}</div>
|
|
|
|
<div class="host">{{ instance.host }}</div>
|
2022-06-25 23:01:40 +09:00
|
|
|
</div>
|
|
|
|
<MkMiniChart class="chart" :src="charts[i].requests.received"/>
|
2022-06-26 01:45:33 +09:00
|
|
|
</MkA>
|
2022-06-25 23:01:40 +09:00
|
|
|
</transition-group>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted, onUnmounted, ref } from 'vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkMiniChart from '@/components/MkMiniChart.vue';
|
2022-06-25 23:01:40 +09:00
|
|
|
import * as os from '@/os';
|
2022-06-26 03:12:58 +09:00
|
|
|
import { useInterval } from '@/scripts/use-interval';
|
2022-06-25 23:01:40 +09:00
|
|
|
|
|
|
|
const instances = ref([]);
|
|
|
|
const charts = ref([]);
|
|
|
|
const fetching = ref(true);
|
|
|
|
|
|
|
|
const fetch = async () => {
|
|
|
|
const fetchedInstances = await os.api('federation/instances', {
|
|
|
|
sort: '+lastCommunicatedAt',
|
|
|
|
limit: 5,
|
|
|
|
});
|
|
|
|
const fetchedCharts = await Promise.all(fetchedInstances.map(i => os.apiGet('charts/instance', { host: i.host, limit: 16, span: 'hour' })));
|
|
|
|
instances.value = fetchedInstances;
|
|
|
|
charts.value = fetchedCharts;
|
|
|
|
fetching.value = false;
|
|
|
|
};
|
|
|
|
|
2022-06-26 03:12:58 +09:00
|
|
|
useInterval(fetch, 1000 * 60, {
|
|
|
|
immediate: true,
|
|
|
|
afterMounted: true,
|
2022-06-25 23:01:40 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.wbrkwale {
|
|
|
|
> .instances {
|
|
|
|
.chart-move {
|
|
|
|
transition: transform 1s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .instance {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
border-bottom: solid 0.5px var(--divider);
|
|
|
|
}
|
|
|
|
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
width: 34px;
|
|
|
|
height: 34px;
|
|
|
|
object-fit: cover;
|
|
|
|
border-radius: 4px;
|
|
|
|
margin-right: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
flex: 1;
|
|
|
|
overflow: hidden;
|
|
|
|
font-size: 0.9em;
|
|
|
|
color: var(--fg);
|
|
|
|
padding-right: 8px;
|
|
|
|
|
2022-06-26 01:45:33 +09:00
|
|
|
> .name {
|
2022-06-25 23:01:40 +09:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
2022-06-26 01:45:33 +09:00
|
|
|
> .host {
|
2022-06-25 23:01:40 +09:00
|
|
|
margin: 0;
|
|
|
|
font-size: 75%;
|
|
|
|
opacity: 0.7;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .chart {
|
|
|
|
height: 30px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|