initial setup
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||
import Home from "./components/Home";
|
||||
import ProtectedRoute from "./ProtectedRoute";
|
||||
|
||||
const App: React.FC = () => {
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
{/* <Route path="/login" element={<Login />} />
|
||||
<Route element={<ProtectedRoute />}>
|
||||
<Route path="/" element={<Home />} />
|
||||
</Route> */}
|
||||
<Route path="/" element={<Home />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useLocation, Outlet, Navigate } from "react-router-dom";
|
||||
import useAuth from "./hooks/useAuth";
|
||||
import { Box } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
const ProtectedRoute = () => {
|
||||
const auth = useAuth();
|
||||
const location = useLocation();
|
||||
|
||||
return auth?.isLoggedIn ? (
|
||||
<>
|
||||
<Box id="drawer-container" sx={{ display: "flex", height: "100%" }}>
|
||||
<Box sx={{ flexGrow: 1 }}>
|
||||
<Outlet />
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
) : (
|
||||
<Navigate to="/login" state={{ from: location }} replace />
|
||||
);
|
||||
};
|
||||
|
||||
export default ProtectedRoute;
|
||||
@@ -0,0 +1,5 @@
|
||||
import axios from "axios";
|
||||
|
||||
export default axios.create({
|
||||
baseURL: "" + "/v2"
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import React from "react";
|
||||
|
||||
const Home: React.FC = () => {
|
||||
return(
|
||||
<>
|
||||
<p>Temp</p>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
||||
@@ -0,0 +1 @@
|
||||
export const ENV: string = process.env.ENV || "dev";
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createContext, useState } from "react";
|
||||
|
||||
interface loginInfo {
|
||||
uuid: string;
|
||||
isLoggedIn: boolean;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<loginInfo>({
|
||||
uuid: "",
|
||||
isLoggedIn: false,
|
||||
});
|
||||
|
||||
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const [auth] = useState<loginInfo>({ uuid: "", isLoggedIn: false });
|
||||
|
||||
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
|
||||
};
|
||||
|
||||
export default AuthContext;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { useContext } from "react";
|
||||
import AuthContext from "../context/AuthProvider";
|
||||
|
||||
interface loginInfo {
|
||||
uuid: string;
|
||||
isLoggedIn: boolean;
|
||||
}
|
||||
|
||||
const useAuth = () => {
|
||||
return useContext<loginInfo>(AuthContext);
|
||||
};
|
||||
|
||||
export default useAuth;
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Docker Registry Web UI</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
import ReactDOM from "react-dom";
|
||||
import App from "./App";
|
||||
import "./style/style.css";
|
||||
import { AuthProvider } from "./context/AuthProvider";
|
||||
|
||||
|
||||
const Index: React.FC = () => {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<App />
|
||||
</AuthProvider>
|
||||
);
|
||||
};
|
||||
|
||||
ReactDOM.render(<Index />, document.getElementById("root"));
|
||||
@@ -0,0 +1 @@
|
||||
@import "base"
|
||||
@@ -0,0 +1,52 @@
|
||||
// .col-1
|
||||
// width: 8.33% !important
|
||||
// .col-2
|
||||
// width: 16.66% !important
|
||||
// .col-3
|
||||
// width: 25% !important
|
||||
// .col-4
|
||||
// width: 33.33% !important
|
||||
// .col-5
|
||||
// width: 41.66% !important
|
||||
// .col-6
|
||||
// width: 50% !important
|
||||
// .col-7
|
||||
// width: 58.33% !important
|
||||
// .col-8
|
||||
// width: 66.66% !important
|
||||
// .col-9
|
||||
// width: 75% !important
|
||||
// .col-10
|
||||
// width: 83.33% !important
|
||||
// .col-11
|
||||
// width: 91.66% !important
|
||||
// .col-12
|
||||
// width: 100% !important
|
||||
|
||||
// [class*="col-"]
|
||||
// flex: 0 0 auto
|
||||
|
||||
// .row
|
||||
// box-sizing: border-box
|
||||
// display: flex
|
||||
// max-width: 100%
|
||||
// *
|
||||
// width: 100%
|
||||
|
||||
// .container-fluid
|
||||
// width: 100%
|
||||
// margin-right: auto
|
||||
// margin-left: auto
|
||||
|
||||
// label
|
||||
// display: inline-block
|
||||
|
||||
// html
|
||||
// overflow-y: hidden
|
||||
|
||||
.full-width
|
||||
width: 100%
|
||||
|
||||
a
|
||||
text-decoration: none
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@import "header"
|
||||
@import "footer"
|
||||
@@ -0,0 +1 @@
|
||||
@import "sectionMain"
|
||||
@@ -0,0 +1 @@
|
||||
.sectionMain
|
||||
@@ -0,0 +1,8 @@
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
/*# sourceMappingURL=style.css.map */
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AG8CA,AAAA,WAAW,CAAC;EACR,KAAK,EAAE,IAAI;CAAG;;AAElB,AAAA,CAAC,CAAC;EACE,eAAe,EAAE,IAAI;CAAG",
|
||||
"sources": [
|
||||
"style.sass",
|
||||
"_variables.sass",
|
||||
"base/_base-dir.sass",
|
||||
"base/_base.sass",
|
||||
"layouts/_layouts-dir.sass",
|
||||
"layouts/_header.sass",
|
||||
"layouts/_footer.sass",
|
||||
"modules/_modules-dir.sass",
|
||||
"modules/_sectionMain.sass"
|
||||
],
|
||||
"names": [],
|
||||
"file": "style.css"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@import "variables"
|
||||
@import "base/base-dir"
|
||||
@import "layouts/layouts-dir"
|
||||
@import "modules/modules-dir"
|
||||
Reference in New Issue
Block a user