Skip to content

Commit 8276de5

Browse files
committed
Preview templates, web links, tips
1 parent a51c3d6 commit 8276de5

14 files changed

+260
-238
lines changed

public/favicon.ico

320 Bytes
Binary file not shown.

src/App.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
>
1414
<n-space justify="space-between" size="large" :wrap="false">
1515
<n-space justify="space-around" :wrap="false">
16-
<n-image :src="logoUrl" :height="32" preview-disabled></n-image>
16+
<a
17+
href="https://labctl.net/guide/config-engine-ui"
18+
target="_blank"
19+
>
20+
<n-image
21+
:src="logoUrl"
22+
:height="32"
23+
preview-disabled
24+
></n-image
25+
></a>
1726
<span style="font-size: 24px">{{ store.topo.name }}</span>
1827
</n-space>
1928

@@ -115,7 +124,7 @@ import {
115124
WsMessage,
116125
WsMsgCodes,
117126
} from "@/utils/websocket";
118-
import logoUrl from "@/assets/labctl.png";
127+
import logoUrl from "@/assets/labctl1.svg";
119128
120129
const store = useMainStore();
121130

src/assets/labctl.png

-33.3 KB
Binary file not shown.

src/assets/labctl1.svg

Lines changed: 22 additions & 0 deletions
Loading

src/components/ce_control.vue

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@
4242
<td v-for="(r, i) in roles" :key="`td:${name}_${i}`" class="cen">
4343
<n-popover v-if="rols[r]" trigger="hover">
4444
<template #trigger>
45-
<n-icon
46-
:component="
47-
getT(name, r).shadow.length
48-
? LibraryAddCheckOutlined
49-
: CheckBoxOutlined
50-
"
51-
size="18px"
52-
/>
45+
<n-button circle @click="templateView = getT(name, r).name">
46+
<n-icon
47+
:component="
48+
getT(name, r).shadow.length
49+
? LibraryAddCheckOutlined
50+
: CheckBoxOutlined
51+
"
52+
size="18px"
53+
/>
54+
</n-button>
5355
</template>
5456

5557
<p>
@@ -64,8 +66,8 @@
6466
&hellip;/{{ getT(name, r).shadow.join(", ") }}/
6567
</span>
6668
</p>
67-
<n-ellipsis :line-clamp="5">
68-
<pre>{{ getT(name, r).value }}</pre>
69+
<n-ellipsis :line-clamp="5" :tooltip="false">
70+
<pre><code>{{ getT(name, r).value }}</code></pre>
6971
</n-ellipsis>
7072
</n-popover>
7173
</td>
@@ -175,6 +177,12 @@
175177

176178
<div v-else>unknown tab ?? {{ selected_tab }}</div>
177179
</n-card>
180+
<template-preview-dialog
181+
v-if="templateView !== ''"
182+
visible
183+
:template="templateView"
184+
@close="templateView = ''"
185+
></template-preview-dialog>
178186
</template>
179187

180188
<script setup lang="ts">
@@ -205,10 +213,11 @@ import {
205213
} from "@vicons/material";
206214
import ConfigResults from "@/components/config_results.vue";
207215
208-
import { ceTemplateName } from "@/utils/helpers";
216+
import { parseTemplateFN } from "@/utils/helpers";
209217
import { wsSend, WsMsgCodes, wsRxBus } from "@/utils/websocket";
210218
import { storeToRefs } from "pinia";
211219
import { MsgWarning } from "@/utils/message";
220+
import TemplatePreviewDialog from "@/components/template_preview_dialog.vue";
212221
213222
export interface PropDef {
214223
selected: Array<string>;
@@ -230,29 +239,31 @@ const cmd_active = ref("compare -l ports -f R1,R2");
230239
const visible = ref(true);
231240
const selected_tab = ref(optCommands.value.length > 0 ? tab.home : tab.run);
232241
242+
/** Dict of all templates, values includes all roles */
233243
const templates = computed(() => {
234-
const roles = {} as Record<string, Record<string, boolean>>;
244+
const temps = {} as Record<string, Record<string, boolean>>;
235245
Object.keys(store.templateFiles)
236246
.sort()
237247
.forEach((fn) => {
238-
const tn = ceTemplateName(fn);
239-
if (!(tn.name in roles)) {
240-
roles[tn.name] = {} as Record<string, boolean>;
248+
const tn = parseTemplateFN(fn);
249+
if (!(tn.name in temps)) {
250+
temps[tn.name] = {} as Record<string, boolean>;
241251
}
242-
roles[tn.name][tn.role] = true;
252+
temps[tn.name][tn.role] = true;
243253
});
244-
return roles;
254+
return temps;
245255
});
246256
257+
/** List available roles/kinds from the templateFiles */
247258
const roles = computed(() => {
248-
const r = new Set<string>();
249-
Object.keys(store.templateFiles).forEach((fn) => {
250-
const tn = ceTemplateName(fn);
251-
r.add(tn.role);
252-
});
253-
return [...r].sort();
259+
const ra = Object.keys(store.templateFiles).map(
260+
(fn) => parseTemplateFN(fn).role
261+
);
262+
const rs = new Set<string>(ra);
263+
return [...rs].sort();
254264
});
255265
266+
/** Get the templateFile from the store using name & role */
256267
function getT(name: string, role: string) {
257268
const n = `${name}__${role}.tmpl`;
258269
return n in store.templateFiles
@@ -285,9 +296,6 @@ function run_config() {
285296
}
286297
287298
const results_all = computed(() => Object.keys(store.results).sort());
288-
// const results_selected = computed(() =>
289-
// results_all.value.filter((v) => props.selected.includes(v))
290-
// );
291299
292300
wsRxBus.on((msg) => {
293301
if (msg.code === WsMsgCodes.config && msg.config && msg.config.results) {
@@ -326,13 +334,17 @@ function close() {
326334
emit("update:close", false);
327335
visible.value = false;
328336
}
337+
338+
const templateView = ref("");
329339
</script>
330340

331341
<style>
332342
span.fn {
333343
/*border: 1px solid black;*/
334344
background-color: aliceblue;
335-
padding: 4px;
345+
padding: 5px;
346+
margin-left: 3px;
347+
margin-right: 3px;
336348
}
337349
td.cen,
338350
th.cen {

src/components/template_preview.vue

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)