Compare commits

..

No commits in common. "e38f3cbd373c5dc1365715e4479b127ae92931b8" and "4a5aec36dd9c1898305fc7571795ef267b600b0a" have entirely different histories.

9 changed files with 66 additions and 71 deletions

View file

@ -7,7 +7,7 @@ import type { PermissionObject } from "@/types/permissionTypes";
import { useAbilityStore } from "@/stores/ability";
export type Payload = JwtPayload & {
userId: string;
userId: number;
username: string;
firstname: string;
lastname: string;
@ -67,7 +67,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
});
}
var { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded;
var { firstname, lastname, mail, username, permissions, isOwner } = decoded;
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
auth.setFailed();
@ -75,7 +75,7 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
}
auth.setSuccess();
account.setAccountData(userId, firstname, lastname, mail, username);
account.setAccountData(firstname, lastname, mail, username);
ability.setAbility(permissions, isOwner);
resolve(decoded);
}

View file

@ -661,11 +661,6 @@ const router = createRouter({
},
],
},
{
path: "version",
name: "admin-user-version",
component: () => import("@/views/admin/user/version/VersionDisplay.vue"),
},
],
},
{
@ -706,6 +701,11 @@ const router = createRouter({
name: "account-administration",
component: () => import("@/views/account/Administration.vue"),
},
{
path: "version",
name: "account-version",
component: () => import("@/views/account/VersionDisplay.vue"),
},
{
path: ":pathMatch(.*)*",
name: "account-404",

View file

@ -43,11 +43,6 @@ export const useAbilityStore = defineStore("ability", {
return true;
return false;
},
isAdmin: (state) => (): boolean => {
const permissions = state.permissions;
if (state.isOwner) return true;
return permissions?.admin ?? false;
},
_can:
() =>
(

View file

@ -5,7 +5,6 @@ import { useAbilityStore } from "./ability";
export const useAccountStore = defineStore("account", {
state: () => {
return {
id: "" as string,
firstname: "" as string,
lastname: "" as string,
mail: "" as string,
@ -18,8 +17,7 @@ export const useAccountStore = defineStore("account", {
localStorage.removeItem("refreshToken");
window.open("/login", "_self");
},
setAccountData(id: string, firstname: string, lastname: string, mail: string, alias: string) {
this.id = id;
setAccountData(firstname: string, lastname: string, mail: string, alias: string) {
this.firstname = firstname;
this.lastname = lastname;
this.mail = mail;

View file

@ -30,7 +30,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
this.loading = "failed";
});
},
async sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) {
sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) {
this.queryError = "";
if (offset == 0) {
this.data = [];
@ -40,7 +40,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == ""))
return;
this.loadingData = "loading";
await http
http
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {
query: queryToSend,
})
@ -65,8 +65,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
this.queryError = "";
this.loadingData = "fetched";
},
async exportData() {
await this.sendQuery(0, this.totalLength);
exportData() {
if (this.data.length == 0) return;
const csvString = [Object.keys(this.data[0]), ...this.data.map((d) => Object.values(d))]
.map((e) => e.join(";"))

View file

@ -134,7 +134,6 @@ export const useNavigationStore = defineStore("navigation", {
...(abilityStore.can("read", "user", "role") ? [{ key: "role", title: "Rollen" }] : []),
...(abilityStore.can("read", "user", "webapi") ? [{ key: "webapi", title: "Webapi-Token" }] : []),
...(abilityStore.can("read", "user", "backup") ? [{ key: "backup", title: "Backups" }] : []),
...(abilityStore.isAdmin() ? [{ key: "version", title: "Version" }] : []),
],
},
} as navigationModel;

View file

@ -103,7 +103,6 @@ import {
} from "@headlessui/vue";
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
import type { UserViewModel } from "@/viewmodels/admin/user/user.models";
import { useAccountStore } from "@/stores/account";
</script>
<script lang="ts">
@ -117,18 +116,15 @@ export default defineComponent({
},
computed: {
...mapState(useUserStore, ["users", "loading"]),
...mapState(useAccountStore, ["id"]),
filtered(): Array<UserViewModel> {
return (
this.query === ""
return this.query === ""
? this.users
: this.users.filter((user) =>
(user.firstname + " " + user.lastname)
.toLowerCase()
.replace(/\s+/g, "")
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
)
).filter((u) => u.id != this.id);
);
},
},
mounted() {

View file

@ -10,17 +10,7 @@
<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>
<p>V{{ clientVersion }}</p>
</div>
<div class="grow flex flex-col gap-4 overflow-y-scroll">
<div v-for="version in newerClientVersions">
@ -28,7 +18,7 @@
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
{{
new Date(version.isoDate).toLocaleDateString("de", {
month: "2-digit",
month: "long",
day: "2-digit",
year: "numeric",
})
@ -44,17 +34,7 @@
<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>
<p>V{{ serverVersion }}</p>
</div>
<div class="grow flex flex-col gap-2 overflow-y-scroll">
<div v-for="version in newerServerVersions">
@ -62,7 +42,7 @@
<span class="font-semibold text-lg">V{{ version.title }}</span> vom
{{
new Date(version.isoDate).toLocaleDateString("de", {
month: "2-digit",
month: "long",
day: "2-digit",
year: "numeric",
})
@ -83,8 +63,8 @@
<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";
import clientPackage from "../../../package.json";
import type { Releases } from "../../viewmodels/version.models";
</script>
<script lang="ts">
@ -100,19 +80,11 @@ export default defineComponent({
computed: {
newerServerVersions() {
if (!this.serverRss) return [];
return this.serverRss.items.filter((i) => new Date(i.isoDate) > new Date(this.serverVersionRelease));
return this.serverRss.items.filter((i) => this.compareVersionStrings(this.serverVersion, i.title) < 0);
},
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 ?? "";
return this.clientRss.items.filter((i) => this.compareVersionStrings(this.clientVersion, i.title) < 0);
},
},
mounted() {
@ -130,7 +102,7 @@ export default defineComponent({
})
.catch(() => {});
},
getServerFeed() {
async getServerFeed() {
this.$http
.get("/server/serverrss")
.then((res) => {
@ -138,7 +110,7 @@ export default defineComponent({
})
.catch(() => {});
},
getClientFeed() {
async getClientFeed() {
this.$http
.get("/server/clientrss")
.then((res) => {
@ -146,6 +118,37 @@ export default defineComponent({
})
.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>

View file

@ -12,6 +12,11 @@
:link="{ name: 'account-administration' }"
:active="activeRouteName == 'account-administration'"
/>
<RoutingLink
title="Versions-Verwaltung"
:link="{ name: 'account-version' }"
:active="activeRouteName == 'account-version'"
/>
</template>
<template #list>
<RoutingLink title="Mein Account" :link="{ name: 'account-me' }" :active="activeRouteName == 'account-me'" />