implement partial SSR of instances

This commit is contained in:
2025-03-12 20:16:51 +00:00
parent 8b508d14cc
commit 59d12d2e99
15 changed files with 611 additions and 264 deletions

View File

@@ -8,6 +8,7 @@
<script>
window.PVE = "{{.global.PVE}}";
window.API = "{{.global.API}}";
window.DASH = "{{.global.DASH}}";
</script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/nav.css">

View File

@@ -0,0 +1,35 @@
{{define "instance"}}
<instance-card data-type="{{.Type}}" data-status="{{.Status}}" data-vmid="{{.VMID}}" data-name="{{.Name}}" data-node="{{.Node}}" data-nodestatus="{{.NodeStatus}}">
<template shadowrootmode="open">
<link rel="stylesheet" href="modules/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="css/style.css">
<style>
* {
margin: 0;
}
</style>
<div class="w3-row" style="margin-top: 1em; margin-bottom: 1em;">
<hr class="w3-show-small w3-hide-medium w3-hide-large" style="margin: 0; margin-bottom: 1em;">
<p class="w3-col l1 m2 s6">{{.VMID}}</p>
<p class="w3-col l2 m3 s6" id="instance-name">{{.Name}}</p>
<p class="w3-col l1 m2 w3-hide-small">{{.Type}}</p>
<div class="w3-col l2 m3 s6 flex row nowrap">
{{template "svg" .StatusIcon}}
<p>{{.Status}}</p>
</div>
<p class="w3-col l2 w3-hide-medium w3-hide-small">{{.Node}}</p>
<div class="w3-col l2 w3-hide-medium w3-hide-small flex row nowrap">
{{template "svg" .NodeStatusIcon}}
<p>{{.NodeStatus}}</p>
</div>
<div class="w3-col l2 m2 s6 flex row nowrap" style="height: 1lh;">
{{template "svg" .PowerBtnIcon}}
{{template "svg" .ConsoleBtnIcon}}
{{template "svg" .ConfigureBtnIcon}}
{{template "svg" .DeleteBtnIcon}}
</div>
</div>
</template>
</instance-card>
{{end}}

View File

@@ -0,0 +1,3 @@
{{range .instances}}
{{template "instance" .}}
{{end}}

7
web/templates/svg.tmpl Normal file
View File

@@ -0,0 +1,7 @@
{{define "svg"}}
{{if .Clickable}}
<svg id={{.ID}} alt="{{.Alt}}" class="clickable"><use href="{{.Src}}#symb"></svg>
{{else}}
<svg id={{.ID}} alt="{{.Alt}}"><use href="{{.Src}}#symb"></svg>
{{end}}
{{end}}