switch to nuxt ui

This commit is contained in:
2025-09-11 00:58:55 +02:00
parent 3975d26caa
commit 0a7de8b78b
143 changed files with 19019 additions and 9899 deletions

View File

@ -1,46 +1,50 @@
import type { IActionMenuItem } from '~/components/ui/button/types'
//import type { IActionMenuItem } from '~/components/ui/button/types'
import type { DropdownMenuItem } from '@nuxt/ui'
import de from './de.json'
import en from './en.json'
export const usePasswordsActionMenuStore = defineStore(
'passwordsActionMenuStore',
() => {
const { t } =
useI18n()
/* {
messages: {
de: { passwordActionMenu: de },
en: { passwordActionMenu: en },
},
} */
const { $i18n } = useNuxtApp()
const menu = computed<IActionMenuItem[]>(() => [
$i18n.setLocaleMessage('de', {
...de,
})
$i18n.setLocaleMessage('en', { ...en })
const localeRoute = useLocaleRoute()
const menu = computed<DropdownMenuItem[]>(() => [
{
label: 'passwordActionMenu.group.create',
label: $i18n.t('group.create'),
icon: 'mdi:folder-plus-outline',
to: {
name: 'passwordGroupCreate',
params: {
...useRouter().currentRoute.value.params,
groupId: usePasswordGroupStore().currentGroupId,
},
query: {
...useRouter().currentRoute.value.query,
},
type: 'link',
onSelect: () => {
navigateTo(
localeRoute({
name: 'passwordGroupCreate',
params: {
...useRouter().currentRoute.value.params,
groupId: usePasswordGroupStore().currentGroupId,
},
}),
)
},
},
{
label: 'passwordActionMenu.entry.create',
label: $i18n.t('entry.create'),
icon: 'mdi:key-plus',
to: {
name: 'passwordItemCreate',
params: {
...useRouter().currentRoute.value.params,
groupId: usePasswordGroupStore().currentGroupId,
},
query: {
...useRouter().currentRoute.value.query,
},
type: 'link',
onSelect: () => {
navigateTo(
localeRoute({
name: 'passwordItemCreate',
params: {
...useRouter().currentRoute.value.params,
groupId: usePasswordGroupStore().currentGroupId,
},
}),
)
},
},
])

View File

@ -49,13 +49,13 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
const syncGroupItemsAsync = async () => {
const { syncItemsAsync } = usePasswordItemStore()
groups.value = await readGroupsAsync()
groups.value = (await readGroupsAsync()) ?? []
await syncItemsAsync()
/* currentGroup.value = groups.value?.find(
(group) => group.id === currentGroupId,
) */
(group) => group.id === currentGroupId.value,
)
/* try {
try {
currentGroupItems.groups =
(await getByParentIdAsync(currentGroupId)) ?? []
currentGroupItems.items = (await readByGroupIdAsync(currentGroupId)) ?? []
@ -115,29 +115,31 @@ const addGroupAsync = async (group: Partial<InsertHaexPasswordsGroups>) => {
name: group.name,
order: group.order,
}
await currentVault.drizzle?.insert(haexPasswordsGroups).values(newGroup)
await currentVault?.drizzle?.insert(haexPasswordsGroups).values(newGroup)
await syncGroupItemsAsync()
return newGroup
}
const readGroupAsync = async (groupId: string) => {
const { currentVault } = useVaultStore()
const group = await currentVault.drizzle.query.haexPasswordsGroups.findFirst({
where: eq(haexPasswordsGroups.id, groupId),
})
const group = await currentVault?.drizzle.query.haexPasswordsGroups.findFirst(
{
where: eq(haexPasswordsGroups.id, groupId),
},
)
console.log('readGroupAsync', groupId, group)
return group
}
const readGroupsAsync = async (filter?: { parentId?: string | null }) => {
const { currentVault } = storeToRefs(useVaultStore())
const { currentVault } = useVaultStore()
if (filter?.parentId) {
return await currentVault.value.drizzle
return await currentVault?.drizzle
.select()
.from(haexPasswordsGroups)
.where(eq(haexPasswordsGroups.id, filter.parentId))
} else {
return await currentVault.value.drizzle
return await currentVault?.drizzle
.select()
.from(haexPasswordsGroups)
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
@ -150,15 +152,19 @@ const readGroupItemsAsync = async (
const { currentVault } = useVaultStore()
if (groupId) {
return currentVault.drizzle
?.select()
.from(haexPasswordsGroupItems)
.where(eq(haexPasswordsGroupItems.groupId, groupId))
return (
currentVault?.drizzle
?.select()
.from(haexPasswordsGroupItems)
.where(eq(haexPasswordsGroupItems.groupId, groupId)) ?? []
)
} else {
return currentVault.drizzle
?.select()
.from(haexPasswordsGroupItems)
.where(isNull(haexPasswordsGroupItems.groupId))
return (
currentVault?.drizzle
?.select()
.from(haexPasswordsGroupItems)
.where(isNull(haexPasswordsGroupItems.groupId)) ?? []
)
}
}
@ -182,21 +188,21 @@ const getByParentIdAsync = async (
console.log('getByParentIdAsync', parentId)
if (parentId) {
const groups = await currentVault.drizzle
const groups = await currentVault?.drizzle
?.select()
.from(haexPasswordsGroups)
.where(eq(haexPasswordsGroups.parentId, parentId))
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
return groups
return groups ?? []
} else {
const groups = await currentVault.drizzle
const groups = await currentVault?.drizzle
?.select()
.from(haexPasswordsGroups)
.where(isNull(haexPasswordsGroups.parentId))
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
return groups
return groups ?? []
}
} catch (error) {
console.error(error)
@ -220,7 +226,7 @@ const navigateToGroupAsync = (groupId?: string | null) =>
const updateAsync = async (group: InsertHaexPasswordsGroups) => {
console.log('updateAsync', group)
const { currentVault } = storeToRefs(useVaultStore())
const { currentVault } = useVaultStore()
if (!group.id) return
const newGroup: InsertHaexPasswordsGroups = {
@ -233,7 +239,7 @@ const updateAsync = async (group: InsertHaexPasswordsGroups) => {
parentId: group.parentId,
}
return currentVault.value.drizzle
return currentVault?.drizzle
.update(haexPasswordsGroups)
.set(newGroup)
.where(eq(haexPasswordsGroups.id, newGroup.id))
@ -271,14 +277,14 @@ const insertGroupItemsAsync = async (
if (updateGroup) {
updateGroup.parentId = targetGroup?.id ?? null
await currentVault.drizzle
await currentVault?.drizzle
.update(haexPasswordsGroups)
.set(updateGroup)
.where(eq(haexPasswordsGroups.id, updateGroup.id))
}
} else {
if (targetGroup)
await currentVault.drizzle
await currentVault?.drizzle
.update(haexPasswordsGroupItems)
.set({ groupId: targetGroup.id, itemId: item.id })
.where(eq(haexPasswordsGroupItems.itemId, item.id))
@ -313,13 +319,13 @@ const deleteGroupAsync = async (groupId: string, final: boolean = false) => {
await deleteGroupAsync(child.id, true)
}
const items = await readByGroupIdAsync(groupId)
const items = (await readByGroupIdAsync(groupId)) ?? []
console.log('deleteGroupAsync delete Items', items)
for (const item of items) {
await deleteAsync(item.id, true)
}
return await currentVault.drizzle
return await currentVault?.drizzle
.delete(haexPasswordsGroups)
.where(eq(haexPasswordsGroups.id, groupId))
} else {

View File

@ -14,7 +14,7 @@ const getAsync = async (itemId: string | null) => {
try {
const { currentVault } = useVaultStore()
const history = await currentVault.drizzle
const history = await currentVault?.drizzle
?.select()
.from(haexPasswordsItemHistory)
.where(eq(haexPasswordsItemHistory.itemId, itemId))

View File

@ -34,13 +34,14 @@ export const usePasswordItemStore = defineStore('passwordItemStore', () => {
const syncItemsAsync = async () => {
const { currentVault } = useVaultStore()
items.value = await currentVault.drizzle
.select()
.from(haexPasswordsItemDetails)
.innerJoin(
haexPasswordsGroupItems,
eq(haexPasswordsItemDetails.id, haexPasswordsGroupItems.itemId),
)
items.value =
(await currentVault?.drizzle
.select()
.from(haexPasswordsItemDetails)
.innerJoin(
haexPasswordsGroupItems,
eq(haexPasswordsItemDetails.id, haexPasswordsGroupItems.itemId),
)) ?? []
}
return {
@ -158,7 +159,7 @@ const readByGroupIdAsync = async (groupId?: string | null) => {
console.log('get entries by groupId', groupId || null)
if (groupId) {
const entries = await currentVault.drizzle
const entries = await currentVault?.drizzle
.select()
.from(haexPasswordsGroupItems)
.innerJoin(
@ -168,9 +169,9 @@ const readByGroupIdAsync = async (groupId?: string | null) => {
.where(eq(haexPasswordsGroupItems.groupId, groupId))
console.log('found entries by groupId', entries)
return entries.map((entry) => entry.haex_passwords_item_details)
return entries?.map((entry) => entry.haex_passwords_item_details)
} else {
const entries = await currentVault.drizzle
const entries = await currentVault?.drizzle
.select()
.from(haexPasswordsGroupItems)
.innerJoin(
@ -180,7 +181,7 @@ const readByGroupIdAsync = async (groupId?: string | null) => {
.where(isNull(haexPasswordsGroupItems.groupId))
console.log('found entries', entries)
return entries.map((entry) => entry.haex_passwords_item_details)
return entries?.map((entry) => entry.haex_passwords_item_details)
}
} catch (error) {
console.error(error)
@ -195,7 +196,7 @@ const readAsync = async (itemId: string | null) => {
const { currentVault } = useVaultStore()
const details =
await currentVault.drizzle.query.haexPasswordsItemDetails.findFirst({
await currentVault?.drizzle.query.haexPasswordsItemDetails.findFirst({
where: eq(haexPasswordsItemDetails.id, itemId),
})
@ -219,7 +220,7 @@ const readKeyValuesAsync = async (itemId: string | null) => {
const { currentVault } = useVaultStore()
const keyValues =
await currentVault.drizzle.query.haexPasswordsItemKeyValues.findMany({
await currentVault?.drizzle.query.haexPasswordsItemKeyValues.findMany({
where: eq(haexPasswordsGroupItems.itemId, itemId),
})
return keyValues
@ -329,7 +330,7 @@ const deleteAsync = async (itemId: string, final: boolean = false) => {
})
else {
if (await createTrashIfNotExistsAsync())
await currentVault.drizzle
await currentVault?.drizzle
.update(haexPasswordsGroupItems)
.set({ groupId: trashId })
.where(eq(haexPasswordsGroupItems.itemId, itemId))
@ -339,12 +340,12 @@ const deleteAsync = async (itemId: string, final: boolean = false) => {
const deleteKeyValueAsync = async (id: string) => {
console.log('deleteKeyValueAsync', id)
const { currentVault } = useVaultStore()
return await currentVault.drizzle
return await currentVault?.drizzle
.delete(haexPasswordsItemKeyValues)
.where(eq(haexPasswordsItemKeyValues.id, id))
}
const areItemsEqual = (
/* const areItemsEqual = (
groupA: unknown | unknown[] | null,
groupB: unknown | unknown[] | null,
) => {
@ -359,4 +360,4 @@ const areItemsEqual = (
})
}
return areObjectsEqual(groupA, groupB)
}
} */

View File

@ -1,58 +1,74 @@
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
//import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
import de from './de.json'
import en from './en.json'
export interface ITheme {
/* export interface ITheme {
value: string
name: string
icon: string
}
} */
export const useUiStore = defineStore('uiStore', () => {
const breakpoints = useBreakpoints(breakpointsTailwind)
/* const breakpoints = useBreakpoints(breakpointsTailwind)
const currentScreenSize = computed(() =>
const current ScreenSize = computed(() =>
breakpoints.active().value.length > 0 ? breakpoints.active().value : 'xs',
)
) */
const { t } = useI18n({
messages: {
de: { ui: de },
en: { ui: en },
},
const { $i18n } = useNuxtApp()
$i18n.setLocaleMessage('de', {
ui: de,
})
$i18n.setLocaleMessage('en', { ui: en })
const availableThemes = ref([
{
value: 'dark',
name: t('ui.dark'),
label: $i18n.t('ui.dark'),
icon: 'line-md:moon-rising-alt-loop',
},
{
value: 'light',
name: t('ui.light'),
label: $i18n.t('ui.light'),
icon: 'line-md:moon-to-sunny-outline-loop-transition',
},
{ value: 'soft', name: t('ui.soft'), icon: 'line-md:paint-drop' },
/* {
value: 'soft',
label: t('ui.soft'),
icon: 'line-md:paint-drop',
},
{
value: 'corporate',
name: t('ui.corporate'),
label: t('ui.corporate'),
icon: 'hugeicons:corporate',
},
}, */
])
const defaultTheme = ref(availableThemes.value[0])
const defaultTheme = ref('dark')
const currentTheme = ref(defaultTheme)
const currentThemeName = ref(defaultTheme.value)
const currentThemeValue = computed(() => currentTheme.value.value)
const currentTheme = computed(
() =>
availableThemes.value.find(
(theme) => theme.value === currentThemeName.value,
) ?? availableThemes.value.at(0),
)
const colorMode = useColorMode()
watchImmediate(currentThemeName, () => {
console.log('set colorMode', currentThemeName.value)
colorMode.preference = currentThemeName.value
})
return {
availableThemes,
breakpoints,
currentScreenSize,
//currentScreenSize,
currentTheme,
currentThemeValue,
currentThemeName,
defaultTheme,
}
})

View File

@ -7,6 +7,7 @@ export interface ISidebarItem {
id: string
to?: RouteLocationAsRelativeGeneric
iconType?: 'icon' | 'svg'
onSelect?: () => void
}
export const useSidebarStore = defineStore('sidebarStore', () => {
@ -17,13 +18,100 @@ export const useSidebarStore = defineStore('sidebarStore', () => {
id: 'haex-pass',
name: 'HaexPass',
icon: 'mdi:safe',
to: { name: 'passwords' },
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'haex-extensions',
name: 'Haex Extensions',
icon: 'gg:extension',
to: { name: 'extensionOverview' },
onSelect: () => {
navigateTo(useLocalePath()({ name: 'extensionOverview' }))
},
},
{
id: 'test',
name: 'Test',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test2',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test3',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test4',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test5',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test6',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test7',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test8',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
{
id: 'test9',
name: 'Testsdfsfsdfsdf',
icon: 'mdi:account',
onSelect: () => {
navigateTo(useLocalePath()({ name: 'passwordGroupItems' }))
},
},
])

View File

@ -60,8 +60,8 @@ export const useVaultStore = defineStore('vaultStore', () => {
name: fileName ?? path,
drizzle: drizzle<typeof schema>(
async (sql, params: unknown[], method) => {
let rows: unknown[] = []
let results: any = []
let rows: any[] = []
let results: any[] = []
// If the query is a SELECT, use the select method
if (isSelectQuery(sql)) {

View File

@ -62,9 +62,9 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
)
}
const syncThemeAsync = async () => {
const { availableThemes, defaultTheme, currentTheme } = storeToRefs(
useUiStore(),
)
const { defaultTheme, currentTheme, currentThemeName, availableThemes } =
storeToRefs(useUiStore())
const currentThemeRow =
await currentVault.value?.drizzle.query.haexSettings.findFirst({
where: eq(schema.haexSettings.key, VaultSettingsKeyEnum.theme),
@ -74,13 +74,13 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
const theme = availableThemes.value.find(
(theme) => theme.value === currentThemeRow.value,
)
currentTheme.value = theme ?? defaultTheme.value
currentThemeName.value = theme?.value || defaultTheme.value
} else {
await currentVault.value?.drizzle.insert(schema.haexSettings).values({
id: crypto.randomUUID(),
key: VaultSettingsKeyEnum.theme,
type: VaultSettingsTypeEnum.settings,
value: currentTheme.value.value,
value: currentTheme.value?.value,
})
}
}
@ -121,14 +121,13 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
const readDeviceNameAsync = async (id: string) => {
const { currentVault } = useVaultStore()
const deviceName = await currentVault.drizzle?.query.haexSettings.findFirst(
{
const deviceName =
await currentVault?.drizzle?.query.haexSettings.findFirst({
where: and(
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
eq(schema.haexSettings.key, id),
),
},
)
})
console.log('readDeviceNameAsync', deviceName)
return deviceName
}
@ -148,7 +147,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
return
}
return currentVault.drizzle?.insert(schema.haexSettings).values({
return currentVault?.drizzle?.insert(schema.haexSettings).values({
id: crypto.randomUUID(),
type: VaultSettingsTypeEnum.deviceName,
key: deviceId,
@ -168,7 +167,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
const isNameOk = vaultDeviceNameSchema.safeParse(deviceName)
if (!isNameOk.success) return
return currentVault.drizzle
return currentVault?.drizzle
?.update(schema.haexSettings)
.set({
value: deviceName,