mirror of https://github.com/wg-easy/wg-easy
Browse Source
* feat: Add search client based on #1978 * moved the filtering to the DB level using zod and tidied up some imports. * minor fix * minor fix * fix typo --------- Co-authored-by: Bernd Storath <[email protected]>pull/2223/head
committed by
GitHub
14 changed files with 225 additions and 15 deletions
@ -0,0 +1,38 @@ |
|||||
|
<template> |
||||
|
<div class="relative w-60 md:mr-2"> |
||||
|
<div class="relative flex h-full items-center"> |
||||
|
<MagnifyingGlassIcon |
||||
|
class="absolute left-2.5 h-4 w-4 text-gray-400 dark:text-neutral-500" |
||||
|
/> |
||||
|
<input |
||||
|
v-model="searchQuery" |
||||
|
type="text" |
||||
|
:placeholder="$t('client.search')" |
||||
|
class="w-full rounded bg-white py-2 pr-8 text-sm text-gray-900 shadow-sm ring-1 ring-gray-300 transition-all placeholder:text-gray-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-red-600 dark:bg-neutral-800 dark:text-white dark:ring-neutral-700 dark:placeholder:text-neutral-500 dark:focus:ring-red-700" |
||||
|
@input="updateSearch" |
||||
|
/> |
||||
|
<button |
||||
|
v-if="searchQuery" |
||||
|
class="absolute right-2 flex h-5 w-5 items-center justify-center rounded-full bg-gray-200 text-gray-600 hover:bg-gray-300 hover:text-gray-800 dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-600 dark:hover:text-neutral-100" |
||||
|
aria-label="Clear search" |
||||
|
@click="clearSearch" |
||||
|
> |
||||
|
<IconsClose class="h-3 w-3" /> |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
const clientsStore = useClientsStore(); |
||||
|
const searchQuery = ref(''); |
||||
|
|
||||
|
const updateSearch = useDebounceFn(() => { |
||||
|
clientsStore.setSearchQuery(searchQuery.value); |
||||
|
}, 300); |
||||
|
|
||||
|
function clearSearch() { |
||||
|
searchQuery.value = ''; |
||||
|
clientsStore.setSearchQuery(''); |
||||
|
} |
||||
|
</script> |
||||
@ -1,5 +1,5 @@ |
|||||
<template> |
<template> |
||||
<div class="flex flex-shrink-0 space-x-1 md:block"> |
<div class="flex flex-shrink-0 items-center space-x-2"> |
||||
<slot /> |
<slot /> |
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|||||
@ -35,6 +35,12 @@ importers: |
|||||
'@tailwindcss/forms': |
'@tailwindcss/forms': |
||||
specifier: ^0.5.10 |
specifier: ^0.5.10 |
||||
version: 0.5.10([email protected]([email protected])([email protected])) |
version: 0.5.10([email protected]([email protected])([email protected])) |
||||
|
'@vueuse/core': |
||||
|
specifier: ^13.9.0 |
||||
|
version: 13.9.0([email protected]([email protected])) |
||||
|
'@vueuse/nuxt': |
||||
|
specifier: ^13.9.0 |
||||
|
version: 13.9.0([email protected])([email protected](@libsql/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected](@libsql/[email protected])([email protected](@libsql/[email protected])))([email protected](@libsql/[email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]))([email protected]([email protected])) |
||||
apexcharts: |
apexcharts: |
||||
specifier: ^5.3.5 |
specifier: ^5.3.5 |
||||
version: 5.3.5 |
version: 5.3.5 |
||||
@ -1874,6 +1880,9 @@ packages: |
|||||
'@types/[email protected]': |
'@types/[email protected]': |
||||
resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==} |
resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==} |
||||
|
|
||||
|
'@types/[email protected]': |
||||
|
resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==} |
||||
|
|
||||
'@types/[email protected]': |
'@types/[email protected]': |
||||
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} |
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} |
||||
|
|
||||
@ -2155,12 +2164,31 @@ packages: |
|||||
'@vueuse/[email protected]': |
'@vueuse/[email protected]': |
||||
resolution: {integrity: sha512-guoy26JQktXPcz+0n3GukWIy/JDNKti9v6VEMu6kV2sYBsWuGiTU8OWdg+ADfUbHg3/3DlqySDe7JmdHrktiww==} |
resolution: {integrity: sha512-guoy26JQktXPcz+0n3GukWIy/JDNKti9v6VEMu6kV2sYBsWuGiTU8OWdg+ADfUbHg3/3DlqySDe7JmdHrktiww==} |
||||
|
|
||||
|
'@vueuse/[email protected]': |
||||
|
resolution: {integrity: sha512-ts3regBQyURfCE2BcytLqzm8+MmLlo5Ln/KLoxDVcsZ2gzIwVNnQpQOL/UKV8alUqjSZOlpFZcRNsLRqj+OzyA==} |
||||
|
peerDependencies: |
||||
|
vue: ^3.5.0 |
||||
|
|
||||
'@vueuse/[email protected]': |
'@vueuse/[email protected]': |
||||
resolution: {integrity: sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==} |
resolution: {integrity: sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==} |
||||
|
|
||||
|
'@vueuse/[email protected]': |
||||
|
resolution: {integrity: sha512-1AFRvuiGphfF7yWixZa0KwjYH8ulyjDCC0aFgrGRz8+P4kvDFSdXLVfTk5xAN9wEuD1J6z4/myMoYbnHoX07zg==} |
||||
|
|
||||
|
'@vueuse/[email protected]': |
||||
|
resolution: {integrity: sha512-n/9BRU3nLl2mVI6rYbB3jOctCmQD0xT799hXPCwCn1PyvK7r6O9Nt1dxfVCMfKCDAiCi8Fz2IqPC6Zs2Dv1pVA==} |
||||
|
peerDependencies: |
||||
|
nuxt: ^3.0.0 || ^4.0.0-0 |
||||
|
vue: ^3.5.0 |
||||
|
|
||||
'@vueuse/[email protected]': |
'@vueuse/[email protected]': |
||||
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==} |
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==} |
||||
|
|
||||
|
'@vueuse/[email protected]': |
||||
|
resolution: {integrity: sha512-e89uuTLMh0U5cZ9iDpEI2senqPGfbPRTHM/0AaQkcxnpqjkZqDYP8rpfm7edOz8s+pOCOROEy1PIveSW8+fL5g==} |
||||
|
peerDependencies: |
||||
|
vue: ^3.5.0 |
||||
|
|
||||
'@yr/[email protected]': |
'@yr/[email protected]': |
||||
resolution: {integrity: sha512-FQXkOta0XBSUPHndIKON2Y9JeQz5ZeMqLYZVVK93FliNBFm7LNMIZmY6FrMEB9XPcDbE2bekMbZD6kzDkxwYjA==} |
resolution: {integrity: sha512-FQXkOta0XBSUPHndIKON2Y9JeQz5ZeMqLYZVVK93FliNBFm7LNMIZmY6FrMEB9XPcDbE2bekMbZD6kzDkxwYjA==} |
||||
|
|
||||
@ -7190,6 +7218,8 @@ snapshots: |
|||||
|
|
||||
'@types/[email protected]': {} |
'@types/[email protected]': {} |
||||
|
|
||||
|
'@types/[email protected]': {} |
||||
|
|
||||
'@types/[email protected]': |
'@types/[email protected]': |
||||
dependencies: |
dependencies: |
||||
'@types/node': 24.7.2 |
'@types/node': 24.7.2 |
||||
@ -7558,8 +7588,28 @@ snapshots: |
|||||
- '@vue/composition-api' |
- '@vue/composition-api' |
||||
- vue |
- vue |
||||
|
|
||||
|
'@vueuse/[email protected]([email protected]([email protected]))': |
||||
|
dependencies: |
||||
|
'@types/web-bluetooth': 0.0.21 |
||||
|
'@vueuse/metadata': 13.9.0 |
||||
|
'@vueuse/shared': 13.9.0([email protected]([email protected])) |
||||
|
vue: 3.5.22([email protected]) |
||||
|
|
||||
'@vueuse/[email protected]': {} |
'@vueuse/[email protected]': {} |
||||
|
|
||||
|
'@vueuse/[email protected]': {} |
||||
|
|
||||
|
'@vueuse/[email protected]([email protected])([email protected](@libsql/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected](@libsql/[email protected])([email protected](@libsql/[email protected])))([email protected](@libsql/[email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]))([email protected]([email protected]))': |
||||
|
dependencies: |
||||
|
'@nuxt/kit': 3.19.3([email protected]) |
||||
|
'@vueuse/core': 13.9.0([email protected]([email protected])) |
||||
|
'@vueuse/metadata': 13.9.0 |
||||
|
local-pkg: 1.1.2 |
||||
|
nuxt: 3.19.3(@libsql/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected](@libsql/[email protected])([email protected](@libsql/[email protected])))([email protected](@libsql/[email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]) |
||||
|
vue: 3.5.22([email protected]) |
||||
|
transitivePeerDependencies: |
||||
|
- magicast |
||||
|
|
||||
'@vueuse/[email protected]([email protected]([email protected]))': |
'@vueuse/[email protected]([email protected]([email protected]))': |
||||
dependencies: |
dependencies: |
||||
vue-demi: 0.14.10([email protected]([email protected])) |
vue-demi: 0.14.10([email protected]([email protected])) |
||||
@ -7567,6 +7617,10 @@ snapshots: |
|||||
- '@vue/composition-api' |
- '@vue/composition-api' |
||||
- vue |
- vue |
||||
|
|
||||
|
'@vueuse/[email protected]([email protected]([email protected]))': |
||||
|
dependencies: |
||||
|
vue: 3.5.22([email protected]) |
||||
|
|
||||
'@yr/[email protected]': {} |
'@yr/[email protected]': {} |
||||
|
|
||||
[email protected]: {} |
[email protected]: {} |
||||
|
|||||
@ -1,6 +1,17 @@ |
|||||
export default definePermissionEventHandler('clients', 'custom', ({ user }) => { |
import { ClientQuerySchema } from '#db/repositories/client/types'; |
||||
if (user.role === roles.ADMIN) { |
|
||||
return WireGuard.getAllClients(); |
export default definePermissionEventHandler( |
||||
|
'clients', |
||||
|
'custom', |
||||
|
async ({ event, user }) => { |
||||
|
const { filter } = await getValidatedQuery( |
||||
|
event, |
||||
|
validateZod(ClientQuerySchema, event) |
||||
|
); |
||||
|
|
||||
|
if (user.role === roles.ADMIN) { |
||||
|
return WireGuard.getAllClients(filter); |
||||
|
} |
||||
|
return WireGuard.getClientsForUser(user.id, filter); |
||||
} |
} |
||||
return WireGuard.getClientsForUser(user.id); |
); |
||||
}); |
|
||||
|
|||||
Loading…
Reference in new issue