Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import Metrics from './Metrics';
import useStatus, { StatusContext } from '../hooks/useStatus';
import Repositories from './Repositories';
import Connections from './Connections';
import Loading from './Loading';

export default function App() {
const routerState = useRouter();
const { status, roto } = useStatus();
const routeName = routerState.route.name;

if (status && status.error) {
return <Loading status={status} />
}

return (
<RouterContext.Provider value={routerState}>
<Nav />
Expand Down
39 changes: 39 additions & 0 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useEffect, useState } from "react";
import useStatus from "../hooks/useStatus";
import { RoutinatorStatus } from "../types";
import { API_ENDPOINT } from "../core/contants";

interface LoadingProps {
status: RoutinatorStatus | null;
}

export default function Loading({ status }: LoadingProps) {
useEffect(() => {
if (status && status.error) {
const checkStatus = () => {
setTimeout(() => {
fetch(`${API_ENDPOINT}/api/v1/status`)
.then((r) => r.json())
.then((status) => {
if (status && !status.error) {
window.location.reload();
} else {
checkStatus();
}
}).catch(() => checkStatus());
}, 3000)
};
checkStatus();
}
}, []);

return (
<div id="loading">
<div>
<img src='/src/img/routinator_logo_white.svg' alt='Routinator logo' />
<br />
<p>{status?.error || "Something went wrong"}</p>
</div>
</div>
);
}
1 change: 1 addition & 0 deletions src/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import './prefix-check-sidebar.css';
@import './prefix-check.css';
@import './help.css';
@import './loading.css';
28 changes: 28 additions & 0 deletions src/style/loading.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#loading {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
min-height: 100vh;
background-color: var(--blue-dark);
background: radial-gradient(circle,rgba(0, 31, 109, 1) 0%, rgba(0, 25, 87, 1) 100%);
color: var(--white);
font-weight: bold;
font-size: 2rem;
}

#loading img {
max-width: 40rem;
}

#loading p {
animation: pulsate 2s infinite;
}

@keyframes pulsate {
from { opacity: 1; }
50% { opacity: 0; }
to { opacity: 1; }
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface RoutinatorStatus {
error?: string;
version: string;
serial: number;
now: Date;
Expand Down
Loading