annotate web/tiledLayoutPersistence.ts @ 2405:69ca2b2fc133

overcomplicated attempt at persisting the pane layout in the rdf graph this was hard because we have to somehow wait for the graph to load before config'ing the panes
author drewp@bigasterisk.com
date Fri, 17 May 2024 16:58:26 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2405
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
1 // for persistence
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
2 interface SimpleLayoutTab {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
3 type: "tab";
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
4 light9Element: string;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
5 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
6 export interface SimpleLayout {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
7 type: string;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
8 weight?: number;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
9 children: (SimpleLayout | SimpleLayoutTab)[];
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
10 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
11 // for FlexLayout
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
12 interface FullLayoutTab {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
13 type: "tab";
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
14 name: string;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
15 component: string;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
16 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
17 interface FullLayout {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
18 type: string;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
19 weight?: number;
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
20 children: (FullLayout | FullLayoutTab)[];
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
21 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
22 function tabConfigFromSimpleTabName(name: string): FullLayoutTab {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
23 return { type: "tab", name: name.replace(/^light9-/, ""), component: name };
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
24 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
25 export function simpleLayout(full: FullLayout | FullLayoutTab): SimpleLayout | SimpleLayoutTab {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
26 if (full.type == "tab") {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
27 return { type: "tab", light9Element: (full as FullLayoutTab).component };
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
28 } else {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
29 return { ...(full as FullLayout), children: (full as FullLayout).children.map(simpleLayout) };
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
30 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
31 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
32 export function fullLayout(simple: SimpleLayout | SimpleLayoutTab): FullLayout | FullLayoutTab {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
33 if (simple.type == "tab") {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
34 return tabConfigFromSimpleTabName((simple as SimpleLayoutTab).light9Element);
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
35 } else {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
36 return { ...(simple as SimpleLayout), children: (simple as SimpleLayout).children.map(fullLayout) };
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
37 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
38 }
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
39 export const persistedLayout: SimpleLayout = {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
40 type: "row",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
41 children: [
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
42 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
43 // type: "tabset",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
44 // weight: 50,
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
45 // children: [
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
46 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
47 // type: "tab",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
48 // light9Element: "light9-device-settings",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
49 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
50 // ],
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
51 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
52 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
53 // type: "row",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
54 // weight: 50,
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
55 // children: [
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
56 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
57 // type: "tabset",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
58 // weight: 50,
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
59 // children: [
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
60 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
61 // type: "tab",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
62 // light9Element: "light9-fade-ui",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
63 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
64 // ],
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
65 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
66 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
67 // type: "tabset",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
68 // weight: 50,
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
69 // children: [
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
70 // {
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
71 // type: "tab",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
72 // light9Element: "light9-collector-ui",
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
73 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
74 // ],
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
75 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
76 // ],
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
77 // },
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
78 ],
69ca2b2fc133 overcomplicated attempt at persisting the pane layout in the rdf graph
drewp@bigasterisk.com
parents:
diff changeset
79 };