You've already forked AstralRinth
forked from didirus/AstralRinth
* feat: abstract api-client DI into ui package * feat: cross platform page system * feat: tanstack as cross platform useAsyncData * feat: archon servers routes + labrinth billing routes * fix: dont use partial * feat: migrate server list page to tanstack + api-client + re-enabled broken features! * feat: migrate servers manage page to api-client before page system * feat: migrate manage page to page system * fix: type issues * fix: upgrade wrapper bugs * refactor: move state types into api-client * feat: disable financial stuff on app frontend * feat: finalize cross platform page system for now * fix: lint * fix: build issues * feat: remove papaparse * fix: lint * fix: interface error --------- Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
67 lines
1.7 KiB
Vue
67 lines
1.7 KiB
Vue
<template>
|
|
<div
|
|
v-if="uptimeSeconds || uptimeSeconds !== 0"
|
|
v-tooltip="`Online for ${verboseUptime}`"
|
|
class="server-action-buttons-anim flex min-w-0 flex-row items-center gap-4"
|
|
data-pyro-uptime
|
|
>
|
|
<div v-if="!noSeparator" class="experimental-styles-within h-6 w-0.5 bg-button-border"></div>
|
|
|
|
<div class="flex gap-2">
|
|
<TimerIcon class="flex size-5 shrink-0" />
|
|
<time class="truncate text-sm font-semibold" :aria-label="verboseUptime">
|
|
{{ formattedUptime }}
|
|
</time>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { TimerIcon } from '@modrinth/assets'
|
|
import { computed } from 'vue'
|
|
|
|
const props = defineProps<{
|
|
uptimeSeconds: number
|
|
noSeparator?: boolean
|
|
}>()
|
|
|
|
const formattedUptime = computed(() => {
|
|
const days = Math.floor(props.uptimeSeconds / (24 * 3600))
|
|
const hours = Math.floor((props.uptimeSeconds % (24 * 3600)) / 3600)
|
|
const minutes = Math.floor((props.uptimeSeconds % 3600) / 60)
|
|
const seconds = props.uptimeSeconds % 60
|
|
|
|
let formatted = ''
|
|
if (days > 0) {
|
|
formatted += `${days}d `
|
|
}
|
|
if (hours > 0 || days > 0) {
|
|
formatted += `${hours}h `
|
|
}
|
|
formatted += `${minutes}m ${seconds}s`
|
|
|
|
return formatted.trim()
|
|
})
|
|
|
|
const verboseUptime = computed(() => {
|
|
const days = Math.floor(props.uptimeSeconds / (24 * 3600))
|
|
const hours = Math.floor((props.uptimeSeconds % (24 * 3600)) / 3600)
|
|
const minutes = Math.floor((props.uptimeSeconds % 3600) / 60)
|
|
const seconds = props.uptimeSeconds % 60
|
|
|
|
let verbose = ''
|
|
if (days > 0) {
|
|
verbose += `${days} day${days > 1 ? 's' : ''} `
|
|
}
|
|
if (hours > 0) {
|
|
verbose += `${hours} hour${hours > 1 ? 's' : ''} `
|
|
}
|
|
if (minutes > 0) {
|
|
verbose += `${minutes} minute${minutes > 1 ? 's' : ''} `
|
|
}
|
|
verbose += `${seconds} second${seconds > 1 ? 's' : ''}`
|
|
|
|
return verbose.trim()
|
|
})
|
|
</script>
|