diff --git a/webapp/src/components/AutomationEditor/index.css b/webapp/src/components/AutomationEditor/index.css index 49bba06..abd6764 100644 --- a/webapp/src/components/AutomationEditor/index.css +++ b/webapp/src/components/AutomationEditor/index.css @@ -1,5 +1,6 @@ .automation-editor { display: flex; + position: relative; flex-direction: row; width: 100%; height: 100%; @@ -74,4 +75,26 @@ .automation-editor--info-box.hide>.automation-editor--info-box--icon { transform: rotate(180deg); z-index: 2; +} + +.automation-editor.loading .mock-list { + position: absolute; + left: 0; + width: 40%; + height: 100%; +} + + +.automation-editor.loading .mock-graph { + position: absolute; + left: 40%; + width: 60%; + height: 100%; +} + +.automation-editor .linear-loader { + position: absolute; + top: 0; + left: 0; + width: 100%; } \ No newline at end of file diff --git a/webapp/src/components/AutomationEditor/index.stories.tsx b/webapp/src/components/AutomationEditor/index.stories.tsx index 0a2bdde..347d4f6 100644 --- a/webapp/src/components/AutomationEditor/index.stories.tsx +++ b/webapp/src/components/AutomationEditor/index.stories.tsx @@ -21,7 +21,7 @@ const Template: ComponentStory = args => { return { window.setTimeout(() => setState(s), 3000) diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index 7fa932e..7df1f19 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -11,6 +11,8 @@ import { DAGAutomationFlowDims } from "components/DAGFlow/types"; import { MiniFailure } from 'types/validators/helper'; import InputYaml from "components/Inputs/InputYaml"; import { TagDB } from "components/AutomationList/TagDB"; +import Skeleton from "@mui/material/Skeleton"; +import LinearProgress from "@mui/material/LinearProgress"; interface Props { automation?: AutomationData; @@ -41,7 +43,9 @@ export const AutomationEditor: FC = ({ // render if (state.status === 'loading') { return
- Loading... + + +
} if (state.status === 'invalid') { @@ -53,6 +57,7 @@ export const AutomationEditor: FC = ({ /> } return
+ {state.status === 'saving' && } ; export type EditorState = { - status: 'unchanged' | 'changed', + status: 'unchanged' | 'changed' | 'saving', data: EditorData } | { status: 'loading' @@ -43,7 +43,8 @@ export const useAutomatioEditorState = ( }), {}) }; update({ - status: "loading", + status: "saving", + data, }) onSave(cleanData); } diff --git a/webapp/src/components/AutomationList/AutomationList.stories.tsx b/webapp/src/components/AutomationList/AutomationList.stories.tsx index 69f8721..3a6a2fa 100644 --- a/webapp/src/components/AutomationList/AutomationList.stories.tsx +++ b/webapp/src/components/AutomationList/AutomationList.stories.tsx @@ -140,3 +140,41 @@ BadAutmations.args = { } ], } + + +export const FewAutosWithSlowLoader: ComponentStory = args => { + const [autos, setAutos] = useState(args.automations) + return + { + window.setTimeout(() => { + args.onAdd(a); + setAutos([...autos, a]); + }, 10000) + }} + onRemove={i => { + window.setTimeout(() => { + args.onRemove(i); + setAutos([ + ...autos.slice(0, i), + ...autos.slice(i + 1), + ]); + }, 10000) + }} + onUpdate={(i, a) => { + window.setTimeout(() => { + args.onUpdate(i, a); + setAutos([ + ...autos.slice(0, i), + a, + ...autos.slice(i + 1), + ]); + }, 10000) + }} + /> + +} +FewAutosWithSlowLoader.args = { + ...FewAutosWithSlowLoader.args, + automations: bigMockAutoList, +} diff --git a/webapp/src/components/AutomationList/ConnectedAutomationList.stories.tsx b/webapp/src/components/AutomationList/ConnectedAutomationList.stories.tsx index 495a9f5..34dc072 100644 --- a/webapp/src/components/AutomationList/ConnectedAutomationList.stories.tsx +++ b/webapp/src/components/AutomationList/ConnectedAutomationList.stories.tsx @@ -45,3 +45,20 @@ FewAutos.args = { createMockAuto(), ], } + +export const Loading: ComponentStory = args => { + const api = useMockApiService(args.initialAutomations); + return + + +} \ No newline at end of file diff --git a/webapp/src/components/AutomationList/TagDB.ts b/webapp/src/components/AutomationList/TagDB.ts index ed9fac3..d816680 100644 --- a/webapp/src/components/AutomationList/TagDB.ts +++ b/webapp/src/components/AutomationList/TagDB.ts @@ -3,6 +3,7 @@ import { AutomationData } from "types/automations"; export type TagDB = ReturnType; export const makeTagDB = (automations: AutomationData[]) => { const allTags: Record> = {}; + console.log(automations) automations.forEach(({ tags }) => Object.keys(tags).forEach(tagName => { const tagValue = tags[tagName]; diff --git a/webapp/src/components/AutomationList/index.css b/webapp/src/components/AutomationList/index.css index 5370bd4..248334e 100644 --- a/webapp/src/components/AutomationList/index.css +++ b/webapp/src/components/AutomationList/index.css @@ -18,6 +18,25 @@ flex: 1; } +/* Loading state */ +.automation-list--root.loading { + width: 100%; + height: 100%; + flex-direction: column; +} + +.automation-list--root.loading>* { + width: 100%; +} + +.automation-list--root.loading .automation-list--circle-loader { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + display: flex; +} + /* list children: on hide */ .automation-list--list.hide>.automation-list-box { width: 0; diff --git a/webapp/src/components/AutomationList/index.tsx b/webapp/src/components/AutomationList/index.tsx index b3b770d..4a108a8 100644 --- a/webapp/src/components/AutomationList/index.tsx +++ b/webapp/src/components/AutomationList/index.tsx @@ -11,6 +11,8 @@ import { AutomationListBox } from "./AutomationListBox"; import { DAGAutomationFlowDims } from 'components/DAGFlow/types'; import useWindowSize from "utils/useWindowSize"; import { makeTagDB } from "./TagDB"; +import LinearProgress from "@mui/material/LinearProgress"; +import CircularProgress from "@mui/material/CircularProgress"; interface AutomationListParams { @@ -88,7 +90,12 @@ export const ConnectedAutomationList: FC = ({ dims }) => { if (!automations.ready) { - return Loading... + return
+ +
+ +
+
} if (!automations.ok) { return Error {automations.error}