42
42
<td v-for =" (r, i) in roles" :key =" `td:${name}_${i}`" class =" cen" >
43
43
<n-popover v-if =" rols[r]" trigger =" hover" >
44
44
<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 >
53
55
</template >
54
56
55
57
<p >
64
66
&hellip ; /{{ getT(name, r).shadow.join(", ") }}/
65
67
</span >
66
68
</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 >
69
71
</n-ellipsis >
70
72
</n-popover >
71
73
</td >
175
177
176
178
<div v-else >unknown tab ?? {{ selected_tab }}</div >
177
179
</n-card >
180
+ <template -preview-dialog
181
+ v-if =" templateView !== ' ' "
182
+ visible
183
+ :template =" templateView "
184
+ @close =" templateView = ' ' "
185
+ ></template -preview-dialog>
178
186
</template >
179
187
180
188
<script setup lang="ts">
@@ -205,10 +213,11 @@ import {
205
213
} from " @vicons/material" ;
206
214
import ConfigResults from " @/components/config_results.vue" ;
207
215
208
- import { ceTemplateName } from " @/utils/helpers" ;
216
+ import { parseTemplateFN } from " @/utils/helpers" ;
209
217
import { wsSend , WsMsgCodes , wsRxBus } from " @/utils/websocket" ;
210
218
import { storeToRefs } from " pinia" ;
211
219
import { MsgWarning } from " @/utils/message" ;
220
+ import TemplatePreviewDialog from " @/components/template_preview_dialog.vue" ;
212
221
213
222
export interface PropDef {
214
223
selected: Array <string >;
@@ -230,29 +239,31 @@ const cmd_active = ref("compare -l ports -f R1,R2");
230
239
const visible = ref (true );
231
240
const selected_tab = ref (optCommands .value .length > 0 ? tab .home : tab .run );
232
241
242
+ /** Dict of all templates, values includes all roles */
233
243
const templates = computed (() => {
234
- const roles = {} as Record <string , Record <string , boolean >>;
244
+ const temps = {} as Record <string , Record <string , boolean >>;
235
245
Object .keys (store .templateFiles )
236
246
.sort ()
237
247
.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 >;
241
251
}
242
- roles [tn .name ][tn .role ] = true ;
252
+ temps [tn .name ][tn .role ] = true ;
243
253
});
244
- return roles ;
254
+ return temps ;
245
255
});
246
256
257
+ /** List available roles/kinds from the templateFiles */
247
258
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 ();
254
264
});
255
265
266
+ /** Get the templateFile from the store using name & role */
256
267
function getT(name : string , role : string ) {
257
268
const n = ` ${name }__${role }.tmpl ` ;
258
269
return n in store .templateFiles
@@ -285,9 +296,6 @@ function run_config() {
285
296
}
286
297
287
298
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
- // );
291
299
292
300
wsRxBus .on ((msg ) => {
293
301
if (msg .code === WsMsgCodes .config && msg .config && msg .config .results ) {
@@ -326,13 +334,17 @@ function close() {
326
334
emit (" update:close" , false );
327
335
visible .value = false ;
328
336
}
337
+
338
+ const templateView = ref (" " );
329
339
</script >
330
340
331
341
<style >
332
342
span .fn {
333
343
/* border: 1px solid black;*/
334
344
background-color : aliceblue ;
335
- padding : 4px ;
345
+ padding : 5px ;
346
+ margin-left : 3px ;
347
+ margin-right : 3px ;
336
348
}
337
349
td .cen ,
338
350
th .cen {
0 commit comments