2025-02-17 11:18:57 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
|
import { Button } from 'pankow';
|
2025-03-16 11:12:49 +01:00
|
|
|
import moment from 'moment-timezone';
|
2025-02-17 11:42:10 +01:00
|
|
|
import { prettyDecimalSize } from 'pankow/utils';
|
2025-02-17 11:18:57 +01:00
|
|
|
import Section from '../components/Section.vue';
|
2025-02-17 16:38:30 +01:00
|
|
|
import DiskUsage from '../components/DiskUsage.vue';
|
2025-02-18 11:31:11 +01:00
|
|
|
import MemoryUsage from '../components/MemoryUsage.vue';
|
|
|
|
|
import CpuUsage from '../components/CpuUsage.vue';
|
2025-02-17 11:18:57 +01:00
|
|
|
import SystemModel from '../models/SystemModel.js';
|
|
|
|
|
import DashboardModel from '../models/DashboardModel.js';
|
|
|
|
|
|
|
|
|
|
const systemModel = SystemModel.create();
|
|
|
|
|
const dashboardModel = DashboardModel.create();
|
|
|
|
|
|
|
|
|
|
const config = ref({});
|
|
|
|
|
const info = ref({});
|
|
|
|
|
const memory = ref({});
|
|
|
|
|
const cpus = ref({});
|
2025-02-17 11:42:10 +01:00
|
|
|
const uptime = ref('');
|
|
|
|
|
const activeSince = ref('');
|
2025-02-17 11:18:57 +01:00
|
|
|
|
|
|
|
|
function onReboot() {
|
2025-03-16 11:12:49 +01:00
|
|
|
// TODO ask the user!
|
2025-02-17 11:18:57 +01:00
|
|
|
systemModel.reboot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
let [error, result] = await systemModel.memory();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
memory.value = result;
|
|
|
|
|
|
|
|
|
|
[error, result] = await systemModel.cpus();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
cpus.value = result;
|
|
|
|
|
|
|
|
|
|
[error, result] = await systemModel.info();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
info.value = result;
|
|
|
|
|
|
2025-02-17 11:42:10 +01:00
|
|
|
uptime.value = moment.duration(info.value.uptimeSecs, 'seconds').locale(navigator.language).humanize();
|
|
|
|
|
activeSince.value = info.value.activationTime ? moment(info.value.activationTime).fromNow() : 'unknown';
|
|
|
|
|
|
2025-03-12 13:41:07 +01:00
|
|
|
[error, result] = await dashboardModel.config();
|
2025-02-17 11:18:57 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
config.value = result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<Section :title="$t('system.title')">
|
|
|
|
|
<template #header-buttons>
|
|
|
|
|
<Button href="/logs.html?id=box" target="_blank">{{ $t('main.action.logs') }}</Button>
|
|
|
|
|
<Button @click="onReboot()">{{ $t('main.action.reboot') }}</Button>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.platformVersion') }}</div>
|
|
|
|
|
<div class="info-value">v{{ config.version }} ({{ config.ubuntuVersion }})</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.vendor') }}</div>
|
|
|
|
|
<div class="info-value">{{ info.sysVendor }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.product') }}</div>
|
|
|
|
|
<div class="info-value">{{ info.productName }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">CPU</div>
|
|
|
|
|
<div class="info-value">{{ cpus.length ? `${cpus.length} Core "${cpus[0].model}"` : '' }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.memory') }}</div>
|
|
|
|
|
<div class="info-value">{{ prettyDecimalSize(memory.memory) }} RAM <span v-show="memory.swap">& {{ prettyDecimalSize(memory.swap) }} Swap</span></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.uptime') }}</div>
|
2025-02-17 11:42:10 +01:00
|
|
|
<div class="info-value">{{ uptime }}</div>
|
2025-02-17 11:18:57 +01:00
|
|
|
</div>
|
|
|
|
|
<div class="info-row" ng-show="info.activationTime">
|
|
|
|
|
<div class="info-label">{{ $t('system.info.activationTime') }}</div>
|
2025-02-17 11:42:10 +01:00
|
|
|
<div class="info-value">{{ activeSince }}</div>
|
2025-02-17 11:18:57 +01:00
|
|
|
</div>
|
|
|
|
|
</Section>
|
2025-02-17 16:38:30 +01:00
|
|
|
|
2025-02-18 11:31:11 +01:00
|
|
|
<div class="graphs">
|
|
|
|
|
<MemoryUsage style="flex-grow: 1;" />
|
|
|
|
|
<CpuUsage style="flex-grow: 1;" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-02-17 16:38:30 +01:00
|
|
|
<DiskUsage />
|
2025-02-17 11:18:57 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2025-02-18 11:31:11 +01:00
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
.graphs {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 60px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|