mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-04 05:27:04 +08:00
refactoring (page): standalone page
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import { FormBuilder, Loader, Button, Icon } from "../../components/";
|
||||
import { FormBuilder, Loader, Button } from "../../components/";
|
||||
import { Config, Log } from "../../model/";
|
||||
import { FormObjToJSON, notify, format, nop } from "../../helpers/";
|
||||
import { t } from "../../locales/";
|
||||
@ -16,10 +16,10 @@ export function LogPage({ isSaving = nop }) {
|
||||
return `access_${t}.log`;
|
||||
};
|
||||
const onChange = (r) => {
|
||||
const c = Object.assign({}, config)
|
||||
const c = Object.assign({}, config);
|
||||
c["log"] = r[""]["params"];
|
||||
c["connections"] = window.CONFIG.connections;
|
||||
delete c["constant"]
|
||||
delete c["constant"];
|
||||
isSaving(true);
|
||||
Config.save(c, true, () => {
|
||||
isSaving(false);
|
||||
@ -46,7 +46,7 @@ export function LogPage({ isSaving = nop }) {
|
||||
});
|
||||
fetchLogs();
|
||||
const id = setInterval(fetchLogs, 5000);
|
||||
return () => clearInterval(id)
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -70,7 +70,9 @@ export function LogPage({ isSaving = nop }) {
|
||||
<span className="nothing"></span>
|
||||
<div style={{ width: "100%" }}>
|
||||
{
|
||||
struct.description ? (<div className="description">{struct.description}</div>) : null
|
||||
struct.description && (
|
||||
<div className="description">{struct.description}</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@ -81,7 +83,9 @@ export function LogPage({ isSaving = nop }) {
|
||||
{ log === "" ? <Loader/> : log }
|
||||
</pre>
|
||||
<div>
|
||||
<a href={Log.url()} download={filename()}><Button className="primary">{ t("Download") }</Button></a>
|
||||
<a href={Log.url()} download={filename()}>
|
||||
<Button className="primary">{ t("Download") }</Button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -10,10 +10,10 @@ export function HomePage() {
|
||||
useEffect(() => {
|
||||
Session.currentUser().then((res) => {
|
||||
if (res && res.is_authenticated === true) {
|
||||
setRedirection(res.home ? "/files" + res.home : "/files");
|
||||
} else {
|
||||
setRedirection("/login");
|
||||
setRedirection(res.home ? `/files${res.home}` : "/files");
|
||||
return;
|
||||
}
|
||||
setRedirection("/login");
|
||||
}).catch((err) => setRedirection("/login"));
|
||||
}, []);
|
||||
|
||||
|
||||
@ -4,24 +4,19 @@ import { Session } from "../model/";
|
||||
import { Loader, ErrorPage } from "../components/";
|
||||
import { cache } from "../helpers/";
|
||||
|
||||
@ErrorPage
|
||||
export class LogoutPage extends React.Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
function LogoutPageComponent({ error, history }) {
|
||||
useEffect(() => {
|
||||
Session.logout().then((res) => {
|
||||
cache.destroy();
|
||||
CONFIG["logout"] ?
|
||||
window.CONFIG["logout"] ?
|
||||
location.href = CONFIG["logout"] :
|
||||
this.props.history.push("/");
|
||||
}).catch((err) => this.props.error(err));
|
||||
}
|
||||
history.push("/");
|
||||
}).catch((err) => error(err));
|
||||
}, []);
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div> <Loader /> </div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const LogoutPage = ErrorPage(LogoutPageComponent);
|
||||
|
||||
Reference in New Issue
Block a user