This commit is contained in:
Adria Navarro 2023-12-15 14:15:39 +01:00
parent bce1b86059
commit 13f80ad735
3 changed files with 24 additions and 8 deletions

View File

@ -4,13 +4,18 @@
import { API } from "api" import { API } from "api"
let timeout const timeoutMs = 60000 // 1 minute
const loadTime = Date.now()
async function checkMigrationsFinished() { async function checkMigrationsFinished() {
timeout = setTimeout(async () => { setTimeout(async () => {
const response = await API.get({ url: "/api/migrations/status" }) const response = await API.getMigrationStatus()
if (!response.migrated) { if (!response.migrated) {
checkMigrationsFinished() if (loadTime + timeoutMs > Date.now()) {
return return checkMigrationsFinished()
}
return migrationTimeout()
} }
const urlParams = new URLSearchParams(window.location.search) const urlParams = new URLSearchParams(window.location.search)
@ -22,11 +27,10 @@
checkMigrationsFinished() checkMigrationsFinished()
setTimeout(() => { function migrationTimeout() {
clearTimeout(timeout)
// TODO // TODO
alert("Something went wrong 💀") alert("Something went wrong 💀")
}, 60000) }
</script> </script>
<div class="loading"> <div class="loading">

View File

@ -33,6 +33,7 @@ import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
import { buildEventEndpoints } from "./events" import { buildEventEndpoints } from "./events"
import { buildAuditLogsEndpoints } from "./auditLogs" import { buildAuditLogsEndpoints } from "./auditLogs"
import { buildLogsEndpoints } from "./logs" import { buildLogsEndpoints } from "./logs"
import { buildMigrationEndpoints } from "./migrations"
/** /**
* Random identifier to uniquely identify a session in a tab. This is * Random identifier to uniquely identify a session in a tab. This is
@ -298,6 +299,7 @@ export const createAPIClient = config => {
...buildEventEndpoints(API), ...buildEventEndpoints(API),
...buildAuditLogsEndpoints(API), ...buildAuditLogsEndpoints(API),
...buildLogsEndpoints(API), ...buildLogsEndpoints(API),
...buildMigrationEndpoints(API),
viewV2: buildViewV2Endpoints(API), viewV2: buildViewV2Endpoints(API),
} }
} }

View File

@ -0,0 +1,10 @@
export const buildMigrationEndpoints = API => ({
/**
* Gets the info about the current app migration
*/
getMigrationStatus: async () => {
return await API.get({
url: "/api/migrations/status",
})
},
})