π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Add advanced search
louloudev59332c933f89f8
diff --git a/backend/.env.example b/backend/.env.exampledeleted file mode 100644index f6d7e954..00000000--- a/backend/.env.example+++ /dev/null@@ -1,16 +0,0 @@-JWT_SECRET=your_secret_key-DATABASE_USER=root-DATABASE_PASSWORD=root--DOMAIN_CLIENT=http://localhost:3000-COOKIE_DOMAIN=localhost---MINIO_ACCESSKEY=access_key-MINIO_SECRETKEY=secret_key-MINIO_ENDPOINT=localhost:9000-MINIO_BUCKET=alexandrie--SMTP_HOST=smtp.example.com-SMTP_PASSWORD=your_password\ No newline at end of filediff --git a/frontend/app/components/GlobalSearch.vue b/frontend/app/components/GlobalSearch.vueindex f5e70111..6949396c 100644--- a/frontend/app/components/GlobalSearch.vue+++ b/frontend/app/components/GlobalSearch.vue@@ -1,469 +1,318 @@-<template>- <Teleport to="body">- <div v-if="isOpen" class="global-search-overlay" @click="closeSearch">- <div class="global-search-modal" @click.stop>- <!-- Header -->- <div class="search-header">- <div class="search-input-wrapper">- <Icon name="search" class="search-icon" fill="var(--font-color)" />- <input ref="searchInput" v-model="searchQuery" type="text" placeholder="Search for a page, action, or document..." class="search-input" @keydown="handleSearchKeydown" />- </div>- <button class="close-btn" @click="closeSearch">- <Icon name="close" />- </button>- </div>-- <!-- Results -->- <div class="search-results">- <div v-if="searchQuery && flattenedItems.length === 0" class="no-results">- <Icon fill="var(--font-color)" name="search" class="no-results-icon" />- <p>No results found for "{{ searchQuery }}"</p>- </div>-- <div v-else class="search-results-list">- <div v-for="(items, section) in groupedResults" :key="section" class="section">- <div class="section-title">{{ section }}</div>- <NuxtLink v-for="item in items" :key="item.id" class="search-result-item" :to="item.path" :class="{ selected: selectedIndex === item.globalIndex }" @click="closeSearch" @mouseenter="selectedIndex = item.globalIndex">- <Icon :name="item.icon" class="result-icon" fill="var(--font-color)" />- <div class="result-content">- <span class="result-title">{{ item.title }}</span>- <span class="result-description">{{ item.description }}</span>- </div>- <Icon name="new_tab" class="navigate-icon" />- </NuxtLink>- </div>- </div>- </div>-- <!-- Footer -->- <div class="search-footer">- <div class="shortcuts"><kbd>ββ</kbd> Navigate <kbd>Enter</kbd> Select <kbd>Escape</kbd> Close</div>- </div>- </div>- </div>- </Teleport>-</template>--<script setup lang="ts">-import CreateCategoryModal from '~/pages/dashboard/categories/_modals/CreateCategoryModal.vue';-import { quickActions, availablePages, type SearchResult, type BaseCommand } from '@/helpers/navigation';--const router = useRouter();-const isOpen = ref(false);-const documentsStore = useDocumentsStore();-const searchQuery = ref('');-const selectedIndex = ref(0);-const searchInput = ref<HTMLInputElement>();--// *********** Utils ***********-function tokenize(text: string) {- return text.trim().toLowerCase().split(/\s+/).filter(Boolean);-}-function matchesTokens(haystack: string, tokens: string[]) {- const value = haystack.toLowerCase();- return tokens.every(t => value.includes(t));-}-function filterByTokens<T>(items: T[], getText: (item: T) => string): T[] {- const tokens = tokenize(searchQuery.value);- if (tokens.length === 0) return items;- return items.filter(item => matchesTokens(getText(item), tokens));-}--// ******** Filtered data ***********-const filteredActions = computed(() => filterByTokens(quickActions, a => `${a.title} ${a.description}`));--const filteredDocuments = computed<SearchResult[]>(() =>- filterByTokens(documentsStore.getAll, d => {- const name = d.name || '';- const tags = Array.isArray(d.tags) ? d.tags.join(' ') : String(d.tags || '');- return `${name} ${tags}`;- })- .slice(0, 5)- .map(d => ({- id: d.id,- title: d.name,- description: d.tags ? `#${String(d.tags)}` : 'Document',- icon: 'files',- path: `/dashboard/docs/${d.id}`,- category: 'Documents',- })),-);--const filteredPages = computed(() => filterByTokens(availablePages, p => `${p.title} ${p.description} ${p.category}`));--// ******** Flattened results ********-interface FlattenedItem extends BaseCommand {- section: string;- globalIndex: number;-}--const flattenedItems = computed(() => {- const items: FlattenedItem[] = [];- let globalIndex = 0;-- const pushWithIndex = (arr: Omit<FlattenedItem, 'section' | 'globalIndex'>[], section: string) => {- arr.forEach(item => {- items.push({ ...item, section, globalIndex });- globalIndex++;- });- };-- pushWithIndex(- filteredActions.value.map(a => ({- id: `action-${a.id}`,- icon: a.icon,- title: a.title,- description: a.description,- path: a.path,- })),- 'Pages & actions',- );-- pushWithIndex(- filteredPages.value.map(p => ({- id: `page-${p.id}`,- icon: p.icon,- title: p.title,- description: p.description,- path: p.path,- })),- 'Pages & actions',- );-- pushWithIndex(- filteredDocuments.value.map(d => ({- id: `doc-${d.id}`,- icon: d.icon,- title: d.title,- description: d.description,- path: d.path,- })),- 'Documents',- );-- return items;-});--const groupedResults = computed(() => {- return flattenedItems.value.reduce((acc, item) => {- (acc[item.section] ||= []).push(item);- return acc;- }, {} as Record<string, typeof flattenedItems.value>);-});--// ******** Lifecycle ********-onMounted(() => {- const handleGlobalKeydown = (e: KeyboardEvent) => {- if ((e.ctrlKey || e.metaKey) && e.key === 'k') {- e.preventDefault();- openSearch();- } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'u') {- e.preventDefault();- router.push('/dashboard/cdn');- } else if ((e.ctrlKey || e.metaKey) && e.altKey && e.key.toLowerCase() === 'n') {- e.preventDefault();- useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));- } else if (e.key === 'Escape' && isOpen.value) {- closeSearch();- }- };-- document.addEventListener('keydown', handleGlobalKeydown);- const openListener = () => openSearch();- window.addEventListener('global-search-open', openListener as EventListener);-- onUnmounted(() => {- document.removeEventListener('keydown', handleGlobalKeydown);- window.removeEventListener('global-search-open', openListener as EventListener);- });-});--// --- Methods ----function openSearch() {- isOpen.value = true;- selectedIndex.value = 0;- searchQuery.value = '';- nextTick(() => searchInput.value?.focus());-}--function closeSearch() {- isOpen.value = false;- searchQuery.value = '';- selectedIndex.value = 0;-}--function handleSearchKeydown(e: KeyboardEvent) {- if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey && selectedIndex.value < flattenedItems.value.length - 1)) {- e.preventDefault();- selectedIndex.value = (selectedIndex.value + 1) % flattenedItems.value.length;- } else if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey && selectedIndex.value > 0)) {- e.preventDefault();- selectedIndex.value = (selectedIndex.value - 1 + flattenedItems.value.length) % flattenedItems.value.length;- } else if (e.key === 'Enter' && flattenedItems.value.length > 0) {- e.preventDefault();- navigateTo(flattenedItems.value[selectedIndex.value]?.path);- closeSearch();- }-}--defineExpose({ openSearch, closeSearch });--watch(searchQuery, () => {- selectedIndex.value = 0;-});-</script>--<style scoped lang="scss">-.global-search-overlay {- position: fixed;- top: 0;- left: 0;- right: 0;- bottom: 0;- background: rgba(0, 0, 0, 0.5);- backdrop-filter: blur(2px);- z-index: 9999;- display: flex;- align-items: flex-start;- justify-content: center;- padding-top: 10vh;-}-.global-search-modal {- background: var(--bg-color);- border: 1px solid var(--border-color);- border-radius: 16px;- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);- width: 92%;- max-width: 720px;- max-height: 80vh;- overflow: hidden;- animation: slideIn 0.2s ease-out;-}-.search-header {- display: flex;- align-items: center;- padding: 20px;- border-bottom: 1px solid var(--border-color);- gap: 12px;-}-.search-input-wrapper {- flex: 1;- position: relative;-}-.search-icon {- position: absolute;- left: 12px;- top: 50%;- transform: translateY(-50%);- width: 20px;- height: 20px;- color: var(--text-muted);-}-.search-input {- width: 100%;- padding: 12px 12px 12px 44px;- border: none;- background: transparent;- color: var(--text-color);- font-size: 16px;- outline: none;- &::placeholder {- color: var(--text-muted);- }-}-.close-btn {- background: transparent;- border: none;- color: var(--text-muted);- cursor: pointer;- padding: 8px;- border-radius: 8px;- transition: all 0.2s ease;- &:hover {- background: var(--border-color);- color: var(--text-color);- }-}-.search-results {- max-height: calc(80vh - 160px);- overflow-y: auto;-}-.quick-actions {- padding: 20px;- h3 {- margin: 0 0 16px 0;- font-size: 14px;- font-weight: 600;- color: var(--text-muted);- text-transform: uppercase;- letter-spacing: 0.5px;- }-}-.quick-actions-grid {- display: grid;- gap: 8px;-}-.quick-action-btn {- display: flex;- align-items: center;- gap: 12px;- padding: 12px;- background: transparent;- border: none;- border-radius: 8px;- cursor: pointer;- transition: all 0.2s ease;- text-align: left;- &:hover {- background: var(--border-color);- }- &:active {- transform: scale(0.98);- }-}-.action-icon {- width: 20px;- height: 20px;- color: var(--primary);- flex-shrink: 0;-}-.action-content {- flex: 1;- display: flex;- flex-direction: column;- gap: 2px;-}-.action-title {- font-weight: 600;- color: var(--text-color);-}-.action-description {- font-size: 13px;- color: var(--text-muted);-}-.shortcut {- background: var(--border-color);- color: var(--text-muted);- padding: 4px 8px;- border-radius: 6px;- font-size: 11px;- font-family: monospace;- font-weight: 600;-}-.search-results-list {- padding: 8px 0;-}-.search-result-item {- display: flex;- align-items: center;- gap: 10px;- padding: 8px 20px;- margin: 0 5px;- border-radius: 8px;- cursor: pointer;- &:hover,- &.selected {- background: var(--border-color);- }-}-.result-icon {- width: 20px;- height: 20px;- color: var(--primary);- flex-shrink: 0;-}-.result-content {- flex: 1;- display: flex;- flex-direction: column;- gap: 4px;- min-width: 0;-}-.result-title {- font-weight: 600;- color: var(--text-color);- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;-}-.result-description {- font-size: 13px;- color: var(--text-muted);- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;-}-.navigate-icon {- width: 16px;- height: 16px;- color: var(--text-muted);- flex-shrink: 0;-}-.section {- padding: 8px 0 4px;-}-.section-title {- position: sticky;- top: 0;- background: var(--bg-color);- z-index: 1;- font-size: 12px;- text-transform: uppercase;- color: var(--text-muted);- padding: 6px 20px;-}-.no-results {- padding: 40px 20px;- text-align: center;- color: var(--text-muted);- .no-results-icon {- width: 48px;- height: 48px;- margin-bottom: 16px;- opacity: 0.5;- }- p {- margin: 0;- font-size: 14px;- }-}-.search-footer {- padding: 16px 20px;- border-top: 1px solid var(--border-color);- background: var(--bg-color-secondary);-}-.shortcuts {- display: flex;- gap: 16px;- font-size: 12px;- color: var(--text-muted);- kbd {- background: var(--border-color);- padding: 2px 6px;- border-radius: 4px;- font-family: monospace;- font-weight: 600;- }-}-@keyframes slideIn {- from {- opacity: 0;- transform: scale(0.95);- }- to {- opacity: 1;- transform: scale(1);- }-}-@media (max-width: 768px) {- .global-search-modal {- width: 95%;- margin: 20px;- max-height: 80vh;- }- .shortcuts {- flex-direction: column;- gap: 8px;- }-}-</style>+<template>+ <Teleport to="body">+ <div v-if="isOpen" class="global-search-overlay" @click="closeSearch">+ <div class="global-search-modal" @click.stop>+ <!-- Header -->+ <div class="search-header">+ <div class="search-input-wrapper">+ <Icon name="search" class="search-icon" fill="var(--font-color)" />+ <input ref="searchInput" v-model="searchQuery" type="text" placeholder="Search for a page, action, or document..." class="search-input" @keydown="handleSearchKeydown" />+ </div>+ <button class="close-btn" @click="closeSearch">+ <Icon name="close" />+ </button>+ </div>++ <!-- Tab Navigation -->+ <TabNavigation :active-tab="activeTab" @change-tab="changeTab" />++ <!-- Tab Content -->+ <div class="tab-content">+ <QuickSearchTab+ v-if="activeTab === 'quick'"+ :search-query="searchQuery"+ :selected-index="selectedIndex"+ :documents="documentsStore.getAll"+ @select-item="closeSearch"+ @update-selected-index="updateSelectedIndex"+ ref="quickSearchTab"+ />++ <AdvancedSearchTab+ v-else-if="activeTab === 'advanced'"+ :documents="documentsStore.getAll"+ @select-document="handleDocumentSelect"+ />+ </div>++ <!-- Footer -->+ <div class="search-footer">+ <div class="shortcuts">+ <kbd>ββ</kbd> Navigate+ <kbd>Enter</kbd> Select+ <kbd>Tab</kbd> Switch tabs+ <kbd>Escape</kbd> Close+ </div>+ </div>+ </div>+ </div>+ </Teleport>+</template>++<script setup lang="ts">+import CreateCategoryModal from '~/pages/dashboard/categories/_modals/CreateCategoryModal.vue';+import TabNavigation from './GlobalSearch/TabNavigation.vue';+import QuickSearchTab from './GlobalSearch/QuickSearchTab.vue';+import AdvancedSearchTab from './GlobalSearch/AdvancedSearchTab.vue';+import { useModal, Modal } from '~/composables/ModalBus';++const router = useRouter();+const isOpen = ref(false);+const documentsStore = useDocumentsStore();+const searchQuery = ref('');+const selectedIndex = ref(0);+const activeTab = ref('quick');+const searchInput = ref<HTMLInputElement>();+const quickSearchTab = ref();++// *********** Lifecycle ***********+onMounted(() => {+ const handleGlobalKeydown = (e: KeyboardEvent) => {+ if ((e.ctrlKey || e.metaKey) && e.key === 'k') {+ e.preventDefault();+ openSearch();+ } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'u') {+ e.preventDefault();+ router.push('/dashboard/cdn');+ } else if ((e.ctrlKey || e.metaKey) && e.altKey && e.key.toLowerCase() === 'n') {+ e.preventDefault();+ useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));+ } else if (e.key === 'Escape' && isOpen.value) {+ closeSearch();+ } else if (e.key === 'Tab' && isOpen.value) {+ e.preventDefault();+ changeTab(activeTab.value === 'quick' ? 'advanced' : 'quick');+ }+ };++ const handleWheel = (e: WheelEvent) => {+ if (isOpen.value) {+ e.preventDefault();+ e.stopPropagation();+ }+ };++ const handleTouchMove = (e: TouchEvent) => {+ if (isOpen.value) {+ e.preventDefault();+ e.stopPropagation();+ }+ };++ document.addEventListener('keydown', handleGlobalKeydown);+ document.addEventListener('wheel', handleWheel, { passive: false });+ document.addEventListener('touchmove', handleTouchMove, { passive: false });+ const openListener = () => openSearch();+ window.addEventListener('global-search-open', openListener as EventListener);++ onUnmounted(() => {+ document.removeEventListener('keydown', handleGlobalKeydown);+ document.removeEventListener('wheel', handleWheel);+ document.removeEventListener('touchmove', handleTouchMove);+ window.removeEventListener('global-search-open', openListener as EventListener);+ });+});++// --- Methods ---+function openSearch() {+ isOpen.value = true;+ selectedIndex.value = 0;+ searchQuery.value = '';+ activeTab.value = 'quick';+ document.body.style.overflow = 'hidden';+ nextTick(() => searchInput.value?.focus());+}++function closeSearch() {+ isOpen.value = false;+ searchQuery.value = '';+ selectedIndex.value = 0;+ document.body.style.overflow = '';+}++function changeTab(tabId: string) {+ activeTab.value = tabId;+ selectedIndex.value = 0;+ if (tabId === 'quick') {+ nextTick(() => searchInput.value?.focus());+ }+}++function updateSelectedIndex(index: number) {+ selectedIndex.value = index;+}++function handleDocumentSelect(document: any) {+ navigateTo(`/dashboard/docs/${document.id}`);+ closeSearch();+}++function handleSearchKeydown(e: KeyboardEvent) {+ if (activeTab.value === 'advanced') {+ return;+ }++ if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey && selectedIndex.value < (quickSearchTab.value?.flattenedItems?.length || 0) - 1)) {+ e.preventDefault();+ const maxIndex = (quickSearchTab.value?.flattenedItems?.length || 0) - 1;+ selectedIndex.value = (selectedIndex.value + 1) % Math.max(maxIndex + 1, 1);+ } else if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey && selectedIndex.value > 0)) {+ e.preventDefault();+ const maxIndex = (quickSearchTab.value?.flattenedItems?.length || 0) - 1;+ selectedIndex.value = (selectedIndex.value - 1 + Math.max(maxIndex + 1, 1)) % Math.max(maxIndex + 1, 1);+ } else if (e.key === 'Enter' && quickSearchTab.value?.flattenedItems?.length > 0) {+ e.preventDefault();+ const selectedItem = quickSearchTab.value.flattenedItems[selectedIndex.value];+ if (selectedItem) {+ navigateTo(selectedItem.path);+ closeSearch();+ }+ }+}++defineExpose({ openSearch, closeSearch });++watch(searchQuery, () => {+ selectedIndex.value = 0;+});+</script>++<style scoped lang="scss">+.global-search-overlay {+ position: fixed;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;+ background: rgba(0, 0, 0, 0.5);+ backdrop-filter: blur(2px);+ z-index: 9999;+ display: flex;+ align-items: flex-start;+ justify-content: center;+ padding-top: 10vh;+ overflow: hidden;+}++.global-search-modal {+ background: var(--bg-color);+ border: 1px solid var(--border-color);+ border-radius: 16px;+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);+ width: 92%;+ max-width: 720px;+ max-height: 80vh;+ display: flex;+ flex-direction: column;+ overflow: hidden;+ animation: slideIn 0.2s ease-out;+ position: relative;+ overscroll-behavior: contain;+}++.search-header {+ display: flex;+ align-items: center;+ padding: 20px;+ border-bottom: 1px solid var(--border-color);+ gap: 12px;+ flex-shrink: 0;+}++.search-input-wrapper {+ flex: 1;+ position: relative;+}++.search-icon {+ position: absolute;+ left: 12px;+ top: 50%;+ transform: translateY(-50%);+ width: 20px;+ height: 20px;+ color: var(--text-muted);+}++.search-input {+ width: 100%;+ padding: 12px 12px 12px 44px;+ border: none;+ background: transparent;+ color: var(--text-color);+ font-size: 16px;+ outline: none;++ &::placeholder {+ color: var(--text-muted);+ }+}++.close-btn {+ background: transparent;+ border: none;+ color: var(--text-muted);+ cursor: pointer;+ padding: 8px;+ border-radius: 8px;+ transition: all 0.2s ease;++ &:hover {+ background: var(--border-color);+ color: var(--text-color);+ }+}++.tab-content {+ flex: 1;+ overflow: hidden;+ min-height: 0;+ position: relative;+}++.search-footer {+ padding: 16px 20px;+ border-top: 1px solid var(--border-color);+ background: var(--bg-color-secondary);+ flex-shrink: 0;+}++.shortcuts {+ display: flex;+ gap: 16px;+ font-size: 12px;+ color: var(--text-muted);++ kbd {+ background: var(--border-color);+ padding: 2px 6px;+ border-radius: 4px;+ font-family: monospace;+ font-weight: 600;+ }+}++@keyframes slideIn {+ from {+ opacity: 0;+ transform: scale(0.95);+ }+ to {+ opacity: 1;+ transform: scale(1);+ }+}++@media (max-width: 768px) {+ .global-search-modal {+ width: 95%;+ margin: 20px;+ max-height: 80vh;+ }++ .shortcuts {+ flex-direction: column;+ gap: 8px;+ }+}+</style>diff --git a/frontend/app/components/GlobalSearch/AdvancedSearchTab.vue b/frontend/app/components/GlobalSearch/AdvancedSearchTab.vuenew file mode 100644index 00000000..f97fd93c--- /dev/null+++ b/frontend/app/components/GlobalSearch/AdvancedSearchTab.vue@@ -0,0 +1,714 @@+<template>+ <div class="advanced-search-tab">+ <div class="search-filters">+ <div class="filters-header">+ <h3 class="filters-title">Advanced Filters</h3>+ <button @click="toggleFilters" class="toggle-filters-btn" :class="{ collapsed: !showFilters }">+ <Icon :name="showFilters ? 'collapse' : 'expand'" />+ </button>+ </div>++ <div v-show="showFilters" class="filters-content">+ <div class="filter-group">+ <label class="filter-label">Date Range</label>+ <div class="date-filters">+ <div class="date-input">+ <label>From</label>+ <input v-model="dateFrom" type="date" class="date-picker" />+ </div>+ <div class="date-input">+ <label>To</label>+ <input v-model="dateTo" type="date" class="date-picker" />+ </div>+ </div>+ </div>++ <div class="filter-group">+ <label class="filter-label">Date Type</label>+ <div class="radio-group">+ <label class="radio-option">+ <input v-model="dateType" type="radio" value="created" />+ <span>Created</span>+ </label>+ <label class="radio-option">+ <input v-model="dateType" type="radio" value="modified" />+ <span>Modified</span>+ </label>+ </div>+ </div>++ <div class="filter-group">+ <label class="filter-label">Tags</label>+ <div class="tags-filter">+ <div class="tags-input-wrapper">+ <div class="tags-input">+ <input+ v-model="tagInput"+ type="text"+ placeholder="Add tag filter..."+ class="tag-input"+ @keydown.enter="handleEnter"+ @keydown.arrow-up="handleArrowUp"+ @keydown.arrow-down="handleArrowDown"+ @keydown.escape="hideSuggestions"+ @input="handleTagInput"+ @focus="showSuggestions = true"+ @blur="hideSuggestions"+ />+ <button @click="addTag" class="add-tag-btn">+ <Icon name="plus" />+ </button>+ </div>++ <div v-if="showSuggestions && filteredTagSuggestions.length > 0" class="tag-suggestions">+ <div+ v-for="(tag, index) in filteredTagSuggestions"+ :key="tag"+ class="tag-suggestion"+ :class="{ selected: selectedSuggestionIndex === index }"+ @mousedown="selectTag(tag)"+ @mouseenter="selectedSuggestionIndex = index"+ >+ {{ tag }}+ </div>+ </div>+ </div>+ <div class="selected-tags">+ <span v-for="tag in selectedTags" :key="tag" class="tag-chip">+ {{ tag }}+ <button @click="removeTag(tag)" class="remove-tag">+ <Icon name="close" />+ </button>+ </span>+ </div>+ </div>+ </div>++ <div class="filter-group">+ <label class="filter-label">Category</label>+ <select v-model="selectedCategory" class="category-select">+ <option value="">All Categories</option>+ <option v-for="category in categories" :key="category.id" :value="category.id">+ {{ category.name }}+ </option>+ </select>+ </div>++ <div class="filter-actions">+ <button @click="clearFilters" class="clear-filters-btn">Clear Filters</button>+ <button @click="applyFilters" class="apply-filters-btn">Apply Filters</button>+ </div>+ </div>+ </div>++ <div class="search-results">+ <div v-if="filteredDocuments.length === 0" class="no-results">+ <Icon name="search" class="no-results-icon" />+ <p>No documents match your filters</p>+ </div>++ <div v-else class="documents-list">+ <div v-for="doc in filteredDocuments" :key="doc.id" class="document-item" @click="selectDocument(doc)">+ <Icon :name="getDocumentIcon(doc)" class="document-icon" />+ <div class="document-info">+ <div class="document-title">{{ doc.name }}</div>+ <div class="document-meta">+ <span class="document-category">{{ getCategoryName(doc.category) }}</span>+ <span class="document-date">{{ formatDate(doc[dateType === 'created' ? 'created_timestamp' : 'updated_timestamp']) }}</span>+ </div>+ <div v-if="doc.tags" class="document-tags">+ <span v-for="tag in parseTags(doc.tags)" :key="tag" class="tag">{{ tag }}</span>+ </div>+ </div>+ <Icon name="new_tab" class="navigate-icon" />+ </div>+ </div>+ </div>+ </div>+</template>++<script setup lang="ts">+import type { Document } from '~/stores';+import Icon from '~/components/Icon.vue';++const props = defineProps<{+ documents: Document[];+}>();++const emit = defineEmits<{+ selectDocument: [document: Document];+}>();++const dateFrom = ref('');+const dateTo = ref('');+const dateType = ref<'created' | 'modified'>('modified');+const tagInput = ref('');+const selectedTags = ref<string[]>([]);+const selectedCategory = ref('');+const showFilters = ref(true);+const showSuggestions = ref(false);+const selectedSuggestionIndex = ref(0);++const categoryStore = useCategoriesStore();+const categories = computed(() => categoryStore.getAll);++const allTags = computed(() => {+ const tags = new Set<string>();+ props.documents.forEach(doc => {+ if (doc.tags) {+ parseTags(doc.tags).forEach(tag => tags.add(tag));+ }+ });+ return Array.from(tags).sort();+});++const filteredTagSuggestions = computed(() => {+ if (!tagInput.value) return [];+ const input = tagInput.value.toLowerCase();+ return allTags.value+ .filter(tag =>+ tag.toLowerCase().includes(input) &&+ !selectedTags.value.includes(tag)+ )+ .slice(0, 5);+});++const filteredDocuments = computed(() => {+ let filtered = [...props.documents];++ if (selectedCategory.value) {+ filtered = filtered.filter(doc => doc.category === selectedCategory.value);+ }++ if (dateFrom.value) {+ const fromDate = new Date(dateFrom.value).getTime();+ filtered = filtered.filter(doc => {+ const docDate = parseInt(doc[dateType.value === 'created' ? 'created_timestamp' : 'updated_timestamp']);+ return docDate >= fromDate;+ });+ }++ if (dateTo.value) {+ const toDate = new Date(dateTo.value).getTime();+ filtered = filtered.filter(doc => {+ const docDate = parseInt(doc[dateType.value === 'created' ? 'created_timestamp' : 'updated_timestamp']);+ return docDate <= toDate;+ });+ }++ if (selectedTags.value.length > 0) {+ filtered = filtered.filter(doc => {+ if (!doc.tags) return false;+ const docTags = parseTags(doc.tags);+ return selectedTags.value.some(tag => docTags.includes(tag));+ });+ }++ return filtered.sort((a, b) => {+ const aDate = parseInt(a[dateType.value === 'created' ? 'created_timestamp' : 'updated_timestamp']);+ const bDate = parseInt(b[dateType.value === 'created' ? 'created_timestamp' : 'updated_timestamp']);+ return bDate - aDate;+ });+});++function addTag() {+ const tag = tagInput.value.trim();+ if (tag && !selectedTags.value.includes(tag)) {+ selectedTags.value.push(tag);+ tagInput.value = '';+ showSuggestions.value = false;+ }+}++function selectTag(tag: string) {+ selectedTags.value.push(tag);+ tagInput.value = '';+ showSuggestions.value = false;+}++function handleTagInput() {+ selectedSuggestionIndex.value = 0;+ showSuggestions.value = filteredTagSuggestions.value.length > 0;+}++function hideSuggestions() {+ setTimeout(() => {+ showSuggestions.value = false;+ }, 200);+}++function handleEnter(event: KeyboardEvent) {+ event.preventDefault();+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ selectTag(filteredTagSuggestions.value[selectedSuggestionIndex.value]);+ } else {+ addTag();+ }+}++function handleArrowUp(event: KeyboardEvent) {+ event.preventDefault();+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0+ ? selectedSuggestionIndex.value - 1+ : filteredTagSuggestions.value.length - 1;+ }+}++function handleArrowDown(event: KeyboardEvent) {+ event.preventDefault();+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredTagSuggestions.value.length - 1+ ? selectedSuggestionIndex.value + 1+ : 0;+ }+}++function toggleFilters() {+ showFilters.value = !showFilters.value;+}++function removeTag(tag: string) {+ selectedTags.value = selectedTags.value.filter(t => t !== tag);+}++function clearFilters() {+ dateFrom.value = '';+ dateTo.value = '';+ selectedTags.value = [];+ selectedCategory.value = '';+}++function applyFilters() {+ // Filters are applied automatically via computed+}++function selectDocument(doc: Document) {+ emit('selectDocument', doc);+}++function getDocumentIcon(doc: Document) {+ if (doc.pinned === 1) return 'pin';+ if (doc.pinned === 2) return 'pin';+ return 'files';+}++function getCategoryName(categoryId?: string) {+ if (!categoryId) return 'Uncategorized';+ const category = categoryStore.getById(categoryId);+ return category?.name || 'Unknown';+}++function formatDate(timestamp: string) {+ const date = new Date(parseInt(timestamp));+ return date.toLocaleDateString();+}++function parseTags(tags: string): string[] {+ if (typeof tags === 'string') {+ return tags.split(',').map(tag => tag.trim()).filter(Boolean);+ }+ return [];+}+</script>++<style scoped lang="scss">+.advanced-search-tab {+ display: flex;+ flex-direction: column;+ height: 100%;+ overflow: hidden;+}++.search-filters {+ flex-shrink: 0;+ background: var(--bg-color-secondary);+ border-bottom: 1px solid var(--border-color);+}++.filters-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: 16px 20px;+ border-bottom: 1px solid var(--border-color);+}++.filters-title {+ margin: 0;+ font-size: 14px;+ font-weight: 600;+ color: var(--text-color);+ text-transform: uppercase;+ letter-spacing: 0.5px;+}++.toggle-filters-btn {+ background: transparent;+ border: none;+ color: var(--text-muted);+ cursor: pointer;+ padding: 4px;+ border-radius: 4px;+ transition: all 0.2s ease;+ display: flex;+ align-items: center;+ justify-content: center;++ &:hover {+ background: var(--border-color);+ color: var(--text-color);+ }++ &.collapsed {+ transform: rotate(180deg);+ }+}++.filters-content {+ padding: 20px;+}++.filter-group {+ margin-bottom: 20px;++ &:last-child {+ margin-bottom: 0;+ }+}++.filter-label {+ display: block;+ font-size: 12px;+ font-weight: 600;+ text-transform: uppercase;+ color: var(--text-muted);+ margin-bottom: 8px;+ letter-spacing: 0.5px;+}++.date-filters {+ display: flex;+ gap: 12px;+}++.date-input {+ flex: 1;++ label {+ display: block;+ font-size: 11px;+ color: var(--text-muted);+ margin-bottom: 4px;+ }+}++.date-picker {+ width: 100%;+ padding: 8px 12px;+ border: 1px solid var(--border-color);+ border-radius: 6px;+ background: var(--bg-color);+ color: var(--text-color);+ font-size: 14px;+ outline: none;++ &:focus {+ border-color: var(--primary);+ }+}++.radio-group {+ display: flex;+ gap: 16px;+}++.radio-option {+ display: flex;+ align-items: center;+ gap: 6px;+ cursor: pointer;+ font-size: 14px;+ color: var(--text-color);++ input[type="radio"] {+ accent-color: var(--primary);+ }+}++.tags-filter {+ .tags-input-wrapper {+ position: relative;+ margin-bottom: 12px;+ }++ .tags-input {+ display: flex;+ gap: 8px;+ }++ .tag-input {+ flex: 1;+ padding: 8px 12px;+ border: 1px solid var(--border-color);+ border-radius: 6px;+ background: var(--bg-color);+ color: var(--text-color);+ font-size: 14px;+ outline: none;++ &:focus {+ border-color: var(--primary);+ }+ }++ .add-tag-btn {+ padding: 8px 12px;+ background: var(--primary);+ border: none;+ border-radius: 6px;+ color: white;+ cursor: pointer;+ display: flex;+ align-items: center;+ justify-content: center;+ transition: all 0.2s ease;++ &:hover {+ background: var(--primary-dark, #0056b3);+ }+ }+}++.tag-suggestions {+ position: absolute;+ top: 100%;+ left: 0;+ right: 48px;+ background: var(--bg-color);+ border: 1px solid var(--border-color);+ border-radius: 6px;+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);+ z-index: 10;+ max-height: 200px;+ overflow-y: auto;+}++.tag-suggestion {+ padding: 8px 12px;+ cursor: pointer;+ font-size: 14px;+ color: var(--text-color);+ transition: background 0.2s ease;++ &:hover,+ &.selected {+ background: var(--border-color);+ }++ &:first-child {+ border-radius: 6px 6px 0 0;+ }++ &:last-child {+ border-radius: 0 0 6px 6px;+ }+}++.selected-tags {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+}++.tag-chip {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ padding: 4px 8px;+ background: var(--border-color);+ border-radius: 12px;+ font-size: 12px;+ color: var(--text-color);++ .remove-tag {+ background: none;+ border: none;+ color: var(--text-muted);+ cursor: pointer;+ padding: 0;+ display: flex;+ align-items: center;+ justify-content: center;+ width: 16px;+ height: 16px;+ border-radius: 50%;++ &:hover {+ background: var(--text-muted);+ color: white;+ }+ }+}++.category-select {+ width: 100%;+ padding: 8px 12px;+ border: 1px solid var(--border-color);+ border-radius: 6px;+ background: var(--bg-color);+ color: var(--text-color);+ font-size: 14px;+ outline: none;++ &:focus {+ border-color: var(--primary);+ }+}++.filter-actions {+ display: flex;+ gap: 12px;+ margin-top: 20px;+}++.clear-filters-btn,+.apply-filters-btn {+ flex: 1;+ padding: 10px 16px;+ border: none;+ border-radius: 6px;+ font-size: 14px;+ font-weight: 500;+ cursor: pointer;+ transition: all 0.2s ease;+}++.clear-filters-btn {+ background: var(--border-color);+ color: var(--text-color);++ &:hover {+ background: var(--selection-color);+ }+}++.apply-filters-btn {+ background: var(--primary);+ color: white;++ &:hover {+ background: var(--primary-dark, #0056b3);+ }+}++.search-results {+ flex: 1;+ overflow-y: auto;+ min-height: 0;+ position: relative;+ overscroll-behavior: contain;+ -webkit-overflow-scrolling: touch;+}++.no-results {+ padding: 40px 20px;+ text-align: center;+ color: var(--text-muted);++ .no-results-icon {+ width: 48px;+ height: 48px;+ margin-bottom: 16px;+ opacity: 0.5;+ }++ p {+ margin: 0;+ font-size: 14px;+ }+}++.documents-list {+ padding: 8px 0;+ overflow-y: auto;+ max-height: 100%;+}++.document-item {+ display: flex;+ align-items: center;+ gap: 12px;+ padding: 12px 20px;+ margin: 0 5px;+ border-radius: 8px;+ cursor: pointer;+ transition: all 0.2s ease;++ &:hover {+ background: var(--border-color);+ }+}++.document-icon {+ width: 20px;+ height: 20px;+ color: var(--primary);+ flex-shrink: 0;+}++.document-info {+ flex: 1;+ min-width: 0;+}++.document-title {+ font-weight: 600;+ color: var(--text-color);+ margin-bottom: 4px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.document-meta {+ display: flex;+ gap: 12px;+ margin-bottom: 6px;+ font-size: 12px;+ color: var(--text-muted);+}++.document-category {+ background: var(--border-color);+ padding: 2px 6px;+ border-radius: 4px;+ font-size: 11px;+}++.document-date {+ font-family: monospace;+}++.document-tags {+ display: flex;+ gap: 4px;+ flex-wrap: wrap;+}++.tag {+ background: var(--primary);+ color: white;+ padding: 2px 6px;+ border-radius: 4px;+ font-size: 10px;+ font-weight: 500;+}++.navigate-icon {+ width: 16px;+ height: 16px;+ color: var(--text-muted);+ flex-shrink: 0;+}+</style>diff --git a/frontend/app/components/GlobalSearch/QuickSearchTab.vue b/frontend/app/components/GlobalSearch/QuickSearchTab.vuenew file mode 100644index 00000000..5ad91c3d--- /dev/null+++ b/frontend/app/components/GlobalSearch/QuickSearchTab.vue@@ -0,0 +1,249 @@+<template>+ <div class="quick-search-tab">+ <div class="search-results">+ <div v-if="searchQuery && flattenedItems.length === 0" class="no-results">+ <Icon fill="var(--font-color)" name="search" class="no-results-icon" />+ <p>No results found for "{{ searchQuery }}"</p>+ </div>++ <div v-else class="search-results-list">+ <div v-for="(items, section) in groupedResults" :key="section" class="section">+ <div class="section-title">{{ section }}</div>+ <NuxtLink v-for="item in items" :key="item.id" class="search-result-item" :to="item.path" :class="{ selected: selectedIndex === item.globalIndex }" @click="$emit('selectItem')" @mouseenter="$emit('updateSelectedIndex', item.globalIndex)">+ <Icon :name="item.icon" class="result-icon" fill="var(--font-color)" />+ <div class="result-content">+ <span class="result-title">{{ item.title }}</span>+ <span class="result-description">{{ item.description }}</span>+ </div>+ <Icon name="new_tab" class="navigate-icon" />+ </NuxtLink>+ </div>+ </div>+ </div>+ </div>+</template>++<script setup lang="ts">+import { quickActions, availablePages, type SearchResult, type BaseCommand } from '@/helpers/navigation';+import Icon from '~/components/Icon.vue';++const props = defineProps<{+ searchQuery: string;+ selectedIndex: number;+ documents: any[];+}>();++const emit = defineEmits<{+ selectItem: [];+ updateSelectedIndex: [index: number];+}>();++function tokenize(text: string) {+ return text.trim().toLowerCase().split(/\s+/).filter(Boolean);+}++function matchesTokens(haystack: string, tokens: string[]) {+ const value = haystack.toLowerCase();+ return tokens.every(t => value.includes(t));+}++function filterByTokens<T>(items: T[], getText: (item: T) => string): T[] {+ const tokens = tokenize(props.searchQuery);+ if (tokens.length === 0) return items;+ return items.filter(item => matchesTokens(getText(item), tokens));+}++const filteredActions = computed(() => filterByTokens(quickActions, a => `${a.title} ${a.description}`));++const filteredDocuments = computed<SearchResult[]>(() =>+ filterByTokens(props.documents, d => {+ const name = d.name || '';+ const tags = Array.isArray(d.tags) ? d.tags.join(' ') : String(d.tags || '');+ return `${name} ${tags}`;+ })+ .slice(0, 5)+ .map(d => ({+ id: d.id,+ title: d.name,+ description: d.tags ? `#${String(d.tags)}` : 'Document',+ icon: 'files',+ path: `/dashboard/docs/${d.id}`,+ category: 'Documents',+ })),+);++const filteredPages = computed(() => filterByTokens(availablePages, p => `${p.title} ${p.description} ${p.category}`));++interface FlattenedItem extends BaseCommand {+ section: string;+ globalIndex: number;+}++const flattenedItems = computed(() => {+ const items: FlattenedItem[] = [];+ let globalIndex = 0;++ const pushWithIndex = (arr: Omit<FlattenedItem, 'section' | 'globalIndex'>[], section: string) => {+ arr.forEach(item => {+ items.push({ ...item, section, globalIndex });+ globalIndex++;+ });+ };++ pushWithIndex(+ filteredActions.value.map(a => ({+ id: `action-${a.id}`,+ icon: a.icon,+ title: a.title,+ description: a.description,+ path: a.path,+ })),+ 'Pages & actions',+ );++ pushWithIndex(+ filteredPages.value.map(p => ({+ id: `page-${p.id}`,+ icon: p.icon,+ title: p.title,+ description: p.description,+ path: p.path,+ })),+ 'Pages & actions',+ );++ pushWithIndex(+ filteredDocuments.value.map(d => ({+ id: `doc-${d.id}`,+ icon: d.icon,+ title: d.title,+ description: d.description,+ path: d.path,+ })),+ 'Documents',+ );++ return items;+});++const groupedResults = computed(() => {+ return flattenedItems.value.reduce((acc, item) => {+ (acc[item.section] ||= []).push(item);+ return acc;+ }, {} as Record<string, typeof flattenedItems.value>);+});++defineExpose({ flattenedItems });+</script>++<style scoped lang="scss">+.quick-search-tab {+ display: flex;+ flex-direction: column;+ height: 100%;+ overflow: hidden;+}++.search-results {+ flex: 1;+ overflow-y: auto;+ min-height: 0;+ position: relative;+ overscroll-behavior: contain;+ -webkit-overflow-scrolling: touch;+}++.search-results-list {+ padding: 8px 0;+ overflow-y: auto;+ max-height: 100%;+}++.search-result-item {+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 8px 20px;+ margin: 0 5px;+ border-radius: 8px;+ cursor: pointer;+ text-decoration: none;+ color: inherit;++ &:hover,+ &.selected {+ background: var(--border-color);+ }+}++.result-icon {+ width: 20px;+ height: 20px;+ color: var(--primary);+ flex-shrink: 0;+}++.result-content {+ flex: 1;+ display: flex;+ flex-direction: column;+ gap: 4px;+ min-width: 0;+}++.result-title {+ font-weight: 600;+ color: var(--text-color);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.result-description {+ font-size: 13px;+ color: var(--text-muted);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.navigate-icon {+ width: 16px;+ height: 16px;+ color: var(--text-muted);+ flex-shrink: 0;+}++.section {+ padding: 8px 0 4px;+}++.section-title {+ position: sticky;+ top: 0;+ background: var(--bg-color);+ z-index: 1;+ font-size: 12px;+ text-transform: uppercase;+ color: var(--text-muted);+ padding: 6px 20px;+}++.no-results {+ padding: 40px 20px;+ text-align: center;+ color: var(--text-muted);++ .no-results-icon {+ width: 48px;+ height: 48px;+ margin-bottom: 16px;+ opacity: 0.5;+ }++ p {+ margin: 0;+ font-size: 14px;+ }+}+</style>diff --git a/frontend/app/components/GlobalSearch/TabNavigation.vue b/frontend/app/components/GlobalSearch/TabNavigation.vuenew file mode 100644index 00000000..b74bde4f--- /dev/null+++ b/frontend/app/components/GlobalSearch/TabNavigation.vue@@ -0,0 +1,88 @@+<template>+ <div class="tab-navigation">+ <button+ v-for="tab in tabs"+ :key="tab.id"+ class="tab-button"+ :class="{ active: activeTab === tab.id }"+ @click="$emit('changeTab', tab.id)"+ >+ <Icon :name="tab.icon" class="tab-icon" />+ <span class="tab-label">{{ tab.label }}</span>+ </button>+ </div>+</template>++<script setup lang="ts">+import Icon from '~/components/Icon.vue';++interface Tab {+ id: string;+ label: string;+ icon: string;+}++const props = defineProps<{+ activeTab: string;+}>();++const emit = defineEmits<{+ changeTab: [tabId: string];+}>();++const tabs: Tab[] = [+ {+ id: 'quick',+ label: 'Quick Search',+ icon: 'search',+ },+ {+ id: 'advanced',+ label: 'Advanced Search',+ icon: 'layers',+ },+];+</script>++<style scoped lang="scss">+.tab-navigation {+ display: flex;+ border-bottom: 1px solid var(--border-color);+ background: var(--bg-color);+}++.tab-button {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 16px 20px;+ background: transparent;+ border: none;+ color: var(--text-muted);+ cursor: pointer;+ font-size: 14px;+ font-weight: 500;+ transition: all 0.2s ease;+ border-bottom: 2px solid transparent;++ &:hover {+ color: var(--text-color);+ background: var(--bg-color-secondary);+ }++ &.active {+ color: var(--primary);+ border-bottom-color: var(--primary);+ background: var(--bg-color-secondary);+ }+}++.tab-icon {+ width: 16px;+ height: 16px;+}++.tab-label {+ white-space: nowrap;+}+</style>diff --git a/frontend/app/components/GlobalSearch/index.ts b/frontend/app/components/GlobalSearch/index.tsnew file mode 100644index 00000000..e4011ff8--- /dev/null+++ b/frontend/app/components/GlobalSearch/index.ts@@ -0,0 +1,3 @@+export { default as TabNavigation } from './TabNavigation.vue';+export { default as QuickSearchTab } from './QuickSearchTab.vue';+export { default as AdvancedSearchTab } from './AdvancedSearchTab.vue';