-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updates to webpack * fix for #132 * pm2 config watch changes * shrinkwrap swap * added antd, broke the frontend just a regular day in the IDE * LiveVideo and FileStats * multi-deprecation * group by hours for fileStats * more v2 stuff * summary scrubber * more updates * updates * updates * updates * updates * updates * more updates and hooks * updates to listing * updates to process list * updates * updates, adding hooks * updates * updates * npm start prepare auth 3 minute timeout (#137) * fixing date deletion, glob was very incorrect * responsive main * updates * updates * updates * delete old app * multi fix commit cron tasks destroy not a function due to npm dep change hooks fix task listing works scheduling processes * updates * updates to views * updates * updates * updates to status for #136 * more for #136 * updates for livestream command * updates to gateway, helmet * adding to env * the big v5 release prep * extra line removed
- Loading branch information
Showing
93 changed files
with
33,483 additions
and
25,264 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
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
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,148 +1,66 @@ | ||
import React from "react" | ||
import React, {useEffect, useState} from "react" | ||
import ReactDOM from "react-dom" | ||
import { | ||
BrowserRouter as Router, | ||
Route, | ||
Routes, | ||
Navigate | ||
} from "react-router-dom" | ||
import Main from "./app/Main.jsx" | ||
import ResponsiveMain from "./app_v2/ResponsiveMain.jsx" | ||
|
||
import "./css/style.less" | ||
import Cookies from "js-cookie" | ||
import LoadingIcon from "./app/LoadingIcon.jsx" | ||
import LoginPage from "./app/LoginPage.jsx" | ||
|
||
import { request } from "./js/request.js" | ||
|
||
const timeout = 750 | ||
import LoadingIcon from "./app_v2/LoadingIcon.jsx" | ||
import LoginPage from "./app_v2/LoginPage.jsx" | ||
import ThemeProvider from "./app_v2/ThemeProvider.jsx" | ||
|
||
import * as FastClick from "fastclick" | ||
import useAuth from "./hooks/useAuth.js" | ||
|
||
if ("addEventListener" in document) { | ||
document.addEventListener("DOMContentLoaded", () => { | ||
FastClick.attach(document.body) | ||
}, false) | ||
} | ||
|
||
class App extends React.Component{ | ||
constructor(props){ | ||
super(props) | ||
this.state = { | ||
loaded: false, | ||
loggedIn: false, | ||
key: 1, | ||
timestamp: new Date() | ||
} | ||
} | ||
|
||
attemptLogin = (password, url="/authorization/login", body={password}) => { | ||
return request(url, { | ||
method: "POST", | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
credentials: "include", | ||
body: JSON.stringify(body) | ||
}, (prom) => { | ||
return prom.then(res => { | ||
return res.json() | ||
}, (err)=> { | ||
return {error: true} | ||
}) | ||
}) | ||
} | ||
|
||
attemptVerification = () => { | ||
return request("/authorization/verify", { | ||
method: "POST", | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
}, (prom) => { | ||
return prom.then(res => { | ||
return res.json() | ||
}, (err)=> { | ||
return {error: true} | ||
}) | ||
}) | ||
} | ||
const App = () => { | ||
const [loaded, loggedIn, tryLogin] = useAuth() | ||
const [key, setKey] = useState(0) | ||
|
||
handleLoginAttempt = (res, timestamp, callback=()=>{}) => { | ||
console.log("login attempt", res) | ||
callback(res.error) | ||
setTimeout(() => this.setState(() => ({loaded: true, loggedIn: !res.error}), () => { | ||
setTimeout(() => { | ||
this.setState((oldState) => ({ | ||
key: oldState.key + 1 | ||
}), () => console.log("APP KEY", this.state.key)) | ||
}, Math.max(0, timeout - (new Date() - timestamp))) | ||
}), 500) | ||
} | ||
useEffect(() => { | ||
console.log("UPDATED CHIMERA KEY: ", key) | ||
setKey((k) => k+1) | ||
}, [loggedIn]) | ||
|
||
componentDidMount() { | ||
if(Cookies.get("bearertoken") != undefined){ | ||
this.attemptVerification().then(res => { | ||
this.handleLoginAttempt(res, this.state.timestamp) | ||
}) | ||
} | ||
else{ | ||
this.setState(() => ({ | ||
loaded: true, | ||
loggedIn: false | ||
})) | ||
} | ||
} | ||
|
||
render() { | ||
const loginProps = { | ||
loginReq: this.attemptLogin, | ||
handler: this.handleLoginAttempt, | ||
timestamp: this.state.timestamp | ||
} | ||
return ( | ||
<Router> | ||
{this.state.loaded ? <Routes> | ||
<Route path="/login/:password" element={this.state.loggedIn ? <Navigate to="/" /> : <LoginPage withPassword {...loginProps} />} | ||
return ( | ||
<ThemeProvider> | ||
<Router key={`ROUTER-${key}`}> | ||
{loaded ? <Routes> | ||
<Route | ||
key={`ROUTE-${key}-1`} | ||
path="/login/:password" | ||
element={loggedIn ? <Navigate to="/" /> : <LoginPage withPassword tryLogin={tryLogin} />} | ||
/> | ||
<Route | ||
key={`ROUTE-${key}-2`} | ||
path="/login" | ||
element={loggedIn ? <Navigate to="/" /> : <LoginPage tryLogin={tryLogin} />} | ||
/> | ||
<Route path="/login" element={this.state.loggedIn ? <Navigate to="/" /> : <LoginPage {...loginProps} />} | ||
<Route | ||
key={`ROUTE-${key}-3`} | ||
path="/:route" | ||
element={loggedIn ? <ResponsiveMain /> : <Navigate to="/login" />} | ||
/> | ||
<Route | ||
key={`ROUTE-${key}-4`} | ||
path="/" | ||
element={loggedIn ? <ResponsiveMain /> : <Navigate to="/login" />} | ||
/> | ||
<Route path="/:route" element={this.state.loggedIn ? <Main /> : <Navigate to="/login" />}/> | ||
<Route path="/" element={this.state.loggedIn ? <Main /> : <Navigate to="/login" />}/> | ||
</Routes> : <LoadingIcon />} | ||
</Router> | ||
) | ||
} | ||
</ThemeProvider> | ||
) | ||
} | ||
|
||
ReactDOM.render(<App />, | ||
document.getElementById("root"), | ||
) | ||
|
||
/* | ||
const [key, value] = location.search.split('=') | ||
console.log(key, value, this.state.loggedIn) | ||
if(key == "?loginForm") { | ||
if(this.state.loggedIn){ | ||
return <div>bruh</div>//this.props.history.push({pathname: "/"}) | ||
} | ||
else{ | ||
if(value == undefined){ | ||
return <LoginForm /> | ||
} | ||
else{ | ||
return <div>bruh</div>//this.props.history.push({pathname: "/", state: { otp: value }}) | ||
} | ||
} | ||
} | ||
else { | ||
if(this.state.loggedIn) { | ||
return <Main /> | ||
} | ||
else{ | ||
return <div>bruh</div>//this.props.history.push({pathname: "/?loginForm"}) | ||
} | ||
} | ||
*/ | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.