Add and automatic check links to resources
Some checks failed
/ build (push) Failing after 9s

This commit is contained in:
phil 2025-02-07 05:00:27 +01:00
parent f7d2279d19
commit 24dcb7a9db
2 changed files with 50 additions and 4 deletions

View file

@ -44,6 +44,7 @@ axios.get("settings.json").then().then(
},
onReady(keycloak: Keycloak) {
initializeTokenInterceptor(keycloak)
checkPerms('links-to-check')
},
})
app.mount("#app")
@ -72,4 +73,25 @@ function initializeTokenInterceptor(keycloak: Keycloak) {
})
}
async function checkHref(elem: HTMLLinkElement) {
await resourceServer.get(elem.href).then(
resp => {
elem.classList.add("hasResponseStatus")
elem.classList.add("status-" + resp.status)
elem.title = "Response code: " + resp.status + " - " + resp.statusText
}).catch(err => {
elem.classList.add("hasResponseStatus")
elem.classList.add("status-" + err.response.status)
elem.title = "Response code: " + err.response.status + " - " + err.response.statusText
})
}
function checkPerms(className: string) {
var rootElems = document.getElementsByClassName(className)
Array.from(rootElems).forEach(elem =>
Array.from(elem.children).forEach(elem => checkHref(<HTMLLinkElement>elem))
)
}
const app = createApp(App)