- added working typescript support to vue

- added bouncer support
- added UserPolicies
- added first user index call
This commit is contained in:
Sockenklaus
2023-07-08 08:16:08 +02:00
parent 6d28aaecb7
commit 864da02de5
23 changed files with 619 additions and 582 deletions

View File

@@ -1,8 +1,8 @@
<template>
</template>
<script setup>
<script setup lang="ts">
import { useMessage } from 'naive-ui'
import { watch, defineProps, onUpdated, onMounted } from 'vue'
import { onUpdated, onMounted } from 'vue'
const message = useMessage()
const props = defineProps(['messages'])
@@ -15,16 +15,13 @@
displayNewMessages(props.messages)
})
function displayNewMessages(messages) {
function displayNewMessages(messages: any) {
console.log(messages)
let output = []
let output: Array<Object> = []
output = flattenObject(removeValidationErrors(messages))
console.log(output)
output?.forEach((item) => {
output?.forEach((item: any) => {
for (let key in item) {
switch (key){
case 'error':
@@ -55,33 +52,32 @@
})
}
function removeValidationErrors(input) {
if(input === null || !Object.hasOwn(input, "errors")) return input
function removeValidationErrors(input: any) {
if(input === null || !input.hasOwnProperty("errors")) return input
const { errors: _, ...output } = input
const { errors: _, ...output } = (input as any)
return output
}
function flattenObject(input) {
function flattenObject(input: Object) {
if (input === null) return input
return Object.values(input).map((value) => Object.entries(value)).flat().reduce((acc, [key, value]) => {
return Object.values(input).map((value) => Object.entries(value)).flat().reduce((acc: Array<Object>, [key, value]) => {
acc.push({[key]: value});
return acc;
}, []);
}
function translateError(errorMsg) {
function translateError(errorMsg: string) {
switch(errorMsg.split(":")[0]) {
case 'E_INVALID_AUTH_PASSWORD':
return "Falsches Passwort eingegeben."
case 'E_INVALID_AUTH_UID':
return "Benutzername nicht gefunden"
case 'E_AUTHORIZATION_FAILURE':
return 'Rechte unzureichend um diese Aktion auszuführen.'
}
return errorMsg
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
</script>