You've already forked AstralRinth
forked from didirus/AstralRinth
* fix(content): changing mod versions works again * chore(assets): update pyro logo * fix(properties): deprecate fetchconfigfile * Revert "fix(content): changing mod versions works again" This reverts commit d7c0d1196f8c1850fd7ccbc1644941c6db4dc306. * feat(files): ability to sort via column click * chore(startup): update clunky wording * feat(serverListing): server icons SSR friendly * fix(servers): if archon fails, display err in listing * chore(serverlisting): use pyroserver hook to init icon * chore(servers): much more graceful reinstall * fix(servers): tw warn * fix(platform): correctly react when pack reinstalled * fix(serversroot): explicitly import navigateTo Signed-off-by: Evan Song <theevansong@gmail.com> * chore(serverlabels): show skeleton instead of hiding Signed-off-by: Evan Song <theevansong@gmail.com> * feat(platform): install-aware controls Signed-off-by: Evan Song <theevansong@gmail.com> * refactor!(platform): rewrite platform page * fix(platform): regression in autoselecting loader * chore(platform): prefer version over project modification date * fix(platform): permanent hang after initial mount * chore(platform): do not silently fail and hang if modpack fails loading * oops: remove hardcoded error causer * fix(platform): switch modpack btn while installing doesnt need class Signed-off-by: Evan Song <theevansong@gmail.com> * chore(platform): adjust styling in version modal Signed-off-by: Evan Song <theevansong@gmail.com> * chore(platform): prevent changing project card style Signed-off-by: Evan Song <theevansong@gmail.com> * refactor(pyrodropdown): rewrite Signed-off-by: Evan Song <theevansong@gmail.com> * fix(pyrodropdown): do nopt use deprecated substr Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * fix(network): sentence case Signed-off-by: Evan Song <theevansong@gmail.com> * refactor(terminal): initial batch Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): fulllog over fullscreen Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): fullscreen conflict with body scroll Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): init drag select * feat(terminal): shift click support Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): double lines limit Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): copy button Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): protip style Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): improve styles Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): regex search Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): move icons to icons dir Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): improve drag select autoscroll inertia Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): cancel selection on right click Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): progblur and stb btn disappearing Signed-off-by: Evan Song <theevansong@gmail.com> * refactor(serverstats): power efficiency * fix(subdomainlabel): correct tooltip terminology Signed-off-by: Evan Song <theevansong@gmail.com> * feat(preferences): users hide subdomain label Signed-off-by: Evan Song <theevansong@gmail.com> * chore(servers): clean Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): deselect lines on escape Signed-off-by: Evan Song <theevansong@gmail.com> * fix(serversidebar): type err Signed-off-by: Evan Song <theevansong@gmail.com> * fix(fileitem): vue server render type Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): disable pointer events on lines if scrolling Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): search result counts style Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): plural Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): clean Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): view selection Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): show actively selected lines in scrollbar Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminallog): btn color Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * fix(gamelabel): align to text Signed-off-by: Evan Song <theevansong@gmail.com> * fix(gamelabel): align to text Signed-off-by: Evan Song <theevansong@gmail.com> * fix(listing): remove deadcode Signed-off-by: Evan Song <theevansong@gmail.com> * fix(serverlisting): deprecated process.server Signed-off-by: Evan Song <theevansong@gmail.com> * fix(platform): correctly disable button Signed-off-by: Evan Song <theevansong@gmail.com> * fix(backups): do not allow backup creation during server installation Signed-off-by: Evan Song <theevansong@gmail.com> * fix(platform): flush stale currentversion data on successful install Signed-off-by: Evan Song <theevansong@gmail.com> * fix(gamelabel): fix gap Signed-off-by: Evan Song <theevansong@gmail.com> * chore(network): vaporize uppercase Signed-off-by: Evan Song <theevansong@gmail.com> * chore(info): vaporize uppercase Signed-off-by: Evan Song <theevansong@gmail.com> * chore(backups): style unification Signed-off-by: Evan Song <theevansong@gmail.com> * chore(backups): finalize style change Signed-off-by: Evan Song <theevansong@gmail.com> * fix(servers): catch pyro servers fetch errors during ssr Signed-off-by: Evan Song <theevansong@gmail.com> * fix(serverstats): ram as bytes graph now works Signed-off-by: Evan Song <theevansong@gmail.com> * fix(platform): unify attempts and refresh interval Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): input Signed-off-by: Evan Song <theevansong@gmail.com> * feat(servers): installing ticket + update available notice back in platform Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): dont add bg to scroll track Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): preserve whitespace Signed-off-by: Evan Song <theevansong@gmail.com> * chore(serversroot): unnest blurred icon query Signed-off-by: Evan Song <theevansong@gmail.com> * fix(serverstats): clamp memory usage to 100% no matter what Signed-off-by: Evan Song <theevansong@gmail.com> * feat(terminal): allow copy of single lines, show btn Signed-off-by: Evan Song <theevansong@gmail.com> * chore(terminal): animate copy>view transition Signed-off-by: Evan Song <theevansong@gmail.com> * init: search improvements Signed-off-by: Evan Song <theevansong@gmail.com> * fix: lint Signed-off-by: Evan Song <theevansong@gmail.com> * chore: change log modal title Signed-off-by: Evan Song <theevansong@gmail.com> * fix: hide fullscreen when selecting and cancel selection on clickout Signed-off-by: Evan Song <theevansong@gmail.com> * refactor(terminal): more reliable jumpToLine Signed-off-by: Evan Song <theevansong@gmail.com> * feat: search results separator Signed-off-by: Evan Song <theevansong@gmail.com> * chore: remove buggy isScrollable check Signed-off-by: Evan Song <theevansong@gmail.com> * fix: style Signed-off-by: Evan Song <theevansong@gmail.com> * refactor: correctly store pos to make jump reliable Signed-off-by: Evan Song <theevansong@gmail.com> * fix: disparity between search/log dragselect Signed-off-by: Evan Song <theevansong@gmail.com> * fix: prevent propagation of click events when clicking on jump btn Signed-off-by: Evan Song <theevansong@gmail.com> * fix: switch selection strategies depending on terminal mode Signed-off-by: Evan Song <theevansong@gmail.com> * chore: smarter esc handling Signed-off-by: Evan Song <theevansong@gmail.com> * finalize Signed-off-by: Evan Song <theevansong@gmail.com> * run fix * fix: ensure lines between cannot be selected Signed-off-by: Evan Song <theevansong@gmail.com> * fix: increase initial log batch to 256 Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): click on scroll track should take user to new scroll position Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): update aria label for view selected logs btn Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> --------- Signed-off-by: Evan Song <theevansong@gmail.com>
197 lines
5.4 KiB
Vue
197 lines
5.4 KiB
Vue
<template>
|
|
<div
|
|
data-pyro-server-stats
|
|
style="font-variant-numeric: tabular-nums"
|
|
class="flex select-none flex-col items-center gap-6 md:flex-row"
|
|
>
|
|
<div
|
|
v-for="(metric, index) in metrics"
|
|
:key="index"
|
|
class="relative isolate min-h-[156px] w-full overflow-hidden rounded-2xl bg-bg-raised p-8"
|
|
>
|
|
<div class="relative z-10 -ml-3 w-fit rounded-xl px-3 py-1">
|
|
<div class="relative z-10">
|
|
<div class="-mb-0.5 mt-0.5 flex flex-row items-center gap-2">
|
|
<h2 class="m-0 -ml-0.5 text-3xl font-extrabold text-contrast">{{ metric.value }}</h2>
|
|
<h3 class="text-sm font-normal text-secondary">/ {{ metric.max }}</h3>
|
|
</div>
|
|
<h3 class="flex items-center gap-2 text-base font-normal text-secondary">
|
|
{{ metric.title }}
|
|
<WarningIcon
|
|
v-if="metric.warning"
|
|
v-tooltip="metric.warning"
|
|
class="size-5"
|
|
:style="{ color: 'var(--color-orange)' }"
|
|
/>
|
|
</h3>
|
|
</div>
|
|
<div class="absolute -left-8 -top-4 h-28 w-56 rounded-full bg-bg-raised blur-lg" />
|
|
</div>
|
|
|
|
<component :is="metric.icon" class="absolute right-10 top-10 z-10" />
|
|
<ClientOnly>
|
|
<VueApexCharts
|
|
v-if="metric.showGraph"
|
|
type="area"
|
|
height="142"
|
|
:options="getChartOptions(metric.warning)"
|
|
:series="[{ name: metric.title, data: metric.data }]"
|
|
class="chart absolute bottom-0 left-0 right-0 w-full opacity-0"
|
|
/>
|
|
</ClientOnly>
|
|
</div>
|
|
|
|
<NuxtLink
|
|
:to="`/servers/manage/${serverId}/files`"
|
|
class="relative isolate min-h-[156px] w-full overflow-hidden rounded-2xl bg-bg-raised p-8 transition-transform duration-100 hover:scale-105 active:scale-100"
|
|
>
|
|
<div class="flex flex-row items-center gap-2">
|
|
<h2 class="m-0 -ml-0.5 mt-1 text-3xl font-extrabold text-contrast">
|
|
{{ formatBytes(stats.storage_usage_bytes) }}
|
|
</h2>
|
|
</div>
|
|
<h3 class="text-base font-normal text-secondary">Storage usage</h3>
|
|
<FolderOpenIcon class="absolute right-10 top-10 size-8" />
|
|
</NuxtLink>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed, shallowRef } from "vue";
|
|
import { FolderOpenIcon, CPUIcon, DBIcon } from "@modrinth/assets";
|
|
import { useStorage } from "@vueuse/core";
|
|
import type { Stats } from "~/types/servers";
|
|
import WarningIcon from "~/assets/images/utils/issues.svg?component";
|
|
|
|
const route = useNativeRoute();
|
|
const serverId = route.params.id;
|
|
const VueApexCharts = defineAsyncComponent(() => import("vue3-apexcharts"));
|
|
|
|
const userPreferences = useStorage(`pyro-server-${serverId}-preferences`, {
|
|
ramAsNumber: false,
|
|
});
|
|
|
|
const props = defineProps<{ data: Stats }>();
|
|
|
|
const stats = shallowRef(props.data.current);
|
|
|
|
const formatBytes = (bytes: number) => {
|
|
const units = ["B", "KB", "MB", "GB"];
|
|
let value = bytes;
|
|
let unit = 0;
|
|
while (value >= 1024 && unit < units.length - 1) {
|
|
value /= 1024;
|
|
unit++;
|
|
}
|
|
return `${Math.round(value * 10) / 10} ${units[unit]}`;
|
|
};
|
|
|
|
const cpuData = ref<number[]>(Array(20).fill(0));
|
|
const ramData = ref<number[]>(Array(20).fill(0));
|
|
|
|
const updateGraphData = (arr: number[], newValue: number) => {
|
|
arr.push(newValue);
|
|
arr.shift();
|
|
};
|
|
|
|
const metrics = computed(() => {
|
|
const ramPercent = Math.min(
|
|
(stats.value.ram_usage_bytes / stats.value.ram_total_bytes) * 100,
|
|
100,
|
|
);
|
|
const cpuPercent = Math.min(stats.value.cpu_percent, 100);
|
|
|
|
updateGraphData(cpuData.value, cpuPercent);
|
|
updateGraphData(ramData.value, ramPercent);
|
|
|
|
return [
|
|
{
|
|
title: "CPU usage",
|
|
value: `${cpuPercent.toFixed(2)}%`,
|
|
max: "100%",
|
|
icon: CPUIcon,
|
|
data: cpuData.value,
|
|
showGraph: true,
|
|
warning: cpuPercent >= 90 ? "CPU usage is very high" : null,
|
|
},
|
|
{
|
|
title: "Memory usage",
|
|
value: userPreferences.value.ramAsNumber
|
|
? formatBytes(stats.value.ram_usage_bytes)
|
|
: `${ramPercent.toFixed(2)}%`,
|
|
max: userPreferences.value.ramAsNumber ? formatBytes(stats.value.ram_total_bytes) : "100%",
|
|
icon: DBIcon,
|
|
data: ramData.value,
|
|
showGraph: true,
|
|
warning: ramPercent >= 90 ? "Memory usage is very high" : null,
|
|
},
|
|
];
|
|
});
|
|
|
|
const getChartOptions = (hasWarning: string | null) => ({
|
|
chart: {
|
|
type: "area",
|
|
animations: { enabled: false },
|
|
sparkline: { enabled: true },
|
|
toolbar: { show: false },
|
|
padding: {
|
|
left: -10,
|
|
right: -10,
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
},
|
|
stroke: { curve: "smooth", width: 3 },
|
|
fill: {
|
|
type: "gradient",
|
|
gradient: {
|
|
shadeIntensity: 1,
|
|
opacityFrom: 0.25,
|
|
opacityTo: 0.05,
|
|
stops: [0, 100],
|
|
},
|
|
},
|
|
tooltip: { enabled: false },
|
|
grid: { show: false },
|
|
xaxis: {
|
|
labels: { show: false },
|
|
axisBorder: { show: false },
|
|
type: "numeric",
|
|
tickAmount: 20,
|
|
range: 20,
|
|
},
|
|
yaxis: {
|
|
show: false,
|
|
min: 0,
|
|
max: 100,
|
|
forceNiceScale: false,
|
|
},
|
|
colors: [hasWarning ? "var(--color-orange)" : "var(--color-brand)"],
|
|
dataLabels: {
|
|
enabled: false,
|
|
},
|
|
});
|
|
|
|
watch(
|
|
() => props.data.current,
|
|
(newStats) => {
|
|
stats.value = newStats;
|
|
},
|
|
);
|
|
</script>
|
|
|
|
<style scoped>
|
|
.chart {
|
|
animation: fadeIn 0.2s ease-out 0.2s forwards;
|
|
margin-left: -24px;
|
|
margin-right: -24px;
|
|
width: calc(100% + 48px) !important;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|