build(ui): expand application shell and implement administrative dashboard pages

This commit significantly expands the application's routing, navigation, and administrative capabilities. It introduces several new functional modules and refines the core layout for a more professional, dashboard-oriented experience.

- **Routing & Navigation**:
  - Added routes for `wallboard`, `call-center`, `call-center/calls`, and `chat-questions`.
  - Updated `SidebarComponent` to include all new navigation items.
  - Enhanced `LayoutComponent` with dynamic navigation based on user roles (admin vs. user).
- **New Administrative Pages**:
  - `WallboardPage`: Implements a real-time KPI dashboard with call activity trends and outcome distributions.
  - `CallCenterPage`: Provides a symbolic interface for managing call center connectivity and synchronization.
  - `CallCenterCallsPage`: Implements a call history retrieval interface with filtering capabilities.
  - `ChatQuestionsPage`: Adds a module for reviewing user questions from web and mobile channels.
- **Core Infrastructure & Refinement**:
  - Updated `AppConfig` to include an `APP_INITIALIZER` for validating user identity via `AuthService` on startup.
  - Refined `HomeComponent` layout to a "Claude-style" continuous chat column.
  - Implemented global themed scrollbars and integrated the 'Lahze' font family.
  - Added `proxy.conf.json` and updated `angular.json` to support local backend development.
- **Documentation**:
  - Added comprehensive API handoff guides for frontend-backend connection and MVP API catalog.
This commit is contained in:
Peyman Honarjoo
2026-10-10 00:20:00 +03:30
parent 0b5a882ecb
commit ff7fcbc4bb
71 changed files with 9148 additions and 780 deletions
@@ -0,0 +1,25 @@
/* Page-specific styles for «بازخوانی تماس‌ها از کال سنتر» (shared chrome: shared/styles/demo-page.css) */
.demo-filters {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
gap: 1rem 1.25rem;
align-items: end;
}
@media (max-width: 1024px) {
.demo-filters {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.demo-filters .demo-btn {
grid-column: 1 / -1;
justify-self: start;
}
}
@media (max-width: 640px) {
.demo-filters {
grid-template-columns: minmax(0, 1fr);
}
}
@@ -0,0 +1,148 @@
<div class="demo-page">
<header class="demo-header">
<div class="demo-title-group">
<span class="demo-title-icon">
<svg
width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" />
</svg>
</span>
<div>
<h1 class="demo-title">بازخوانی تماس‌ها از کال سنتر</h1>
<p class="demo-subtitle">دریافت و بازخوانی سابقه تماس‌ها از سامانه کال سنتر</p>
</div>
</div>
<span class="demo-chip">نمایشی</span>
</header>
<section class="demo-card demo-notice">
<span class="demo-notice-icon">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</svg>
</span>
<div>
<h2>این بخش هنوز فعال نیست</h2>
<p>
این صفحه مکانیزم بازخوانی سابقه تماس‌ها از کال سنتر را نمایش می‌دهد. رکوردهای زیر داده نمونه
هستند و از سرور واقعی دریافت نشده‌اند؛ پس از اتصال به کال سنتر، بازخوانی بر اساس بازه تاریخ و
وضعیت تماس انجام می‌شود.
</p>
</div>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">فیلتر بازخوانی</h2>
<p class="demo-card-description">
بازه تاریخ و وضعیت مورد نظر را انتخاب کنید تا گزارش تماس‌ها دریافت شود.
</p>
</div>
</div>
<div class="demo-filters">
@for (filter of filters; track filter.label) {
<label class="demo-field">
<span class="demo-field-label">{{ filter.label }}</span>
@if (filter.type === 'select') {
<select class="demo-field-input" disabled>
@for (option of filter.options ?? []; track option) {
<option [value]="option">{{ option }}</option>
}
</select>
} @else {
<input class="demo-field-input" type="text" [value]="filter.value" readonly />
}
<span class="demo-field-hint">{{ filter.hint }}</span>
</label>
}
<button type="button" class="demo-btn demo-btn--primary" disabled>بازخوانی تماس‌ها</button>
</div>
<div class="demo-actions">
<span class="demo-hint">
این کنترل‌ها در فاز جاری فعال نیستند و هیچ درخواستی به کال سنتر ارسال نمی‌شود.
</span>
</div>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">سابقه تماس‌ها</h2>
<p class="demo-card-description">
نمونه‌ای از رکوردهایی که پس از اتصال، از کال سنتر بازخوانی می‌شود.
</p>
</div>
<span class="demo-badge">داده نمونه</span>
</div>
<div class="demo-table-wrapper">
<table class="demo-table">
<thead>
<tr>
<th>شماره تماس</th>
<th>مدت تماس</th>
<th>وضعیت</th>
<th>تاریخ</th>
</tr>
</thead>
<tbody>
@for (call of exampleCalls; track call.phone) {
<tr>
<td>{{ call.phone }}</td>
<td>{{ call.duration }}</td>
<td>
<span class="demo-tag demo-tag--{{ call.statusKind }}">{{ call.status }}</span>
</td>
<td>{{ call.date }}</td>
</tr>
}
</tbody>
</table>
</div>
</section>
<section class="demo-card">
<div class="demo-empty">
<svg
width="40"
height="40"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 3v18h18" />
<path d="M7 15l4-6 4 4 4-7" />
</svg>
<h3>هنوز گزارشی بازخوانی نشده است</h3>
<p>
پس از اتصال به سامانه کال سنتر، گزارش‌های تماس بر اساس بازه زمانی انتخاب‌شده در این صفحه
نمایش داده می‌شود.
</p>
</div>
</section>
</div>
@@ -0,0 +1,46 @@
import { TestBed } from '@angular/core/testing';
import { provideZonelessChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient } from '@angular/common/http';
import { provideRouter } from '@angular/router';
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
import { CallCenterCallsPage } from './call-center-calls.page';
describe('CallCenterCallsPage', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CallCenterCallsPage],
providers: [
provideZonelessChangeDetection(),
provideHttpClient(),
provideRouter([]),
provideAnimations(),
{ provide: TOAST_CONFIG, useValue: { default: DefaultGlobalConfig, config: {} } },
],
}).compileComponents();
});
it('should create the page', () => {
const fixture = TestBed.createComponent(CallCenterCallsPage);
expect(fixture.componentInstance).toBeTruthy();
});
it('renders example call rows and disabled symbolic controls', () => {
const fixture = TestBed.createComponent(CallCenterCallsPage);
fixture.detectChanges();
const element: HTMLElement = fixture.nativeElement;
expect(element.querySelector('.demo-title')?.textContent?.trim()).toBe('بازخوانی تماس‌ها از کال سنتر');
expect(element.textContent).toContain('این بخش هنوز فعال نیست');
expect(element.textContent).toContain('داده نمونه');
const rows = element.querySelectorAll('.demo-table tbody tr');
expect(rows.length).toBe(4);
expect(element.textContent).toContain('۰۹۱۲۱۲۳۴۵۶۷');
expect(element.textContent).toContain('پاسخ‌داده شده');
const buttons = Array.from(element.querySelectorAll('button')) as HTMLButtonElement[];
buttons.forEach((button) => expect(button.disabled).toBe(true));
expect(element.querySelector('select')?.disabled).toBe(true);
});
});
@@ -0,0 +1,85 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
interface ExampleCall {
phone: string;
duration: string;
status: string;
statusKind: 'answered' | 'pending' | 'missed';
date: string;
}
interface CallFilter {
label: string;
value: string;
hint: string;
type: 'text' | 'select';
options?: string[];
}
/**
* Symbolic demonstration page for retrieving call records from the call
* center. The rows are example data and every control is a placeholder.
*/
@Component({
selector: 'app-call-center-calls',
standalone: true,
imports: [CommonModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './call-center-calls.page.html',
styleUrls: ['./call-center-calls.page.css', '../../shared/styles/demo-page.css'],
})
export class CallCenterCallsPage {
readonly filters: CallFilter[] = [
{
label: 'از تاریخ',
value: '۱۴۰۴/۰۷/۰۱',
hint: 'نمونه — بازه تاریخ قابل انتخاب است.',
type: 'text',
},
{
label: 'تا تاریخ',
value: '۱۴۰۴/۰۷/۳۰',
hint: 'نمونه — بازه تاریخ قابل انتخاب است.',
type: 'text',
},
{
label: 'وضعیت تماس',
value: 'همه وضعیت‌ها',
hint: 'فیلتر نمونه.',
type: 'select',
options: ['همه وضعیت‌ها', 'پاسخ‌داده شده', 'بدون پاسخ', 'در انتظار بازبینی'],
},
];
readonly exampleCalls: ExampleCall[] = [
{
phone: '۰۹۱۲۱۲۳۴۵۶۷',
duration: '۲:۴۵',
status: 'پاسخ‌داده شده',
statusKind: 'answered',
date: '۱۴ مهر ۱۴۰۴',
},
{
phone: '۰۹۳۵۱۱۲۲۳۳۴۴',
duration: '۰:۳۸',
status: 'بدون پاسخ',
statusKind: 'missed',
date: '۱۴ مهر ۱۴۰۴',
},
{
phone: '۰۹۱۲۹۸۷۶۵۴۳۲',
duration: '۵:۱۲',
status: 'پاسخ‌داده شده',
statusKind: 'answered',
date: '۱۳ مهر ۱۴۰۴',
},
{
phone: '۰۹۱۵۵۵۱۲۳۴۵',
duration: '۱:۰۳',
status: 'در انتظار بازبینی',
statusKind: 'pending',
date: '۱۳ مهر ۱۴۰۴',
},
];
}
@@ -0,0 +1,5 @@
/* Page-specific styles for «ارتباط با کال سنتر» (shared chrome: shared/styles/demo-page.css) */
.demo-field-input--masked {
letter-spacing: 0.2em;
}
@@ -0,0 +1,158 @@
<div class="demo-page">
<header class="demo-header">
<div class="demo-title-group">
<span class="demo-title-icon">
<svg
width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
/>
</svg>
</span>
<div>
<h1 class="demo-title">ارتباط با کال سنتر</h1>
<p class="demo-subtitle">اتصال برنامه به سامانه کال سنتر و همگام‌سازی تماس‌ها</p>
</div>
</div>
<span class="demo-chip">نمایشی</span>
</header>
<section class="demo-card demo-notice">
<span class="demo-notice-icon">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</svg>
</span>
<div>
<h2>این بخش هنوز فعال نیست</h2>
<p>
این صفحه نحوه اتصال برنامه به سامانه کال سنتر را نمایش می‌دهد. در فاز جاری هیچ اتصالی برقرار
نشده است و مقادیر نشان‌داده‌شده صرفاً نمونه هستند؛ پس از راه‌اندازی، اتصال از همین‌جا پیکربندی
و بررسی می‌شود.
</p>
</div>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">وضعیت اتصال</h2>
<p class="demo-card-description">
آخرین وضعیت بررسی اتصال برنامه به سامانه کال سنتر.
</p>
</div>
<div class="demo-status-row">
<span class="demo-status demo-status--off">اتصال برقرار نشده</span>
</div>
</div>
<p class="demo-card-description">
تا زمانی که اتصال برقرار نشده باشد، تماس‌های کال سنتر در والبرد و گزارش‌ها ثبت نمی‌شوند و
انتقال تماس از هوش مصنوعی به کارشناس انجام نمی‌شود.
</p>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">اطلاعات اتصال</h2>
<p class="demo-card-description">
مقادیر زیر از نمونه‌های نمایشی گرفته شده‌اند و قابل ویرایش نیستند.
</p>
</div>
</div>
<div class="demo-form-grid">
@for (field of connectionFields; track field.label) {
<label class="demo-field">
<span class="demo-field-label">{{ field.label }}</span>
<input
class="demo-field-input"
[class.demo-field-input--masked]="field.masked"
type="text"
[value]="field.value"
readonly
/>
<span class="demo-field-hint">{{ field.hint }}</span>
</label>
}
</div>
<div class="demo-actions">
<button type="button" class="demo-btn demo-btn--primary" disabled>بررسی اتصال</button>
<button type="button" class="demo-btn demo-btn--outline" disabled>ذخیره تنظیمات</button>
<span class="demo-hint">این کنترل‌ها در فاز جاری فعال نیستند.</span>
</div>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">قابلیت‌های پس از اتصال</h2>
<p class="demo-card-description">با برقراری اتصال به کال سنتر، این قابلیت‌ها فعال می‌شوند.</p>
</div>
</div>
<div class="demo-features">
@for (feature of features; track feature.id) {
<article class="demo-feature">
<span class="demo-feature-icon">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path [attr.d]="feature.icon" />
</svg>
</span>
<h3>{{ feature.title }}</h3>
<p>{{ feature.description }}</p>
</article>
}
</div>
</section>
<section class="demo-card">
<div class="demo-empty">
<svg
width="40"
height="40"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M22 12h-4l-3 9L9 3l-3 9H2" />
</svg>
<h3>رخداد اتصالی ثبت نشده است</h3>
<p>
پس از برقراری اتصال، رخدادهای آزمایش اتصال، قطع و راه‌اندازی مجدد در این بخش نمایش داده
می‌شود.
</p>
</div>
</section>
</div>
@@ -0,0 +1,47 @@
import { TestBed } from '@angular/core/testing';
import { provideZonelessChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient } from '@angular/common/http';
import { provideRouter } from '@angular/router';
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
import { CallCenterPage } from './call-center.page';
describe('CallCenterPage', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CallCenterPage],
providers: [
provideZonelessChangeDetection(),
provideHttpClient(),
provideRouter([]),
provideAnimations(),
{ provide: TOAST_CONFIG, useValue: { default: DefaultGlobalConfig, config: {} } },
],
}).compileComponents();
});
it('should create the page', () => {
const fixture = TestBed.createComponent(CallCenterPage);
expect(fixture.componentInstance).toBeTruthy();
});
it('renders the symbolic call-center connection state', () => {
const fixture = TestBed.createComponent(CallCenterPage);
fixture.detectChanges();
const element: HTMLElement = fixture.nativeElement;
expect(element.querySelector('.demo-title')?.textContent?.trim()).toBe('ارتباط با کال سنتر');
expect(element.textContent).toContain('این بخش هنوز فعال نیست');
expect(element.textContent).toContain('اتصال برقرار نشده');
expect(element.querySelectorAll('.demo-feature').length).toBe(3);
const inputs = Array.from(element.querySelectorAll('input')) as HTMLInputElement[];
expect(inputs.some((input) => input.value.includes('callcenter.raymand.ir'))).toBe(true);
expect(inputs.some((input) => input.readOnly)).toBe(true);
// every control stays a disabled placeholder
const buttons = Array.from(element.querySelectorAll('button')) as HTMLButtonElement[];
expect(buttons.length).toBeGreaterThan(0);
buttons.forEach((button) => expect(button.disabled).toBe(true));
});
});
@@ -0,0 +1,74 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
interface ConnectionField {
label: string;
value: string;
hint: string;
masked?: boolean;
}
interface CenterFeature {
id: string;
icon: string;
title: string;
description: string;
}
/**
* Symbolic demonstration page for the call-center integration. No backend
* connection exists yet: every value shown is illustrative and the controls
* are disabled placeholders.
*/
@Component({
selector: 'app-call-center',
standalone: true,
imports: [CommonModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './call-center.page.html',
styleUrls: ['./call-center.page.css', '../../shared/styles/demo-page.css'],
})
export class CallCenterPage {
readonly connectionFields: ConnectionField[] = [
{
label: 'آدرس سرویس کال سنتر',
value: 'https://callcenter.raymandcti.com/api/v1',
hint: 'مقدار نمونه — آدرس واقعی پس از راه‌اندازی ثبت می‌شود.',
},
{
label: 'کلید API',
value: '••••••••••••••••••••',
hint: 'کلید به‌صورت رمزنگاری‌شده نگهداری می‌شود.',
masked: true,
},
{
label: 'صف پیش‌فرض',
value: 'پشتیبانی',
hint: 'تماس‌های ارجاع‌شده به این صف وصل می‌شوند.',
},
];
readonly features: CenterFeature[] = [
{
id: 'live',
icon: 'M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z',
title: 'تماس‌های در جریان',
description:
'فهرست تماس‌های فعال و وضعیت لحظه‌ای هر کارشناس به‌صورت بلادرنگ نمایش داده می‌شود.',
},
{
id: 'transfer',
icon: 'M8 3 4 7l4 4M4 7h16M16 21l4-4-4-4M20 17H4',
title: 'انتقال از هوش مصنوعی به کارشناس',
description:
'تماس‌هایی که هوش مصنوعی نتوانسته پاسخ دهد، به همراه سابقه گفتگو به کارشناس ارجاع می‌شود.',
},
{
id: 'sync',
icon: 'M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z',
title: 'همگام‌سازی وضعیت کارشناسان',
description:
'حاضر بودن، مرخصی و خارج‌شدن کارشناسان بین برنامه و سامانه کال سنتر همگام می‌شود.',
},
];
}
@@ -0,0 +1,6 @@
/* Page-specific styles for «سوالات چت سایت و اپلیکیشن» (shared chrome: shared/styles/demo-page.css) */
.demo-list-main {
flex: 1 1 22rem;
min-width: 0;
}
@@ -0,0 +1,106 @@
<div class="demo-page">
<header class="demo-header">
<div class="demo-title-group">
<span class="demo-title-icon">
<svg
width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z" />
</svg>
</span>
<div>
<h1 class="demo-title">سوالات چت سایت و اپلیکیشن</h1>
<p class="demo-subtitle">پرسش‌های ثبت‌شده در چت سایت و اپلیکیشن موبایل</p>
</div>
</div>
<span class="demo-chip">نمایشی</span>
</header>
<section class="demo-card demo-notice">
<span class="demo-notice-icon">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</svg>
</span>
<div>
<h2>این بخش هنوز فعال نیست</h2>
<p>
این صفحه پرسش‌هایی را که کاربران در چت سایت یا اپلیکیشن موبایل ثبت کرده‌اند نمایش می‌دهد. در
فاز جاری این کانال‌ها به برنامه متصل نیستند و موارد زیر صرفاً نمونه هستند؛ پس از اتصال،
پرسش‌های بی‌پاسخ در این صفحه برای بررسی و افزودن به پایگاه دانش نمایش داده می‌شوند.
</p>
</div>
</section>
<section class="demo-card">
<div class="demo-card-header">
<div>
<h2 class="demo-card-title">نمونه پرسش‌های چت</h2>
<p class="demo-card-description">
پرسش‌های دریافتی به همراه منبع ثبت و وضعیت پاسخ‌گویی.
</p>
</div>
<span class="demo-badge">داده نمونه</span>
</div>
<div class="demo-list">
@for (item of exampleQuestions; track item.id) {
<article class="demo-list-item">
<div class="demo-list-main">
<p class="demo-question">{{ item.question }}</p>
<div class="demo-meta">
<span class="demo-tag" [class.demo-tag--site]="item.sourceKind === 'site'" [class.demo-tag--app]="item.sourceKind === 'app'">
{{ item.source }}
</span>
<span class="demo-tag" [class.demo-tag--answered]="item.statusKind === 'answered'" [class.demo-tag--pending]="item.statusKind === 'pending'">
{{ item.status }}
</span>
<span>{{ item.date }}</span>
</div>
</div>
<button type="button" class="demo-btn demo-btn--outline" disabled>پاسخ به پرسش</button>
</article>
}
</div>
</section>
<section class="demo-card">
<div class="demo-empty">
<svg
width="40"
height="40"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
<path d="M8 10h8M8 14h5" />
</svg>
<h3>پرسشی از چت ثبت نشده است</h3>
<p>
پس از اتصال چت سایت و اپلیکیشن موبایل، پرسش‌های جدید کاربران به‌صورت خودکار در این صفحه نمایش
داده می‌شود تا برای آن‌ها پاسخ ثبت شود.
</p>
</div>
</section>
</div>
@@ -0,0 +1,47 @@
import { TestBed } from '@angular/core/testing';
import { provideZonelessChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient } from '@angular/common/http';
import { provideRouter } from '@angular/router';
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
import { ChatQuestionsPage } from './chat-questions.page';
describe('ChatQuestionsPage', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChatQuestionsPage],
providers: [
provideZonelessChangeDetection(),
provideHttpClient(),
provideRouter([]),
provideAnimations(),
{ provide: TOAST_CONFIG, useValue: { default: DefaultGlobalConfig, config: {} } },
],
}).compileComponents();
});
it('should create the page', () => {
const fixture = TestBed.createComponent(ChatQuestionsPage);
expect(fixture.componentInstance).toBeTruthy();
});
it('renders example chat questions with source and status tags', () => {
const fixture = TestBed.createComponent(ChatQuestionsPage);
fixture.detectChanges();
const element: HTMLElement = fixture.nativeElement;
expect(element.querySelector('.demo-title')?.textContent?.trim()).toBe('سوالات چت سایت و اپلیکیشن');
expect(element.textContent).toContain('این بخش هنوز فعال نیست');
expect(element.textContent).toContain('داده نمونه');
const items = element.querySelectorAll('.demo-list-item');
expect(items.length).toBe(3);
expect(element.querySelectorAll('.demo-tag--site').length).toBe(2);
expect(element.querySelectorAll('.demo-tag--app').length).toBe(1);
expect(element.querySelectorAll('.demo-tag--pending').length).toBe(1);
expect(element.textContent).toContain('هزینه ارسال به شهرستان‌ها چگونه محاسبه می‌شود؟');
const buttons = Array.from(element.querySelectorAll('button')) as HTMLButtonElement[];
buttons.forEach((button) => expect(button.disabled).toBe(true));
});
});
@@ -0,0 +1,56 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
interface ExampleQuestion {
id: string;
question: string;
source: string;
sourceKind: 'site' | 'app';
status: string;
statusKind: 'answered' | 'pending';
date: string;
}
/**
* Symbolic demonstration page for questions submitted through the website and
* mobile application chat channels. Example data only; no channel is connected.
*/
@Component({
selector: 'app-chat-questions',
standalone: true,
imports: [CommonModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './chat-questions.page.html',
styleUrls: ['./chat-questions.page.css', '../../shared/styles/demo-page.css'],
})
export class ChatQuestionsPage {
readonly exampleQuestions: ExampleQuestion[] = [
{
id: 'q-1',
question: 'برای ایمپورت محصولات جدید چه مراحلی را باید طی کنم؟',
source: 'سایت',
sourceKind: 'site',
status: 'پاسخ داده شده',
statusKind: 'answered',
date: '۱۴ مهر ۱۴۰۴',
},
{
id: 'q-2',
question: 'هزینه ارسال به شهرستان‌ها چگونه محاسبه می‌شود؟',
source: 'اپلیکیشن',
sourceKind: 'app',
status: 'در انتظار پاسخ',
statusKind: 'pending',
date: '۱۴ مهر ۱۴۰۴',
},
{
id: 'q-3',
question: 'آیا امکان لغو سفارش پس از پرداخت وجود دارد؟',
source: 'سایت',
sourceKind: 'site',
status: 'پاسخ داده شده',
statusKind: 'answered',
date: '۱۳ مهر ۱۴۰۴',
},
];
}
+145 -75
View File
@@ -1,16 +1,33 @@
/* --------------------------------------------------------------------------
Home page — Claude-style chat column
Structure:
.home-page
.chat-column
.transcript-list (flex: 1, scroll)
.composer (pinned bottom of column)
Two layouts, CSS-only, driven by [class.has-conversation]:
- empty state column hugs its content and centers (logo + composer as a group)
- conversation column is exactly one viewport tall, transcript scrolls inside it
-------------------------------------------------------------------------- */
/* The host defaults to `display: inline`, which adds a line-box strut under the
full-height column and pushes the page into Y overflow. Block removes it. */
:host {
display: block;
min-height: 0;
}
.home-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100dvh;
box-sizing: border-box;
padding: 2rem 1rem;
transition: padding 0.4s ease;
padding: 0;
position: relative;
background:
radial-gradient(ellipse 50% 40% at 50% 45%, rgba(59, 130, 246, 0.1), transparent 70%),
var(--app-bg);
/* Flat page color; every decorative glow lives in ::below so it can fade out as one. */
background: var(--app-bg);
}
.home-page::before {
@@ -18,54 +35,91 @@
position: absolute;
inset: 0;
background:
radial-gradient(ellipse 50% 40% at 50% 45%, rgba(59, 130, 246, 0.1), transparent 70%),
radial-gradient(circle at 50% 40%, rgba(59, 130, 246, 0.07), transparent 55%),
radial-gradient(circle at 35% 55%, rgba(99, 102, 241, 0.05), transparent 50%),
radial-gradient(circle at 65% 50%, rgba(59, 130, 246, 0.04), transparent 45%);
pointer-events: none;
z-index: 0;
transition: opacity 0.35s ease;
}
.home-page > .home-content {
/* Conversation open (messages or voice call): the bluish glow disappears completely. */
.home-page.has-conversation::before {
opacity: 0;
}
/* ---- Chat column (Claude: one continuous column) ---- */
.chat-column {
position: relative;
z-index: 1;
}
.home-page.has-messages {
justify-content: flex-end;
background: var(--app-bg);
}
.home-page.has-messages::before {
opacity: 0;
}
.home-header {
position: absolute;
top: 2rem;
left: 50%;
transform: translateX(-50%);
text-align: center;
transition:
opacity 0.35s ease,
transform 0.35s ease,
margin 0.35s ease;
opacity: 1;
}
.home-page.has-messages .home-header {
opacity: 0;
transform: translateX(-50%) translateY(-8px);
pointer-events: none;
}
.home-page.has-messages .home-title {
opacity: 0;
pointer-events: none;
}
.home-content {
display: flex;
flex-direction: column;
width: 100%;
max-width: 800px;
/* Auto height + viewport floor: grows only if the empty group cannot fit (then the
shell scrolls) instead of clipping. */
height: auto;
min-height: 100dvh;
box-sizing: border-box;
}
/* Conversation: the column is exactly one viewport tall so the composer stays pinned
and only the transcript area scrolls. `overflow` keeps any stray child box from
propagating phantom height to the page. */
.home-page.has-conversation .chat-column {
height: 100dvh;
overflow: hidden;
}
/* Empty state: the column stops stretching, so the empty content and the composer are
centered together in the viewport instead of the composer being pinned to the bottom. */
.home-page:not(.has-conversation) .chat-column {
justify-content: center;
}
.home-page:not(.has-conversation) .transcript-list {
flex: 0 0 auto;
overflow: visible;
}
.home-page:not(.has-conversation) .empty-state {
flex: 0 0 auto;
}
/* ---- Transcript list (scrollable body) ---- */
.transcript-list {
flex: 1 1 auto;
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
/* Hide the scrollbar, keep wheel / trackpad / touch scrolling */
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* legacy Edge */
scroll-behavior: smooth;
display: flex;
flex-direction: column;
/* Space so last message clears the composer */
padding: 1.25rem 1rem 0.5rem;
box-sizing: border-box;
}
.transcript-list::-webkit-scrollbar {
display: none; /* Chrome, Safari, Edge */
width: 0;
height: 0;
}
/* Empty state centered in the transcript area */
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 2rem 1rem;
min-height: 0;
}
.home-icon-wrapper {
@@ -89,7 +143,7 @@
.home-title {
width: 100%;
margin: 0 0 1rem;
margin: 0;
display: flex;
align-items: center;
@@ -98,7 +152,7 @@
text-align: center;
direction: rtl;
font-size: 1.5rem;
font-size: 1.45rem;
font-weight: 400;
line-height: 1.5;
color: var(--text-primary);
@@ -110,18 +164,12 @@
.cursor {
display: inline-block;
width: 2px;
height: 1.15em;
margin-right: 3px;
background-color: var(--text-primary);
border-radius: 1px;
animation: cursorBlink 0.8s ease-in-out infinite;
flex-shrink: 0;
}
@@ -134,20 +182,56 @@
45% {
opacity: 1;
}
46%,
100% {
opacity: 0;
}
}
/* Voice panel becomes the transcript body — no extra card chrome */
.chat-transcript-body {
display: block;
flex: 1 1 auto;
min-height: 0;
width: 100%;
}
/* ---- Composer (pinned bottom of the chat column) ---- */
.composer {
flex-shrink: 0;
width: 100%;
padding: 0.75rem 1rem 1.25rem;
box-sizing: border-box;
background: transparent;
/* Subtle top fade so messages don't collide with the input */
position: relative;
}
.composer::before {
content: '';
position: absolute;
left: 0;
right: 0;
bottom: 100%;
height: 1.5rem;
pointer-events: none;
background: linear-gradient(to top, var(--app-bg), transparent);
opacity: 0;
transition: opacity 0.25s ease;
}
.home-page.has-conversation .composer::before {
opacity: 1;
}
/* ---- Responsive ---- */
@media (max-width: 640px) {
.home-page {
padding: 1.25rem 0.75rem;
.transcript-list {
padding: 1rem 0.75rem 0.5rem;
}
.home-header {
top: 1.25rem;
.composer {
padding: 0.5rem 0.75rem 1rem;
}
.home-icon-wrapper {
@@ -156,11 +240,6 @@
padding: 0.5rem;
}
.home-logo {
width: 100%;
height: 100%;
}
.home-title {
font-size: 1.375rem;
}
@@ -168,20 +247,11 @@
@media (prefers-reduced-motion: reduce) {
.home-page,
.home-header,
.home-icon-wrapper {
.home-page::before,
.transcript-list,
.composer::before {
transition: none !important;
animation: none !important;
scroll-behavior: auto !important;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
}
+47 -31
View File
@@ -1,36 +1,52 @@
<div class="home-page" [class.has-messages]="hasMessages()">
<div
class="home-page"
[class.has-conversation]="hasConversation()"
>
<!-- Claude-style chat column: transcript list + composer in one continuous column -->
<div class="chat-column" role="main">
<!-- Transcript list (scrollable). Empty state or live/ended voice transcript. -->
<div
class="transcript-list"
#transcriptScroller
role="log"
aria-label="متن گفتگو"
aria-live="polite"
aria-relevant="additions"
>
@if (!hasConversation()) {
<!-- Empty state: logo + typing title (Claude empty chat feel) -->
<div class="empty-state">
<div class="home-icon-wrapper">
<img
class="home-logo"
[src]="logoSrc()"
alt="Raymand"
/>
</div>
<h1 class="home-title">
<span class="home-title-text">{{ streamedText() }}</span>
<span
class="cursor"
[class.cursor-hidden]="!isStreaming()"
aria-hidden="true"
></span>
</h1>
</div>
} @else if (voiceHasTranscript()) {
<!-- Voice stream fills the transcript list (no separate card chrome) -->
<app-voice-stream-panel class="chat-transcript-body" />
}
</div>
<div class="home-header" [class.header-hidden]="hasMessages()">
<div class="home-icon-wrapper">
<img
class="home-logo"
[src]="logoSrc()"
alt="Raymand"
<!-- Composer: always at the bottom of the same column (Claude pattern) -->
<div class="composer">
<app-ai-chat-input
placeholder="پیام خود را بنویسید..."
[hasMessages]="hasConversation()"
(messageSent)="onMessageSent($event)"
(fileSelected)="onFileSelected($event)"
(voiceToggled)="onVoiceToggled($event)"
/>
</div>
</div>
<div class="home-content">
<h1 class="home-title">
<span class="home-title-text">
{{ streamedText() }}
</span>
<span
class="cursor"
[class.cursor-hidden]="!isStreaming()"
aria-hidden="true"
></span>
</h1>
<app-ai-chat-input
placeholder="پیام خود را بنویسید..."
[hasMessages]="hasMessages()"
(messageSent)="onMessageSent($event)"
(fileSelected)="onFileSelected($event)"
(voiceToggled)="onVoiceToggled($event)"
/>
</div>
</div>
+21 -7
View File
@@ -3,18 +3,21 @@ import {
Component,
inject,
signal,
computed,
OnInit,
OnDestroy,
} from '@angular/core';
import { CommonModule } from '@angular/common';
import { AiChatInputComponent } from '../../shared/ui/ai-chat-input/ai-chat-input.component';
import { VoiceStreamPanelComponent } from '../../shared/ui/voice-stream-panel/voice-stream-panel.component';
import { VoiceStreamService } from '../../services/voice-stream/voice-stream.service';
import { Router, NavigationEnd } from '@angular/router';
import { filter } from 'rxjs/operators';
import { ThemeService } from '../../services/theme/theme.service';
import { Subscription } from 'rxjs';
const HOME_TITLES = [
'چه چیزی می‌خواهید بدانید؟...',
'چه چیزی می‌خواهید بدانید؟',
'سوالتان را بپرسید، با شما هستم...',
'هر سوالی دارید، از من بپرسید...',
'از هر چیزی که می‌خواهید شروع کنید...',
@@ -29,7 +32,7 @@ const HOME_TITLES = [
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, AiChatInputComponent],
imports: [CommonModule, AiChatInputComponent, VoiceStreamPanelComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './home.page.html',
styleUrl: './home.page.css',
@@ -37,6 +40,7 @@ const HOME_TITLES = [
export class HomePage implements OnInit, OnDestroy {
private readonly themeService = inject(ThemeService);
private readonly router = inject(Router);
private readonly voiceStream = inject(VoiceStreamService);
readonly isDarkMode = this.themeService.isDarkMode;
@@ -45,6 +49,20 @@ export class HomePage implements OnInit, OnDestroy {
readonly hasMessages = signal(false);
/**
* Conversation owns the layout when there is a live voice call,
* leftover voice transcript, or text messages — same idea as Claude's
* chat column switching from empty state to transcript list.
*/
readonly voiceHasTranscript = computed(
() => this.voiceStream.isOpen() || this.voiceStream.messages().length > 0,
);
readonly hasConversation = computed(() => this.hasMessages() || this.voiceHasTranscript());
/** @deprecated use hasConversation — kept for any external bindings */
readonly voicePanelVisible = this.hasConversation;
readonly homeTitle = signal('');
readonly streamedText = signal('');
readonly isStreaming = signal(false);
@@ -97,12 +115,9 @@ export class HomePage implements OnInit, OnDestroy {
}
index++;
this.streamedText.set(text.substring(0, index));
// Slightly random timing makes it feel more natural
const delay = 16 + Math.random() * 8;
this.typingTimer = setTimeout(typeNextCharacter, delay);
};
@@ -114,7 +129,6 @@ export class HomePage implements OnInit, OnDestroy {
clearTimeout(this.typingTimer);
this.typingTimer = null;
}
this.isStreaming.set(false);
}
@@ -130,4 +144,4 @@ export class HomePage implements OnInit, OnDestroy {
onVoiceToggled(active: boolean): void {
console.log('Voice mode:', active ? 'active' : 'inactive');
}
}
}
+7 -6
View File
@@ -127,7 +127,6 @@ export class LoginPage {
}
onSubmit(): void {
this.router.navigate(['/']);
const allErrors = this.validateAllFields();
if (Object.keys(allErrors).length > 0) {
@@ -159,11 +158,13 @@ export class LoginPage {
},
error: (err) => {
this.isLoading.set(false);
const message =
(err as any)?.error?.message ||
(err as any)?.message ||
'خطا در اتصال به سرور. لطفاً دوباره تلاش کنید.';
this.generalError.set(message);
// Errors are mapped by backend code instead of showing the raw server message.
this.generalError.set(
AuthService.messageForError(
err,
'خطا در اتصال به سرور. لطفاً دوباره تلاش کنید.',
),
);
this.triggerShake();
},
});
+146
View File
@@ -0,0 +1,146 @@
import { ChangeDetectionStrategy, Component, computed, inject, signal, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { forkJoin } from 'rxjs';
import { ReportsService } from '../../services/reports/reports.service';
import { ReportsView } from '../../services/reports/reports.types';
import { BarChartComponent, BarChartItem } from '../../shared/ui/charts/bar-chart.component';
import { DoughnutChartComponent, DoughnutSegment } from '../../shared/ui/charts/doughnut-chart.component';
import { LineChartComponent, LinePoint } from '../../shared/ui/charts/line-chart.component';
import { CHART_PALETTE } from '../../shared/utils/chart-palette';
import { formatCount, formatDecimal, formatPercent } from '../../shared/utils/format.util';
type ReportTabId = 'questions' | 'performance';
@Component({
selector: 'app-reports',
standalone: true,
imports: [CommonModule, BarChartComponent, DoughnutChartComponent, LineChartComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './reports.page.html',
styleUrl: './reports.page.css',
})
export class ReportsPage implements OnInit {
private readonly reports = inject(ReportsService);
readonly tabs: { id: ReportTabId; label: string; icon: string }[] = [
{
id: 'questions',
label: 'پرسش‌های کاربران',
icon: 'M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z',
},
{
id: 'performance',
label: 'عملکرد و روند',
icon: 'M22 12h-4l-3 9L9 3l-3 9H2',
},
];
readonly activeTab = signal<ReportTabId>('questions');
readonly loading = signal(true);
readonly loadError = signal(false);
readonly data = signal<ReportsView | null>(null);
readonly summary = computed(() => this.data()?.summary ?? null);
readonly ai = computed(() => this.data()?.aiPerformance ?? null);
readonly topQuestions = computed<BarChartItem[]>(() => {
const questions = this.data()?.topQuestions ?? [];
return questions.map((question, index) => ({
label: question.text,
value: question.count,
color: CHART_PALETTE[index % CHART_PALETTE.length],
hint: `دسته: ${question.category}`,
}));
});
readonly categories = computed<DoughnutSegment[]>(() => {
const shares = this.data()?.categories ?? [];
return shares.map((share, index) => ({
label: share.category,
value: share.count,
color: CHART_PALETTE[index % CHART_PALETTE.length],
}));
});
readonly trend = computed<LinePoint[]>(() => {
const points = this.data()?.trend ?? [];
return points.map((point) => ({ label: point.label, value: point.count }));
});
readonly channels = computed<BarChartItem[]>(() => {
const channels = this.data()?.aiPerformance.channels ?? [];
return channels.map((channel, index) => ({
label: channel.label,
value: channel.count,
color: CHART_PALETTE[index % CHART_PALETTE.length],
}));
});
readonly aiAnswerRate = computed(() => {
const summary = this.summary();
if (!summary || summary.totalQuestions === 0) return 0;
return (summary.aiAnswered / summary.totalQuestions) * 100;
});
readonly faqBasedRate = computed(() => {
const ai = this.ai();
if (!ai || ai.totalResponses === 0) return 0;
return (ai.faqBasedResponses / ai.totalResponses) * 100;
});
readonly trendTotal = computed(() => this.trend().reduce((sum, point) => sum + point.value, 0));
readonly trendPeak = computed(() => {
const points = this.trend();
if (points.length === 0) return null;
return points.reduce((peak, point) => (point.value > peak.value ? point : peak), points[0]);
});
ngOnInit(): void {
this.load();
}
selectTab(id: ReportTabId): void {
this.activeTab.set(id);
}
load(): void {
this.loading.set(true);
this.loadError.set(false);
forkJoin({
topQuestions: this.reports.getTopQuestions(),
summary: this.reports.getQuestionSummary(),
categories: this.reports.getCategoryDistribution(),
trend: this.reports.getUsageTrend(),
aiPerformance: this.reports.getAiPerformance(),
}).subscribe({
next: (data) => {
this.data.set(data);
this.loading.set(false);
},
error: () => {
this.data.set(null);
this.loading.set(false);
this.loadError.set(true);
},
});
}
retry(): void {
this.load();
}
formatCount(value: number): string {
return formatCount(value);
}
formatDecimal(value: number): string {
return formatDecimal(value);
}
formatPercent(value: number): string {
return formatPercent(value);
}
}
+354 -92
View File
@@ -88,12 +88,6 @@
animation: slideInRight 0.3s ease-out;
}
.file-item:nth-child(1) { animation-delay: 0.05s; }
.file-item:nth-child(2) { animation-delay: 0.1s; }
.file-item:nth-child(3) { animation-delay: 0.15s; }
.file-item:nth-child(4) { animation-delay: 0.2s; }
.file-item:nth-child(5) { animation-delay: 0.25s; }
.file-icon-wrapper {
transition: all 0.2s ease;
}
@@ -113,11 +107,6 @@
animation: fadeInUp 0.4s ease-out forwards;
}
.setting-item:nth-child(1) { animation-delay: 0.05s; }
.setting-item:nth-child(2) { animation-delay: 0.1s; }
.setting-item:nth-child(3) { animation-delay: 0.15s; }
.setting-item:nth-child(4) { animation-delay: 0.2s; }
.form-select {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
@@ -197,9 +186,11 @@
border-color: var(--color-primary);
}
/* `.toggle-active` mirrors the checked state set by the host; keep it solid too
so it never wins over the neutral base with a transparent primary wash. */
.toggle-switch.toggle-active {
background-color: var(--color-primary)/15;
border-color: var(--color-primary)/25;
background-color: var(--color-primary);
border-color: var(--color-primary);
}
.toggle-switch:focus-within {
@@ -207,111 +198,55 @@
box-shadow: 0 0 0 3px var(--color-primary)/30;
}
.toggle-switch:hover {
background-color: var(--color-primary)/10;
/* Unchecked (off) hover: solid neutral, never transparent. */
.toggle-switch:hover:not(:has(input:checked)) {
background-color: color-mix(in srgb, var(--toggle-bg) 60%, #000);
}
.toggle-switch:hover:has(input:checked) {
background-color: var(--color-primary);
}
.toggle-switch:hover.toggle-active {
background-color: var(--color-primary)/20;
/* Checked hover: solid, slightly darker primary. */
.toggle-switch:has(input:checked):hover {
background-color: color-mix(in srgb, var(--color-primary) 78%, #000);
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(20px);
}
to {
opacity: 1;
transform: translateX(0);
}
from { opacity: 0; transform: translateX(20px); }
to { opacity: 1; transform: translateX(0); }
}
@keyframes slideIn {
from {
width: 0;
opacity: 0;
}
to {
width: 1.5rem;
opacity: 1;
}
from { width: 0; opacity: 0; }
to { width: 1.5rem; opacity: 1; }
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-5px);
}
60% {
transform: translateY(-3px);
}
0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
40% { transform: translateY(-5px); }
60% { transform: translateY(-3px); }
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
0%, 100% { transform: scale(1); }
50% { transform: scale(1.1); }
}
@media (max-width: 640px) {
@@ -392,4 +327,331 @@
:host-context([data-bs-theme="dark"]) .file-item:hover,
:host-context([data-bs-theme="dark"]) .setting-item:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}
:host-context([data-bs-theme="dark"]) .btn--outline:hover:not(:disabled) {
background: color-mix(in srgb, var(--color-primary) 30%, #171717);
}
:host-context([data-bs-theme="dark"]) .toggle-switch:hover:not(:has(input:checked)) {
background-color: color-mix(in srgb, var(--toggle-bg) 50%, #000);
}
:host-context([data-bs-theme="dark"]) .toggle-switch:has(input:checked):hover {
background-color: color-mix(in srgb, var(--color-primary) 75%, #000);
}
/* ===== Dropzone disabled overlay ===== */
.dropzone-disabled {
opacity: 0.6;
pointer-events: none;
}
/* ===== Upload actions + queue ===== */
.upload-actions {
animation: fadeInUp 0.4s ease-out;
}
.upload-queue {
animation: fadeInUp 0.4s ease-out;
}
.upload-task {
animation: slideInRight 0.3s ease-out;
}
.upload-progress-bar {
background: var(--surface-border);
}
.upload-progress-bar > div {
background: var(--color-primary);
}
/* ===== Buttons ===== */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.4rem;
border-radius: 0.5rem;
padding: 0.5rem 0.9rem;
font-size: 0.85rem;
font-weight: 500;
border: 1px solid transparent;
cursor: pointer;
transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn--primary {
background: var(--color-primary);
color: #ffffff;
}
.btn--primary:hover:not(:disabled) {
background: color-mix(in srgb, var(--color-primary) 80%, #000);
}
.btn--primary:active:not(:disabled) {
background: color-mix(in srgb, var(--color-primary) 70%, #000);
}
.btn--outline {
background: transparent;
border-color: var(--color-input-border);
color: var(--text-secondary);
}
.btn--outline:hover:not(:disabled) {
background: color-mix(in srgb, var(--color-primary) 22%, #ffffff);
border-color: var(--color-primary);
color: var(--color-primary);
}
/* ===== Documents table ===== */
.documents-section {
animation: fadeInUp 0.5s ease-out;
}
.documents-filters {
animation: fadeInUp 0.4s ease-out;
}
.documents-table-wrapper {
border: 1px solid var(--color-card-border);
}
.documents-table {
border-collapse: separate;
border-spacing: 0;
}
.documents-table th,
.documents-table td {
padding: 0.6rem 0.75rem;
text-align: right;
vertical-align: top;
border-bottom: 1px solid var(--color-card-border);
}
.documents-table thead th {
background: var(--sidebar-hover);
}
.table-row-animate {
animation: fadeInUp 0.3s ease-out;
}
.documents-table tbody tr:last-child td {
border-bottom: none;
}
/* Status badges */
.status-queued {
background: var(--color-warning)/15;
color: var(--color-warning);
}
.status-processing {
background: var(--color-info)/15;
color: var(--color-info);
}
.status-ready {
background: var(--color-success)/15;
color: var(--color-success);
}
.status-failed {
background: var(--color-danger)/15;
color: var(--color-danger);
}
.status-dot,
.dot-queued,
.dot-processing,
.dot-ready,
.dot-failed {
width: 0.4rem;
height: 0.4rem;
border-radius: 9999px;
flex-shrink: 0;
}
.dot-queued { background: var(--color-warning); }
.dot-processing { background: var(--color-info); animation: pulse-dot 1.5s ease-in-out infinite; }
.dot-ready { background: var(--color-success); }
.dot-failed { background: var(--color-danger); }
@keyframes pulse-dot {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
/* Active toggle button */
.active-toggle {
display: inline-flex;
align-items: center;
gap: 0.35rem;
border-radius: 9999px;
padding: 0.25rem 0.7rem;
font-size: 0.78rem;
font-weight: 600;
border: 1px solid var(--color-input-border);
cursor: pointer;
transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.active-toggle--on {
background: var(--color-success)/15;
border-color: var(--color-success);
color: var(--color-success);
}
.active-toggle:not(.active-toggle--on) {
background: var(--color-input-border)/40;
color: var(--text-muted);
}
.active-toggle:hover {
opacity: 0.85;
}
.active-toggle:disabled {
cursor: default;
opacity: 0.6;
}
/* Documents empty / error / pagination */
.documents-loading,
.documents-empty,
.documents-error {
animation: fadeIn 0.3s ease-out;
}
/* ===== Review modal ===== */
.review-backdrop {
position: fixed;
inset: 0;
background: var(--overlay);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
padding: 1rem;
}
.review-modal {
background: var(--card-bg);
border: 1px solid var(--color-card-border);
border-radius: 1rem;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
width: 100%;
max-width: 56rem;
max-height: 85dvh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.review-modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.25rem;
border-bottom: 1px solid var(--color-card-border);
}
.review-modal-body {
padding: 1.25rem;
overflow-y: auto;
flex: 1 1 auto;
min-height: 0;
}
.review-modal-footer {
border-top: 1px solid var(--color-card-border);
}
.review-loading {
animation: fadeIn 0.3s ease-out;
}
.review-items {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 1rem;
}
.review-item {
animation: fadeInUp 0.3s ease-out;
}
.review-item-header {
animation: fadeInDown 0.3s ease-out;
}
.review-item-body {
animation: fadeIn 0.3s ease-out;
}
.review-preview {
background: var(--sidebar-hover);
border: 1px dashed var(--color-card-border);
}
.review-preview img {
max-width: 100%;
height: auto;
display: block;
}
.review-item-actions {
animation: fadeInDown 0.3s ease-out;
}
/* ===== App settings: AI model cards grid ===== */
.ai-models-grid {
animation: fadeInUp 0.5s ease-out;
}
.ai-models-grid > app-ai-model-config-card {
animation: fadeInUp 0.4s ease-out;
}
/* Shared form utilities (also used by the review modal — page-scoped) */
.form-label {
font-size: 0.8rem;
font-weight: 500;
color: var(--text-secondary);
}
.form-input {
background: var(--color-input-bg);
color: var(--text-secondary);
border: 1px solid var(--color-input-border);
border-radius: 0.5rem;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
width: 100%;
box-sizing: border-box;
}
.form-input:focus {
border-color: var(--color-primary);
box-shadow: 0 0 0 3px var(--color-primary)/20;
}
.form-input:disabled {
background: var(--surface-bg);
cursor: default;
opacity: 0.7;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
.dot-processing { animation: none; }
}
@media (max-width: 640px) {
.documents-table {
font-size: 0.75rem;
}
.documents-table th,
.documents-table td {
padding: 0.4rem 0.3rem;
}
.review-modal {
max-width: 100%;
max-height: 90dvh;
border-radius: 0.75rem;
}
.review-item-body {
grid-template-columns: 1fr;
}
.ai-models-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 480px) {
.documents-filters {
flex-wrap: wrap;
gap: 0.5rem;
}
}
+655 -45
View File
@@ -1,4 +1,5 @@
<div class="settings-page max-w-3xl mx-auto px-4 py-8">
<!-- prettier-ignore -->
<div class="settings-page max-w-6xl mx-auto px-4 py-8">
<header class="settings-header mb-8">
<h1 class="text-3xl font-semibold text-[var(--text-primary)] mb-1">تنظیمات</h1>
<p class="text-sm text-[var(--text-muted)]">مدیریت FAQ و ترجیحات برنامه</p>
@@ -58,7 +59,7 @@
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l-.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l-.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
<span>تنظیمات برنامه</span>
@@ -93,13 +94,32 @@
آپلود سند FAQ
</h2>
<p class="text-sm text-[var(--text-muted)]">
فایل‌های PDF، DOCX یا TXT خود را بکشید و رها کنید یا برای آپلود کلیک کنید.
فایل‌های {{ supportedFormatsLabel() }} خود را بکشید و رها کنید یا برای آپلود کلیک کنید.
</p>
@if (!capabilitiesLoaded() && !configLoading()) {
<p class="text-xs text-[var(--color-danger)] mt-1">
محدودیت‌های آپلود از سرور دریافت نشده‌اند؛ آپلود غیرفعال است.
</p>
}
@if (maxUploadBytes()) {
<p class="text-xs text-[var(--text-muted)] mt-1">
حداکثر حجم: {{ formatFileSize(maxUploadBytes()) }}
</p>
}
@if (pdfPageLimitLabel()) {
<p class="text-xs text-[var(--text-muted)] mt-1">
حداکثر تعداد صفحات PDF: {{ pdfPageLimitLabel() }}
</p>
}
@if (configError()) {
<p class="text-xs text-[var(--color-danger)] mt-1">{{ configError() }}</p>
}
</div>
<div
class="dropzone relative flex flex-col items-center justify-center gap-3 p-8 border-2 border-dashed border-[rgba(148,163,184,0.25)] rounded-xl bg-[var(--dropzone-bg)] cursor-pointer transition-all duration-300 hover:border-primary/50 hover:bg-primary/5 hover:shadow-[0_10px_30px_rgba(59,130,246,0.15)]"
[class.dropzone-active]="isDragging()"
[class.dropzone-disabled]="isUploading()"
(dragover)="onDragOver($event)"
(dragleave)="onDragLeave()"
(drop)="onDrop($event)"
@@ -114,8 +134,9 @@
id="faq-file-input"
type="file"
class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
accept=".pdf,.docx,.doc,.txt"
[accept]="supportedUploadAccept()"
multiple
[disabled]="isUploading()"
(change)="onFileSelected($event)"
/>
@@ -140,11 +161,11 @@
فایل‌ها را اینجا رها کنید
</p>
<p class="text-xs text-[var(--text-muted)] mt-1">یا کلیک کنید برای انتخاب</p>
<p class="text-xs text-[var(--text-muted)] mt-2">پشتیبانی: PDF، DOCX، TXT</p>
<p class="text-xs text-[var(--text-muted)] mt-2">پشتیبانی: {{ supportedFormatsLabel() }}</p>
</div>
</div>
@if (fileCount > 0) {
@if (fileCount > 0 && !isUploading()) {
<div class="file-list mt-6 animate-slide-up">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-[var(--text-primary)] flex items-center gap-2">
@@ -204,7 +225,7 @@
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"
(click)="removeFile($index)"
aria-label="حذف فایل {{ file.name }}"
[attr.aria-label]="'حذف فایل ' + file.name"
>
<svg
class="w-4 h-4"
@@ -224,6 +245,517 @@
</ul>
</div>
}
@if (fileCount > 0 && !isUploading()) {
<div class="upload-actions mt-4 flex items-center justify-between gap-3">
<button
type="button"
class="btn btn--primary"
(click)="uploadFiles()"
[disabled]="isUploading() || !capabilitiesLoaded() || !isAdmin()"
>
<span>آپلود فایل‌ها</span>
@if (!isAdmin()) {
<span class="text-xs">(مدیریت اسناد فقط برای ادمین‌ها)</span>
}
@if (!capabilitiesLoaded()) {
<span class="text-xs">(تنظیمات سرور بارگذاری نشد)</span>
}
</button>
</div>
}
@if (isUploading()) {
<div class="upload-queue mt-4 space-y-3" aria-live="polite" aria-label="وضعیت آپلود">
<h3 class="text-sm font-medium text-[var(--text-secondary)] mb-2">در حال آپلود...</h3>
@for (task of uploadQueue(); track $index) {
<div class="upload-task flex items-center gap-3">
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between gap-2">
<span class="text-sm text-[var(--text-secondary)] truncate">{{ task.file.name }}</span>
<span class="text-xs text-[var(--text-muted)]">
@if (task.status === 'uploading') {
{{ task.progress }}%
} @else if (task.status === 'done') {
<span class="text-[var(--color-success)]">بارگذاری شد</span>
} @else {
<span class="text-[var(--color-danger)]">خطا</span>
}
</span>
</div>
<div class="upload-progress-bar mt-1 h-1.5 bg-[var(--surface-border)] rounded-full overflow-hidden">
<div
class="h-full bg-primary rounded-full transition-all duration-200"
[style.width]="(task.progress) + '%'"
></div>
</div>
@if (task.error) {
<p class="text-xs text-[var(--color-danger)] mt-1">{{ task.error }}</p>
}
</div>
@if (task.status === 'uploading') {
<button
type="button"
class="file-remove-btn p-1 text-[var(--text-muted)] rounded transition-colors hover:text-red-400"
(click)="cancelUpload($index)"
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>
}
@if (task.status === 'error') {
<button
type="button"
class="file-remove-btn p-1 text-[var(--text-muted)] rounded transition-colors hover:text-[var(--color-primary)]"
(click)="retryUpload($index)"
aria-label="دوباره‌سعی آپلود"
title="دوباره‌سعی"
>
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
</svg>
</button>
}
</div>
}
</div>
}
<!-- اسناد آپلود شده -->
<div class="documents-section mt-8">
@if (!isAdmin()) {
<div class="documents-locked flex flex-col items-center justify-center gap-3 py-10 text-center">
<svg class="w-10 h-10 text-[var(--text-muted)]" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round">
<path d="M12 1.75v20.5" />
<path d="M4.25 12h15.5" />
</svg>
<p class="text-sm text-[var(--text-secondary)]">مدیریت و لیست اسناد فقط برای ادمین‌ها در دسترس است.</p>
</div>
}
@if (isAdmin()) {
<div class="section-header mb-4">
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
<polyline points="14 8 20 8 20 14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8z" />
</svg>
اسناد آپلود شده
</h2>
<p class="text-sm text-[var(--text-muted)]">
فهرست اسناد ثبت‌شده و وضعیت پردازش آن‌ها. وضعیت در صف یا پردازش در حال پردازش به‌صورت خودکار به‌روز می‌شود.
</p>
</div>
@if (documentsLoading() && documents().length === 0) {
<div class="documents-loading flex items-center justify-center gap-2 py-10 text-[var(--text-muted)]">
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19" />
<path d="M19 12a7 7 0 1 1-14 0a7 7 0 0 1 14 0z" />
</svg>
<span>در حال بارگذاری اسناد...</span>
</div>
}
@if (documentsError() && documents().length === 0) {
<div class="documents-error flex flex-col items-center justify-center gap-3 py-10 text-center">
<p class="text-sm text-[var(--text-secondary)]">{{ documentsError() }}</p>
<button type="button" class="btn btn--outline" (click)="refreshDocuments()">
تلاش مجدد
</button>
</div>
}
@if (documents().length > 0) {
<div class="documents-filters mb-3 flex items-center justify-between gap-2">
<div class="flex items-center gap-2">
<select
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-1.5 text-xs min-w-[130px] cursor-pointer"
[value]="activeFilter()"
(change)="activeFilter.set($any($event.target).value); applyDocumentFilters()"
>
<option value="all">همه وضعیت‌ها</option>
<option value="queued">در صف</option>
<option value="processing">در حال پردازش</option>
<option value="ready">آماده</option>
<option value="failed">ناموفق</option>
</select>
<label class="toggle-switch" [class.toggle-active]="activeOnly()">
<input type="checkbox" [checked]="activeOnly()" (change)="activeOnly.set($any($event.target).checked); applyDocumentFilters()" />
<span class="toggle-slider"></span>
</label>
<span class="text-xs text-[var(--text-muted)]">فقط فعال</span>
</div>
<button type="button" class="btn btn--outline" (click)="refreshDocuments()" [disabled]="documentsLoading()">
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 12a9 9 0 0 1 9-9a9 9 0 1 1 0 18a9 9 0 0 1 0-18z" />
<path d="M12 8v4l2 2" />
</svg>
<span>به‌روزرسانی</span>
</button>
</div>
<div class="documents-table-wrapper overflow-x-auto rounded-xl border border-[var(--color-card-border)] bg-[var(--card-bg)]">
<table class="documents-table min-w-full text-sm text-right">
<thead class="bg-[var(--sidebar-hover)]">
<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>
</tr>
</thead>
<tbody class="divide-y divide-[var(--color-card-border)]">
@for (doc of documents(); track doc.id) {
<tr class="table-row-animate">
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-secondary)] truncate block max-w-[14rem]"
>{{ doc.filename }}</span>
</td>
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-secondary)]">{{ doc.title ?? '—' }}</span>
</td>
<td class="px-3 py-2.5 align-top">
<span
class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium"
[class.status-queued]="doc.status === 'queued'"
[class.status-processing]="doc.status === 'processing'"
[class.status-ready]="doc.status === 'ready'"
[class.status-failed]="doc.status === 'failed'"
>
<span class="status-dot" [class.dot-queued]="doc.status === 'queued'"
[class.dot-processing]="doc.status === 'processing'" [class.dot-ready]="doc.status === 'ready'"
[class.dot-failed]="doc.status === 'failed'"></span>
{{ statusLabel(doc.status) }}
</span>
@if (isReviewNeeded(doc)) {
<span class="block text-xs text-[var(--color-warning)] mt-1 font-medium">
نیازمند بازبینی ادمین
</span>
}
@if (doc.job.error; as jobError) {
<span class="block text-xs text-[var(--color-danger)] mt-1"
title="{{ jobError.message }}">{{ jobError.code }}</span>
}
</td>
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-muted)]">{{ doc.chunk_count }}</span>
</td>
<td class="px-3 py-2.5 align-top">
<span class="text-sm text-[var(--text-muted)]">{{ formatDateTime(doc.created_at) }}</span>
</td>
<td class="px-3 py-2.5 align-top min-w-[11rem]">
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
@if (togglingDocId() === doc.id) {
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
<svg class="w-3 h-3 animate-spin" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19" />
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
</svg>
<span>در حال به‌روزرسانی</span>
</div>
} @else {
<button
type="button"
class="active-toggle"
[class.active-toggle--on]="isDocumentActive(doc)"
(click)="toggleDocumentActive(doc)"
>
<span>{{ isDocumentActive(doc) ? 'فعال' : 'غیرفعال' }}</span>
</button>
}
} @else {
<span
class="text-xs"
[class.text-[var(--color-success)]="doc.is_active"
[class.text-[var(--text-muted)]="!doc.is_active"
>{{ doc.is_active ? 'فعال' : 'غیرفعال' }}</span
>
}
</td>
<td class="px-3 py-2.5 align-top">
<div class="flex items-center gap-1.5">
@if (isReviewNeeded(doc) && doc.status === 'failed') {
<button
type="button"
class="btn btn--outline"
[disabled]="reviewingDocId() === doc.id"
(click)="openReview(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">
<path d="M2 12s9-7 19-7c2.6 0 4.5 2 4.5 4.5S23.6 19 21 19s-4.5-2.5-4.5-4.5S17.4 7 9 7" />
<path d="M2 12s9 7 19 7c2.6 0 4.5-2 4.5-4.5S23.6 7 21 7s-4.5 2.5-4.5 4.5S16.6 17 21 17" />
<circle cx="12" cy="12" r="3" />
</svg>
<span>بازبینی سند</span>
</button>
}
@if (canRetryDocument(doc)) {
<button
type="button"
class="btn btn--outline"
(click)="retryDocument(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">
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
</svg>
<span>دوباره‌سعی</span>
</button>
}
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
@if (!hasMoreDocuments() && !documentsLoading()) {
<p class="text-xs text-[var(--text-muted)] text-center mt-3">
{{ documents().length }} سند ثبت شده
</p>
}
@if (hasMoreDocuments() && !documentsLoading()) {
<div class="documents-pagination mt-3 text-center">
<button type="button" class="btn btn--outline" (click)="loadMoreDocuments()">
بیشتر بارگذاری
</button>
</div>
}
} @else {
@if (!documentsLoading() && !documentsError()) {
<div class="documents-empty flex flex-col items-center justify-center gap-3 py-10 text-center">
<svg class="w-10 h-10 text-[var(--text-muted)]" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
<polyline points="14 8 20 8 20 14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 a2 0 0 1 2-2h8z" />
</svg>
<p class="text-sm text-[var(--text-muted)]">هنوز سندی آپلود نشده است.</p>
</div>
}
}
}
</div>
<!-- Extraction review modal -->
@if (reviewingDocId()) {
<div class="review-backdrop" (click)="closeReview()">
<div
class="review-modal"
(click)="onReviewModalClick($event)"
role="dialog"
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)="closeReview()" 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">
@if (reviewLoading()) {
<div class="review-loading flex items-center justify-center gap-2 py-8 text-[var(--text-muted)]">
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19" />
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
</svg>
<span>در حال بارگذاری شواهد...</span>
</div>
}
@if (!reviewLoading() && reviewItems().length === 0) {
<p class="text-sm text-[var(--text-muted)]">شاهده‌ای نیازمند بازبینی یافت نشد.</p>
}
@if (!reviewLoading() && reviewItems().length > 0) {
<div class="review-items space-y-5">
@for (item of reviewItems(); track item.evidence_sha256) {
<div class="review-item border border-[var(--color-card-border)] rounded-xl p-4 bg-[var(--surface-bg)]">
<div class="review-item-header flex items-center justify-between gap-2 mb-3">
<div class="text-xs text-[var(--text-muted)]">
<span>{{ reviewKindLabel(item) }}</span>
@if (item.location; as location) {
<span>
@if (location.page != null) { صفحه {{ location.page }} }
@if (location.section) { — {{ location.section }} }
</span>
}
</div>
@if (decisionFor(item) === 'approve' && isReviewSubmittable(item)) {
<span class="text-xs text-[var(--color-success)] font-medium">تکمیل شد</span>
}
</div>
<div class="review-item-body grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="review-preview min-h-[120px] flex items-center justify-center bg-[var(--sidebar-hover)] rounded-lg overflow-hidden">
@if (previewImageUrl(item); as previewUrl) {
<img
[src]="previewUrl"
[alt]="'پیش‌نمایش صفحه ' + (item.location?.page ?? '')"
class="max-w-full max-h-48 object-contain"
loading="lazy"
/>
} @else {
<span class="text-xs text-[var(--text-muted)]">پیش‌نمایشی موجود نیست</span>
}
</div>
<div class="review-content space-y-3">
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
متن استخراج‌شده
</label>
<ul class="text-xs text-[var(--text-secondary)] space-y-1 max-h-36 overflow-y-auto pr-2">
@for (block of item.blocks; track block.block_id) {
<li class="leading-relaxed">{{ block.text }}</li>
}
</ul>
</div>
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
بررسی‌های الزامی
</label>
<ul class="space-y-1 text-xs">
@for (check of item.required_checks; track check) {
<li class="flex items-center gap-2">
<input
type="checkbox"
[id]="item.evidence_sha256 + '-' + check"
[checked]="isCheckChecked(item, check)"
(change)="toggleCheck(item, check, $any($event.target).checked)"
/>
<label [attr.for]="item.evidence_sha256 + '-' + check" class="text-[var(--text-secondary)] cursor-pointer">{{ checkLabel(check) }}</label>
</li>
}
</ul>
</div>
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
تصمیم
</label>
<div class="flex items-center gap-3 text-xs">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="radio" name="decision-{{ item.evidence_sha256 }}"
value="approve" [checked]="decisionFor(item) === 'approve'"
(change)="setDecision(item, 'approve')" />
<span class="text-[var(--text-secondary)]">تایید</span>
</label>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="radio" name="decision-{{ item.evidence_sha256 }}"
value="reject" [checked]="decisionFor(item) === 'reject'"
(change)="setDecision(item, 'reject')" />
<span class="text-[var(--text-secondary)]">رد</span>
</label>
</div>
</div>
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
یادداشت بازبینی (الزامی)
</label>
<textarea
class="form-input w-full text-xs"
rows="2"
[value]="noteFor(item)"
(input)="setNote(item, $any($event.target).value)"
placeholder="مثال: با صفحه اصلی مقایسه و تاریخ و ساعت تأیید شد."
></textarea>
</div>
@if (item.review_kind !== 'extraction') {
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
شناسه گروه‌های حذف‌شده (اختیاری)
</label>
<input
type="text"
class="form-input w-full text-xs"
[value]="excludedGroupIdsFor(item)"
(input)="setExcludedGroupIds(item, $any($event.target).value)"
placeholder="با کامای جدا کنید"
/>
</div>
}
</div>
</div>
<div class="review-item-actions flex items-center justify-end gap-2 mt-3">
<button
type="button"
class="btn btn--primary"
[disabled]="!isReviewSubmittable(item)"
(click)="submitReviewDecision(item)"
>
<span>ثبت تصمیم بازبینی</span>
</button>
</div>
</div>
}
</div>
}
</div>
<footer class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2">
@if (canRetryAfterReview()) {
<button type="button" class="btn btn--primary" (click)="finishReviewAndRetry()">
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
</svg>
<span>بستن و دوباره‌سعی پردازش</span>
</button>
}
<button type="button" class="btn btn--outline" (click)="closeReview()">
<span>بستن</span>
</button>
</footer>
</div>
</div>
}
</section>
}
@@ -244,7 +776,7 @@
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l-.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l-.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l-.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
تنظیمات کلی
@@ -252,43 +784,6 @@
</div>
<div class="settings-grid space-y-3">
<!-- <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">
<span class="text-sm font-medium text-[var(--text-secondary)]"
>زبان رابط کاربری</span
>
<span class="text-xs text-[var(--text-muted)]"
>زبان نمایش برنامه را انتخاب کنید</span
>
</div>
<div class="setting-control shrink-0">
<select
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-2 text-sm min-w-[140px] cursor-pointer transition-all duration-200 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 focus:shadow-[0_0_0_3px_var(--color-primary)/20]"
[(ngModel)]="language"
>
<option value="fa">فارسی</option>
<option value="en">English</option>
</select>
</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">
<span class="text-sm font-medium text-[var(--text-secondary)]">اعلان‌ها</span>
<span class="text-xs text-[var(--text-muted)]">دریافت اعلان‌های برنامه</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="notificationsEnabled()">
<input type="checkbox" [(ngModel)]="notificationsEnabled" />
<span class="toggle-slider"></span>
</label>
</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"
>
@@ -304,7 +799,122 @@
</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">
نیاز به تأیید ادمین برای اسناد OCR شده
</label>
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
در صورت فعال بودن، محتوای استخراج‌شده از اسناد باید توسط ادمین بازبینی و تأیید شود.
</span>
<span class="text-xs text-[var(--color-warning)] mt-0.5">پیش‌نویس — ذخیره‌سازی در فاز MVP پشتیبانی نمی‌شود</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="ocrAdminApproval()">
<input type="checkbox" [checked]="ocrAdminApproval()" (change)="toggleOcrApproval()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
</div>
<div class="mt-8">
<h3 class="text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2">
<svg class="w-5 h-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
<line x1="12" x2="12" y1="19" y2="22" />
</svg>
تنظیمات مدل‌های هوش مصنوعی
</h3>
<p class="text-xs text-[var(--text-muted)] mb-4">
هر کارت به‌صورت مستقل پیکربندی می‌شود. در فاز MVP، این تنظیمات در حافظه نگهداری می‌شوند و به سرور ارسال نمی‌شوند.
</p>
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
<app-ai-model-config-card
title="تنظیمات مدل هوش مصنوعی"
task="text"
[config]="textModelConfig()"
(configChange)="textModelConfig.set($event)"
[connected]="textModelConnected()"
(save)="saveModelConfig('text')"
(testConnection)="testModelConnection('text')"
></app-ai-model-config-card>
<app-ai-model-config-card
title="تنظیمات مدل امبدینگ"
task="embedding"
[config]="embeddingModelConfig()"
(configChange)="embeddingModelConfig.set($event)"
[connected]="embeddingModelConnected()"
(save)="saveModelConfig('embedding')"
(testConnection)="testModelConnection('embedding')"
></app-ai-model-config-card>
<app-ai-model-config-card
title="تنظیمات مدل OCR"
task="ocr"
[config]="ocrModelConfig()"
(configChange)="ocrModelConfig.set($event)"
[connected]="ocrModelConnected()"
(save)="saveModelConfig('ocr')"
(testConnection)="testModelConnection('ocr')"
></app-ai-model-config-card>
</div>
</div>
<div class="mt-8">
<h3 class="text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2">
<svg class="w-5 h-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
<line x1="12" x2="12" y1="19" y2="22" />
</svg>
تنظیمات مدل‌های داخلی
</h3>
<p class="text-xs text-[var(--text-muted)] mb-4">
مدل‌های داخلی مرکز تماس — تبدیل گفتار به نوشتار، تبدیل نوشتار به گفتار و مدل گفتگو —
هر کارت به‌صورت مستقل پیکربندی می‌شود. در فاز MVP، این تنظیمات در حافظه نگهداری می‌شوند و به
سرور ارسال نمی‌شوند.
</p>
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
<app-ai-model-config-card
title="تنظیمات مدل تبدیل گفتار به نوشتار"
task="stt"
[config]="sttModelConfig()"
(configChange)="sttModelConfig.set($event)"
[connected]="sttModelConnected()"
(save)="saveModelConfig('stt')"
(testConnection)="testModelConnection('stt')"
></app-ai-model-config-card>
<app-ai-model-config-card
title="تنظیمات مدل تبدیل نوشتار به گفتار"
task="tts"
[config]="ttsModelConfig()"
(configChange)="ttsModelConfig.set($event)"
[connected]="ttsModelConnected()"
(save)="saveModelConfig('tts')"
(testConnection)="testModelConnection('tts')"
></app-ai-model-config-card>
<app-ai-model-config-card
title="تنظیمات مدل گفتگوی داخلی"
task="dialogue"
[config]="dialogueModelConfig()"
(configChange)="dialogueModelConfig.set($event)"
[connected]="dialogueModelConnected()"
(save)="saveModelConfig('dialogue')"
(testConnection)="testModelConnection('dialogue')"
></app-ai-model-config-card>
</div>
</div>
</section>
}
</div>
File diff suppressed because it is too large Load Diff
+398
View File
@@ -0,0 +1,398 @@
.wallboard-page {
min-height: 100%;
padding: 2.25rem 3rem 3.5rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
animation: fadeIn 0.4s ease-out;
}
.wallboard-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
}
.wallboard-title-group {
display: flex;
align-items: center;
gap: 0.875rem;
}
.wallboard-title-icon {
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: 0.875rem;
background: var(--color-primary);
color: #ffffff;
flex-shrink: 0;
}
.wallboard-title {
margin: 0;
font-size: 1.5rem;
font-weight: 700;
color: var(--text-primary);
line-height: 1.3;
}
.wallboard-subtitle {
margin: 0.15rem 0 0;
font-size: 0.8125rem;
color: var(--text-muted);
}
.wallboard-header-actions {
display: flex;
align-items: center;
gap: 0.75rem;
flex-wrap: wrap;
}
.period-chip {
padding: 0.45rem 0.9rem;
border: 1px solid var(--card-border);
border-radius: 9999px;
background: var(--card-bg);
font-size: 0.75rem;
color: var(--text-secondary);
white-space: nowrap;
}
.last-updated {
font-size: 0.75rem;
color: var(--text-muted);
white-space: nowrap;
}
.refresh-btn {
display: inline-flex;
align-items: center;
gap: 0.45rem;
padding: 0.45rem 0.9rem;
border: 1px solid var(--card-border);
border-radius: 9999px;
background: var(--card-bg);
color: var(--text-secondary);
font-size: 0.75rem;
font-weight: 500;
cursor: pointer;
transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.refresh-btn:hover:not(:disabled) {
color: var(--color-primary);
border-color: var(--color-primary);
transform: translateY(-1px);
}
.refresh-btn:disabled {
opacity: 0.6;
cursor: default;
}
.refresh-icon--spinning {
animation: spin 1s linear infinite;
}
/* ---- KPI tiles ---- */
.kpi-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 1.25rem;
}
.kpi-card {
position: relative;
display: flex;
flex-direction: column;
gap: 0.4rem;
padding: 1.1rem 1.25rem 1.15rem;
border: 1px solid var(--card-border);
border-radius: 1.25rem;
background: var(--card-bg);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.03);
overflow: hidden;
animation: fadeInUp 0.5s ease-out both;
}
.kpi-card::before {
content: '';
position: absolute;
inset-block-start: 0;
inset-inline: 0;
height: 3px;
background: var(--kpi-color, var(--color-primary));
}
.kpi-card:nth-child(1) { animation-delay: 0.03s; }
.kpi-card:nth-child(2) { animation-delay: 0.06s; }
.kpi-card:nth-child(3) { animation-delay: 0.09s; }
.kpi-card:nth-child(4) { animation-delay: 0.12s; }
.kpi-card:nth-child(5) { animation-delay: 0.15s; }
.kpi-card-top {
display: flex;
align-items: center;
gap: 0.6rem;
}
.kpi-icon {
display: flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
border-radius: 0.7rem;
background: var(--kpi-color, var(--color-primary));
color: #ffffff;
flex-shrink: 0;
}
.kpi-label {
margin: 0;
font-size: 0.8125rem;
font-weight: 500;
color: var(--text-secondary);
line-height: 1.5;
}
.kpi-value {
font-size: 1.75rem;
font-weight: 700;
color: var(--text-primary);
line-height: 1.2;
}
.kpi-progress {
height: 6px;
border-radius: 9999px;
background: var(--stat-progress-bg, rgba(100, 116, 139, 0.16));
overflow: hidden;
}
.kpi-progress-fill {
display: block;
height: 100%;
border-radius: 9999px;
background: var(--kpi-color, var(--color-primary));
transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.kpi-hint {
font-size: 0.6875rem;
color: var(--text-muted);
line-height: 1.6;
}
/* ---- charts ---- */
.charts-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1.25rem;
}
.report-card {
padding: 1.25rem 1.4rem;
border: 1px solid var(--card-border);
border-radius: 1.25rem;
background: var(--card-bg);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.03);
animation: fadeInUp 0.5s ease-out both;
}
.card-header {
margin-bottom: 1.1rem;
}
.card-title {
margin: 0;
font-size: 1.0625rem;
font-weight: 600;
color: var(--text-primary);
}
.card-description {
margin: 0.2rem 0 0;
font-size: 0.75rem;
color: var(--text-muted);
line-height: 1.7;
}
.chart-peak {
display: inline-block;
margin-inline-start: 0.35rem;
color: var(--text-secondary);
}
/* ---- states ---- */
.error-card {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 3rem 1.5rem;
text-align: center;
color: var(--text-muted);
}
.error-card h2 {
margin: 0.5rem 0 0;
font-size: 1.0625rem;
font-weight: 600;
color: var(--text-primary);
}
.error-card p {
margin: 0;
font-size: 0.8125rem;
}
.retry-btn {
margin-top: 0.75rem;
padding: 0.55rem 1.5rem;
border: none;
border-radius: 0.75rem;
background: var(--color-primary);
color: #ffffff;
font-size: 0.8125rem;
font-weight: 500;
cursor: pointer;
transition: opacity 0.2s ease, transform 0.2s ease;
}
.retry-btn:hover {
opacity: 0.9;
transform: translateY(-1px);
}
.skeleton-card {
min-height: 148px;
}
.skeleton {
border-radius: 0.5rem;
background: linear-gradient(
90deg,
var(--stat-progress-bg, rgba(100, 116, 139, 0.12)) 25%,
rgba(100, 116, 139, 0.05) 37%,
var(--stat-progress-bg, rgba(100, 116, 139, 0.12)) 63%
);
background-size: 400% 100%;
animation: skeletonShimmer 1.4s ease infinite;
}
.skeleton-title {
width: 45%;
height: 0.875rem;
}
.skeleton-value {
width: 35%;
height: 2rem;
margin-top: 0.75rem;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(16px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes skeletonShimmer {
from {
background-position: 100% 50%;
}
to {
background-position: 0 50%;
}
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.kpi-card,
.report-card,
.skeleton,
.refresh-icon--spinning {
animation: none;
}
}
@media (max-width: 1400px) {
.wallboard-page {
padding: 1.75rem 2rem 3rem;
}
.kpi-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (max-width: 1024px) {
.wallboard-page {
padding: 1.5rem 1.75rem 2.75rem;
}
.kpi-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.charts-grid {
grid-template-columns: minmax(0, 1fr);
}
}
@media (max-width: 640px) {
.wallboard-page {
padding: 1.25rem 1.25rem 2.25rem;
}
.kpi-grid {
grid-template-columns: minmax(0, 1fr);
}
.wallboard-header-actions {
width: 100%;
}
}
:host-context([data-bs-theme='dark']) .report-card,
:host-context([data-bs-theme='dark']) .kpi-card {
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.2);
}
:host-context([data-bs-theme='dark']) .kpi-progress {
background: rgba(148, 163, 184, 0.2);
}
:host-context([data-bs-theme='dark']) .skeleton {
background: linear-gradient(90deg, rgba(148, 163, 184, 0.14) 25%, rgba(148, 163, 184, 0.05) 37%, rgba(148, 163, 184, 0.14) 63%);
background-size: 400% 100%;
}
+159
View File
@@ -0,0 +1,159 @@
<div class="wallboard-page">
<header class="wallboard-header">
<div class="wallboard-title-group">
<span class="wallboard-title-icon">
<svg
width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M2 4h20v12H2zM8 20h8M12 16v4" />
</svg>
</span>
<div>
<h1 class="wallboard-title">والبورد</h1>
<p class="wallboard-subtitle">نمای یک‌نگاه فعالیت مرکز تماس مبتنی بر هوش مصنوعی</p>
</div>
</div>
<div class="wallboard-header-actions">
@if (periodLabel()) {
<span class="period-chip">بازه گزارش: {{ periodLabel() }}</span>
}
<span class="last-updated">آخرین به‌روزرسانی: {{ lastUpdated() }}</span>
<button type="button" class="refresh-btn" (click)="refresh()" [disabled]="loading()">
<svg
class="refresh-icon"
[class.refresh-icon--spinning]="loading()"
width="15"
height="15"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
</svg>
<span>به‌روزرسانی</span>
</button>
</div>
</header>
@if (loading()) {
<div class="kpi-grid">
@for (card of [1, 2, 3, 4, 5]; track card) {
<div class="kpi-card skeleton-card">
<div class="skeleton skeleton-title"></div>
<div class="skeleton skeleton-value"></div>
</div>
}
</div>
} @else if (loadError()) {
<div class="report-card error-card" role="alert">
<svg
width="40"
height="40"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</svg>
<h2>دریافت اطلاعات والبرد ممکن نشد</h2>
<p>ارتباط با سرور برقرار نشد. لطفاً دوباره تلاش کنید.</p>
<button type="button" class="retry-btn" (click)="retry()">تلاش مجدد</button>
</div>
} @else if (data(); as view) {
<section class="kpi-grid" aria-label="شاخص‌های کلیدی والبرد">
@for (kpi of kpis(); track kpi.id) {
<article class="kpi-card" [style.--kpi-color]="kpi.color">
<div class="kpi-card-top">
<span class="kpi-icon" aria-hidden="true">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path [attr.d]="kpi.icon" />
</svg>
</span>
<h2 class="kpi-label">{{ kpi.label }}</h2>
</div>
<strong class="kpi-value">{{ kpi.value }}</strong>
@if (kpi.progress !== null) {
<div class="kpi-progress" aria-hidden="true">
<span class="kpi-progress-fill" [style.width.%]="kpi.progress"></span>
</div>
}
<span class="kpi-hint">{{ kpi.hint }}</span>
</article>
}
</section>
<div class="charts-grid">
<section class="report-card chart-card">
<div class="card-header">
<h2 class="card-title">هوش مصنوعی در مقابل کارشناس</h2>
<p class="card-description">
سهم هر روش پاسخ‌گویی از کل {{ formatCount(view.kpis.totalCalls) }} تماس در
{{ view.kpis.periodLabel }}
</p>
</div>
<app-doughnut-chart
[segments]="outcomes()"
centerLabel="کل تماس‌ها"
ariaLabel="نمودار دایره‌ای سهم روش‌های پاسخ‌گویی به تماس‌ها"
/>
</section>
<section class="report-card chart-card">
<div class="card-header">
<h2 class="card-title">توزیع تماس‌ها در ساعات روز</h2>
<p class="card-description">
حجم تماس‌ها در بازه‌های دو ساعته
@if (busiestHour(); as peak) {
<span class="chart-peak">پرفشارترین بازه: {{ peak.label }}</span>
}
</p>
</div>
<app-bar-chart
[items]="hourly()"
valueSuffix=" تماس"
ariaLabel="نمودار میله‌ای توزیع تماس‌ها در ساعات روز"
/>
</section>
</div>
<section class="report-card chart-card chart-card--wide">
<div class="card-header">
<h2 class="card-title">روند فعالیت تماس‌ها</h2>
<p class="card-description">
تغییرات حجم کل تماس‌ها در ۱۴ روز گذشته — روی نمودار بر روی هر نقطه بایست تا جزئیات آن روز
را ببینید.
</p>
</div>
<app-line-chart
[points]="activity()"
seriesLabel="تعداد تماس‌ها"
gradientId="wallboardCallActivity"
ariaLabel="نمودار خطی روند فعالیت تماس‌ها در گذر زمان"
/>
</section>
}
</div>
@@ -0,0 +1,74 @@
import { TestBed } from '@angular/core/testing';
import { provideZonelessChangeDetection } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideHttpClient } from '@angular/common/http';
import { provideRouter } from '@angular/router';
import { TOAST_CONFIG, DefaultGlobalConfig } from 'ngx-toastr';
import { WallboardPage } from './wallboard.page';
describe('WallboardPage', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [WallboardPage],
providers: [
provideZonelessChangeDetection(),
provideHttpClient(),
provideRouter([]),
provideAnimations(),
{ provide: TOAST_CONFIG, useValue: { default: DefaultGlobalConfig, config: {} } },
],
}).compileComponents();
});
function titles(fixture: { nativeElement: HTMLElement }): (string | undefined)[] {
return Array.from(fixture.nativeElement.querySelectorAll('.card-title')).map((node) =>
node.textContent?.trim(),
);
}
it('should create the page', () => {
const fixture = TestBed.createComponent(WallboardPage);
expect(fixture.componentInstance).toBeTruthy();
});
it('renders the five wallboard KPIs with Persian values', () => {
const fixture = TestBed.createComponent(WallboardPage);
fixture.detectChanges();
const element: HTMLElement = fixture.nativeElement;
expect(element.querySelector('.wallboard-title')?.textContent?.trim()).toBe('والبورد');
const labels = Array.from(element.querySelectorAll('.kpi-label')).map((node) =>
node.textContent?.trim(),
);
expect(labels).toEqual([
'تعداد کل تماس‌ها',
'تعداد تماس با هوش مصنوعی',
'میانگین زمان صحبت با هوش مصنوعی',
'تعداد تماس موفق با هوش مصنوعی',
'تعداد تماس با کارشناس بعد از هوش مصنوعی',
]);
const values = Array.from(element.querySelectorAll('.kpi-value')).map((node) =>
node.textContent?.trim(),
);
expect(values).toEqual(['۱۲,۸۴۶', '۸,۴۱۲', '۲:۲۲', '۷,۱۵۶', '۱,۲۵۶']);
expect(element.querySelectorAll('.kpi-card').length).toBe(5);
expect(element.textContent).toContain('۶۵٪ از کل تماس‌ها');
});
it('renders the wallboard charts', () => {
const fixture = TestBed.createComponent(WallboardPage);
fixture.detectChanges();
const element: HTMLElement = fixture.nativeElement;
expect(titles(fixture)).toEqual([
'هوش مصنوعی در مقابل کارشناس',
'توزیع تماس‌ها در ساعات روز',
'روند فعالیت تماس‌ها',
]);
expect(element.querySelector('app-doughnut-chart')).toBeTruthy();
expect(element.querySelector('app-bar-chart')).toBeTruthy();
expect(element.querySelector('app-line-chart')).toBeTruthy();
});
});
+193
View File
@@ -0,0 +1,193 @@
import { ChangeDetectionStrategy, Component, computed, inject, signal, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { forkJoin } from 'rxjs';
import { WallboardService } from '../../services/wallboard/wallboard.service';
import { WallboardView } from '../../services/wallboard/wallboard.types';
import { BarChartComponent, BarChartItem } from '../../shared/ui/charts/bar-chart.component';
import { DoughnutChartComponent, DoughnutSegment } from '../../shared/ui/charts/doughnut-chart.component';
import { LineChartComponent, LinePoint } from '../../shared/ui/charts/line-chart.component';
import { CHART_COLORS, CHART_PALETTE } from '../../shared/utils/chart-palette';
import { formatCount, formatPercent, toPersianDigits } from '../../shared/utils/format.util';
/** One KPI tile on the wallboard; rendering stays fully data-driven. */
export interface WallboardKpiCard {
id: string;
label: string;
value: string;
hint: string;
icon: string;
color: string;
/** Share of the related total (0–100) rendered as a progress bar; null hides it. */
progress: number | null;
}
@Component({
selector: 'app-wallboard',
standalone: true,
imports: [CommonModule, BarChartComponent, DoughnutChartComponent, LineChartComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './wallboard.page.html',
styleUrl: './wallboard.page.css',
})
export class WallboardPage implements OnInit {
private readonly wallboard = inject(WallboardService);
readonly loading = signal(true);
readonly loadError = signal(false);
readonly data = signal<WallboardView | null>(null);
readonly lastUpdated = signal<string>('—');
readonly kpis = computed<WallboardKpiCard[]>(() => {
const view = this.data();
if (!view) {
return [];
}
return this.buildKpiCards(view);
});
readonly periodLabel = computed(() => this.data()?.kpis.periodLabel ?? '');
readonly outcomes = computed<DoughnutSegment[]>(() => {
const outcomes = this.data()?.outcomes ?? [];
return outcomes.map((outcome, index) => ({
label: outcome.label,
value: outcome.value,
color: CHART_PALETTE[index % CHART_PALETTE.length],
}));
});
readonly activity = computed<LinePoint[]>(() => {
const points = this.data()?.activity ?? [];
return points.map((point) => ({ label: point.label, value: point.count }));
});
readonly hourly = computed<BarChartItem[]>(() => {
const buckets = this.data()?.hourly ?? [];
return buckets.map((bucket) => ({
label: bucket.label,
value: bucket.count,
color: CHART_COLORS.primary,
}));
});
readonly busiestHour = computed(() => {
const buckets = this.data()?.hourly ?? [];
if (buckets.length === 0) {
return null;
}
return buckets.reduce((peak, bucket) => (bucket.count > peak.count ? bucket : peak), buckets[0]);
});
ngOnInit(): void {
this.load();
}
load(): void {
this.loading.set(true);
this.loadError.set(false);
forkJoin({
kpis: this.wallboard.getKpis(),
outcomes: this.wallboard.getOutcomes(),
activity: this.wallboard.getActivity(),
hourly: this.wallboard.getHourlyDistribution(),
}).subscribe({
next: (data) => {
this.data.set(data);
this.loading.set(false);
this.lastUpdated.set(this.formatClock(new Date()));
},
error: () => {
this.data.set(null);
this.loading.set(false);
this.loadError.set(true);
},
});
}
retry(): void {
this.load();
}
refresh(): void {
this.load();
}
/** KPI tiles in display order, each with its own icon, accent colour and share bar. */
private buildKpiCards(view: WallboardView): WallboardKpiCard[] {
const { kpis } = view;
const aiShare = kpis.totalCalls > 0 ? (kpis.aiCalls / kpis.totalCalls) * 100 : 0;
const successRate = kpis.aiCalls > 0 ? (kpis.successfulAiCalls / kpis.aiCalls) * 100 : 0;
const transferRate = kpis.aiCalls > 0 ? (kpis.transferredToAgentCalls / kpis.aiCalls) * 100 : 0;
return [
{
id: 'total-calls',
label: 'تعداد کل تماس‌ها',
value: formatCount(kpis.totalCalls),
hint: `کل تماس‌های دریافتی در ${kpis.periodLabel}`,
icon: 'M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z',
color: CHART_COLORS.primary,
progress: null,
},
{
id: 'ai-calls',
label: 'تعداد تماس با هوش مصنوعی',
value: formatCount(kpis.aiCalls),
hint: `${formatPercent(aiShare)} از کل تماس‌ها`,
icon: 'M12 3l1.9 5.8a2 2 0 0 0 1.3 1.3L21 12l-5.8 1.9a2 2 0 0 0-1.3 1.3L12 21l-1.9-5.8a2 2 0 0 0-1.3-1.3L3 12l5.8-1.9a2 2 0 0 0 1.3-1.3z',
color: CHART_COLORS.ai,
progress: aiShare,
},
{
id: 'avg-ai-talk',
label: 'میانگین زمان صحبت با هوش مصنوعی',
value: this.formatDuration(kpis.avgAiTalkSeconds),
hint: `دقیقه و ثانیه — میانگین روی ${formatCount(kpis.aiCalls)} تماس`,
icon: 'M3.34 19a10 10 0 1 1 17.32 0M12 14l4-4',
color: CHART_COLORS.info,
progress: null,
},
{
id: 'successful-ai-calls',
label: 'تعداد تماس موفق با هوش مصنوعی',
value: formatCount(kpis.successfulAiCalls),
hint: `${formatPercent(successRate)} از تماس‌های هوش مصنوعی`,
icon: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M8.5 12.5l2.5 2.5 4.5-5',
color: CHART_COLORS.success,
progress: successRate,
},
{
id: 'transferred-to-agent',
label: 'تعداد تماس با کارشناس بعد از هوش مصنوعی',
value: formatCount(kpis.transferredToAgentCalls),
hint: `${formatPercent(transferRate)} از تماس‌های هوش مصنوعی`,
icon: 'M8 3 4 7l4 4M4 7h16M16 21l4-4-4-4M20 17H4',
color: CHART_COLORS.warning,
progress: transferRate,
},
];
}
/** 142 -> «۲:۲۲» (دقیقه:ثانیه) */
formatDuration(totalSeconds: number): string {
const minutes = Math.floor(totalSeconds / 60);
const seconds = Math.round(totalSeconds % 60);
return toPersianDigits(`${minutes}:${String(seconds).padStart(2, '0')}`);
}
formatCount(value: number): string {
return formatCount(value);
}
formatPercent(value: number): string {
return formatPercent(value);
}
private formatClock(date: Date): string {
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
return toPersianDigits(`${hours}:${minutes}`);
}
}