Cache refresh may work, local testing easier
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
This commit is contained in:
parent
b5a0d8bda2
commit
f49d3ec9ab
File diff suppressed because it is too large
Load Diff
|
@ -25,3 +25,18 @@
|
||||||
.App-menu {
|
.App-menu {
|
||||||
max-width: 98%;
|
max-width: 98%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Footer {
|
||||||
|
max-width: 98%;
|
||||||
|
background-color: #6207a4 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Footer a {
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FooterCell {
|
||||||
|
border: none !important;
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import logo from './../../logo.svg';
|
import logo from './../../logo.svg';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import Container from '@material-ui/core/Container';
|
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { Button, Paper } from '@material-ui/core';
|
import { Button, Paper, Container, AppBar, Table, TableBody, TableCell, TableContainer, TableRow } from '@material-ui/core';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const client_id = "sau3e70wvs369jw1u25ex8g3cve599"
|
const client_id = "sau3e70wvs369jw1u25ex8g3cve599"
|
||||||
|
@ -44,6 +43,22 @@ function App() {
|
||||||
<Typography component="p" gutterBottom>
|
<Typography component="p" gutterBottom>
|
||||||
...Coming "Soon"(tm)
|
...Coming "Soon"(tm)
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<AppBar position="static" className="Footer">
|
||||||
|
<TableContainer component={Container}>
|
||||||
|
<Table><TableBody>
|
||||||
|
<TableRow className="FooterRow">
|
||||||
|
<TableCell className="FooterCell"><a href="https://discord.gg/sVgZeRt">Discord</a></TableCell>
|
||||||
|
<TableCell className="FooterCell"><a href="https://git.martyn.berlin/martyn/twitchsingstools">Source Code</a></TableCell>
|
||||||
|
<TableCell className="FooterCell"><a href="https://twitch.tv/iMartynOnTwitch">Martyn's Twitch</a></TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow className="FooterRow">
|
||||||
|
<TableCell className="FooterCell">Announcements, Support, Optional notifications</TableCell>
|
||||||
|
<TableCell className="FooterCell">Geek out at the really hacky source code from an SRE type person</TableCell>
|
||||||
|
<TableCell className="FooterCell">Streaming and singing is my hobby, not my job, so only if you want to...</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody></Table>
|
||||||
|
</TableContainer>
|
||||||
|
</AppBar>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
|
@ -26,3 +26,18 @@
|
||||||
.App-menu {
|
.App-menu {
|
||||||
max-width: 98%;
|
max-width: 98%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Footer {
|
||||||
|
max-width: 98%;
|
||||||
|
background-color: #6207a4 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Footer a {
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FooterCell {
|
||||||
|
border: none !important;
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import Typography from '@material-ui/core/Typography';
|
||||||
import TopTenSongs from "../TopTenSongs/TopTenSongs";
|
import TopTenSongs from "../TopTenSongs/TopTenSongs";
|
||||||
import TopTenSingers from "../TopTenSingers/TopTenSingers";
|
import TopTenSingers from "../TopTenSingers/TopTenSingers";
|
||||||
import DuetData from "../DuetData/DuetData";
|
import DuetData from "../DuetData/DuetData";
|
||||||
|
import CacheDeets from "../CacheDeets/CacheDeets";
|
||||||
|
import BotDeets from "../BotDeets/BotDeets";
|
||||||
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@material-ui/core';
|
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@material-ui/core';
|
||||||
import ProblemContainer from "../ProblemContainer/ProblemContainer";
|
import ProblemContainer from "../ProblemContainer/ProblemContainer";
|
||||||
|
|
||||||
|
@ -40,22 +42,36 @@ function a11yProps(index) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function AppAdmin() {
|
class AppAdmin extends React.Component {
|
||||||
const [page, setPage] = React.useState(0);
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.setPage = this.setPage.bind(this);
|
||||||
|
this.state = {page: 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
setPage(pageNum) {
|
||||||
|
this.setState({page: pageNum})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const page = this.state.page
|
||||||
if (
|
if (
|
||||||
(window.location.href.split("/").length < 6) ||
|
(window.location.href.split("/").length < 6) ||
|
||||||
(window.location.href.split("/")[3].search(/^admin/) < 0) ||
|
(window.location.href.split("/")[3].search(/^admin/) < 0) ||
|
||||||
(window.location.href.split("/")[5].length !== 48)
|
(window.location.href.split("/")[5].length !== 48)
|
||||||
) {
|
) {
|
||||||
|
if (window.location.href.split("/")[2] !== "192.168.1.111:3000") {
|
||||||
return (
|
return (
|
||||||
<ProblemContainer />
|
<ProblemContainer />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const channelName = window.location.href.split("/")[4]
|
const channelName = window.location.href.split("/")[4]
|
||||||
const adminToken = window.location.href.split("/")[5]
|
const adminToken = window.location.href.split("/")[5]
|
||||||
const csvURL = "/csv/"+ channelName + "/" + adminToken
|
const csvURL = "/csv/"+ channelName + "/" + adminToken
|
||||||
const tsvURL = "/tsv/"+ channelName + "/" + adminToken
|
const tsvURL = "/tsv/"+ channelName + "/" + adminToken
|
||||||
|
const setPage = this.setPage
|
||||||
|
|
||||||
function handleChange(event, newValue) {
|
function handleChange(event, newValue) {
|
||||||
setPage(newValue);
|
setPage(newValue);
|
||||||
|
@ -74,6 +90,8 @@ function AppAdmin() {
|
||||||
<Tab label="Top Singers" {...a11yProps(1)}/>
|
<Tab label="Top Singers" {...a11yProps(1)}/>
|
||||||
<Tab label="Data" {...a11yProps(2)}/>
|
<Tab label="Data" {...a11yProps(2)}/>
|
||||||
<Tab label="Export" {...a11yProps(3)}/>
|
<Tab label="Export" {...a11yProps(3)}/>
|
||||||
|
<Tab label="Cache Details" {...a11yProps(4)}/>
|
||||||
|
<Tab label="Chatbot" {...a11yProps(4)}/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<TabPanel value={page} index={0}>
|
<TabPanel value={page} index={0}>
|
||||||
|
@ -113,9 +131,31 @@ function AppAdmin() {
|
||||||
<Typography component="p" gutterBottom>LibreOffice calc kinda just works...just sayin' ;-)</Typography>
|
<Typography component="p" gutterBottom>LibreOffice calc kinda just works...just sayin' ;-)</Typography>
|
||||||
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
<TabPanel value={page} index={4}>
|
||||||
|
<CacheDeets />
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel value={page} index={5}>
|
||||||
|
<BotDeets />
|
||||||
|
</TabPanel>
|
||||||
|
<AppBar position="static" className="Footer">
|
||||||
|
<TableContainer component={Container}>
|
||||||
|
<Table><TableBody>
|
||||||
|
<TableRow className="FooterRow">
|
||||||
|
<TableCell className="FooterCell"><a href="https://discord.gg/sVgZeRt">Discord</a></TableCell>
|
||||||
|
<TableCell className="FooterCell"><a href="https://git.martyn.berlin/martyn/twitchsingstools">Source Code</a></TableCell>
|
||||||
|
<TableCell className="FooterCell"><a href="https://twitch.tv/iMartynOnTwitch">Martyn's Twitch</a></TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow className="FooterRow">
|
||||||
|
<TableCell className="FooterCell">Announcements, Support, Optional notifications</TableCell>
|
||||||
|
<TableCell className="FooterCell">Geek out at the really hacky source code from an SRE type person</TableCell>
|
||||||
|
<TableCell className="FooterCell">Streaming and singing is my hobby, not my job, so only if you want to...</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody></Table>
|
||||||
|
</TableContainer>
|
||||||
|
</AppBar>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
export default AppAdmin;
|
export default AppAdmin;
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { Container, Typography, Button } from '@material-ui/core';
|
||||||
|
|
||||||
|
const channelName = window.location.href.split("/")[4]
|
||||||
|
const adminToken = window.location.href.split("/")[5]
|
||||||
|
const dataURL = "/botdeets/"+ channelName + "/" + adminToken
|
||||||
|
|
||||||
|
function BotDeets() {
|
||||||
|
|
||||||
|
const [botState, setBotState] = React.useState({loading: true, botData: []})
|
||||||
|
useEffect(() => {
|
||||||
|
// We should only fetch once!
|
||||||
|
if (botState.loading) {
|
||||||
|
fetch(dataURL).then((res) => res.json().then((data)=>{
|
||||||
|
setBotState({botData: data, loading: false })
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, [setBotState, botState.loading]);
|
||||||
|
|
||||||
|
if (botState.loading) {
|
||||||
|
return <p>Sorry, still loading...</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
let dd = botState.botData
|
||||||
|
if (dd.hasleft) {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Typography variant="h5" component="h2" gutterBottom>
|
||||||
|
The chatbot is currently <b>not</b> in your channel. To change the settings, invite it to your channel using the button below :
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="p">
|
||||||
|
You really don't wanna do that, because it's not ready yet.
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="p">
|
||||||
|
<Button variant="contained" color="primary">Join my channel!</Button>
|
||||||
|
</Typography>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Typography variant="h5" component="h2" gutterBottom>
|
||||||
|
Coming soon! Bot control panel!
|
||||||
|
</Typography>
|
||||||
|
<Typography component="tt" gutterBottom>
|
||||||
|
{dd}
|
||||||
|
</Typography>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BotDeets;
|
|
@ -0,0 +1,56 @@
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { Container, Typography, Button } from '@material-ui/core';
|
||||||
|
|
||||||
|
const channelName = window.location.href.split("/")[4]
|
||||||
|
const adminToken = window.location.href.split("/")[5]
|
||||||
|
const dataURL = "/cachedeets/"+ channelName + "/" + adminToken
|
||||||
|
const forceURL = "/force/"+ channelName + "/" + adminToken
|
||||||
|
|
||||||
|
function CacheDeets() {
|
||||||
|
|
||||||
|
function handleClick(e) {
|
||||||
|
setCacheState({cacheData: null, loading: true })
|
||||||
|
fetch(forceURL).then((res) => res.json().then((data)=>{
|
||||||
|
setCacheState({cacheData: data, loading: false })
|
||||||
|
}));
|
||||||
|
console.log('The link was clicked.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// render() {
|
||||||
|
const [cacheState, setCacheState] = React.useState({loading: true, cacheData: []})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// We should only fetch once!
|
||||||
|
if (cacheState.loading) {
|
||||||
|
let actualURL = dataURL
|
||||||
|
if (window.location.href.split("/")[2] === "192.168.1.111:3000") {
|
||||||
|
//Frontend dev mode only
|
||||||
|
actualURL = "/sampleData/cache.json"
|
||||||
|
}
|
||||||
|
fetch(actualURL).then((res) => res.json().then((data)=>{
|
||||||
|
setCacheState({cacheData: data, loading: false })
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, [setCacheState, cacheState.loading]);
|
||||||
|
|
||||||
|
if (cacheState.loading) {
|
||||||
|
return <p>Sorry, still loading...</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
let dd = cacheState.cacheData
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Typography variant="h5" component="h2" gutterBottom>
|
||||||
|
Server has cached data from <b>{dd.SongCount} published</b> performances
|
||||||
|
</Typography>
|
||||||
|
<Typography component="p" gutterBottom>
|
||||||
|
Cache data is from about {dd.AgeStr} - it automatically gets updated if it's older than an hour. If you're convinced using Martyn's bandwidth to refresh the cache earlier than that is worth it, here's the button below :
|
||||||
|
</Typography>
|
||||||
|
<Button variant="contained" color="primary" onClick={handleClick}>Force refresh cache</Button>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
export default CacheDeets;
|
Loading…
Reference in New Issue