Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonSmith committed Jan 19, 2024
1 parent ebd16d9 commit 5165b18
Show file tree
Hide file tree
Showing 8 changed files with 1,136 additions and 1,102 deletions.
1,854 changes: 928 additions & 926 deletions esp/src/package-lock.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions esp/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@
},
"main": "src/stub.js",
"dependencies": {
"@fluentui/react": "8.114.0",
"@fluentui/react-components": "9.44.0",
"@fluentui/react-experiments": "8.14.122",
"@fluentui/react-hooks": "8.6.34",
"@fluentui/react-icons-mdl2": "1.3.53",
"@fluentui/react-migration-v8-v9": "9.4.42",
"@hpcc-js/chart": "2.81.8",
"@hpcc-js/codemirror": "2.61.0",
"@hpcc-js/common": "2.71.13",
"@hpcc-js/comms": "2.86.0",
"@fluentui/react": "8.114.3",
"@fluentui/react-components": "9.44.5",
"@fluentui/react-experiments": "8.14.125",
"@fluentui/react-hooks": "8.6.35",
"@fluentui/react-icons-mdl2": "1.3.55",
"@fluentui/react-migration-v8-v9": "9.5.2",
"@hpcc-js/chart": "2.81.9",
"@hpcc-js/codemirror": "2.61.1",
"@hpcc-js/common": "2.71.14",
"@hpcc-js/comms": "2.86.1",
"@hpcc-js/dataflow": "8.1.6",
"@hpcc-js/eclwatch": "2.73.31",
"@hpcc-js/graph": "2.85.9",
"@hpcc-js/html": "2.42.14",
"@hpcc-js/layout": "2.49.13",
"@hpcc-js/map": "2.77.12",
"@hpcc-js/other": "2.15.13",
"@hpcc-js/phosphor": "2.17.0",
"@hpcc-js/react": "2.53.10",
"@hpcc-js/tree": "2.40.13",
"@hpcc-js/eclwatch": "2.73.32",
"@hpcc-js/graph": "2.85.10",
"@hpcc-js/html": "2.42.15",
"@hpcc-js/layout": "2.49.14",
"@hpcc-js/map": "2.77.13",
"@hpcc-js/other": "2.15.14",
"@hpcc-js/phosphor": "2.18.0",
"@hpcc-js/react": "2.53.11",
"@hpcc-js/tree": "2.40.14",
"@hpcc-js/util": "2.50.6",
"@kubernetes/client-node": "0.20.0",
"clipboard": "2.0.11",
Expand All @@ -72,7 +72,7 @@
"octokit": "3.1.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "7.49.2",
"react-hook-form": "7.49.3",
"react-hot-toast": "2.4.1",
"react-reflex": "4.2.1",
"react-sizeme": "3.0.2",
Expand All @@ -82,23 +82,23 @@
"devDependencies": {
"@simbathesailor/use-what-changed": "^2.0.0",
"@types/dojo": "1.9.48",
"@types/react": "17.0.74",
"@types/react": "17.0.75",
"@types/react-dom": "17.0.25",
"@typescript-eslint/eslint-plugin": "6.17.0",
"@typescript-eslint/parser": "6.17.0",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"copyfiles": "2.4.1",
"css-loader": "6.8.1",
"css-loader": "6.9.0",
"dojo-webpack-plugin": "3.0.6",
"eslint": "8.56.0",
"eslint-plugin-eclwatch": "file:./eslint",
"eslint-plugin-react-hooks": "4.6.0",
"file-loader": "6.2.0",
"local-web-server": "5.3.0",
"local-web-server": "5.3.1",
"npm-run-all": "4.1.5",
"rimraf": "5.0.5",
"source-map-loader": "4.0.2",
"string-replace-loader": "3.1.0",
"style-loader": "3.3.3",
"style-loader": "3.3.4",
"tslib": "2.6.2",
"typescript": "5.3.3",
"url-loader": "4.1.1",
Expand Down
110 changes: 5 additions & 105 deletions esp/src/src-react/components/ECLArchive.tsx
Original file line number Diff line number Diff line change
@@ -1,123 +1,23 @@
import * as React from "react";
import { CommandBar, ContextualMenuItemType, ICommandBarItemProps } from "@fluentui/react";
import { FlatTree, useHeadlessFlatTree_unstable, HeadlessFlatTreeItemProps, TreeItem, TreeItemLayout, CounterBadge } from "@fluentui/react-components";
import { useConst } from "@fluentui/react-hooks";
import { FluentIconsProps, FolderOpen20Regular, Folder20Regular, FolderOpen20Filled, Folder20Filled, Document20Regular, Document20Filled, Important16Regular } from "@fluentui/react-icons";
import { Palette } from "@hpcc-js/common";
import { Table } from "@hpcc-js/dgrid";
import { ECLEditor } from "@hpcc-js/codemirror";
import { WUDetails } from "@hpcc-js/comms";
import nlsHPCC from "src/nlsHPCC";
import { useWorkunitArchive } from "../hooks/workunit";
import { useWorkunitMetrics } from "../hooks/metrics";
import { useUserTheme } from "../hooks/theme";
import { HolyGrail } from "../layouts/HolyGrail";
import { DockPanel, DockPanelItem, ResetableDockPanel } from "../layouts/DockPanel";
import { AutosizeHpccJSComponent } from "../layouts/HpccJSAdapter";
import { Archive, isAttribute } from "../util/metricArchive";
import { pushUrl } from "../util/history";
import { ShortVerticalDivider } from "./Common";
import { WUDetails } from "@hpcc-js/comms";
import { ECLArchiveTree } from "./ECLArchiveTree";

const palette = Palette.rainbow("YlOrRd");

type FlatItem = HeadlessFlatTreeItemProps & { fileTimePct?: number, content: string };

const iconStyleProps: FluentIconsProps = {
primaryFill: "red",
};

const AsideContent = ({
isImportant,
messageCount,
}: {
isImportant?: boolean;
messageCount?: number;
}) => {
const color = messageCount < 50 ? "brand" :
messageCount < 70 ? "informative" :
messageCount < 90 ? "important" :
"danger";
return <>
{isImportant && <Important16Regular {...iconStyleProps} />}
{!isNaN(messageCount) && messageCount > 0 && (
<CounterBadge count={messageCount} color={color} size="small" />
)}
</>;
};

interface ECLArchiveTreeProps {
archive?: Archive;
selectedItem: string;
setSelectedItem: (_: string) => void;
}

export const ECLArchiveTree: React.FunctionComponent<ECLArchiveTreeProps> = ({
archive,
selectedItem,
setSelectedItem
}) => {

const defaultOpenItems = React.useMemo(() => {
return (archive?.modAttrs.filter(modAttr => modAttr.type === "Module") ?? []).map(modAttr => modAttr.id) ?? [];
}, [archive?.modAttrs]);

const [flatTreeItems, setFlatTreeItems] = React.useState<FlatItem[]>([]);
const flatTree = useHeadlessFlatTree_unstable(flatTreeItems, { defaultOpenItems });

React.useEffect(() => {
const flatTreeItems: FlatItem[] = [];
archive?.modAttrs.forEach(modAttr => {
flatTreeItems.push({
value: modAttr.id,
parentValue: modAttr.parentId ? modAttr.parentId : undefined,
content: modAttr.name,
fileTimePct: isAttribute(modAttr) && Math.round((archive?.fileTimeTotalExecute[modAttr.sourcePath]?.total / archive?.timeTotalExecute) * 100),
});
});
setFlatTreeItems(flatTreeItems);
}, [archive?.fileTimeTotalExecute, archive?.modAttrs, archive?.timeTotalExecute]);

const onClick = React.useCallback(evt => {
const selId = evt.currentTarget?.dataset?.fuiTreeItemValue;
if (archive?.modAttrs.find(modAttr => modAttr.id === selId)?.type === "Attribute") {
setSelectedItem(selId);
}
}, [archive?.modAttrs, setSelectedItem]);

const { ...treeProps } = flatTree.getTreeProps();
return <FlatTree {...treeProps} size="small">
{
Array.from(flatTree.items(), flatTreeItem => {
console.log(flatTreeItem.getTreeItemProps());
const { fileTimePct, content, ...treeItemProps } = flatTreeItem.getTreeItemProps();
return <TreeItem {...treeItemProps} onClick={onClick}>
<TreeItemLayout
// expandIcon={
// flatTreeItem.itemType === "branch" ?
// (treeProps.openItems.has(flatTreeItem.value) ?
// selectedItem?.startsWith(content) ? <FolderOpen20Filled /> : <FolderOpen20Regular /> :
// selectedItem?.startsWith(content) ? <Folder20Filled /> : <Folder20Regular />)
// :
// undefined
// }
iconBefore={
flatTreeItem.itemType === "branch" ?
(treeProps.openItems.has(flatTreeItem.value) ?
selectedItem?.startsWith(content) ? <FolderOpen20Filled /> : <FolderOpen20Regular /> :
selectedItem?.startsWith(content) ? <Folder20Filled /> : <Folder20Regular />) :
flatTreeItem.value === selectedItem ?
<Document20Filled /> :
<Document20Regular />
}
aside={<AsideContent isImportant={false} messageCount={fileTimePct} />}
>
{content}
</TreeItemLayout>
</TreeItem>;
})
}
</FlatTree >;
};
interface ECLArchiveProps {
wuid: string;
parentUrl?: string;
Expand Down Expand Up @@ -173,7 +73,7 @@ export const ECLArchive: React.FunctionComponent<ECLArchiveProps> = ({
?.text(selectionText ?? "")
?.lazyRender()
;
}, [archive, archive?.fileTimeTotalExecute, editor, selection]);
}, [archive, editor, selection]);

React.useEffect(() => {
const fontFamily = "Verdana";
Expand Down Expand Up @@ -241,13 +141,13 @@ export const ECLArchive: React.FunctionComponent<ECLArchiveProps> = ({
header={<CommandBar items={buttons} farItems={rightButtons} />}
main={
<DockPanel hideSingleTabs onDockPanelCreate={setDockpanel}>
<DockPanelItem key="eclEditor" title="ECL">
<DockPanelItem key="eclEditor" title="ECL" padding={4}>
<AutosizeHpccJSComponent widget={editor}></AutosizeHpccJSComponent>
</DockPanelItem>
<DockPanelItem key="scopesTable" title="Files" location="split-left" relativeTo="eclEditor" >
{ // Only render after archive is loaded (to ensure it "defaults to open") ---
archive?.modAttrs.length &&
<ECLArchiveTree archive={archive} selectedItem={selection} setSelectedItem={setSelectedItem} />
<ECLArchiveTree archive={archive} selectedAttrIDs={[selection]} setSelectedItem={setSelectedItem} />
}
</DockPanelItem>
<DockPanelItem key="properties" title="Properties" location="split-bottom" relativeTo="scopesTable" >
Expand Down
104 changes: 104 additions & 0 deletions esp/src/src-react/components/ECLArchiveTree.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import * as React from "react";
import { FlatTree, useHeadlessFlatTree_unstable, HeadlessFlatTreeItemProps, TreeItem, TreeItemLayout, CounterBadge } from "@fluentui/react-components";
import { FluentIconsProps, FolderOpen20Regular, Folder20Regular, FolderOpen20Filled, Folder20Filled, Document20Regular, Document20Filled, Important16Regular } from "@fluentui/react-icons";
import { Archive, isAttribute } from "../util/metricArchive";

type FlatItem = HeadlessFlatTreeItemProps & { fileTimePct?: number, content: string };

const iconStyleProps: FluentIconsProps = {
primaryFill: "red",
};

const AsideContent = ({
isImportant,
messageCount,
}: {
isImportant?: boolean;
messageCount?: number;
}) => {
const color = messageCount < 50 ? "brand" :
messageCount < 70 ? "informative" :
messageCount < 90 ? "important" :
"danger";
return <>
{isImportant && <Important16Regular {...iconStyleProps} />}
{!isNaN(messageCount) && messageCount > 0 && (
<CounterBadge count={messageCount} color={color} size="small" />
)}
</>;
};

interface ECLArchiveTreeProps {
archive?: Archive;
selectedAttrIDs: string[];
setSelectedItem: (eclId: string, scopeID: string[]) => void;
}

export const ECLArchiveTree: React.FunctionComponent<ECLArchiveTreeProps> = ({
archive,
selectedAttrIDs = [],
setSelectedItem
}) => {

const defaultOpenItems = React.useMemo(() => {
return (archive?.modAttrs.filter(modAttr => modAttr.type === "Module") ?? []).map(modAttr => modAttr.id) ?? [];
}, [archive?.modAttrs]);

const [flatTreeItems, setFlatTreeItems] = React.useState<FlatItem[]>([]);
const flatTree = useHeadlessFlatTree_unstable(flatTreeItems, { defaultOpenItems });

React.useEffect(() => {
const flatTreeItems: FlatItem[] = [];
archive?.modAttrs.forEach(modAttr => {
flatTreeItems.push({
value: modAttr.id,
parentValue: modAttr.parentId ? modAttr.parentId : undefined,
content: modAttr.name,
fileTimePct: isAttribute(modAttr) && Math.round((archive?.sourcePathTime(modAttr.sourcePath) / archive?.timeTotalExecute) * 100),
});
});
setFlatTreeItems(flatTreeItems);
}, [archive, archive?.modAttrs, archive?.timeTotalExecute]);

const onClick = React.useCallback(evt => {
const attrId = evt.currentTarget?.dataset?.fuiTreeItemValue;
const modAttr = archive?.modAttrs.find(modAttr => modAttr.id === attrId);
if (modAttr?.type === "Attribute") {
setSelectedItem(attrId, archive.metrics(attrId));
}
}, [archive, setSelectedItem]);

const { ...treeProps } = flatTree.getTreeProps();
return <FlatTree {...treeProps} size="small">
{
Array.from(flatTree.items(), flatTreeItem => {
console.log(flatTreeItem.getTreeItemProps());
const { fileTimePct, content, ...treeItemProps } = flatTreeItem.getTreeItemProps();
return <TreeItem {...treeItemProps} onClick={onClick}>
<TreeItemLayout
// expandIcon={
// flatTreeItem.itemType === "branch" ?
// (treeProps.openItems.has(flatTreeItem.value) ?
// selectedItem?.startsWith(content) ? <FolderOpen20Filled /> : <FolderOpen20Regular /> :
// selectedItem?.startsWith(content) ? <Folder20Filled /> : <Folder20Regular />)
// :
// undefined
// }
iconBefore={
flatTreeItem.itemType === "branch" ?
(treeProps.openItems.has(flatTreeItem.value) ?
selectedAttrIDs.some(attrId => attrId.startsWith(content)) ? <FolderOpen20Filled /> : <FolderOpen20Regular /> :
selectedAttrIDs.some(attrId => attrId.startsWith(content)) ? <Folder20Filled /> : <Folder20Regular />) :
selectedAttrIDs.some(attrId => attrId === flatTreeItem.value) ?
<Document20Filled /> :
<Document20Regular />
}
aside={<AsideContent isImportant={false} messageCount={fileTimePct} />}
>
{content}
</TreeItemLayout>
</TreeItem>;
})
}
</FlatTree >;
};
Loading

0 comments on commit 5165b18

Please sign in to comment.