-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: begin UI integration with backend
- Loading branch information
1 parent
5d00e60
commit cccdd29
Showing
9 changed files
with
186 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Datastructures | ||
|
||
- config | ||
- user provided configuration, is potentially updated either on startup or by set config rpc | ||
- configures | ||
- repos - a list of restic repos to which data may be backed up | ||
- plans - a list of backup plans which consist of | ||
- directories | ||
- schedule | ||
- retention policy | ||
- cache | ||
- the cache is a local cache of the restic repo's properties e.g. output from listing snapshots, etc. This may be held in ram or on disk? TBD: decide. | ||
- state | ||
- state is tracked plan-by-plan and is persisted to disk | ||
- stores recent operations done for a plan e.g. last backup, last prune, last check, etc. | ||
- stores status and errors for each plan | ||
- history is fixed size and is flushed to disk periodically (e.g. every 60 seconds). | ||
- the state of a repo is the merge of the states of the plans that reference it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# unclear if this implementation will be used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useContext } from "react"; | ||
|
||
import { message } from "antd"; | ||
import { MessageInstance } from "antd/es/message/interface"; | ||
|
||
const MessageContext = React.createContext<MessageInstance | null>(null); | ||
|
||
export const AlertContextProvider = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
const [messageApi, contextHolder] = message.useMessage(); | ||
|
||
return ( | ||
<> | ||
{contextHolder} | ||
<MessageContext.Provider value={messageApi}> | ||
{children} | ||
</MessageContext.Provider> | ||
</> | ||
); | ||
}; | ||
|
||
export const useAlertApi = () => { | ||
return useContext(MessageContext); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
import * as React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { App } from "./views/App"; | ||
import { RecoilRoot } from "recoil"; | ||
import ErrorBoundary from "antd/es/alert/ErrorBoundary"; | ||
import { AlertContextProvider } from "./components/Alerts"; | ||
|
||
const Root = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<RecoilRoot> | ||
<AlertContextProvider>{children}</AlertContextProvider> | ||
</RecoilRoot> | ||
); | ||
}; | ||
|
||
const el = document.querySelector("#app"); | ||
el && createRoot(el).render(<App />); | ||
el && | ||
createRoot(el).render( | ||
<Root> | ||
<App /> | ||
</Root> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { atom, useSetRecoilState } from "recoil"; | ||
import { Config } from "../../gen/ts/v1/config.pb"; | ||
import { ResticUI } from "../../gen/ts/v1/service.pb"; | ||
|
||
export const configState = atom({ | ||
key: "config", | ||
default: null as Config | null, | ||
}); | ||
|
||
export const fetchConfig = async (): Promise<Config> => { | ||
return await ResticUI.GetConfig( | ||
{}, | ||
{ | ||
pathPrefix: "/api/", | ||
} | ||
); | ||
}; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters