This commit is contained in:
parent
532c2f1f6f
commit
d3943fc0b2
3 changed files with 101 additions and 57 deletions
18
src/main.ts
18
src/main.ts
|
@ -1,4 +1,4 @@
|
|||
import { createApp } from 'vue'
|
||||
import { createApp, ref } from 'vue'
|
||||
import Keycloak from "keycloak-js"
|
||||
import VueKeycloakJs from '@dsb-norge/vue-keycloak-js'
|
||||
import axios, { type AxiosInstance } from 'axios'
|
||||
|
@ -15,6 +15,14 @@ interface Settings {
|
|||
tokenSandbox: boolean
|
||||
}
|
||||
|
||||
export interface Resource {
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface Resources {
|
||||
[name: string]: Resource
|
||||
}
|
||||
|
||||
export let settings: Settings
|
||||
export let authServer: AxiosInstance
|
||||
export let resourceServer: AxiosInstance
|
||||
|
@ -72,8 +80,8 @@ function initializeTokenInterceptor(keycloak: Keycloak) {
|
|||
})
|
||||
}
|
||||
|
||||
async function checkHref(elem: HTMLLinkElement) {
|
||||
const url = elem.getAttribute("resource-id")
|
||||
export async function checkResource(elem: HTMLLinkElement) {
|
||||
const url = elem.getAttribute("resource-name")
|
||||
if (!url) return
|
||||
await resourceServer.get(url).then(
|
||||
resp => {
|
||||
|
@ -88,11 +96,11 @@ async function checkHref(elem: HTMLLinkElement) {
|
|||
}
|
||||
|
||||
function checkPerms(className: string) {
|
||||
// Scan elements with className and check the respose
|
||||
var rootElems = document.getElementsByClassName(className)
|
||||
Array.from(rootElems).forEach(elem =>
|
||||
Array.from(elem.children).forEach(elem => checkHref(<HTMLLinkElement>elem))
|
||||
Array.from(elem.children).forEach(elem => checkResource(<HTMLLinkElement>elem))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const app = createApp(App)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue