Compare commits
4
Commits
e0b22868f2
...
e268631386
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e268631386 | ||
|
|
a6c466e1ba | ||
|
|
2ac7a099b5 | ||
|
|
c1e7a8ac5a |
@@ -27,6 +27,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
|
"node_modules/ngx-toastr/toastr.css",
|
||||||
"src/styles.css"
|
"src/styles.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+63
-10
@@ -1,12 +1,49 @@
|
|||||||
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZonelessChangeDetection, APP_INITIALIZER } from '@angular/core';
|
import {
|
||||||
|
ApplicationConfig,
|
||||||
|
provideBrowserGlobalErrorListeners,
|
||||||
|
provideZonelessChangeDetection,
|
||||||
|
APP_INITIALIZER,
|
||||||
|
importProvidersFrom,
|
||||||
|
ApplicationRef,
|
||||||
|
Injector,
|
||||||
|
NgZone,
|
||||||
|
} from '@angular/core';
|
||||||
import { provideRouter } from '@angular/router';
|
import { provideRouter } from '@angular/router';
|
||||||
import { provideAnimations } from '@angular/platform-browser/animations';
|
import { provideAnimations } from '@angular/platform-browser/animations';
|
||||||
import { provideHttpClient } from '@angular/common/http';
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
import { Overlay, ToastrModule, ToastrService, TOAST_CONFIG } from 'ngx-toastr';
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
import { routes } from './app.routes';
|
||||||
import { AuthService } from './services/auth/auth.service';
|
import { AuthService } from './services/auth/auth.service';
|
||||||
|
|
||||||
|
/** The type of the injected TOAST_CONFIG value (the `{ default, config }` toast token). */
|
||||||
|
type ToastConfigToken = ConstructorParameters<typeof ToastrService>[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the real ToastrService wrapped so every method forces an `ApplicationRef.tick()`.
|
||||||
|
* ngx-toastr v14 attaches each toast to ApplicationRef without rendering it; under this app's
|
||||||
|
* ZONELESS change detection there is no zone tick to render it, so without this no toast
|
||||||
|
* appears. `tick()` renders the just-attached overlay view.
|
||||||
|
*/
|
||||||
|
function zonelessToastr(
|
||||||
|
real: ToastrService,
|
||||||
|
appRef: ApplicationRef,
|
||||||
|
): ToastrService {
|
||||||
|
return new Proxy(real, {
|
||||||
|
get(target, prop, receiver) {
|
||||||
|
const value = Reflect.get(target, prop, receiver);
|
||||||
|
return typeof value === 'function'
|
||||||
|
? (...args: unknown[]) => {
|
||||||
|
const result = (value as (...a: unknown[]) => unknown).apply(target, args);
|
||||||
|
appRef.tick();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
: value;
|
||||||
|
},
|
||||||
|
}) as ToastrService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On every page load the HttpOnly `rag_session` cookie is validated with `GET /me`
|
* On every page load the HttpOnly `rag_session` cookie is validated with `GET /me`
|
||||||
* before the first route activates; a 401 drops the authenticated state so the
|
* before the first route activates; a 401 drops the authenticated state so the
|
||||||
@@ -23,18 +60,34 @@ export const appConfig: ApplicationConfig = {
|
|||||||
provideRouter(routes),
|
provideRouter(routes),
|
||||||
provideAnimations(),
|
provideAnimations(),
|
||||||
provideHttpClient(),
|
provideHttpClient(),
|
||||||
|
// Registers ngx-toastr's Toast component + TOAST_CONFIG.
|
||||||
|
importProvidersFrom(
|
||||||
|
ToastrModule.forRoot({
|
||||||
|
timeOut: 4000,
|
||||||
|
positionClass: 'toast-bottom-left',
|
||||||
|
preventDuplicates: true,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
// Override the library's root ToastrService with a zoneless-aware wrapper so toasts
|
||||||
|
// actually render (see zonelessToastr()).
|
||||||
|
provide: ToastrService,
|
||||||
|
useFactory: (
|
||||||
|
appRef: ApplicationRef,
|
||||||
|
injector: Injector,
|
||||||
|
config: ToastConfigToken,
|
||||||
|
overlay: Overlay,
|
||||||
|
sanitizer: DomSanitizer,
|
||||||
|
zone: NgZone,
|
||||||
|
) =>
|
||||||
|
zonelessToastr(new ToastrService(config, overlay, injector, sanitizer, zone), appRef),
|
||||||
|
deps: [ApplicationRef, Injector, TOAST_CONFIG, Overlay, DomSanitizer, NgZone],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
useFactory: initializeAuth,
|
useFactory: initializeAuth,
|
||||||
deps: [AuthService],
|
deps: [AuthService],
|
||||||
multi: true,
|
multi: true,
|
||||||
},
|
},
|
||||||
{
|
],
|
||||||
provide: TOAST_CONFIG,
|
|
||||||
useValue: {
|
|
||||||
default: DefaultGlobalConfig,
|
|
||||||
config: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -208,6 +208,10 @@
|
|||||||
background-color: color-mix(in srgb, var(--color-primary) 78%, #000);
|
background-color: color-mix(in srgb, var(--color-primary) 78%, #000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-remove-btn:hover{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fadeInDown {
|
@keyframes fadeInDown {
|
||||||
from { opacity: 0; transform: translateY(-10px); }
|
from { opacity: 0; transform: translateY(-10px); }
|
||||||
to { opacity: 1; transform: translateY(0); }
|
to { opacity: 1; transform: translateY(0); }
|
||||||
@@ -428,6 +432,50 @@
|
|||||||
}
|
}
|
||||||
.documents-table-wrapper {
|
.documents-table-wrapper {
|
||||||
border: 1px solid var(--color-card-border);
|
border: 1px solid var(--color-card-border);
|
||||||
|
/* Clip the table to the rounded corners on wide layouts. */
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* md and below (Tailwind md = 48rem/768px).
|
||||||
|
*
|
||||||
|
* Six fixed-percentage columns stop being readable well before 768px: the date wraps,
|
||||||
|
* and the status column's error text overflows its column and bleeds into the
|
||||||
|
* neighbouring cells — which is what makes the row contents look mixed.
|
||||||
|
*
|
||||||
|
* Switching to `table-layout: auto` lets each column size to its own content, so no
|
||||||
|
* cell can overflow into the next one. The table then grows past the card and the
|
||||||
|
* wrapper scrolls horizontally instead of squeezing the columns.
|
||||||
|
*/
|
||||||
|
@media (max-width: 767.98px) {
|
||||||
|
.documents-table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
/* Keep the scroll chain inside the card instead of leaking to the page. */
|
||||||
|
overscroll-behavior-x: contain;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.documents-table {
|
||||||
|
/* Auto layout ignores the <col> percentages, so columns follow their content. */
|
||||||
|
table-layout: auto;
|
||||||
|
min-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short cells stay on one line so each column keeps a clean width. */
|
||||||
|
.documents-table th,
|
||||||
|
.documents-table td {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Title and status hold long text; let them wrap instead of widening the table. */
|
||||||
|
.documents-table td:nth-child(1),
|
||||||
|
.documents-table td:nth-child(2) {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.documents-table td:nth-child(1) {
|
||||||
|
max-width: 220px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.documents-table {
|
.documents-table {
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
@@ -439,6 +487,8 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
border-bottom: 1px solid var(--color-card-border);
|
border-bottom: 1px solid var(--color-card-border);
|
||||||
|
/* Fixed layout fits the card; wrap long tokens so a cell never widens the table. */
|
||||||
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
.documents-table thead th {
|
.documents-table thead th {
|
||||||
background: var(--sidebar-hover);
|
background: var(--sidebar-hover);
|
||||||
@@ -562,6 +612,10 @@
|
|||||||
padding: 1rem 1.25rem;
|
padding: 1rem 1.25rem;
|
||||||
border-bottom: 1px solid var(--color-card-border);
|
border-bottom: 1px solid var(--color-card-border);
|
||||||
}
|
}
|
||||||
|
/* Narrower variant for confirmations (e.g. remove document). */
|
||||||
|
.review-modal--sm {
|
||||||
|
max-width: 30rem;
|
||||||
|
}
|
||||||
.review-modal-body {
|
.review-modal-body {
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|||||||
@@ -496,11 +496,18 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="documents-table-wrapper overflow-x-auto rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
|
<div class="documents-table-wrapper rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
|
||||||
<table class="documents-table min-w-full text-sm text-right">
|
<table class="documents-table w-full table-fixed text-sm text-right">
|
||||||
|
<colgroup>
|
||||||
|
<col class="w-[26%]" />
|
||||||
|
<col class="w-[18%]" />
|
||||||
|
<col class="w-[10%]" />
|
||||||
|
<col class="w-[16%]" />
|
||||||
|
<col class="w-[15%]" />
|
||||||
|
<col class="w-[15%]" />
|
||||||
|
</colgroup>
|
||||||
<thead class="bg-[var(--sidebar-hover)]">
|
<thead class="bg-[var(--sidebar-hover)]">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">نام فایل</th>
|
|
||||||
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">عنوان سند</th>
|
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">عنوان سند</th>
|
||||||
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">وضعیت پردازش</th>
|
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">وضعیت پردازش</th>
|
||||||
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">تعداد بخشها</th>
|
<th class="px-3 py-2 text-xs font-medium text-[var(--text-muted)]">تعداد بخشها</th>
|
||||||
@@ -513,11 +520,9 @@
|
|||||||
@for (doc of documents(); track doc.id) {
|
@for (doc of documents(); track doc.id) {
|
||||||
<tr class="table-row-animate">
|
<tr class="table-row-animate">
|
||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span class="text-sm text-[var(--text-secondary)] truncate block max-w-[14rem]"
|
<span class="text-sm text-[var(--text-secondary)] truncate block" title="{{ doc.title ?? '' }}">{{
|
||||||
>{{ doc.filename }}</span>
|
doc.title ?? '—'
|
||||||
</td>
|
}}</span>
|
||||||
<td class="px-3 py-2.5 align-top">
|
|
||||||
<span class="text-sm text-[var(--text-secondary)]">{{ doc.title ?? '—' }}</span>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span
|
<span
|
||||||
@@ -548,7 +553,7 @@
|
|||||||
<td class="px-3 py-2.5 align-top">
|
<td class="px-3 py-2.5 align-top">
|
||||||
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
|
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-3 py-2.5 align-top min-w-[11rem]">
|
<td class="px-3 py-2.5 align-top">
|
||||||
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
||||||
@if (togglingDocId() === doc.id) {
|
@if (togglingDocId() === doc.id) {
|
||||||
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
||||||
@@ -632,6 +637,30 @@
|
|||||||
<span>تلاشمجدد</span>
|
<span>تلاشمجدد</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="file-remove-btn p-2 text-[var(--text-muted)] rounded-lg transition-all duration-200 hover:text-red-400 hover:bg-red-400/10 hover:scale-110 shrink-0"
|
||||||
|
[attr.aria-label]="'حذف سند ' + (doc.title ?? doc.filename)"
|
||||||
|
title="حذف سند"
|
||||||
|
(click)="removeDocument(doc)"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-4 h-4"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<path d="M3 6h18" />
|
||||||
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
|
||||||
|
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
|
||||||
|
<line x1="10" y1="11" x2="10" y2="17" />
|
||||||
|
<line x1="14" y1="11" x2="14" y2="17" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -639,7 +668,7 @@
|
|||||||
@if (!documentsLoading()) {
|
@if (!documentsLoading()) {
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
colspan="7"
|
colspan="6"
|
||||||
class="px-3 py-10 text-center text-sm text-[var(--text-muted)]"
|
class="px-3 py-10 text-center text-sm text-[var(--text-muted)]"
|
||||||
>
|
>
|
||||||
هیچ سندی با فیلتر انتخابشده مطابقت ندارد.
|
هیچ سندی با فیلتر انتخابشده مطابقت ندارد.
|
||||||
@@ -884,6 +913,57 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<!-- Remove-document confirmation -->
|
||||||
|
@if (deletingDoc(); as doc) {
|
||||||
|
<div class="review-backdrop" (click)="cancelDelete()">
|
||||||
|
<div
|
||||||
|
class="review-modal review-modal--sm"
|
||||||
|
(click)="onReviewModalClick($event)"
|
||||||
|
role="alertdialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="حذف سند"
|
||||||
|
>
|
||||||
|
<header class="review-modal-header">
|
||||||
|
<h3 class="text-lg font-semibold text-[var(--text-primary)]">حذف سند</h3>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="file-remove-btn p-1 text-[var(--text-muted)]"
|
||||||
|
(click)="cancelDelete()"
|
||||||
|
aria-label="بستن"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-4 h-4"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<line x1="18" y1="6" x2="6" y2="18" />
|
||||||
|
<line x1="6" y1="6" x2="18" y2="18" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
<div class="review-modal-body">
|
||||||
|
<p class="text-sm text-[var(--text-secondary)]">
|
||||||
|
آیا از حذف سند «{{ doc.title ?? doc.filename }}» مطمئن هستید؟ این عملیات قابل بازگشت نیست.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<footer
|
||||||
|
class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2"
|
||||||
|
>
|
||||||
|
<button type="button" class="btn btn--outline" (click)="cancelDelete()">
|
||||||
|
<span>انصراف</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn--primary" (click)="confirmDeleteDocument()">
|
||||||
|
<span>حذف سند</span>
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -946,6 +1026,25 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
|
||||||
|
>
|
||||||
|
<div class="setting-info flex flex-col gap-1 min-w-0">
|
||||||
|
<label class="text-sm font-medium text-[var(--text-secondary)] cursor-pointer">
|
||||||
|
نیاز به تأیید ادمین برای اسناد FAQ
|
||||||
|
</label>
|
||||||
|
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
|
||||||
|
در صورت فعال بودن، محتوای استخراجشده از اسناد FAQ باید توسط ادمین بازبینی و تأیید شود.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="setting-control shrink-0">
|
||||||
|
<label class="toggle-switch" [class.toggle-active]="faqAdminApproval()">
|
||||||
|
<input type="checkbox" [checked]="faqAdminApproval()" (change)="toggleFaqApproval()" />
|
||||||
|
<span class="toggle-slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -30,12 +30,18 @@ function readyDoc(): DocumentListItem {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toastr = { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() };
|
||||||
|
|
||||||
const filterSelect = (el: HTMLElement): HTMLSelectElement | null => el.querySelector('.documents-filters select');
|
const filterSelect = (el: HTMLElement): HTMLSelectElement | null => el.querySelector('.documents-filters select');
|
||||||
|
|
||||||
describe('SettingsPage — document filters', () => {
|
describe('SettingsPage — document filters', () => {
|
||||||
let getDocuments: ReturnType<typeof vi.fn>;
|
let getDocuments: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
toastr.success.mockClear();
|
||||||
|
toastr.error.mockClear();
|
||||||
|
toastr.warning.mockClear();
|
||||||
|
toastr.info.mockClear();
|
||||||
// Server-side filtering: `all` returns one ready doc; every other status matches none.
|
// Server-side filtering: `all` returns one ready doc; every other status matches none.
|
||||||
getDocuments = vi.fn((params: { status?: string } = {}): Observable<DocumentListResponse> => {
|
getDocuments = vi.fn((params: { status?: string } = {}): Observable<DocumentListResponse> => {
|
||||||
const items = params.status ? [] : [readyDoc()];
|
const items = params.status ? [] : [readyDoc()];
|
||||||
@@ -59,7 +65,7 @@ describe('SettingsPage — document filters', () => {
|
|||||||
{ provide: AuthService, useValue: { getCurrentUserValue: () => ({ role: 'admin' }) } },
|
{ provide: AuthService, useValue: { getCurrentUserValue: () => ({ role: 'admin' }) } },
|
||||||
{ provide: HttpService, useValue: { apiUrl: '/api/v1' } },
|
{ provide: HttpService, useValue: { apiUrl: '/api/v1' } },
|
||||||
{ provide: ThemeService, useValue: { isDarkMode: () => false, toggleDarkMode: () => {} } },
|
{ provide: ThemeService, useValue: { isDarkMode: () => false, toggleDarkMode: () => {} } },
|
||||||
{ provide: ToastrService, useValue: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() } },
|
{ provide: ToastrService, useValue: toastr },
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
@@ -108,7 +114,91 @@ describe('SettingsPage — document filters', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const rows = (fixture.nativeElement as HTMLElement).querySelectorAll('.documents-table tbody tr');
|
const rows = (fixture.nativeElement as HTMLElement).querySelectorAll('.documents-table tbody tr');
|
||||||
expect(rows.length).toBe(1);
|
expect(rows.length).toBe(1);
|
||||||
expect(rows[0].textContent).toContain('guide.pdf');
|
// نام فایل column was dropped (redundant with عنوان سند); the row shows the title.
|
||||||
|
expect(rows[0].textContent).toContain('سند آزمون');
|
||||||
|
expect(rows[0].textContent).not.toContain('guide.pdf');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('drops the redundant نام فایل column and renders exactly 6 columns', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const headers = Array.from(el.querySelectorAll('.documents-table thead th')).map((t) =>
|
||||||
|
t.textContent?.trim(),
|
||||||
|
);
|
||||||
|
expect(headers).toEqual([
|
||||||
|
'عنوان سند',
|
||||||
|
'وضعیت پردازش',
|
||||||
|
'تعداد بخشها',
|
||||||
|
'تاریخ آپلود',
|
||||||
|
'فعالسازی',
|
||||||
|
'عملیات',
|
||||||
|
]);
|
||||||
|
expect(headers).not.toContain('نام فایل');
|
||||||
|
// A data row has exactly 6 cells matching the 6 columns.
|
||||||
|
expect(el.querySelector('.documents-table tbody tr')?.children.length).toBe(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('confirms before removing: the bin button opens a modal, cancel keeps the doc, confirm shows the MVP notice', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const openRemoveModal = () => {
|
||||||
|
const row = el.querySelector('.documents-table tbody tr') as HTMLElement;
|
||||||
|
const remove = Array.from(row.querySelectorAll('button')).find((b) =>
|
||||||
|
(b.getAttribute('aria-label') ?? '').includes('حذف سند'),
|
||||||
|
) as HTMLButtonElement;
|
||||||
|
remove.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
};
|
||||||
|
|
||||||
|
openRemoveModal();
|
||||||
|
const modal = el.querySelector('[role="alertdialog"]') as HTMLElement;
|
||||||
|
expect(modal).toBeTruthy();
|
||||||
|
expect(modal.textContent).toContain('سند آزمون');
|
||||||
|
expect(modal.textContent).toContain('مطمئن هستید');
|
||||||
|
expect(toastr.info).not.toHaveBeenCalled(); // nothing happens until confirmed
|
||||||
|
|
||||||
|
// Cancel closes the modal and keeps the document, with no notice.
|
||||||
|
(modal.querySelector('.btn--outline') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(el.querySelector('[role="alertdialog"]')).toBeNull();
|
||||||
|
expect(el.querySelectorAll('.documents-table tbody tr').length).toBe(1);
|
||||||
|
expect(toastr.info).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Confirm closes the modal and surfaces the MVP notice (deletion is not yet implemented);
|
||||||
|
// the row is left in place and no backend delete call is made.
|
||||||
|
openRemoveModal();
|
||||||
|
(el.querySelector('[role="alertdialog"] .btn--primary') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(toastr.info).toHaveBeenCalledTimes(1);
|
||||||
|
expect(el.querySelector('[role="alertdialog"]')).toBeNull();
|
||||||
|
expect(el.querySelectorAll('.documents-table tbody tr').length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders OCR and FAQ admin-approval toggles in the app settings and toggles FAQ', () => {
|
||||||
|
const fixture = TestBed.createComponent(SettingsPage);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const component = fixture.componentInstance;
|
||||||
|
component.selectTab('app');
|
||||||
|
fixture.detectChanges();
|
||||||
|
const el = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
const labels = Array.from(el.querySelectorAll('.setting-info label')).map((l) =>
|
||||||
|
l.textContent?.trim(),
|
||||||
|
);
|
||||||
|
expect(labels).toContain('نیاز به تأیید ادمین برای اسناد OCR شده');
|
||||||
|
expect(labels).toContain('نیاز به تأیید ادمین برای اسناد FAQ');
|
||||||
|
|
||||||
|
// Toggles in order: dark mode, OCR, FAQ. The FAQ toggle flips its own signal.
|
||||||
|
const switches = el.querySelectorAll('.setting-control .toggle-switch');
|
||||||
|
expect(switches.length).toBe(3);
|
||||||
|
expect(component.faqAdminApproval()).toBe(false);
|
||||||
|
(switches[2].querySelector('input') as HTMLInputElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.faqAdminApproval()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hasActiveFilters reflects the active status/active-only filters', () => {
|
it('hasActiveFilters reflects the active status/active-only filters', () => {
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
// ---- knowledge selection (K01/K02) ----
|
// ---- knowledge selection (K01/K02) ----
|
||||||
readonly knowledgeSelection = signal<KnowledgeSelection | null>(null);
|
readonly knowledgeSelection = signal<KnowledgeSelection | null>(null);
|
||||||
readonly togglingDocId = signal<string | null>(null);
|
readonly togglingDocId = signal<string | null>(null);
|
||||||
|
/** Document awaiting remove confirmation (non-null while the confirm modal is open). */
|
||||||
|
readonly deletingDoc = signal<DocumentListItem | null>(null);
|
||||||
|
|
||||||
// ---- extraction review modal (D06/D07) ----
|
// ---- extraction review modal (D06/D07) ----
|
||||||
readonly reviewingDocId = signal<string | null>(null);
|
readonly reviewingDocId = signal<string | null>(null);
|
||||||
@@ -256,6 +258,7 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
readonly notificationsEnabled = signal(true);
|
readonly notificationsEnabled = signal(true);
|
||||||
readonly isDarkMode = this.themeService.isDarkMode;
|
readonly isDarkMode = this.themeService.isDarkMode;
|
||||||
readonly ocrAdminApproval = signal(false);
|
readonly ocrAdminApproval = signal(false);
|
||||||
|
readonly faqAdminApproval = signal(false);
|
||||||
|
|
||||||
readonly textModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.text);
|
readonly textModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.text);
|
||||||
readonly embeddingModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.embedding);
|
readonly embeddingModelConfig = signal<AiModelConfig>(DEFAULT_MODEL_CONFIG.embedding);
|
||||||
@@ -1187,6 +1190,32 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the remove confirmation for a document. Deletion itself is a destructive,
|
||||||
|
* epoch-changing action the backend MVP does not expose, so it is confirmed here before the
|
||||||
|
* (still stubbed) removal runs in `confirmDeleteDocument()`.
|
||||||
|
*/
|
||||||
|
removeDocument(doc: DocumentListItem): void {
|
||||||
|
this.deletingDoc.set(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dismiss the remove confirmation without deleting. */
|
||||||
|
cancelDelete(): void {
|
||||||
|
this.deletingDoc.set(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirmed removal. The backend MVP has no document-deletion endpoint (removing an active
|
||||||
|
* document also revokes its excerpts and can invalidate live voice sessions), so — like the
|
||||||
|
* other not-yet-implemented actions — this closes the dialog and surfaces an informative
|
||||||
|
* notice instead of calling an unsupported route. No data is deleted and no call is made.
|
||||||
|
*/
|
||||||
|
confirmDeleteDocument(): void {
|
||||||
|
const doc = this.deletingDoc();
|
||||||
|
this.deletingDoc.set(null);
|
||||||
|
if (doc) this.toastr.info(`حذف سند «${doc.title ?? doc.filename}» در فاز MVP پشتیبانی نمیشود.`);
|
||||||
|
}
|
||||||
|
|
||||||
/** Server-provided preview URL (authenticated via the session cookie); null = no preview. */
|
/** Server-provided preview URL (authenticated via the session cookie); null = no preview. */
|
||||||
previewImageUrl(item: ExtractionItem): string | null {
|
previewImageUrl(item: ExtractionItem): string | null {
|
||||||
const path = item.preview_path;
|
const path = item.preview_path;
|
||||||
@@ -1227,6 +1256,11 @@ export class SettingsPage implements OnInit, OnDestroy {
|
|||||||
this.toastr.info('ذخیرهسازی سیاست بازبینی OCR در فاز MVP پشتیبانی نمیشود.');
|
this.toastr.info('ذخیرهسازی سیاست بازبینی OCR در فاز MVP پشتیبانی نمیشود.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleFaqApproval(): void {
|
||||||
|
this.faqAdminApproval.set(!this.faqAdminApproval());
|
||||||
|
this.toastr.info('ذخیرهسازی سیاست بازبینی FAQ در فاز MVP پشتیبانی نمیشود.');
|
||||||
|
}
|
||||||
|
|
||||||
toggleDarkMode(): void {
|
toggleDarkMode(): void {
|
||||||
this.themeService.toggleDarkMode();
|
this.themeService.toggleDarkMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
import { Injectable, inject } from '@angular/core';
|
||||||
|
|
||||||
|
export type VoiceCueKind = 'ready' | 'end';
|
||||||
|
|
||||||
|
const CUE_ASSETS: Record<VoiceCueKind, string> = {
|
||||||
|
ready: 'assets/audio/voice-ready.wav',
|
||||||
|
end: 'assets/audio/voice-end.wav',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the short reference cues extracted from the supplied recording.
|
||||||
|
*
|
||||||
|
* Unlike the previous synthesized version, this service plays the original
|
||||||
|
* recorded waveform. Do not add a convolver/reverb to it: the reference cue
|
||||||
|
* already contains its original tone and tail.
|
||||||
|
*/
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class VoiceCueService {
|
||||||
|
private readonly document = inject(DOCUMENT);
|
||||||
|
|
||||||
|
private ctx: AudioContext | null = null;
|
||||||
|
private readonly buffers = new Map<VoiceCueKind, AudioBuffer>();
|
||||||
|
private readonly pending = new Map<VoiceCueKind, Promise<AudioBuffer | null>>();
|
||||||
|
|
||||||
|
private enabled = true;
|
||||||
|
|
||||||
|
/** Disable or enable subsequent cues. */
|
||||||
|
setEnabled(on: boolean): void {
|
||||||
|
this.enabled = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional warm-up. Call once when the voice UI/component initializes,
|
||||||
|
* so fetching and decoding do not delay the first cue.
|
||||||
|
*/
|
||||||
|
async preload(): Promise<void> {
|
||||||
|
if (typeof AudioContext === 'undefined' || typeof fetch === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = this.ensureContext();
|
||||||
|
await Promise.all([this.loadBuffer('ready', ctx), this.loadBuffer('end', ctx)]);
|
||||||
|
} catch {
|
||||||
|
// Preloading is best-effort; audio must never block the voice UI.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Play the recorded cue when the voice session is ready. */
|
||||||
|
playReady(): void {
|
||||||
|
void this.play('ready');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Play the recorded cue when the voice session ends. */
|
||||||
|
playEnd(): void {
|
||||||
|
void this.play('end');
|
||||||
|
}
|
||||||
|
|
||||||
|
private async play(kind: VoiceCueKind): Promise<void> {
|
||||||
|
if (!this.enabled || typeof AudioContext === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = this.ensureContext();
|
||||||
|
|
||||||
|
// Request resume immediately, before awaiting fetch/decode, to preserve
|
||||||
|
// browser user activation when the call originates from a user gesture.
|
||||||
|
const resumePromise =
|
||||||
|
ctx.state === 'suspended' ? ctx.resume().catch(() => undefined) : Promise.resolve();
|
||||||
|
|
||||||
|
const bufferPromise = this.loadBuffer(kind, ctx);
|
||||||
|
const [buffer] = await Promise.all([bufferPromise, resumePromise]);
|
||||||
|
|
||||||
|
if (!buffer || ctx.state !== 'running') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const source = ctx.createBufferSource();
|
||||||
|
const output = ctx.createGain();
|
||||||
|
|
||||||
|
source.buffer = buffer;
|
||||||
|
output.gain.setValueAtTime(1, ctx.currentTime);
|
||||||
|
|
||||||
|
source.connect(output);
|
||||||
|
output.connect(ctx.destination);
|
||||||
|
|
||||||
|
source.onended = () => {
|
||||||
|
source.disconnect();
|
||||||
|
output.disconnect();
|
||||||
|
};
|
||||||
|
|
||||||
|
// A tiny scheduling lead avoids starting mid-render quantum.
|
||||||
|
source.start(ctx.currentTime + 0.01);
|
||||||
|
} catch {
|
||||||
|
// A cue is optional; never let audio playback break session handling.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ensureContext(): AudioContext {
|
||||||
|
if (!this.ctx || this.ctx.state === 'closed') {
|
||||||
|
this.ctx = new AudioContext({ latencyHint: 'interactive' });
|
||||||
|
|
||||||
|
// AudioBuffers are decoded against a particular context. Rebuild them
|
||||||
|
// when that context is recreated.
|
||||||
|
this.buffers.clear();
|
||||||
|
this.pending.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadBuffer(kind: VoiceCueKind, ctx: AudioContext): Promise<AudioBuffer | null> {
|
||||||
|
const cached = this.buffers.get(kind);
|
||||||
|
if (cached) {
|
||||||
|
return Promise.resolve(cached);
|
||||||
|
}
|
||||||
|
|
||||||
|
const inFlight = this.pending.get(kind);
|
||||||
|
if (inFlight) {
|
||||||
|
return inFlight;
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetUrl = new URL(CUE_ASSETS[kind], this.document.baseURI).href;
|
||||||
|
|
||||||
|
const promise = fetch(assetUrl, { cache: 'force-cache' })
|
||||||
|
.then((response) => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Unable to load voice cue: ${response.status}`);
|
||||||
|
}
|
||||||
|
return response.arrayBuffer();
|
||||||
|
})
|
||||||
|
.then((bytes) => ctx.decodeAudioData(bytes))
|
||||||
|
.then((buffer) => {
|
||||||
|
if (this.ctx === ctx) {
|
||||||
|
this.buffers.set(kind, buffer);
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// Let a later call retry if the asset was temporarily unavailable.
|
||||||
|
if (this.ctx === ctx) {
|
||||||
|
this.pending.delete(kind);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pending.set(kind, promise);
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
VoiceSessionEnd,
|
VoiceSessionEnd,
|
||||||
VoiceStreamState,
|
VoiceStreamState,
|
||||||
} from './voice-stream.types';
|
} from './voice-stream.types';
|
||||||
|
import { VoiceCueService } from './voice-cue.service';
|
||||||
|
|
||||||
export type VoiceStartFailure =
|
export type VoiceStartFailure =
|
||||||
| 'cancelled'
|
| 'cancelled'
|
||||||
@@ -115,6 +116,7 @@ export class VoiceStreamService {
|
|||||||
private readonly api = inject(VoiceApiService);
|
private readonly api = inject(VoiceApiService);
|
||||||
private readonly config = inject(VOICE_STREAM_CONFIG);
|
private readonly config = inject(VOICE_STREAM_CONFIG);
|
||||||
private readonly createTransport = inject(VOICE_TRANSPORT_FACTORY);
|
private readonly createTransport = inject(VOICE_TRANSPORT_FACTORY);
|
||||||
|
private readonly cues = inject(VoiceCueService);
|
||||||
|
|
||||||
readonly state = signal<VoiceStreamState>('IDLE');
|
readonly state = signal<VoiceStreamState>('IDLE');
|
||||||
readonly connection = signal<VoiceConnection>('disconnected');
|
readonly connection = signal<VoiceConnection>('disconnected');
|
||||||
@@ -289,6 +291,8 @@ export class VoiceStreamService {
|
|||||||
this.connection.set('connected');
|
this.connection.set('connected');
|
||||||
this.state.set('LISTENING');
|
this.state.set('LISTENING');
|
||||||
this.streaming = true;
|
this.streaming = true;
|
||||||
|
// "You can speak now" — once per session, not per turn (a turn cue would be noise).
|
||||||
|
this.cues.playReady();
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,6 +809,13 @@ export class VoiceStreamService {
|
|||||||
// Stop admitting new media BEFORE any await.
|
// Stop admitting new media BEFORE any await.
|
||||||
this.streaming = false;
|
this.streaming = false;
|
||||||
|
|
||||||
|
// "Call finished" — once per connected session, before local resources (including the
|
||||||
|
// engine AudioContext) are released; every end path funnels through this single-flight
|
||||||
|
// cleanup, so ordered and unordered teardown both trigger it exactly once.
|
||||||
|
if (wasConnected) {
|
||||||
|
this.cues.playEnd();
|
||||||
|
}
|
||||||
|
|
||||||
const release = (): void => {
|
const release = (): void => {
|
||||||
// A newer session may have taken over during an await: never touch its resources.
|
// A newer session may have taken over during an await: never touch its resources.
|
||||||
if (superseded()) return;
|
if (superseded()) return;
|
||||||
|
|||||||
@@ -7,11 +7,14 @@
|
|||||||
background: var(--sidebar-bg);
|
background: var(--sidebar-bg);
|
||||||
color: var(--sidebar-text);
|
color: var(--sidebar-text);
|
||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
transition: width 0.3s ease;
|
/* The width transition drives the whole expansion; text reveal is gated by the
|
||||||
|
matching delay below so labels never reflow mid-flight. */
|
||||||
|
transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
z-index: 40;
|
z-index: 40;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-left: 1px solid var(--sidebar-border);
|
border-left: 1px solid var(--sidebar-border);
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar.open {
|
.sidebar.open {
|
||||||
@@ -30,6 +33,52 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sidebar width animation: 0.35s. Text must not appear until the sidebar is wide
|
||||||
|
enough to hold the label on one line, so every label fades in only AFTER the
|
||||||
|
width transition finishes (delay = full duration) and fades out immediately
|
||||||
|
when collapsing. This prevents Persian text from wrapping vertically. */
|
||||||
|
:root {
|
||||||
|
--sidebar-expand-duration: 0.35s;
|
||||||
|
--sidebar-collapse-duration: 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scoped to `.sidebar`: the account menu is a CDK overlay rendered outside the sidebar
|
||||||
|
DOM, so unscoping these selectors would hide the username inside the dropdown too. */
|
||||||
|
.sidebar .nav-label,
|
||||||
|
.sidebar .history-text,
|
||||||
|
.sidebar .history-header .history-title,
|
||||||
|
.sidebar .user-info,
|
||||||
|
.sidebar .theme-toggle span {
|
||||||
|
max-width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
transform: translateX(-8px);
|
||||||
|
/* Fast fade OUT when collapsing — no delay on the way in. */
|
||||||
|
transition:
|
||||||
|
max-width var(--sidebar-collapse-duration) ease-in,
|
||||||
|
opacity var(--sidebar-collapse-duration) ease-in,
|
||||||
|
transform var(--sidebar-collapse-duration) ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expanded state: the sidebar has finished growing, so the label can fade in.
|
||||||
|
`max-width: 100%` lets it occupy only the remaining space next to the icon
|
||||||
|
(never forcing a second line), and the delay guarantees the width is already
|
||||||
|
sufficient before the text becomes visible. */
|
||||||
|
.sidebar.open .nav-label,
|
||||||
|
.sidebar.open .history-text,
|
||||||
|
.sidebar.open .history-header .history-title,
|
||||||
|
.sidebar.open .user-info,
|
||||||
|
.sidebar.open .theme-toggle span {
|
||||||
|
max-width: 100%;
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
transition:
|
||||||
|
max-width var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
|
||||||
|
opacity var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
|
||||||
|
transform var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration);
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-top {
|
.sidebar-top {
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -67,16 +116,19 @@
|
|||||||
|
|
||||||
.sidebar:not(.open) .sidebar-logo-link {
|
.sidebar:not(.open) .sidebar-logo-link {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .sidebar-logo {
|
.sidebar:not(.open) .sidebar-logo {
|
||||||
height: 36px;
|
height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep the logo in the same 40px column as the nav items. */
|
||||||
.sidebar:not(.open) .sidebar-header {
|
.sidebar:not(.open) .sidebar-header {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.5rem 0.25rem;
|
padding: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .close-btn {
|
.sidebar:not(.open) .close-btn {
|
||||||
@@ -181,6 +233,8 @@
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
/* Keep the icon and label on one line regardless of sidebar width. */
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-item:hover {
|
.nav-item:hover {
|
||||||
@@ -193,17 +247,28 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Collapsed rail (72px): a fixed 40px item column centred in the rail, so every icon
|
||||||
|
lines up with the others and with the logo/avatar above it. */
|
||||||
|
.sidebar:not(.open) .sidebar-top {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .nav-item {
|
.sidebar:not(.open) .nav-item {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.75rem 0;
|
gap: 0;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .nav-item svg {
|
.sidebar:not(.open) .nav-item .nav-icon {
|
||||||
margin: 0;
|
flex-shrink: 0;
|
||||||
}
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
.sidebar:not(.open) .nav-label {
|
justify-content: center;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-divider {
|
.sidebar-divider {
|
||||||
@@ -213,7 +278,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .sidebar-divider {
|
.sidebar:not(.open) .sidebar-divider {
|
||||||
margin: 0 0.5rem;
|
/* Same 40px column inset (16px each side of the 72px rail). */
|
||||||
|
margin: 0 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-bottom {
|
.sidebar-bottom {
|
||||||
@@ -229,15 +295,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-header {
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--sidebar-muted);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar:not(.open) .history-header {
|
.sidebar:not(.open) .history-header {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -277,6 +334,23 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The whole lower section collapses with the sidebar; its labels animate via
|
||||||
|
the shared width/opacity transition defined earlier. */
|
||||||
|
.sidebar:not(.open) .history-header {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-header {
|
||||||
|
display: flex;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--sidebar-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.history-icon {
|
.history-icon {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
@@ -286,10 +360,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
min-width: 0;
|
||||||
|
|
||||||
.sidebar:not(.open) .history-text {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-empty {
|
.history-empty {
|
||||||
@@ -304,10 +375,6 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .history-empty {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.history-empty-icon {
|
.history-empty-icon {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
@@ -324,25 +391,20 @@
|
|||||||
|
|
||||||
.sidebar:not(.open) .sidebar-footer {
|
.sidebar:not(.open) .sidebar-footer {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5rem;
|
padding: 0.75rem 1rem;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .user-info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar:not(.open) .user-profile {
|
.sidebar:not(.open) .user-profile {
|
||||||
width: 56px;
|
width: 40px;
|
||||||
height: 56px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
gap: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle span {
|
/* Theme-toggle label animates with the shared transition instead of display:none. */
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-profile {
|
.user-profile {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -356,6 +418,7 @@
|
|||||||
color: var(--sidebar-text);
|
color: var(--sidebar-text);
|
||||||
text-align: start;
|
text-align: start;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-profile:hover,
|
.user-profile:hover,
|
||||||
@@ -383,10 +446,16 @@
|
|||||||
.account-menu-header {
|
.account-menu-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
/* dir="rtl" on .account-menu already lays children right→left, so the default
|
||||||
|
`row` order puts the avatar on the right and the name beside it to the left. */
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-menu-header .user-info {
|
||||||
|
text-align: start;
|
||||||
|
}
|
||||||
|
|
||||||
.account-menu-divider {
|
.account-menu-divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 0.375rem 0.5rem;
|
margin: 0.375rem 0.5rem;
|
||||||
@@ -396,6 +465,7 @@
|
|||||||
.account-menu-item {
|
.account-menu-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
/* justify-content: space-between; */
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.625rem 0.75rem;
|
padding: 0.625rem 0.75rem;
|
||||||
@@ -436,6 +506,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-name {
|
.user-name {
|
||||||
@@ -479,9 +550,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .claim-btn span {
|
/* Label collapse is handled by the shared width/opacity transition. */
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -504,17 +573,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle {
|
.sidebar:not(.open) .theme-toggle {
|
||||||
width: 56px;
|
width: 40px;
|
||||||
height: 56px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
gap: 0;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle svg {
|
.sidebar:not(.open) .theme-toggle svg {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle span {
|
/* Collapsed rail: the avatar text must not stretch the 40px column. */
|
||||||
display: none;
|
.sidebar:not(.open) .user-avatar {
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
|
class="nav-icon"
|
||||||
>
|
>
|
||||||
<path [attr.d]="item.icon" />
|
<path [attr.d]="item.icon" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -116,13 +117,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<ng-template #accountMenu>
|
<ng-template #accountMenu>
|
||||||
<div class="account-menu" cdkMenu aria-label="Account menu" dir="ltr">
|
<div class="account-menu" cdkMenu aria-label="Account menu" dir="rtl">
|
||||||
<div class="account-menu-header">
|
<div class="account-menu-header">
|
||||||
<div class="user-avatar">{{ userInitials() }}</div>
|
<div class="user-avatar">{{ userInitials() }}</div>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span class="user-name">{{ userName() }}</span>
|
<span class="user-name">{{ userName() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
<div class="account-menu-divider" role="separator"></div>
|
<div class="account-menu-divider" role="separator"></div>
|
||||||
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="profileClick.emit()">
|
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="profileClick.emit()">
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
@@ -132,12 +134,13 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Profile</span>
|
<span>Profile</span>
|
||||||
</button>
|
</button>
|
||||||
|
-->
|
||||||
<div class="account-menu-divider" role="separator"></div>
|
<div class="account-menu-divider" role="separator"></div>
|
||||||
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="logoutClick.emit()">
|
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="logoutClick.emit()">
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
|
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>Log out</span>
|
<span>خروج</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export class SidebarComponent {
|
|||||||
readonly close = output<void>();
|
readonly close = output<void>();
|
||||||
readonly navClick = output<void>();
|
readonly navClick = output<void>();
|
||||||
readonly open = output<void>();
|
readonly open = output<void>();
|
||||||
readonly profileClick = output<void>();
|
// Profile page is disabled; the account-menu entry is commented out in the template.
|
||||||
|
// readonly profileClick = output<void>();
|
||||||
readonly logoutClick = output<void>();
|
readonly logoutClick = output<void>();
|
||||||
|
|
||||||
readonly userInitials = computed(() => {
|
readonly userInitials = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user