mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Added git links to todo sidebar
This commit is contained in:
parent
91e4e24ff7
commit
57f0730f3e
10 changed files with 329 additions and 90 deletions
|
@ -3,83 +3,29 @@
|
|||
import React from 'react'
|
||||
import '../defaultStyles.css'
|
||||
import Layout from '../components/layout'
|
||||
import constants from '../constants.json'
|
||||
|
||||
var data = null
|
||||
|
||||
function fetchData() {
|
||||
return new Promise((resolve) => {
|
||||
if (data) {
|
||||
resolve(data)
|
||||
return
|
||||
}
|
||||
|
||||
console.info('Fetching data')
|
||||
fetch(`${constants.apiUrl}getDbs`, {
|
||||
credentials: 'include',
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
const promises = data.map((db) => {
|
||||
return fetch(`${constants.apiUrl}${db.path}`, {
|
||||
credentials: 'include',
|
||||
}).then((resp) => {
|
||||
return new Promise((resolve) => {
|
||||
resp.json().then((jsonRes) => {
|
||||
resolve({
|
||||
dbName: db.name,
|
||||
data: jsonRes,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Promise.all(promises).then((data) => {
|
||||
const mergedData = data.reduce((acc, db) => {
|
||||
return [
|
||||
...acc,
|
||||
...db.data.map((subj) => {
|
||||
return {
|
||||
...subj,
|
||||
Name: `${subj.Name} (${db.dbName})`,
|
||||
}
|
||||
}),
|
||||
]
|
||||
}, [])
|
||||
|
||||
data = mergedData
|
||||
resolve(mergedData)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function MyApp({ Component, pageProps, router }) {
|
||||
console.log(pageProps)
|
||||
return (
|
||||
<Layout route={router.route}>
|
||||
<Component {...pageProps} router={router} getData={fetchData} />
|
||||
<Component {...pageProps} router={router} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
|
||||
const res = await fetch('https://stuff.frylabs.net/asd.json', {
|
||||
credentials: 'include',
|
||||
})
|
||||
const resp = await res.json()
|
||||
console.log('aaaaaaaaaaaaa', resp)
|
||||
return {
|
||||
props: {
|
||||
msg: 'aaaaa',
|
||||
fetched: resp,
|
||||
},
|
||||
}
|
||||
}
|
||||
// MyApp.getStaticProps = () => {
|
||||
// console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
|
||||
// const res = await fetch('https://stuff.frylabs.net/asd.json', {
|
||||
// credentials: 'include',
|
||||
// })
|
||||
// const resp = await res.json()
|
||||
// console.log('aaaaaaaaaaaaa', resp)
|
||||
// return {
|
||||
// props: {
|
||||
// msg: 'aaaaa',
|
||||
// fetched: resp,
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
|
||||
// Only uncomment this method if you have blocking data requirements for
|
||||
// every single page in your application. This disables the ability to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue