Compare commits
3 commits
4a5aec36dd
...
e38f3cbd37
Author | SHA1 | Date | |
---|---|---|---|
e38f3cbd37 | |||
88ec075d20 | |||
117372af39 |
9 changed files with 71 additions and 66 deletions
|
@ -7,7 +7,7 @@ import type { PermissionObject } from "@/types/permissionTypes";
|
||||||
import { useAbilityStore } from "@/stores/ability";
|
import { useAbilityStore } from "@/stores/ability";
|
||||||
|
|
||||||
export type Payload = JwtPayload & {
|
export type Payload = JwtPayload & {
|
||||||
userId: number;
|
userId: string;
|
||||||
username: string;
|
username: string;
|
||||||
firstname: string;
|
firstname: string;
|
||||||
lastname: string;
|
lastname: string;
|
||||||
|
@ -67,7 +67,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var { firstname, lastname, mail, username, permissions, isOwner } = decoded;
|
var { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded;
|
||||||
|
|
||||||
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
|
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
|
||||||
auth.setFailed();
|
auth.setFailed();
|
||||||
|
@ -75,7 +75,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.setSuccess();
|
auth.setSuccess();
|
||||||
account.setAccountData(firstname, lastname, mail, username);
|
account.setAccountData(userId, firstname, lastname, mail, username);
|
||||||
ability.setAbility(permissions, isOwner);
|
ability.setAbility(permissions, isOwner);
|
||||||
resolve(decoded);
|
resolve(decoded);
|
||||||
}
|
}
|
||||||
|
|
|
@ -661,6 +661,11 @@ const router = createRouter({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "version",
|
||||||
|
name: "admin-user-version",
|
||||||
|
component: () => import("@/views/admin/user/version/VersionDisplay.vue"),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -701,11 +706,6 @@ const router = createRouter({
|
||||||
name: "account-administration",
|
name: "account-administration",
|
||||||
component: () => import("@/views/account/Administration.vue"),
|
component: () => import("@/views/account/Administration.vue"),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "version",
|
|
||||||
name: "account-version",
|
|
||||||
component: () => import("@/views/account/VersionDisplay.vue"),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: ":pathMatch(.*)*",
|
path: ":pathMatch(.*)*",
|
||||||
name: "account-404",
|
name: "account-404",
|
||||||
|
|
|
@ -43,6 +43,11 @@ export const useAbilityStore = defineStore("ability", {
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
isAdmin: (state) => (): boolean => {
|
||||||
|
const permissions = state.permissions;
|
||||||
|
if (state.isOwner) return true;
|
||||||
|
return permissions?.admin ?? false;
|
||||||
|
},
|
||||||
_can:
|
_can:
|
||||||
() =>
|
() =>
|
||||||
(
|
(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useAbilityStore } from "./ability";
|
||||||
export const useAccountStore = defineStore("account", {
|
export const useAccountStore = defineStore("account", {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
|
id: "" as string,
|
||||||
firstname: "" as string,
|
firstname: "" as string,
|
||||||
lastname: "" as string,
|
lastname: "" as string,
|
||||||
mail: "" as string,
|
mail: "" as string,
|
||||||
|
@ -17,7 +18,8 @@ export const useAccountStore = defineStore("account", {
|
||||||
localStorage.removeItem("refreshToken");
|
localStorage.removeItem("refreshToken");
|
||||||
window.open("/login", "_self");
|
window.open("/login", "_self");
|
||||||
},
|
},
|
||||||
setAccountData(firstname: string, lastname: string, mail: string, alias: string) {
|
setAccountData(id: string, firstname: string, lastname: string, mail: string, alias: string) {
|
||||||
|
this.id = id;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
this.lastname = lastname;
|
this.lastname = lastname;
|
||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
||||||
this.loading = "failed";
|
this.loading = "failed";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) {
|
async sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) {
|
||||||
this.queryError = "";
|
this.queryError = "";
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
|
@ -40,7 +40,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
||||||
if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == ""))
|
if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == ""))
|
||||||
return;
|
return;
|
||||||
this.loadingData = "loading";
|
this.loadingData = "loading";
|
||||||
http
|
await http
|
||||||
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {
|
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {
|
||||||
query: queryToSend,
|
query: queryToSend,
|
||||||
})
|
})
|
||||||
|
@ -65,7 +65,8 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
||||||
this.queryError = "";
|
this.queryError = "";
|
||||||
this.loadingData = "fetched";
|
this.loadingData = "fetched";
|
||||||
},
|
},
|
||||||
exportData() {
|
async exportData() {
|
||||||
|
await this.sendQuery(0, this.totalLength);
|
||||||
if (this.data.length == 0) return;
|
if (this.data.length == 0) return;
|
||||||
const csvString = [Object.keys(this.data[0]), ...this.data.map((d) => Object.values(d))]
|
const csvString = [Object.keys(this.data[0]), ...this.data.map((d) => Object.values(d))]
|
||||||
.map((e) => e.join(";"))
|
.map((e) => e.join(";"))
|
||||||
|
|
|
@ -134,6 +134,7 @@ export const useNavigationStore = defineStore("navigation", {
|
||||||
...(abilityStore.can("read", "user", "role") ? [{ key: "role", title: "Rollen" }] : []),
|
...(abilityStore.can("read", "user", "role") ? [{ key: "role", title: "Rollen" }] : []),
|
||||||
...(abilityStore.can("read", "user", "webapi") ? [{ key: "webapi", title: "Webapi-Token" }] : []),
|
...(abilityStore.can("read", "user", "webapi") ? [{ key: "webapi", title: "Webapi-Token" }] : []),
|
||||||
...(abilityStore.can("read", "user", "backup") ? [{ key: "backup", title: "Backups" }] : []),
|
...(abilityStore.can("read", "user", "backup") ? [{ key: "backup", title: "Backups" }] : []),
|
||||||
|
...(abilityStore.isAdmin() ? [{ key: "version", title: "Version" }] : []),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
} as navigationModel;
|
} as navigationModel;
|
||||||
|
|
|
@ -103,6 +103,7 @@ import {
|
||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
||||||
import type { UserViewModel } from "@/viewmodels/admin/user/user.models";
|
import type { UserViewModel } from "@/viewmodels/admin/user/user.models";
|
||||||
|
import { useAccountStore } from "@/stores/account";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -116,15 +117,18 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useUserStore, ["users", "loading"]),
|
...mapState(useUserStore, ["users", "loading"]),
|
||||||
|
...mapState(useAccountStore, ["id"]),
|
||||||
filtered(): Array<UserViewModel> {
|
filtered(): Array<UserViewModel> {
|
||||||
return this.query === ""
|
return (
|
||||||
? this.users
|
this.query === ""
|
||||||
: this.users.filter((user) =>
|
? this.users
|
||||||
(user.firstname + " " + user.lastname)
|
: this.users.filter((user) =>
|
||||||
.toLowerCase()
|
(user.firstname + " " + user.lastname)
|
||||||
.replace(/\s+/g, "")
|
.toLowerCase()
|
||||||
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
|
.replace(/\s+/g, "")
|
||||||
);
|
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
|
||||||
|
)
|
||||||
|
).filter((u) => u.id != this.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
|
@ -12,11 +12,6 @@
|
||||||
:link="{ name: 'account-administration' }"
|
:link="{ name: 'account-administration' }"
|
||||||
:active="activeRouteName == 'account-administration'"
|
:active="activeRouteName == 'account-administration'"
|
||||||
/>
|
/>
|
||||||
<RoutingLink
|
|
||||||
title="Versions-Verwaltung"
|
|
||||||
:link="{ name: 'account-version' }"
|
|
||||||
:active="activeRouteName == 'account-version'"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #list>
|
<template #list>
|
||||||
<RoutingLink title="Mein Account" :link="{ name: 'account-me' }" :active="activeRouteName == 'account-me'" />
|
<RoutingLink title="Mein Account" :link="{ name: 'account-me' }" :active="activeRouteName == 'account-me'" />
|
||||||
|
|
|
@ -10,7 +10,17 @@
|
||||||
<div class="h-1/2 flex flex-col gap-2 p-2 border border-gray-300 rounded-t-md">
|
<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">
|
<div class="flex flex-row justify-between border-b-2 border-gray-300">
|
||||||
<h1 class="text-xl font-semibold">Client</h1>
|
<h1 class="text-xl font-semibold">Client</h1>
|
||||||
<p>V{{ clientVersion }}</p>
|
<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>
|
||||||
<div class="grow flex flex-col gap-4 overflow-y-scroll">
|
<div class="grow flex flex-col gap-4 overflow-y-scroll">
|
||||||
<div v-for="version in newerClientVersions">
|
<div v-for="version in newerClientVersions">
|
||||||
|
@ -18,7 +28,7 @@
|
||||||
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
||||||
{{
|
{{
|
||||||
new Date(version.isoDate).toLocaleDateString("de", {
|
new Date(version.isoDate).toLocaleDateString("de", {
|
||||||
month: "long",
|
month: "2-digit",
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
})
|
})
|
||||||
|
@ -34,7 +44,17 @@
|
||||||
<div class="h-1/2 flex flex-col gap-2 p-2 border border-gray-300 rounded-b-md">
|
<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">
|
<div class="flex flex-row justify-between border-b-2 border-gray-300">
|
||||||
<h1 class="text-xl font-semibold">Server</h1>
|
<h1 class="text-xl font-semibold">Server</h1>
|
||||||
<p>V{{ serverVersion }}</p>
|
<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>
|
||||||
<div class="grow flex flex-col gap-2 overflow-y-scroll">
|
<div class="grow flex flex-col gap-2 overflow-y-scroll">
|
||||||
<div v-for="version in newerServerVersions">
|
<div v-for="version in newerServerVersions">
|
||||||
|
@ -42,7 +62,7 @@
|
||||||
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
|
||||||
{{
|
{{
|
||||||
new Date(version.isoDate).toLocaleDateString("de", {
|
new Date(version.isoDate).toLocaleDateString("de", {
|
||||||
month: "long",
|
month: "2-digit",
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
})
|
})
|
||||||
|
@ -63,8 +83,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import MainTemplate from "@/templates/Main.vue";
|
import MainTemplate from "@/templates/Main.vue";
|
||||||
import clientPackage from "../../../package.json";
|
import clientPackage from "../../../../../package.json";
|
||||||
import type { Releases } from "../../viewmodels/version.models";
|
import type { Releases } from "@/viewmodels/version.models";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -80,11 +100,19 @@ export default defineComponent({
|
||||||
computed: {
|
computed: {
|
||||||
newerServerVersions() {
|
newerServerVersions() {
|
||||||
if (!this.serverRss) return [];
|
if (!this.serverRss) return [];
|
||||||
return this.serverRss.items.filter((i) => this.compareVersionStrings(this.serverVersion, i.title) < 0);
|
return this.serverRss.items.filter((i) => new Date(i.isoDate) > new Date(this.serverVersionRelease));
|
||||||
},
|
},
|
||||||
newerClientVersions() {
|
newerClientVersions() {
|
||||||
if (!this.clientRss) return [];
|
if (!this.clientRss) return [];
|
||||||
return this.clientRss.items.filter((i) => this.compareVersionStrings(this.clientVersion, i.title) < 0);
|
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() {
|
mounted() {
|
||||||
|
@ -102,7 +130,7 @@ export default defineComponent({
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
async getServerFeed() {
|
getServerFeed() {
|
||||||
this.$http
|
this.$http
|
||||||
.get("/server/serverrss")
|
.get("/server/serverrss")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -110,7 +138,7 @@ export default defineComponent({
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
async getClientFeed() {
|
getClientFeed() {
|
||||||
this.$http
|
this.$http
|
||||||
.get("/server/clientrss")
|
.get("/server/clientrss")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -118,37 +146,6 @@ export default defineComponent({
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
compareVersionStrings(activeVersion: string, compareVersion: string) {
|
|
||||||
const parseVersion = (version: string) => {
|
|
||||||
const [main, tag] = version.split("-");
|
|
||||||
const [major, minor, patch] = main.split(".").map(Number);
|
|
||||||
return { major, minor, patch, tag };
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!activeVersion || !compareVersion) return 0;
|
|
||||||
|
|
||||||
const versionA = parseVersion(activeVersion);
|
|
||||||
const versionB = parseVersion(compareVersion);
|
|
||||||
|
|
||||||
if (versionA.major !== versionB.major) {
|
|
||||||
return versionA.major - versionB.major;
|
|
||||||
}
|
|
||||||
if (versionA.minor !== versionB.minor) {
|
|
||||||
return versionA.minor - versionB.minor;
|
|
||||||
}
|
|
||||||
if (versionA.patch !== versionB.patch) {
|
|
||||||
return versionA.patch - versionB.patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (versionA.tag && !versionB.tag) return -1;
|
|
||||||
if (!versionA.tag && versionB.tag) return 1;
|
|
||||||
if (versionA.tag && versionB.tag) {
|
|
||||||
const tags = ["alpha", "beta", ""];
|
|
||||||
return tags.indexOf(versionA.tag) - tags.indexOf(versionB.tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Loading…
Add table
Reference in a new issue