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"; import { useAbilityStore } from "@/stores/ability";
export type Payload = JwtPayload & { export type Payload = JwtPayload & {
userId: string; userId: number;
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 { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded; var { 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(userId, firstname, lastname, mail, username); account.setAccountData(firstname, lastname, mail, username);
ability.setAbility(permissions, isOwner); ability.setAbility(permissions, isOwner);
resolve(decoded); 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", 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",

View file

@ -43,11 +43,6 @@ 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:
() => () =>
( (

View file

@ -5,7 +5,6 @@ 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,
@ -18,8 +17,7 @@ export const useAccountStore = defineStore("account", {
localStorage.removeItem("refreshToken"); localStorage.removeItem("refreshToken");
window.open("/login", "_self"); window.open("/login", "_self");
}, },
setAccountData(id: string, firstname: string, lastname: string, mail: string, alias: string) { setAccountData(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;

View file

@ -30,7 +30,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
this.loading = "failed"; this.loading = "failed";
}); });
}, },
async sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) { 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";
await http http
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, { .post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {
query: queryToSend, query: queryToSend,
}) })
@ -65,8 +65,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
this.queryError = ""; this.queryError = "";
this.loadingData = "fetched"; this.loadingData = "fetched";
}, },
async exportData() { 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(";"))

View file

@ -134,7 +134,6 @@ 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;

View file

@ -103,7 +103,6 @@ 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">
@ -117,18 +116,15 @@ export default defineComponent({
}, },
computed: { computed: {
...mapState(useUserStore, ["users", "loading"]), ...mapState(useUserStore, ["users", "loading"]),
...mapState(useAccountStore, ["id"]),
filtered(): Array<UserViewModel> { filtered(): Array<UserViewModel> {
return ( return this.query === ""
this.query === ""
? this.users ? this.users
: this.users.filter((user) => : this.users.filter((user) =>
(user.firstname + " " + user.lastname) (user.firstname + " " + user.lastname)
.toLowerCase() .toLowerCase()
.replace(/\s+/g, "") .replace(/\s+/g, "")
.includes(this.query.toLowerCase().replace(/\s+/g, "")) .includes(this.query.toLowerCase().replace(/\s+/g, ""))
) );
).filter((u) => u.id != this.id);
}, },
}, },
mounted() { 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="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> <p>V{{ clientVersion }}</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">
@ -28,7 +18,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: "2-digit", month: "long",
day: "2-digit", day: "2-digit",
year: "numeric", 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="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> <p>V{{ serverVersion }}</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">
@ -62,7 +42,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: "2-digit", month: "long",
day: "2-digit", day: "2-digit",
year: "numeric", year: "numeric",
}) })
@ -83,8 +63,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">
@ -100,19 +80,11 @@ export default defineComponent({
computed: { computed: {
newerServerVersions() { newerServerVersions() {
if (!this.serverRss) return []; 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() { newerClientVersions() {
if (!this.clientRss) return []; if (!this.clientRss) return [];
return this.clientRss.items.filter((i) => new Date(i.isoDate) > new Date(this.clientVersionRelease)); return this.clientRss.items.filter((i) => this.compareVersionStrings(this.clientVersion, i.title) < 0);
},
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() {
@ -130,7 +102,7 @@ export default defineComponent({
}) })
.catch(() => {}); .catch(() => {});
}, },
getServerFeed() { async getServerFeed() {
this.$http this.$http
.get("/server/serverrss") .get("/server/serverrss")
.then((res) => { .then((res) => {
@ -138,7 +110,7 @@ export default defineComponent({
}) })
.catch(() => {}); .catch(() => {});
}, },
getClientFeed() { async getClientFeed() {
this.$http this.$http
.get("/server/clientrss") .get("/server/clientrss")
.then((res) => { .then((res) => {
@ -146,6 +118,37 @@ 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>

View file

@ -12,6 +12,11 @@
: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'" />