v1 of loaded manager
This commit is contained in:
1 parent
a9c3e9c890
commit
96617e7b0c
17 files changed
+295
-88
No files matched your search
@@ -1,8 +1,13 @@
|
||||
import "./index.css";
|
||||
|
||||
import { FC, useState } from "react";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
|
||||
import { ApiService } from "apiService/core";
|
||||
import { HAEntitiesState } from "haService/HAEntities";
|
||||
import { FC, useState } from "react";
|
||||
import { AutomationManagerLoaded } from "./Loaded";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import { Alert } from "@mui/material";
|
||||
|
||||
export type AutomationManagerProps = {
|
||||
haEntites: HAEntitiesState;
|
||||
@@ -17,14 +22,26 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
|
||||
// handle bad states
|
||||
if (!haEntites.ready || !api.state.automations.ready) {
|
||||
return <div className="automation-manager loading">...</div>;
|
||||
return (
|
||||
<div className="automation-manager loading">
|
||||
<div className="automation-manager--sidebar loading">
|
||||
<Skeleton />
|
||||
</div>
|
||||
<div className="automation-manager--editor loading">
|
||||
<Skeleton />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!api.state.automations.ok) {
|
||||
return (
|
||||
<div className="automation-manager error">
|
||||
<h1>Failed to load</h1>
|
||||
{api.state.automations.error}
|
||||
<Alert color="error">
|
||||
Failed to load automations from <code>/config</code>
|
||||
</Alert>{" "}
|
||||
<br />
|
||||
<code>{api.state.automations.error}</code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -33,20 +50,19 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
const configAutomations = api.state.automations.data.data;
|
||||
const hassEntities = haEntites.collection.state;
|
||||
return (
|
||||
<div className="automation-manager">
|
||||
<AutomationManagerLoaded
|
||||
configAutomations={configAutomations}
|
||||
hassEntities={hassEntities}
|
||||
onUpdateTags={async (aid, t) => {
|
||||
setIsSaving(true);
|
||||
await api.updateTags({
|
||||
automation_id: aid,
|
||||
tags: t,
|
||||
});
|
||||
setIsSaving(false);
|
||||
}}
|
||||
>
|
||||
{isSaving && <LinearProgress />}
|
||||
<AutomationManagerLoaded
|
||||
configAutomations={configAutomations}
|
||||
hassEntities={hassEntities}
|
||||
onUpdateTags={async (aid, t) => {
|
||||
setIsSaving(true);
|
||||
await api.updateTags({
|
||||
automation_id: aid,
|
||||
tags: t,
|
||||
});
|
||||
setIsSaving(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</AutomationManagerLoaded>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user