Complete GUI Refactor # Patch 1

This commit is contained in:
blessedcoolant
2022-03-30 12:45:34 +13:00
parent eea85b834e
commit b282421c98
23 changed files with 389 additions and 177 deletions

View File

@@ -156,3 +156,29 @@ export function resizeImageFile(
reader.readAsDataURL(file)
})
}
export function keepGUIAlive() {
async function getRequest(url = '') {
const response = await fetch(url, {
method: 'GET',
cache: 'no-cache',
})
return response.json()
}
const keepAliveServer = () => {
const url = document.location
const route = '/flaskwebgui-keep-server-alive'
getRequest(url + route).then(data => {
return data
})
}
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'production') {
document.addEventListener('DOMContentLoaded', () => {
const intervalRequest = 3 * 1000
keepAliveServer()
setInterval(keepAliveServer, intervalRequest)
})
}
}