mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00

* Add FrontendConfig and Loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Merge more setup into the application loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Rename config files Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Remove blank line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Fix url Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make strings more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Restructure store use Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * split methods and actions Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * extract code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove actions.ts Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add reason and rename component Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove unused call Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use redux store in api Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * activate email in backend config Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add new line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * reduce code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make error more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use expectedResponseCode Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Update src/redux/backend-config/types.ts Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Use fragment Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Philip Molares <git@molar.es>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import React, {Fragment, useEffect, useState} from "react";
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
import "./application-loader.scss";
|
|
import {Alert} from "react-bootstrap";
|
|
|
|
interface ApplicationLoaderProps {
|
|
initTasks: Promise<any>[]
|
|
}
|
|
|
|
export const ApplicationLoader: React.FC<ApplicationLoaderProps> = ({children, initTasks}) => {
|
|
const [failed, setFailed] = useState<boolean>(false);
|
|
const [doneTasks, setDoneTasks] = useState<number>(0);
|
|
|
|
useEffect(() => {
|
|
setDoneTasks(0);
|
|
initTasks.map(task =>
|
|
task.then(() =>
|
|
setDoneTasks(prevDoneTasks => {
|
|
return prevDoneTasks + 1;
|
|
}))
|
|
.catch((reason) => {
|
|
setFailed(true);
|
|
console.error(reason);
|
|
})
|
|
)
|
|
}, [initTasks]);
|
|
|
|
return (<Fragment>{
|
|
doneTasks < initTasks.length || initTasks.length === 0 ? (
|
|
<div className="loader middle">
|
|
<div className="icon">
|
|
<FontAwesomeIcon icon="file-alt" size="6x"
|
|
className={failed ? "animation-shake" : "animation-pulse"}/>
|
|
</div>
|
|
{
|
|
failed ? <Alert variant={"danger"}>An error occured while loading the application!</Alert> : null
|
|
}
|
|
</div>
|
|
) : children
|
|
}</Fragment>);
|
|
}
|