iceshrimp-legacy/packages/client/src/widgets/server-metric/meilisearch.vue

86 lines
1.6 KiB
Vue
Raw Normal View History

2023-05-26 10:51:11 +02:00
<template>
2023-05-29 18:32:55 +02:00
<div class="verusivbr">
2023-05-29 22:17:42 +02:00
<XPie
v-tooltip="i18n.ts.meiliIndexCount"
class="pie"
:value="progress"
:reverse="true"
2023-05-29 22:17:42 +02:00
/>
2023-05-26 10:51:11 +02:00
<div>
<p><i class="ph-file-search ph-bold ph-lg"></i>MeiliSearch</p>
<p>{{ i18n.ts._widgets.meiliStatus }}: {{ available }}</p>
2023-05-30 00:10:14 +02:00
<p>{{ i18n.ts._widgets.meiliSize }}: {{ bytes(totalSize, 1) }}</p>
<p>{{ i18n.ts._widgets.meiliIndexCount }}: {{ indexCount }}</p>
2023-05-26 10:51:11 +02:00
</div>
</div>
<br />
</template>
<script lang="ts" setup>
2023-05-29 05:34:18 +02:00
import { onBeforeUnmount, onMounted } from "vue";
2023-05-29 05:37:53 +02:00
import XPie from "./pie.vue";
2023-07-17 00:32:32 +02:00
import bytes from "@/filters/bytes";
2023-05-29 05:34:18 +02:00
import { i18n } from "@/i18n";
2023-05-29 06:10:21 +02:00
import * as os from "@/os";
2023-05-26 10:51:11 +02:00
const props = defineProps<{
2023-05-28 02:58:20 +02:00
connection: any;
meta: any;
2023-05-26 10:51:11 +02:00
}>();
2023-07-17 00:32:32 +02:00
let progress: number = $ref(0),
serverStats = $ref(null),
totalSize: number = $ref(0),
indexCount: number = $ref(0),
available: string = $ref("unavailable");
2023-05-28 02:58:20 +02:00
function onStats(stats) {
2023-05-30 00:10:14 +02:00
totalSize = stats.meilisearch.size;
indexCount = stats.meilisearch.indexed_count;
2023-05-28 03:05:32 +02:00
available = stats.meilisearch.health;
2023-05-30 00:10:14 +02:00
progress = indexCount / serverStats.notesCount;
2023-05-28 02:58:20 +02:00
}
onMounted(() => {
2023-05-29 06:10:21 +02:00
os.api("stats", {}).then((res) => {
serverStats = res;
});
2023-05-28 02:58:20 +02:00
props.connection.on("stats", onStats);
});
onBeforeUnmount(() => {
props.connection.off("stats", onStats);
});
2023-05-26 10:51:11 +02:00
</script>
<style lang="scss" scoped>
2023-05-29 18:32:55 +02:00
.verusivbr {
display: flex;
2023-05-26 10:51:11 +02:00
padding: 16px;
2023-05-29 05:37:53 +02:00
> .pie {
height: 82px;
flex-shrink: 0;
margin-right: 16px;
}
2023-05-26 10:51:11 +02:00
> div {
2023-05-29 18:32:55 +02:00
flex: 1;
2023-05-26 10:51:11 +02:00
> p {
margin: 0;
font-size: 0.8em;
&:first-child {
font-weight: bold;
margin-bottom: 4px;
> i {
margin-right: 4px;
}
}
}
}
}
</style>