mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
removed forum, todos, added p2p info page & lots of minor changes/fixes
This commit is contained in:
parent
32522097c0
commit
e2d304c130
28 changed files with 303 additions and 954 deletions
168
src/pages/p2pinfo.jsx
Normal file
168
src/pages/p2pinfo.jsx
Normal 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>
|
||||
</>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue