-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/pages/navigation/admin/manage-users/ManageUsersButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<ContextMenuButton | ||
:text="t('navigation.admin.manageUsers')" | ||
icon="user-settings-line" | ||
@click="showManageUserModal = !showManageUserModal" | ||
/> | ||
<ManageUsersModal :open="showManageUserModal" @close="showManageUserModal = false" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import ContextMenuButton from '@components/base/context-menu/ContextMenuButton.vue'; | ||
import ManageUsersModal from './ManageUsersModal.vue'; | ||
const { t } = useI18n(); | ||
const showManageUserModal = ref(false); | ||
</script> |
85 changes: 85 additions & 0 deletions
85
src/app/pages/navigation/admin/manage-users/ManageUsersModal.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<template> | ||
<Dialog :title="t('navigation.admin.manageUsers')" :open="open" @close="emit('close')"> | ||
<ul :class="$style.list"> | ||
<li v-for="usr of users" :key="usr.name" :class="$style.item"> | ||
<span :class="$style.name">{{ usr.name }}</span> | ||
<Button | ||
:color="usr.admin ? 'success' : 'dimmed'" | ||
textual | ||
icon="shield-user-line" | ||
@click="toggleAdmin(usr, !usr.admin)" | ||
/> | ||
<Button color="danger" textual icon="close-circle" @click="removeUser(usr)" /> | ||
</li> | ||
</ul> | ||
</Dialog> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import Button from '@components/base/button/Button.vue'; | ||
import Dialog from '@components/base/dialog/Dialog.vue'; | ||
import { GenesisUser } from '@storage/createGenesisStore'; | ||
import { useStorage } from '@storage/index'; | ||
const emit = defineEmits<{ | ||
(e: 'close'): void; | ||
}>(); | ||
defineProps<{ | ||
open: boolean; | ||
}>(); | ||
const { t } = useI18n(); | ||
const { user, getAllUsers, updateUser, deleteUser } = useStorage(); | ||
const users = ref<GenesisUser[]>([]); | ||
const toggleAdmin = async (user: GenesisUser, admin: boolean) => { | ||
await updateUser(user.name, { | ||
...user, | ||
admin | ||
}); | ||
}; | ||
const removeUser = async (user: GenesisUser) => { | ||
await deleteUser(user.name); | ||
await fetchUsers(); | ||
}; | ||
const fetchUsers = async () => (users.value = await getAllUsers()); | ||
watch(user, (user) => user?.admin && void fetchUsers(), { immediate: true }); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.list { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
list-style: none outside none; | ||
gap: 2px; | ||
margin: 0; | ||
} | ||
.item { | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
min-width: 175px; | ||
.name { | ||
display: inline-block; | ||
margin-right: auto; | ||
cursor: default; | ||
} | ||
} | ||
.actions { | ||
width: 100%; | ||
display: flex; | ||
padding-top: 6px; | ||
justify-content: space-between; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters