Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hiddifypanel/admin_v2/src/features/nodes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export interface NodeSyncReportOut {
last_seen: string | null
}

/** The node server's operating system (os_id: /etc/os-release ID, for its logo); empty fields when not known. */
export interface NodeOs {
os_id: string
os_name: string
os_version: string
os_pretty: string
kernel: string
arch: string
}

export interface NodePing {
online: boolean
version: string
Expand Down Expand Up @@ -143,6 +153,10 @@ export const nodesApi = {
const { data } = await getHttp().delete<{ node_unlinked?: boolean }>(`nodes/${id}/`, { timeout: 30_000 })
return data.node_unlinked !== false
},
async os(id: number): Promise<NodeOs> {
const { data } = await getHttp().get<NodeOs>(`nodes/${id}/os/`, { timeout: 20_000 })
return data
},
async ping(id: number): Promise<NodePing> {
const { data } = await getHttp().get<NodePing>(`nodes/${id}/ping/`, { timeout: 30_000 })
return data
Expand Down
53 changes: 53 additions & 0 deletions hiddifypanel/admin_v2/src/features/nodes/os-logos.ts

Large diffs are not rendered by default.

307 changes: 305 additions & 2 deletions hiddifypanel/admin_v2/src/features/nodes/views/NodesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@
:style="{ '--node-delay': `${Math.min(index, 10) * 50}ms` }"
>
<header class="node-card__head">
<span class="node-card__icon"><i class="pi pi-server" /></span>
<!-- The server's OS logo (moving gently); a tap shows the OS, its version, kernel and architecture -->
<button
type="button"
class="node-card__icon"
:class="{ 'node-card__icon--os': osLogoOf(node) }"
:style="osLogoOf(node) ? { '--os-c': osLogoOf(node)!.color, '--os-dark': osLogoOf(node)!.dark } : undefined"
:aria-label="t('nodes.os.title')"
aria-haspopup="dialog"
v-tooltip.top="osById[node.id]?.os_pretty || t('nodes.os.title')"
@click="openOs($event, node)"
>
<svg v-if="osLogoOf(node)" viewBox="0 0 24 24" class="node-os-logo" aria-hidden="true"><path :d="osLogoOf(node)!.path" /></svg>
<i v-else class="pi pi-server" />
</button>
<div class="min-w-0 flex-1">
<form v-if="editing === node.id" class="node-card__rename" @submit.prevent="saveName(node)">
<InputText
Expand Down Expand Up @@ -282,6 +295,28 @@
<NodeSyncPanel v-if="syncInfoNode" :key="syncInfoNode.id" :loader="syncReportLoader(syncInfoNode.id)" embedded />
</Dialog>
</div>
<Popover ref="osPop" class="node-os-pop">
<div v-if="osNode" class="node-os" :style="osLogoOf(osNode) ? { '--os-c': osLogoOf(osNode)!.color, '--os-dark': osLogoOf(osNode)!.dark } : undefined">
<header class="node-os__head">
<span class="node-os__logo" :class="{ 'node-os__logo--app': osLogoOf(osNode) }">
<svg v-if="osLogoOf(osNode)" viewBox="0 0 24 24" aria-hidden="true"><path :d="osLogoOf(osNode)!.path" /></svg>
<i v-else class="pi pi-server" />
</span>
<div class="min-w-0">
<div class="node-os__name">{{ osById[osNode.id]?.os_pretty || osById[osNode.id]?.os_name || t('nodes.os.title') }}</div>
<div class="node-os__node">{{ osNode.name }}</div>
</div>
</header>
<div v-if="osById[osNode.id] === undefined || osById[osNode.id] === null" class="node-os__wait"><i class="pi pi-spin pi-spinner" /></div>
<p v-else-if="!osById[osNode.id]!.os_id" class="node-os__none">{{ t('nodes.os.unknown') }}</p>
<dl v-else class="node-os__rows">
<div><dt>{{ t('nodes.os.system') }}</dt><dd>{{ osById[osNode.id]!.os_name }}</dd></div>
<div v-if="osById[osNode.id]!.os_version"><dt>{{ t('nodes.os.version') }}</dt><dd dir="ltr">{{ osById[osNode.id]!.os_version }}</dd></div>
<div v-if="osById[osNode.id]!.kernel"><dt>{{ t('nodes.os.kernel') }}</dt><dd dir="ltr"><code>{{ osById[osNode.id]!.kernel }}</code></dd></div>
<div v-if="osById[osNode.id]!.arch"><dt>{{ t('nodes.os.arch') }}</dt><dd dir="ltr">{{ osById[osNode.id]!.arch }}</dd></div>
</dl>
</div>
</Popover>
</template>

<script setup lang="ts">
Expand Down Expand Up @@ -309,7 +344,8 @@ import NodeContactError from '@/features/nodes/components/NodeContactError.vue'
import { nodeProblems } from '@/shared/composables/useNodeNotices'
import NodeSyncPanel from '@/features/node-home/components/NodeSyncPanel.vue'
import { NodeContactFailure, type NodeSyncLoader } from '@/features/node-home/composables/useNodeSyncStatus'
import { nodesApi, type NodeStatus, type PanelNode } from '@/features/nodes/api'
import { nodesApi, type NodeOs, type NodeStatus, type PanelNode } from '@/features/nodes/api'
import { osLogo } from '@/features/nodes/os-logos'

interface PingState {
state: 'checking' | 'ok' | 'fail'
Expand Down Expand Up @@ -591,13 +627,36 @@ function stopLive() {
liveFeed = null
}

/** Each node server's OS (asked once per node per page; the panel keeps it an hour): null while it is being asked */
const osById = reactive<Record<number, NodeOs | null>>({})
const osPop = ref<InstanceType<typeof Popover> | null>(null)
const osNode = ref<PanelNode | null>(null)
function osLogoOf(node: PanelNode) {
return osLogo(osById[node.id]?.os_id ?? '')
}
function loadOs(list: PanelNode[]) {
for (const node of list) {
if (node.id in osById) continue
osById[node.id] = null
nodesApi
.os(node.id)
.then((os) => (osById[node.id] = os))
.catch(() => (osById[node.id] = { os_id: '', os_name: '', os_version: '', os_pretty: '', kernel: '', arch: '' }))
}
}
function openOs(event: Event, node: PanelNode) {
osNode.value = node
osPop.value?.toggle(event)
}

async function load(silent = false) {
if (!silent) loading.value = true
loadError.value = null
try {
const res = await nodesApi.list()
nodes.value = res.nodes
panelVersion.value = res.panel_version
loadOs(res.nodes)
now.value = Date.now()
} catch (err) {
if (!silent) loadError.value = apiErrorMessage(err) || t('common.loadFailed')
Expand Down Expand Up @@ -821,12 +880,134 @@ onBeforeUnmount(() => {
width: 2.6rem;
height: 2.6rem;
flex-shrink: 0;
padding: 0;
border: 0;
border-radius: 12px;
display: grid;
place-items: center;
font: inherit;
font-size: 1.15rem;
color: var(--node-accent);
background: color-mix(in srgb, var(--node-accent) 14%, transparent);
cursor: pointer;
transition:
transform 0.2s ease,
box-shadow 0.2s ease;
}
.node-card__icon:hover {
transform: translateY(-1px);
box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--os-color, var(--node-accent)) 70%, transparent);
}
.node-card__icon:focus-visible {
outline: 2px solid var(--p-primary-color);
outline-offset: 2px;
}
/* --os-c: the brand colour (set on the element); the dark theme takes the lighter one where there is one */
.node-card__icon,
.node-os {
--os-color: var(--os-c, var(--node-accent, var(--p-primary-color)));
}
html.app-dark .node-card__icon,
html.app-dark .node-os {
--os-color: var(--os-dark, var(--os-c, var(--node-accent, var(--p-primary-color))));
}
/* The server's OS as an app icon, in the panel's soft style (as its other icons): a tile tinted with the brand colour
(lighter at the top), a gloss on its upper half and a fine border, the logo in the brand colour */
.node-card__icon--os {
--os-tile: var(--p-surface-0, #fff);
position: relative;
overflow: hidden;
color: color-mix(in srgb, var(--os-color) 88%, #000);
background: linear-gradient(165deg, color-mix(in srgb, var(--os-color) 10%, var(--os-tile)) 0%, color-mix(in srgb, var(--os-color) 22%, var(--os-tile)) 100%);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--os-color) 26%, transparent),
inset 0 1px 0 rgb(255 255 255 / 55%),
0 4px 12px -8px color-mix(in srgb, var(--os-color) 55%, transparent);
transition:
transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
box-shadow 0.3s ease;
}
/* The gloss */
.node-card__icon--os::before {
content: '';
position: absolute;
inset: 0 0 50%;
background: linear-gradient(180deg, rgb(255 255 255 / 45%), rgb(255 255 255 / 0%));
border-radius: inherit;
pointer-events: none;
}
html.app-dark .node-card__icon--os {
--os-tile: var(--p-surface-900, #18181b);
color: color-mix(in srgb, var(--os-color) 80%, #fff);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--os-color) 35%, transparent),
0 4px 12px -8px color-mix(in srgb, var(--os-color) 55%, transparent);
}
html.app-dark .node-card__icon--os::before {
background: linear-gradient(180deg, rgb(255 255 255 / 10%), rgb(255 255 255 / 0%));
}
/* A band of light, swept across on hover */
.node-card__icon--os::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(115deg, transparent 35%, rgb(255 255 255 / 70%) 50%, transparent 65%) 140% 0 / 250% 100% no-repeat;
opacity: 0;
pointer-events: none;
}
.node-os-logo {
position: relative;
z-index: 1;
width: 1.6rem;
height: 1.6rem;
fill: currentColor;
shape-rendering: geometricPrecision;
filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--os-color) 30%, transparent));
}
.node-card__icon--os:hover {
transform: translateY(-2px) scale(1.06);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--os-color) 35%, transparent),
0 10px 20px -10px color-mix(in srgb, var(--os-color) 70%, transparent);
}
/* With the mouse on it the logo comes alive: it turns a full circle with a bounce, then breathes, again and again while
the mouse stays; a band of light sweeps the tile (still otherwise, and with reduced motion) */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
.node-card__icon--os:hover .node-os-logo {
animation: node-os-alive 1.8s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}
.node-card__icon--os:hover::after {
animation: node-os-shine 1.8s ease infinite;
}
}
@keyframes node-os-alive {
0% {
transform: rotate(0) scale(1);
}
35% {
transform: rotate(360deg) scale(1.18);
}
50% {
transform: rotate(360deg) scale(0.94);
}
62% {
transform: rotate(360deg) scale(1.06);
}
75%,
100% {
transform: rotate(360deg) scale(1);
}
}
@keyframes node-os-shine {
0% {
opacity: 1;
background-position: 140% 0;
}
45%,
100% {
opacity: 1;
background-position: -40% 0;
}
}
.node-card__name {
display: flex;
Expand Down Expand Up @@ -1384,4 +1565,126 @@ onBeforeUnmount(() => {
.node-why-pop .p-popover-content {
padding: 0.35rem;
}
/* A node's OS card (the logo's popover; in <body>, so not scoped) */
.node-os-pop.p-popover {
--p-popover-content-padding: 0;
}
.node-os-pop .p-popover-content {
padding: 0;
}
html.theme-caddy .node-os-pop.p-popover {
background: var(--p-surface-0);
}
html.theme-caddy.app-dark .node-os-pop.p-popover {
background: var(--p-surface-900);
}
.node-os {
min-width: 15rem;
border-top: 3px solid var(--os-color);
border-radius: inherit;
font-size: 0.85rem;
}
.node-os__head {
display: flex;
align-items: center;
gap: 0.7rem;
padding: 0.8rem 0.9rem 0.6rem;
}
.node-os__logo {
flex: none;
display: grid;
place-items: center;
width: 2.9rem;
height: 2.9rem;
border-radius: 13px;
color: var(--os-color);
background: linear-gradient(145deg, var(--p-surface-0, #fff), color-mix(in srgb, var(--os-color) 9%, var(--p-surface-0, #fff)));
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--os-color) 28%, transparent);
font-size: 1.2rem;
}
.node-os__logo svg {
position: relative;
width: 1.8rem;
height: 1.8rem;
fill: currentColor;
shape-rendering: geometricPrecision;
}
.node-os__logo--app {
--os-tile: var(--p-surface-0, #fff);
position: relative;
overflow: hidden;
color: color-mix(in srgb, var(--os-color) 88%, #000);
background: linear-gradient(165deg, color-mix(in srgb, var(--os-color) 10%, var(--os-tile)) 0%, color-mix(in srgb, var(--os-color) 22%, var(--os-tile)) 100%);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--os-color) 26%, transparent),
0 4px 12px -8px color-mix(in srgb, var(--os-color) 55%, transparent);
}
html.app-dark .node-os__logo--app {
--os-tile: var(--p-surface-900, #18181b);
color: color-mix(in srgb, var(--os-color) 80%, #fff);
}
.node-os__logo--app::before {
content: '';
position: absolute;
inset: 0 0 50%;
background: linear-gradient(180deg, rgb(255 255 255 / 45%), rgb(255 255 255 / 0%));
}
html.app-dark .node-os__logo--app::before {
background: linear-gradient(180deg, rgb(255 255 255 / 10%), rgb(255 255 255 / 0%));
}
@media (prefers-reduced-motion: no-preference) {
.node-os__logo svg {
animation: node-os-spin-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
}
@keyframes node-os-spin-in {
from {
transform: rotate(-90deg) scale(0.6);
opacity: 0;
}
}
.node-os__name {
font-size: 0.95rem;
font-weight: 700;
}
.node-os__node {
margin-top: 0.1rem;
font-size: 0.75rem;
color: var(--p-text-muted-color);
}
.node-os__rows {
margin: 0;
padding: 0 0.9rem 0.65rem;
}
.node-os__rows > div {
display: flex;
justify-content: space-between;
gap: 1.25rem;
padding: 0.38rem 0;
border-top: 1px solid var(--p-content-border-color);
}
.node-os__rows dt {
color: var(--p-text-muted-color);
}
.node-os__rows dd {
margin: 0;
font-weight: 600;
text-align: end;
}
.node-os__rows code {
font-size: 0.78rem;
font-weight: 500;
}
.node-os__wait {
display: grid;
place-items: center;
padding: 0.5rem 0 0.9rem;
color: var(--p-text-muted-color);
}
.node-os__none {
margin: 0;
padding: 0 0.9rem 0.8rem;
line-height: 1.5;
color: var(--p-text-muted-color);
}
</style>
Loading
Loading