converted views/settings/Users.vue to composition api
This commit is contained in:
parent
d1b21c8089
commit
a14adb7cfd
33
frontend/src/types/user.d.ts
vendored
33
frontend/src/types/user.d.ts
vendored
@ -1,7 +1,34 @@
|
|||||||
interface user {
|
type UserKey = keyof IUser;
|
||||||
|
|
||||||
|
interface IUser {
|
||||||
id: number;
|
id: number;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
scope: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
perm: any;
|
lockPassword: boolean;
|
||||||
|
viewMode: string;
|
||||||
|
singleClick: boolean;
|
||||||
|
perm: UserPerm;
|
||||||
|
commands: any[];
|
||||||
|
sorting: UserSorting;
|
||||||
|
rules: any[];
|
||||||
|
hideDotfiles: boolean;
|
||||||
|
dateFormat: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type userKey = keyof user;
|
interface UserPerm {
|
||||||
|
admin: boolean;
|
||||||
|
execute: boolean;
|
||||||
|
create: boolean;
|
||||||
|
rename: boolean;
|
||||||
|
modify: boolean;
|
||||||
|
delete: boolean;
|
||||||
|
share: boolean;
|
||||||
|
download: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserSorting {
|
||||||
|
by: string;
|
||||||
|
asc: boolean;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<errors v-if="error" :errorCode="error.status" />
|
<errors v-if="error" :errorCode="error.status" />
|
||||||
<div class="row" v-else-if="!loading">
|
<div class="row" v-else-if="!layoutStore.loading">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
<h2>{{ $t("settings.users") }}</h2>
|
<h2>{{ t("settings.users") }}</h2>
|
||||||
<router-link to="/settings/users/new"
|
<router-link to="/settings/users/new"
|
||||||
><button class="button">
|
><button class="button">
|
||||||
{{ $t("buttons.new") }}
|
{{ t("buttons.new") }}
|
||||||
</button></router-link
|
</button></router-link
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
@ -15,9 +15,9 @@
|
|||||||
<div class="card-content full">
|
<div class="card-content full">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ $t("settings.username") }}</th>
|
<th>{{ t("settings.username") }}</th>
|
||||||
<th>{{ $t("settings.admin") }}</th>
|
<th>{{ t("settings.admin") }}</th>
|
||||||
<th>{{ $t("settings.scope") }}</th>
|
<th>{{ t("settings.scope") }}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -41,36 +41,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { mapWritableState } from "pinia";
|
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
import { users as api } from "@/api";
|
import { users as api } from "@/api";
|
||||||
import Errors from "@/views/Errors.vue";
|
import Errors from "@/views/Errors.vue";
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
export default {
|
const error = ref<any>(null);
|
||||||
name: "users",
|
const users = ref<IUser[]>([]);
|
||||||
components: {
|
|
||||||
Errors,
|
const layoutStore = useLayoutStore();
|
||||||
},
|
const { t } = useI18n();
|
||||||
data: function () {
|
|
||||||
return {
|
onMounted(async () => {
|
||||||
error: null,
|
layoutStore.loading = true;
|
||||||
users: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
async created() {
|
|
||||||
this.loading = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.users = await api.getAll();
|
users.value = await api.getAll();
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
this.error = e;
|
error.value = e;
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
layoutStore.loading = false;
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
computed: {
|
|
||||||
...mapWritableState(useLayoutStore, ["loading"]),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user