removed forum, todos, added p2p info page & lots of minor changes/fixes

This commit is contained in:
mrfry 2023-03-26 19:16:56 +02:00
parent 32522097c0
commit e2d304c130
28 changed files with 303 additions and 954 deletions

View file

@ -36,7 +36,7 @@ function fetchData(db) {
credentials: 'include',
})
.then((resp) => {
return respon()
return resp.json()
})
.then((resp) => {
resolve({
@ -61,7 +61,7 @@ function fetchDbs() {
credentials: 'include',
})
.then((resp) => {
return respon()
return resp.json()
})
.then((data) => {
resolve(data)

View file

@ -1,91 +0,0 @@
import React, { useState } from 'react'
import Todos from '../components/todoStuff/todos'
import FeedbackArea from '../components/feedbackArea'
import Modal from '../components/modal'
import Header from '../components/header'
import constants from '../constants.json'
import styles from './contribute.module.css'
import repos from '../data/repos.json'
export default function Contribute({ globalState, setGlobalState }) {
const [showFeedback, setShowFeedback] = useState(false)
return (
<div>
<Header title={'Todos'} />
<div className={'pageHeader'}>
<h1>Teendők</h1>
</div>
<div className={'description'}>
<p>
Ezen az oldalon új ötleteket adhatsz hozzá megvalósításra a teendők
listájához.
</p>
<p>
Emellet ha hozzáértő vagy, adott feladatok megvalósításában is
segíthetsz. (lásd: <a href="#gitrepo">lentebb</a>)
<br /> Ha egy kártyára kattintasz, a megjelenő ablakban láthatod annak
részleteit, illetve{' '}
<b>
<i>szavazhatsz</i>
</b>{' '}
is a feladatra, annak érdekében, hogy minél hamarabb megvalósulhasson.
Minél több szavazat érkezik egy kártyára, annál magasabb lesz a
prioritása. (értsd: a legtöbb szavazatot kapó kártya teendője lesz
legelőször megvalósítva)
<br /> A kurzort az oszlopcímekre mozgatva, további információkat
olvashatsz a kategóriák tulajdonságairól.
</p>
</div>
<div className={`buttonContainer`}>
<div
onClick={() => {
setShowFeedback(true)
}}
>
Új feladat
</div>
</div>
<br />
<hr />
<Todos globalState={globalState} setGlobalState={setGlobalState} />
<hr />
<div id={'gitrepo'} className={styles.gitRepos}>
<div>
<div className={'subtitle'}>
<b>Git repos</b>
</div>
<div>
{Object.keys(repos.repos).map((key) => {
let repo = repos.repos[key]
return (
<div key={key}>
<ul>
<li>
<a key={key} href={repo.href}>
{repo.description}
</a>
</li>
</ul>
</div>
)
})}
</div>
</div>
<img src={`${constants.siteUrl}img/bug.png`} />
</div>
<hr />
{showFeedback && (
<Modal
closeClick={() => {
setShowFeedback(false)
}}
>
<FeedbackArea from={'contribute'} />
</Modal>
)}
</div>
)
}

View file

@ -1,32 +0,0 @@
.warning {
color: white;
padding: 10px;
font-size: 26px;
text-align: center;
}
.title {
color: var(--text-color);
font-size: 30px;
text-align: center;
}
.gitRepos {
display: flex;
justify-content: space-around;
}
@media screen and (max-width: 700px) {
.gitRepos {
flex-direction: column;
}
}
.gitRepos a {
margin: 0px 5px;
}
.gitRepos img {
width: 400px;
max-width: 90%;
}

View file

@ -25,12 +25,11 @@ export default function UserForum({
</div>
)}
<Forum
allowPost
router={router}
globalState={globalState}
setGlobalState={setGlobalState}
globalData={globalData}
forumName={'userForum'}
forumName={'frontpage'}
/>
</>
)

View file

@ -1,20 +0,0 @@
import React from 'react'
import Forum from '../components/forum'
export default function Index({
router,
globalData,
globalState,
setGlobalState,
}) {
return (
<Forum
router={router}
globalState={globalState}
setGlobalState={setGlobalState}
globalData={globalData}
forumName={'frontpage'}
/>
)
}

View file

@ -1,21 +0,0 @@
.title {
color: var(--text-color);
font-size: 32px;
text-align: center;
letter-spacing: 2.5px;
}
.motd {
text-align: center;
font-size: 20px;
border: 2px dashed var(--text-color);
padding-top: 13px;
padding-bottom: 15px;
padding-left: 5px;
padding-right: 5px;
margin-top: 18px;
margin-bottom: 30px;
margin-left: 5px;
margin-right: 5px;
}

168
src/pages/p2pinfo.jsx Normal file
View file

@ -0,0 +1,168 @@
import React, { useState, useEffect } from 'react'
import Link from 'next/link'
import Header from '../components/header'
import constants from '../constants.json'
import LoadingIndicator from '../components/LoadingIndicator'
import styles from './p2pinfo.module.css'
const infos = [
{
title: 'Név',
key: 'name',
},
{
title: 'Kontakt',
key: 'contact',
},
{
title: 'Utolsó szinkronizálás',
key: 'lastSync',
type: 'date',
},
{
title: 'Kérdés DB-k',
key: 'questionDbCount',
type: 'number',
},
{
title: 'Tárgyak',
key: 'subjectCount',
type: 'number',
},
{
title: 'Kérdések',
key: 'questionCount',
type: 'number',
},
{
title: 'Szerver build time',
key: 'serverBuildTime',
type: 'date',
},
{
title: 'Script version',
key: 'scriptVersion',
},
{
title: 'Weboldal build time',
key: 'qminingPageBuildTime',
type: 'date',
},
{
title: 'Data editor build time',
key: 'dataEditorBuildTime',
type: 'date',
},
{
title: 'Szerver revision',
key: 'serverRevision',
},
{
title: 'Script revision',
key: 'scriptRevision',
},
{
title: 'Weboldal revision',
key: 'qminingPageRevision',
},
{
title: 'Data editor revision',
key: 'dataEditorRevision',
},
]
export default function P2PInfo({ globalState, setGlobalState }) {
const [p2pInfo, setP2pinfo] = useState()
const info = p2pInfo
? {
...p2pInfo,
...p2pInfo.selfInfo,
...p2pInfo.qdbInfo,
}
: {}
useEffect(() => {
if (globalState.p2pinfo) {
setP2pinfo(globalState.p2pinfo)
} else {
fetch(constants.apiUrl + 'p2pinfo', {
method: 'GET',
credentials: 'include',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then((res) => {
return res.json()
})
.then((res) => {
setP2pinfo(res)
setGlobalState({
p2pinfo: res,
})
})
}
}, [])
if (!p2pInfo) return <LoadingIndicator />
return (
<>
<div className={'pageHeader'}>
<h1>Peer to peer infó</h1>
</div>
<div className={styles.container}>
<Header title={'P2P infó'} />
A weboldal peer to peer (p2p) megoldást implementál, így több szerverrel
együtt tud működni, és a más szerveren hozzáadott adatokat időközönként
elkéri, és hozzáadja a helyileg tárolt adatokhoz. Vagy valami ilyesmi
TODO: normális duma
<hr />
<div className={styles.title}>Szerver P2P információja:</div>
<br />
{infos.map((x) => {
const { title, key, type } = x
let text = info[key]
switch (type) {
case 'date':
text = new Date(text).toLocaleString()
break
case 'number':
text = text.toLocaleString()
break
}
return (
<div key={key} className={styles.infoRow}>
<div>{title}</div>
<div>{text}</div>
</div>
)
})}
<hr />
<div className={styles.title}>Regisztrált peer-ek:</div>
<div className={styles.peerHeader}>
<div>Név</div>
<div>Host</div>
<div>Utolsó szinkronizálás</div>
</div>
{p2pInfo.myPeers.map((peer, i) => {
return (
<div key={i} className={styles.peerContainer}>
<div>{peer.name}</div>
<div>
<a href={`https://${peer.host}:${peer.port}`} target={'_blank'}>
{peer.host}:{peer.port}
</a>
</div>
<div>{new Date(peer.lastSync).toLocaleString()}</div>
</div>
)
})}
</div>
</>
)
}

View file

@ -0,0 +1,44 @@
.container {
padding: 10px;
}
.infoRow {
display: flex;
}
.infoRow > * {
padding: 0px 8px;
}
.infoRow :first-child {
flex: 1;
display: flex;
justify-content: flex-end;
}
.infoRow :last-child {
flex: 2;
color: var(--text-color);
}
.peerContainer, .peerHeader {
display: flex;
justify-content: space-around;
align-content: center;
padding: 5px 10px;
}
.peerContainer {
color: var(--text-color);
}
.peerContainer > *, .peerHeader > * {
flex: 1;
}
.title {
color: var(--text-color);
font-size: 20px;
text-align: center;
}

47
src/pages/validation.jsx Normal file
View file

@ -0,0 +1,47 @@
import React, { useState, useEffect } from 'react'
import Header from '../components/header'
import styles from './validation.module.css'
import constants from '../constants.json'
function fetchValidation() {
return new Promise((resolve) => {
fetch(`${constants.apiUrl}validationtoken`, {
credentials: 'include',
})
.then((resp) => {
return resp.json()
})
.then((res) => {
resolve(res)
})
})
}
export default function Validation() {
const [token, setToken] = React.useState('')
useEffect(() => {
fetchValidation().then((res) => {
setToken(res.key)
})
}, [])
return (
<div>
<Header title={'Validálás'} />
<div className={'pageHeader'}>
<h1>Validálás</h1>
</div>
<center>
<div className={styles.descrip}>
Különböző okokból kellhet, hogy bizonyítsd hogy az oldalhoz van
hozzáférésed. Ebben az esetben ezzel a tokennel tudod: TODO: normális
duma
</div>
{token && <div className={styles.tokenContainer}>{token}</div>}
</center>
</div>
)
}

View file

@ -0,0 +1,16 @@
.descrip {
color: #acabab;
font-weight: bold;
padding-top: 4%;
padding-bottom: 4%;
font-size: 20px;
}
.tokenContainer {
font-family: 'Courier New', Courier, monospace;
text-align: center;
font-size: 24px;
color: white;
padding: 20px;
font-weight: bold;
}