This commit is contained in:
parent
f7d2279d19
commit
24dcb7a9db
2 changed files with 50 additions and 4 deletions
22
src/main.ts
22
src/main.ts
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue