adds telemetry list

This commit is contained in:
2025-02-14 20:22:31 -08:00
parent 44523f3cdb
commit a864c0b41c
19 changed files with 553 additions and 58 deletions

View File

@@ -0,0 +1,92 @@
import type { RouteLocationRaw } from 'vue-router';
export enum PanelHeirarchyType {
LEAF,
FOLDER,
}
export type PanelHeirarchyLeaf = {
name: string;
to: RouteLocationRaw;
type: PanelHeirarchyType.LEAF;
};
export type PanelHeirarchyFolder = {
name: string;
children: PanelHeirarchyChildren;
type: PanelHeirarchyType.FOLDER;
};
export type PanelHeirarchyChildren = (
| PanelHeirarchyFolder
| PanelHeirarchyLeaf
)[];
export function getPanelHeirarchy(): PanelHeirarchyChildren {
const result: PanelHeirarchyChildren = [];
result.push({
name: 'Graph Test',
to: { name: 'graph' },
type: PanelHeirarchyType.LEAF,
});
result.push({
name: 'Telemetry Elements',
to: { name: 'list' },
type: PanelHeirarchyType.LEAF,
});
return result;
}
export function filterHeirarchy(
heirarchy: PanelHeirarchyChildren,
predicate: (leaf: PanelHeirarchyLeaf) => boolean,
): PanelHeirarchyChildren {
const result: PanelHeirarchyChildren = [];
for (const element of heirarchy) {
switch (element.type) {
case PanelHeirarchyType.LEAF:
if (predicate(element)) {
result.push(element);
}
break;
case PanelHeirarchyType.FOLDER:
const folder_contents = filterHeirarchy(
element.children,
predicate,
);
if (folder_contents.length > 0) {
result.push({
name: element.name,
children: folder_contents,
type: PanelHeirarchyType.FOLDER,
});
}
break;
}
}
return result;
}
export function getFirstLeaf(
heirarchy: PanelHeirarchyChildren,
): PanelHeirarchyLeaf | null {
for (const element of heirarchy) {
switch (element.type) {
case PanelHeirarchyType.LEAF:
return element;
case PanelHeirarchyType.FOLDER:
const leaf = getFirstLeaf(element.children);
if (leaf != null) {
return leaf;
}
break;
}
}
return null;
}