change folder structure
This commit is contained in:
parent
662f36b3e2
commit
1d2e113c4b
140 changed files with 400 additions and 323 deletions
78
src/views/admin/management/backup/BackupRouting.vue
Normal file
78
src/views/admin/management/backup/BackupRouting.vue
Normal file
|
@ -0,0 +1,78 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Backups</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-2 grow px-7 overflow-hidden">
|
||||
<div class="flex flex-col grow gap-2 overflow-hidden">
|
||||
<div class="w-full flex flex-row max-lg:flex-wrap justify-center">
|
||||
<RouterLink
|
||||
v-for="tab in tabs"
|
||||
:key="tab.route"
|
||||
v-slot="{ isActive }"
|
||||
:to="{ name: tab.route }"
|
||||
class="w-1/2 p-0.5 first:pl-0 last:pr-0"
|
||||
>
|
||||
<p
|
||||
:class="[
|
||||
'w-full rounded-lg py-2.5 text-sm text-center font-medium leading-5 focus:ring-0 outline-none',
|
||||
isActive ? 'bg-red-200 shadow border-b-2 border-primary rounded-b-none' : ' hover:bg-red-200',
|
||||
]"
|
||||
>
|
||||
{{ tab.title }}
|
||||
</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<RouterView />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useBackupStore } from "@/stores/admin/management/backup";
|
||||
import BackupListItem from "@/components/admin/management/backup/BackupListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
tabs: [
|
||||
{ route: "admin-user-backup-generated", title: "Erstellt" },
|
||||
{ route: "admin-user-backup-uploaded", title: "Uploads" },
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(useBackupStore, ["backups"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchBackups();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBackupStore, ["fetchBackups"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/CreateBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
openUploadModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/UploadBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
48
src/views/admin/management/backup/GeneratedBackup.vue
Normal file
48
src/views/admin/management/backup/GeneratedBackup.vue
Normal file
|
@ -0,0 +1,48 @@
|
|||
<template>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<BackupListItem v-for="backup in backups" :key="backup" :backup="backup" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'user', 'backup')" primary class="!w-fit" @click="openCreateModal">
|
||||
Backup erstellen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useBackupStore } from "@/stores/admin/management/backup";
|
||||
import BackupListItem from "@/components/admin/management/backup/BackupListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useBackupStore, ["backups"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchBackups();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBackupStore, ["fetchBackups"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/CreateBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
openUploadModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/UploadBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
48
src/views/admin/management/backup/UploadedBackup.vue
Normal file
48
src/views/admin/management/backup/UploadedBackup.vue
Normal file
|
@ -0,0 +1,48 @@
|
|||
<template>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<BackupListItem v-for="backup in backups" :key="backup" :backup="backup" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'user', 'backup')" primary class="!w-fit" @click="openUploadModal">
|
||||
Backup hochladen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useBackupStore } from "@/stores/admin/management/backup";
|
||||
import BackupListItem from "@/components/admin/management/backup/BackupListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useBackupStore, ["backups"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchBackups();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBackupStore, ["fetchBackups"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/CreateBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
openUploadModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/backup/UploadBackupModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
52
src/views/admin/management/role/Role.vue
Normal file
52
src/views/admin/management/role/Role.vue
Normal file
|
@ -0,0 +1,52 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Rollen</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<RoleListItem v-for="role in roles" :key="role.id" :role="role" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'user', 'role')" primary class="!w-fit" @click="openCreateModal">
|
||||
Rolle erstellen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useRoleStore } from "@/stores/admin/management/role";
|
||||
import RoleListItem from "@/components/admin/management/role/RoleListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useRoleStore, ["roles"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchRoles();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useRoleStore, ["fetchRoles"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/role/CreateRoleModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
116
src/views/admin/management/role/RoleEdit.vue
Normal file
116
src/views/admin/management/role/RoleEdit.vue
Normal file
|
@ -0,0 +1,116 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Rolle {{ origin?.role }} - Daten bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<form
|
||||
v-else-if="role"
|
||||
class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto"
|
||||
@submit.prevent="triggerRoleUpdate"
|
||||
>
|
||||
<div>
|
||||
<label for="role">Rollenbezeichnung</label>
|
||||
<input type="text" id="role" required v-model="role.role" />
|
||||
</div>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<button primary-outline type="reset" class="!w-fit" :disabled="canSaveOrReset" @click="resetForm">
|
||||
verwerfen
|
||||
</button>
|
||||
<button primary type="submit" class="!w-fit" :disabled="status == 'loading' || canSaveOrReset">
|
||||
speichern
|
||||
</button>
|
||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||
<SuccessCheckmark v-else-if="status?.status == 'success'" />
|
||||
<FailureXMark v-else-if="status?.status == 'failed'" />
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useRoleStore } from "@/stores/admin/management/role";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||
import FailureXMark from "@/components/FailureXMark.vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isequal";
|
||||
import type { RoleViewModel } from "@/viewmodels/admin/management/role.models";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
origin: null as null | RoleViewModel,
|
||||
role: null as null | RoleViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSaveOrReset(): boolean {
|
||||
return isEqual(this.origin, this.role);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useRoleStore, ["fetchRoleById", "updateActiveRole"]),
|
||||
resetForm() {
|
||||
this.role = cloneDeep(this.origin);
|
||||
},
|
||||
fetchItem() {
|
||||
this.fetchRoleById(parseInt(this.id ?? ""))
|
||||
.then((result) => {
|
||||
this.role = result.data;
|
||||
this.origin = cloneDeep(result.data);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerRoleUpdate(e: any) {
|
||||
if (this.role == null) return;
|
||||
let formData = e.target.elements;
|
||||
this.status = "loading";
|
||||
this.updateActiveRole(this.role.id, formData.role.value)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
87
src/views/admin/management/role/RoleEditPermission.vue
Normal file
87
src/views/admin/management/role/RoleEditPermission.vue
Normal file
|
@ -0,0 +1,87 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Rolle {{ role?.role }} - Berechtigungen bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<Permission
|
||||
v-else-if="role != null"
|
||||
:permissions="role.permissions"
|
||||
:status="status"
|
||||
@savePermissions="triggerUpdate"
|
||||
/>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useRoleStore } from "@/stores/admin/management/role";
|
||||
import Permission from "@/components/admin/Permission.vue";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import type { PermissionObject } from "@/types/permissionTypes";
|
||||
import type { RoleViewModel } from "@/viewmodels/admin/management/role.models";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
role: null as null | RoleViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useRoleStore, ["fetchRoleById", "updateActiveRolePermissions"]),
|
||||
fetchItem() {
|
||||
this.fetchRoleById(parseInt(this.id ?? ""))
|
||||
.then((result) => {
|
||||
this.role = result.data;
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerUpdate(e: PermissionObject) {
|
||||
if (this.role == null) return;
|
||||
this.status = "loading";
|
||||
this.updateActiveRolePermissions(this.role.id, e)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
39
src/views/admin/management/user/Invite.vue
Normal file
39
src/views/admin/management/user/Invite.vue
Normal file
|
@ -0,0 +1,39 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink :to="{ name: 'admin-user-user' }" class="text-primary">zurück zur Nutzerliste</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">offene Einladungen</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll px-7">
|
||||
<InviteListItem v-for="invite in invites" :key="invite.username" :invite="invite" />
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useInviteStore } from "@/stores/admin/management/invite";
|
||||
import InviteListItem from "@/components/admin/management/user/InviteListItem.vue";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useInviteStore, ["invites"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchInvites();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useInviteStore, ["fetchInvites"]),
|
||||
},
|
||||
});
|
||||
</script>
|
56
src/views/admin/management/user/User.vue
Normal file
56
src/views/admin/management/user/User.vue
Normal file
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Benutzer</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<UserListItem v-for="user in users" :key="user.id" :user="user" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'user', 'user')" primary class="!w-fit" @click="inviteUser">
|
||||
Nutzer einladen
|
||||
</button>
|
||||
<RouterLink button primary-outline :to="{ name: 'admin-user-user-invites' }" class="!w-fit">
|
||||
offene Einladungen
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useUserStore } from "@/stores/admin/management/user";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import UserListItem from "@/components/admin/management/user/UserListItem.vue";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useUserStore, ["users"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUsers();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useUserStore, ["fetchUsers"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
inviteUser() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/user/InviteUserModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
135
src/views/admin/management/user/UserEdit.vue
Normal file
135
src/views/admin/management/user/UserEdit.vue
Normal file
|
@ -0,0 +1,135 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Nutzer {{ origin?.username }} - Daten bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<form
|
||||
v-else-if="user != null"
|
||||
class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto"
|
||||
@submit.prevent="triggerUpdateUser"
|
||||
>
|
||||
<div>
|
||||
<label for="username">Nutzername</label>
|
||||
<input type="text" id="username" required v-model="user.username" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="firstname">Vorname</label>
|
||||
<input type="text" id="firstname" required v-model="user.firstname" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="lastname">Nachname</label>
|
||||
<input type="text" id="lastname" required v-model="user.lastname" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="mail">Mailadresse</label>
|
||||
<input type="email" id="mail" required v-model="user.mail" />
|
||||
</div>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<button primary-outline type="reset" class="!w-fit" :disabled="canSaveOrReset" @click="resetForm">
|
||||
verwerfen
|
||||
</button>
|
||||
<button primary type="submit" class="!w-fit" :disabled="status == 'loading' || canSaveOrReset">
|
||||
speichern
|
||||
</button>
|
||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||
<SuccessCheckmark v-else-if="status?.status == 'success'" />
|
||||
<FailureXMark v-else-if="status?.status == 'failed'" />
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||
import FailureXMark from "@/components/FailureXMark.vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import { useUserStore } from "@/stores/admin/management/user";
|
||||
import type { UpdateUserViewModel, UserViewModel } from "@/viewmodels/admin/management/user.models";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isequal";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
origin: null as null | UserViewModel,
|
||||
user: null as null | UserViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSaveOrReset(): boolean {
|
||||
return isEqual(this.origin, this.user);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useUserStore, ["fetchUserById", "updateActiveUser"]),
|
||||
resetForm() {
|
||||
this.user = cloneDeep(this.origin);
|
||||
},
|
||||
fetchItem() {
|
||||
this.fetchUserById(this.id ?? "")
|
||||
.then((result) => {
|
||||
this.user = result.data;
|
||||
this.origin = cloneDeep(result.data);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerUpdateUser(e: any) {
|
||||
if (this.user == null) return;
|
||||
let formData = e.target.elements;
|
||||
let user: UpdateUserViewModel = {
|
||||
id: this.user.id,
|
||||
username: formData.username.value,
|
||||
firstname: formData.firstname.value,
|
||||
lastname: formData.lastname.value,
|
||||
mail: formData.mail.value,
|
||||
};
|
||||
this.status = "loading";
|
||||
this.updateActiveUser(user)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
88
src/views/admin/management/user/UserEditPermission.vue
Normal file
88
src/views/admin/management/user/UserEditPermission.vue
Normal file
|
@ -0,0 +1,88 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Nutzer {{ user?.username }} - Berechtigungen bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<p>Hinweis: Berechtigungen von Nutzer und Rolle sind ergänzend.</p>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<Permission
|
||||
v-else-if="user != null"
|
||||
:permissions="user.permissions"
|
||||
:status="status"
|
||||
@savePermissions="triggerUpdate"
|
||||
/>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import Permission from "@/components/admin/Permission.vue";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import { useUserStore } from "@/stores/admin/management/user";
|
||||
import type { PermissionObject } from "@/types/permissionTypes";
|
||||
import type { UserViewModel } from "@/viewmodels/admin/management/user.models";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
user: null as null | UserViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useUserStore, ["fetchUserById", "updateActiveUserPermissions"]),
|
||||
fetchItem() {
|
||||
this.fetchUserById(this.id ?? "")
|
||||
.then((result) => {
|
||||
this.user = result.data;
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerUpdate(e: PermissionObject) {
|
||||
if (this.user == null) return;
|
||||
this.status = "loading";
|
||||
this.updateActiveUserPermissions(this.user.id, e)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
149
src/views/admin/management/user/UserEditRoles.vue
Normal file
149
src/views/admin/management/user/UserEditRoles.vue
Normal file
|
@ -0,0 +1,149 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Nutzer {{ origin?.username }} - Rollen bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<div v-else class="flex flex-col grow gap-4">
|
||||
<div class="flex flex-col gap-2 grow">
|
||||
<p class="text-xl font-semibold">zugewiesene Rollen</p>
|
||||
<div class="flex flex-row flex-wrap gap-2 h-1/2 overflow-y-auto">
|
||||
<div
|
||||
v-for="role in assignedRoles"
|
||||
:key="role.id"
|
||||
class="flex flex-row gap-2 items-center px-2 p-1 border border-gray-300 rounded-md h-fit cursor-pointer"
|
||||
@click="removeAssigned(role.id)"
|
||||
>
|
||||
<p>{{ role.role }}</p>
|
||||
<XMarkIcon class="w-5 h-5" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-xl font-semibold">verfügbare Rollen</p>
|
||||
<div class="flex flex-row flex-wrap gap-2 h-1/2 overflow-y-auto">
|
||||
<div
|
||||
v-for="role in availableRoles"
|
||||
:key="role.id"
|
||||
class="flex flex-row gap-2 items-center px-2 p-1 border border-gray-300 rounded-md h-fit cursor-pointer"
|
||||
@click="addAvailable(role.id)"
|
||||
>
|
||||
<p>{{ role.role }}</p>
|
||||
<PlusIcon class="w-5 h-5" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<button primary-outline class="!w-fit" :disabled="canSaveOrReset" @click="resetForm">verwerfen</button>
|
||||
<button primary class="!w-fit" :disabled="status == 'loading' || canSaveOrReset" @click="triggerRolesUpdate">
|
||||
speichern
|
||||
</button>
|
||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||
<SuccessCheckmark v-else-if="status?.status == 'success'" />
|
||||
<FailureXMark v-else-if="status?.status == 'failed'" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import { useUserStore } from "@/stores/admin/management/user";
|
||||
import { useRoleStore } from "@/stores/admin/management/role";
|
||||
import type { PermissionObject } from "@/types/permissionTypes";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||
import FailureXMark from "@/components/FailureXMark.vue";
|
||||
import { XMarkIcon, PlusIcon } from "@heroicons/vue/24/outline";
|
||||
import type { UserViewModel } from "@/viewmodels/admin/management/user.models";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isequal";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
origin: null as null | UserViewModel,
|
||||
assigned: [] as Array<number>,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(useRoleStore, ["roles"]),
|
||||
assignedRoles() {
|
||||
return this.roles.filter((r) => this.assigned.includes(r.id));
|
||||
},
|
||||
availableRoles() {
|
||||
return this.roles.filter((r) => !this.assigned.includes(r.id));
|
||||
},
|
||||
canSaveOrReset(): boolean {
|
||||
return isEqual(this.origin?.roles.map((r) => r.id) ?? [], this.assigned);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchRoles();
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useUserStore, ["fetchUserById", "updateActiveUserRoles"]),
|
||||
...mapActions(useRoleStore, ["fetchRoles"]),
|
||||
resetForm() {
|
||||
this.assigned = this.origin?.roles.map((r) => r.id) ?? [];
|
||||
},
|
||||
fetchItem() {
|
||||
this.fetchUserById(this.id ?? "")
|
||||
.then((result) => {
|
||||
this.origin = cloneDeep(result.data);
|
||||
this.assigned = this.origin?.roles.map((r) => r.id) ?? [];
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
addAvailable(id: number) {
|
||||
this.assigned.push(id);
|
||||
},
|
||||
removeAssigned(id: number) {
|
||||
this.assigned = this.assigned.filter((roleId) => roleId !== id);
|
||||
},
|
||||
triggerRolesUpdate() {
|
||||
if (this.origin == null) return;
|
||||
this.status = "loading";
|
||||
this.updateActiveUserRoles(this.origin.id, this.assigned)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
151
src/views/admin/management/version/VersionDisplay.vue
Normal file
151
src/views/admin/management/version/VersionDisplay.vue
Normal file
|
@ -0,0 +1,151 @@
|
|||
<template>
|
||||
<MainTemplate :useStagedOverviewLink="false">
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Versions-Kontrolle</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="h-full flex flex-col px-7 overflow-hidden">
|
||||
<div class="h-1/2 flex flex-col gap-2 p-2 border border-gray-300 rounded-t-md">
|
||||
<div class="flex flex-row justify-between border-b-2 border-gray-300">
|
||||
<h1 class="text-xl font-semibold">Client</h1>
|
||||
<p>
|
||||
V{{ clientVersion }} ({{
|
||||
new Date(clientVersionRelease).toLocaleDateString("de", {
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})
|
||||
}})
|
||||
</p>
|
||||
</div>
|
||||
<div class="grow flex flex-col gap-4 overflow-y-scroll">
|
||||
<div v-for="version in newerClientVersions">
|
||||
<p>
|
||||
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
||||
{{
|
||||
new Date(version.isoDate).toLocaleDateString("de", {
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
year: "numeric",
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
<div class="flex flex-col" v-html="version['content:encoded']"></div>
|
||||
</div>
|
||||
<div v-if="newerClientVersions.length == 0" class="flex items-center justify-center">
|
||||
<p>Der Client ist auf der neuesten Version.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-1/2 flex flex-col gap-2 p-2 border border-gray-300 rounded-b-md">
|
||||
<div class="flex flex-row justify-between border-b-2 border-gray-300">
|
||||
<h1 class="text-xl font-semibold">Server</h1>
|
||||
<p>
|
||||
V{{ serverVersion }} ({{
|
||||
new Date(serverVersionRelease).toLocaleDateString("de", {
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})
|
||||
}})
|
||||
</p>
|
||||
</div>
|
||||
<div class="grow flex flex-col gap-2 overflow-y-scroll">
|
||||
<div v-for="version in newerServerVersions">
|
||||
<p>
|
||||
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
||||
{{
|
||||
new Date(version.isoDate).toLocaleDateString("de", {
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
year: "numeric",
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
<div class="flex flex-col" v-html="version['content:encoded']"></div>
|
||||
</div>
|
||||
<div v-if="newerServerVersions.length == 0" class="flex items-center justify-center">
|
||||
<p>Der Server ist auf der neuesten Version.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import clientPackage from "../../../../../package.json";
|
||||
import type { Releases } from "@/viewmodels/version.models";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
serverVersion: "" as string,
|
||||
serverRss: null as null | Releases,
|
||||
clientVersion: "" as string,
|
||||
clientRss: null as null | Releases,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
newerServerVersions() {
|
||||
if (!this.serverRss) return [];
|
||||
return this.serverRss.items.filter((i) => new Date(i.isoDate) > new Date(this.serverVersionRelease));
|
||||
},
|
||||
newerClientVersions() {
|
||||
if (!this.clientRss) return [];
|
||||
return this.clientRss.items.filter((i) => new Date(i.isoDate) > new Date(this.clientVersionRelease));
|
||||
},
|
||||
serverVersionRelease() {
|
||||
if (!this.serverRss) return "";
|
||||
return this.serverRss.items.find((i) => i.title == this.serverVersion)?.isoDate ?? "";
|
||||
},
|
||||
clientVersionRelease() {
|
||||
if (!this.clientRss) return "";
|
||||
return this.clientRss.items.find((i) => i.title == this.clientVersion)?.isoDate ?? "";
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.clientVersion = clientPackage.version;
|
||||
this.getServerVersion();
|
||||
this.getServerFeed();
|
||||
this.getClientFeed();
|
||||
},
|
||||
methods: {
|
||||
getServerVersion() {
|
||||
this.$http
|
||||
.get("/server/version")
|
||||
.then((res) => {
|
||||
this.serverVersion = res.data.version;
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
getServerFeed() {
|
||||
this.$http
|
||||
.get("/server/serverrss")
|
||||
.then((res) => {
|
||||
this.serverRss = res.data;
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
getClientFeed() {
|
||||
this.$http
|
||||
.get("/server/clientrss")
|
||||
.then((res) => {
|
||||
this.clientRss = res.data;
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
52
src/views/admin/management/webapi/Webapi.vue
Normal file
52
src/views/admin/management/webapi/Webapi.vue
Normal file
|
@ -0,0 +1,52 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Webapi-Token</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<WebapiListItem v-for="webapi in webapis" :key="webapi.id" :webapi="webapi" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'user', 'webapi')" primary class="!w-fit" @click="openCreateModal">
|
||||
Webapi-Token erstellen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useWebapiStore } from "@/stores/admin/management/webapi";
|
||||
import WebapiListItem from "@/components/admin/management/webapi/WebapiListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useWebapiStore, ["webapis"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchWebapis();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useWebapiStore, ["fetchWebapis"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/management/webapi/CreateWebapiModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
126
src/views/admin/management/webapi/WebapiEdit.vue
Normal file
126
src/views/admin/management/webapi/WebapiEdit.vue
Normal file
|
@ -0,0 +1,126 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Webapi-Token {{ origin?.title }} - Daten bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<form
|
||||
v-else-if="webapi"
|
||||
class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto"
|
||||
@submit.prevent="triggerWebapiUpdate"
|
||||
>
|
||||
<div>
|
||||
<label for="title">Bezeichnung</label>
|
||||
<input type="text" id="title" required v-model="webapi.title" />
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<label for="expiry">Ablaufdatum (optional)</label>
|
||||
<input type="date" id="expiry" step="1" v-model="webapi.expiry" />
|
||||
</div>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<button primary-outline type="reset" class="!w-fit" :disabled="canSaveOrReset" @click="resetForm">
|
||||
verwerfen
|
||||
</button>
|
||||
<button primary type="submit" class="!w-fit" :disabled="status == 'loading' || canSaveOrReset">
|
||||
speichern
|
||||
</button>
|
||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||
<SuccessCheckmark v-else-if="status?.status == 'success'" />
|
||||
<FailureXMark v-else-if="status?.status == 'failed'" />
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useWebapiStore } from "@/stores/admin/management/webapi";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||
import FailureXMark from "@/components/FailureXMark.vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isequal";
|
||||
import type { UpdateWebapiViewModel, WebapiViewModel } from "@/viewmodels/admin/management/webapi.models";
|
||||
import type { Update } from "vite/types/hmrPayload.js";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
origin: null as null | WebapiViewModel,
|
||||
webapi: null as null | WebapiViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSaveOrReset(): boolean {
|
||||
return isEqual(this.origin, this.webapi);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useWebapiStore, ["fetchWebapiById", "updateActiveWebapi"]),
|
||||
resetForm() {
|
||||
this.webapi = cloneDeep(this.origin);
|
||||
},
|
||||
fetchItem() {
|
||||
this.fetchWebapiById(parseInt(this.id ?? ""))
|
||||
.then((result) => {
|
||||
this.webapi = result.data;
|
||||
this.origin = cloneDeep(result.data);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerWebapiUpdate(e: any) {
|
||||
if (this.webapi == null) return;
|
||||
let formData = e.target.elements;
|
||||
let updateWebapi: UpdateWebapiViewModel = {
|
||||
title: formData.title.value,
|
||||
expiry: formData.expiry.value,
|
||||
};
|
||||
|
||||
this.status = "loading";
|
||||
this.updateActiveWebapi(this.webapi.id, updateWebapi)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
87
src/views/admin/management/webapi/WebapiEditPermission.vue
Normal file
87
src/views/admin/management/webapi/WebapiEditPermission.vue
Normal file
|
@ -0,0 +1,87 @@
|
|||
<template>
|
||||
<MainTemplate>
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #topBar>
|
||||
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||||
<h1 class="font-bold text-xl h-8">Webapi-Token {{ webapi?.title }} - Berechtigungen bearbeiten</h1>
|
||||
</div>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<Permission
|
||||
v-else-if="webapi != null"
|
||||
:permissions="webapi.permissions"
|
||||
:status="status"
|
||||
@savePermissions="triggerUpdate"
|
||||
/>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useWebapiStore } from "@/stores/admin/management/webapi";
|
||||
import Permission from "@/components/admin/Permission.vue";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import type { PermissionObject } from "@/types/permissionTypes";
|
||||
import type { WebapiViewModel } from "@/viewmodels/admin/management/webapi.models";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
webapi: null as null | WebapiViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useWebapiStore, ["fetchWebapiById", "updateActiveWebapiPermissions"]),
|
||||
fetchItem() {
|
||||
this.fetchWebapiById(parseInt(this.id ?? ""))
|
||||
.then((result) => {
|
||||
this.webapi = result.data;
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerUpdate(e: PermissionObject) {
|
||||
if (this.webapi == null) return;
|
||||
this.status = "loading";
|
||||
this.updateActiveWebapiPermissions(this.webapi.id, e)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue