Compare commits

..

1 Commits

Author SHA1 Message Date
c1e7a68438 fix(deps): update dependency vue to v3.3.12
Some checks failed
continuous-integration/drone/pr Build is failing
2023-12-16 07:15:54 +00:00
3 changed files with 12 additions and 57 deletions

View File

@ -113,7 +113,7 @@
"sortablejs": "1.15.1",
"tippy.js": "6.3.7",
"ufo": "1.3.2",
"vue": "3.3.13",
"vue": "3.3.12",
"vue-advanced-cropper": "2.8.8",
"vue-flatpickr-component": "11.0.3",
"vue-i18n": "9.8.0",

View File

@ -160,7 +160,6 @@
"expired": "This token has expired {ago}.",
"tokenCreatedSuccess": "Here is your new api token: {token}",
"tokenCreatedNotSeeAgain": "Store it in a secure location, you won't see it again!",
"selectAll": "Select all",
"delete": {
"header": "Delete this token",
"text1": "Are you sure you want to delete the token \"{token}\"?",

View File

@ -12,24 +12,22 @@ import 'flatpickr/dist/flatpickr.css'
import {useI18n} from 'vue-i18n'
import {useAuthStore} from '@/stores/auth'
import Message from '@/components/misc/message.vue'
import type {IApiToken} from '@/modelTypes/IApiToken'
const service = new ApiTokenService()
const tokens = ref<IApiToken[]>([])
const tokens = ref([])
const apiDocsUrl = window.API_URL + '/docs'
const showCreateForm = ref(false)
const availableRoutes = ref(null)
const newToken = ref<IApiToken>(new ApiTokenModel())
const newToken = ref(new ApiTokenModel())
const newTokenExpiry = ref<string | number>(30)
const newTokenExpiryCustom = ref(new Date())
const newTokenPermissions = ref({})
const newTokenPermissionsGroup = ref({})
const newTokenTitleValid = ref(true)
const apiTokenTitle = ref()
const tokenCreatedSuccessMessage = ref('')
const showDeleteModal = ref<boolean>(false)
const tokenToDelete = ref<IApiToken>()
const showDeleteModal = ref(false)
const tokenToDelete = ref(null)
const {t} = useI18n()
const authStore = useAuthStore()
@ -67,8 +65,8 @@ function resetPermissions() {
async function deleteToken() {
await service.delete(tokenToDelete.value)
showDeleteModal.value = false
const index = tokens.value.findIndex(el => el.id === tokenToDelete.value.id)
tokenToDelete.value = null
const index = tokens.value.findIndex(el => el.id === tokenToDelete.value.id)
if (index === -1) {
return
}
@ -113,32 +111,6 @@ async function createToken() {
function formatPermissionTitle(title: string): string {
return title.replaceAll('_', ' ')
}
function selectPermissionGroup(group: string, checked: boolean) {
Object.entries(availableRoutes.value[group]).forEach(entry => {
const [key] = entry
newTokenPermissions.value[group][key] = checked
})
}
function toggleGroupPermissionsFromChild(group: string, checked: boolean) {
if (checked) {
// Check if all permissions of that group are checked and check the "select all" checkbox in that case
let allChecked = true
Object.entries(availableRoutes.value[group]).forEach(entry => {
const [key] = entry
if (!newTokenPermissions.value[group][key]) {
allChecked = false
}
})
if (allChecked) {
newTokenPermissionsGroup.value[group] = true
}
} else {
newTokenPermissionsGroup.value[group] = false
}
}
</script>
<template>
@ -243,31 +215,15 @@ function toggleGroupPermissionsFromChild(group: string, checked: boolean) {
<p>{{ $t('user.settings.apiTokens.permissionExplanation') }}</p>
<div v-for="(routes, group) in availableRoutes" class="mb-2" :key="group">
<strong class="is-capitalized">{{ formatPermissionTitle(group) }}</strong><br/>
<template
v-if="Object.keys(routes).length > 1"
>
<fancycheckbox
class="mr-2 is-italic"
v-model="newTokenPermissionsGroup[group]"
@update:model-value="checked => selectPermissionGroup(group, checked)"
>
{{ $t('user.settings.apiTokens.selectAll') }}
</fancycheckbox>
<br/>
</template>
<template
<fancycheckbox
v-for="(paths, route) in routes"
:key="group+'-'+route"
class="mr-2 is-capitalized"
v-model="newTokenPermissions[group][route]"
>
<fancycheckbox
class="mr-2 is-capitalized"
v-model="newTokenPermissions[group][route]"
@update:model-value="checked => toggleGroupPermissionsFromChild(group, checked)"
>
{{ formatPermissionTitle(route) }}
</fancycheckbox>
<br/>
</template>
{{ formatPermissionTitle(route) }}
</fancycheckbox>
<br/>
</div>
</div>