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:
@@ -11,8 +11,8 @@
|
||||
transition: min-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
/* Height of the voice view; the wrapper animates to it so the page never jumps. */
|
||||
.ai-chat-input-wrapper.voice-active {
|
||||
/* Height of the dictation view; the wrapper animates to it so the page never jumps. */
|
||||
.ai-chat-input-wrapper.dictation-active {
|
||||
min-height: 460px;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,20 @@
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
transform: translateY(10px) scale(0.98);
|
||||
/* Never blocks the transcript underneath; the dictation view re-enables it. */
|
||||
pointer-events: none;
|
||||
/* The layer is inset:0 of a collapsed wrapper while dictation is not running, so the
|
||||
dictation view inside it would overflow its box and add phantom height to the page
|
||||
(visible as a gap under the composer + a Y scroll). Clipping keeps it out of layout.
|
||||
It stays in the DOM (display is untouched) so the viewChild refs stay valid. */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ai-chat-input-wrapper.voice-active .composer-layer {
|
||||
/* Out of the flow so the voice view takes the full height while it runs. */
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
pointer-events: none;
|
||||
@@ -45,8 +55,8 @@
|
||||
.ai-chat-input-wrapper.voice-active .voice-layer {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
:host-context(.has-messages) {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
@@ -118,6 +128,7 @@
|
||||
}
|
||||
.composer-textarea::-webkit-scrollbar-thumb {
|
||||
background: var(--muted);
|
||||
border: none;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
@@ -307,6 +318,8 @@
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 1.5rem;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
|
||||
/* Re-enabled on the view itself; the layer stays click-through for the transcript. */
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.orb-container {
|
||||
@@ -509,7 +522,7 @@
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.ai-chat-input-wrapper.voice-active {
|
||||
.ai-chat-input-wrapper.dictation-active {
|
||||
min-height: 410px;
|
||||
}
|
||||
|
||||
@@ -554,11 +567,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Live voice call (taller view for the running transcript) ---------- */
|
||||
.ai-chat-input-wrapper.stream-active {
|
||||
min-height: min(580px, 78vh);
|
||||
}
|
||||
|
||||
/* ---------- Send icon ---------- */
|
||||
.send-btn svg {
|
||||
animation: sendIconIn 0.18s ease;
|
||||
}
|
||||
@@ -578,10 +587,4 @@
|
||||
.send-btn svg {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.ai-chat-input-wrapper.stream-active {
|
||||
min-height: min(540px, 80vh);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<div
|
||||
class="ai-chat-input-wrapper"
|
||||
[class.voice-active]="anyVoiceActive()"
|
||||
[class.stream-active]="streamOpen()"
|
||||
[class.dictation-active]="isVoiceMode()"
|
||||
[attr.data-voice-state]="voiceState()"
|
||||
(keydown.escape)="onEscape()"
|
||||
>
|
||||
@@ -153,60 +153,58 @@
|
||||
[attr.inert]="anyVoiceActive() ? null : ''"
|
||||
[attr.aria-hidden]="anyVoiceActive() ? null : 'true'"
|
||||
>
|
||||
@if (layerMode() === 'stream') {
|
||||
<app-voice-stream-panel />
|
||||
} @else {
|
||||
<div class="voice-mode" role="region" aria-label="حالت صوتی">
|
||||
<div class="orb-container" #orbContainer aria-hidden="true">
|
||||
@if (!orbAvailable()) {
|
||||
<div class="orb-fallback"></div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="voice-status" [class.is-speaking]="voiceState() === 'transcribing'">
|
||||
<span class="rec-dot" aria-hidden="true"></span>
|
||||
<p class="voice-mode-text">{{ statusText() }}</p>
|
||||
</div>
|
||||
|
||||
<div class="voice-transcript" #transcript dir="rtl">
|
||||
@if (liveFinal() || liveInterim()) {
|
||||
<span class="t-final">{{ liveFinal() }}</span>
|
||||
@if (liveInterim()) {
|
||||
<span class="t-interim"> {{ liveInterim() }}</span>
|
||||
@if (!streamOpen()) {
|
||||
<div class="voice-mode" role="region" aria-label="حالت صوتی">
|
||||
<div class="orb-container" #orbContainer aria-hidden="true">
|
||||
@if (!orbAvailable()) {
|
||||
<div class="orb-fallback"></div>
|
||||
}
|
||||
} @else {
|
||||
<span class="t-placeholder">صحبت کنید؛ متن اینجا نمایش داده میشود</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="voice-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="voice-stop-btn is-primary"
|
||||
[disabled]="voiceState() === 'stopping'"
|
||||
(click)="stopVoice(true)"
|
||||
aria-label="پایان ضبط و ویرایش متن"
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<rect x="6" y="6" width="12" height="12" rx="2" />
|
||||
</svg>
|
||||
<span>پایان و ویرایش</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="voice-stop-btn"
|
||||
[disabled]="voiceState() === 'stopping'"
|
||||
(click)="stopVoice(false)"
|
||||
aria-label="لغو ضبط و حذف متن گفتاری"
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<line x1="18" x2="6" y1="6" y2="18" />
|
||||
<line x1="6" x2="18" y1="6" y2="18" />
|
||||
</svg>
|
||||
<span>لغو</span>
|
||||
</button>
|
||||
<div class="voice-status" [class.is-speaking]="voiceState() === 'transcribing'">
|
||||
<span class="rec-dot" aria-hidden="true"></span>
|
||||
<p class="voice-mode-text">{{ statusText() }}</p>
|
||||
</div>
|
||||
|
||||
<div class="voice-transcript" #transcript dir="rtl">
|
||||
@if (liveFinal() || liveInterim()) {
|
||||
<span class="t-final">{{ liveFinal() }}</span>
|
||||
@if (liveInterim()) {
|
||||
<span class="t-interim"> {{ liveInterim() }}</span>
|
||||
}
|
||||
} @else {
|
||||
<span class="t-placeholder">صحبت کنید؛ متن اینجا نمایش داده میشود</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="voice-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="voice-stop-btn is-primary"
|
||||
[disabled]="voiceState() === 'stopping'"
|
||||
(click)="stopVoice(true)"
|
||||
aria-label="پایان ضبط و ویرایش متن"
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<rect x="6" y="6" width="12" height="12" rx="2" />
|
||||
</svg>
|
||||
<span>پایان و ویرایش</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="voice-stop-btn"
|
||||
[disabled]="voiceState() === 'stopping'"
|
||||
(click)="stopVoice(false)"
|
||||
aria-label="لغو ضبط و حذف متن گفتاری"
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<line x1="18" x2="6" y1="6" y2="18" />
|
||||
<line x1="6" x2="18" y1="6" y2="18" />
|
||||
</svg>
|
||||
<span>لغو</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
import { VoiceOrbService } from '../../../services/voice-orb/voice-orb.service';
|
||||
import { VoiceStreamService } from '../../../services/voice-stream/voice-stream.service';
|
||||
import { VoiceMessage } from '../../../services/voice-stream/voice-stream.types';
|
||||
import { VoiceStreamPanelComponent } from '../voice-stream-panel/voice-stream-panel.component';
|
||||
|
||||
export type VoiceState =
|
||||
| 'idle'
|
||||
@@ -53,8 +52,6 @@ export const DEFAULT_ATTACHMENT_ACTIONS: readonly AttachmentAction[] = [
|
||||
];
|
||||
|
||||
const NOTICE_TIMEOUT_MS = 7000;
|
||||
/** Keeps the previous voice view mounted while the layer fades out (matches the 0.35 s CSS fade). */
|
||||
const LAYER_SWAP_MS = 400;
|
||||
|
||||
const MIC_ERRORS: Record<string, string> = {
|
||||
unsupported: 'مرورگر شما از دسترسی به میکروفون پشتیبانی نمیکند (اتصال امن HTTPS لازم است).',
|
||||
@@ -76,7 +73,6 @@ const SPEECH_ERRORS: Record<SpeechErrorKind, string> = {
|
||||
@Component({
|
||||
selector: 'app-ai-chat-input',
|
||||
standalone: true,
|
||||
imports: [VoiceStreamPanelComponent],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './ai-chat-input.component.html',
|
||||
styleUrl: './ai-chat-input.component.css',
|
||||
@@ -114,8 +110,6 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
|
||||
// Live voice call (voice-to-voice stream)
|
||||
readonly streamOpen = this.voiceStream.isOpen;
|
||||
/** Which view the voice layer shows; swapped after the fade so nothing flashes. */
|
||||
readonly layerMode = signal<'dictation' | 'stream'>('dictation');
|
||||
readonly canSend = computed(() => !!this.message().trim());
|
||||
readonly anyVoiceActive = computed(() => this.isVoiceMode() || this.streamOpen());
|
||||
readonly actionLabel = computed(() => (this.canSend() ? 'ارسال پیام' : 'شروع گفتگوی صوتی'));
|
||||
@@ -173,7 +167,6 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
/** Textarea content when recording started; dictated text is appended to it. */
|
||||
private baseText = '';
|
||||
private noticeTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
private layerTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
constructor() {
|
||||
// The outside-click listener only exists while the menu is open.
|
||||
@@ -193,7 +186,6 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
this.voiceToggled.emit(false);
|
||||
this.voiceSessionEnded.emit(messages);
|
||||
if (error) this.showNotice({ kind: 'error', text: error });
|
||||
this.scheduleLayerReset();
|
||||
this.focusTextarea();
|
||||
});
|
||||
}
|
||||
@@ -204,7 +196,6 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
this.mic.release();
|
||||
this.voiceStream.dispose();
|
||||
this.voiceOrb.dispose();
|
||||
if (this.layerTimer) clearTimeout(this.layerTimer);
|
||||
this.clearNoticeTimer();
|
||||
}
|
||||
|
||||
@@ -351,36 +342,18 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
|
||||
this.dismissNotice();
|
||||
this.closeAttachmentMenu();
|
||||
this.cancelLayerReset();
|
||||
this.layerMode.set('stream');
|
||||
this.voiceToggled.emit(true);
|
||||
|
||||
const result = await this.voiceStream.start();
|
||||
if (!result.ok) {
|
||||
// The call never connected, so no sessionEnded event is emitted for it.
|
||||
this.voiceToggled.emit(false);
|
||||
this.scheduleLayerReset();
|
||||
if (result.reason !== 'cancelled') {
|
||||
this.showNotice({ kind: 'error', text: result.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private scheduleLayerReset(): void {
|
||||
this.cancelLayerReset();
|
||||
this.layerTimer = setTimeout(() => {
|
||||
this.layerTimer = null;
|
||||
if (!this.streamOpen()) this.layerMode.set('dictation');
|
||||
}, LAYER_SWAP_MS);
|
||||
}
|
||||
|
||||
private cancelLayerReset(): void {
|
||||
if (this.layerTimer) {
|
||||
clearTimeout(this.layerTimer);
|
||||
this.layerTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- voice: start ---------------------------------------------------------
|
||||
|
||||
async toggleVoiceMode(): Promise<void> {
|
||||
@@ -403,8 +376,6 @@ export class AiChatInputComponent implements OnDestroy {
|
||||
private async startVoice(): Promise<void> {
|
||||
if (this.disabled() || this.streamOpen()) return;
|
||||
|
||||
this.cancelLayerReset();
|
||||
this.layerMode.set('dictation');
|
||||
this.dismissNotice();
|
||||
this.closeAttachmentMenu();
|
||||
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
.ai-model-card {
|
||||
animation: fadeInUp 0.4s ease-out;
|
||||
}
|
||||
|
||||
.ai-model-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.25rem 0.75rem;
|
||||
border-bottom: 1px solid var(--surface-border);
|
||||
}
|
||||
|
||||
.ai-model-badge {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
padding: 0.15rem 0.55rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--color-warning)/15;
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.ai-model-badge.ai-model-badge--connected {
|
||||
background: var(--color-success)/15;
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
.ai-model-body {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.form-required {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.form-hint {
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.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");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 0.75rem center;
|
||||
padding-right: 2.5rem;
|
||||
padding-left: 0.75rem;
|
||||
background-color: var(--color-input-bg);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--color-input-border);
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.form-select:focus {
|
||||
box-shadow: 0 0 0 3px var(--color-primary)/20;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.form-visibility-toggle {
|
||||
position: absolute;
|
||||
inset-inline-start: 0.5rem;
|
||||
top: 50%;
|
||||
translate: 0 -50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
border-radius: 0.375rem;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.form-visibility-toggle:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.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: #fff;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
:host-context([data-bs-theme="dark"]) .btn--outline:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--color-primary) 30%, #171717);
|
||||
}
|
||||
|
||||
.ai-model-actions {
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ai-model-card,
|
||||
.ai-model-card-header {
|
||||
animation-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
export type AiProvider = 'openai' | 'gemini' | 'local';
|
||||
export type AiTask = 'text' | 'embedding' | 'ocr' | 'stt' | 'tts' | 'dialogue';
|
||||
|
||||
export interface AiModelConfig {
|
||||
provider: AiProvider;
|
||||
model: string;
|
||||
apiKey: string;
|
||||
apiKeyVisible: boolean;
|
||||
serviceUrl: string;
|
||||
}
|
||||
|
||||
interface ProviderOption {
|
||||
value: AiProvider;
|
||||
label: string;
|
||||
needsApiKey: boolean;
|
||||
}
|
||||
|
||||
interface ModelOption {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reusable, self-contained configuration card for one AI model class (text /
|
||||
* embedding / OCR). All state lives in the parent (passed in as a signal-backed
|
||||
* config object + `@Output`); this component is intentionally "dumb": it emits
|
||||
* every user change so three instances stay fully independent, and it never
|
||||
* pretends to persist anything — there is no documented backend for model
|
||||
* configuration, so the Save / Test buttons surface a clear "not connected"
|
||||
* status instead of simulating success.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-ai-model-config-card',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
<div class="ai-model-card settings-card">
|
||||
<header class="ai-model-card-header">
|
||||
<h3 class="text-base font-medium text-[var(--text-primary)]">{{ title() }}</h3>
|
||||
<span class="ai-model-badge" [class.ai-model-badge--connected]="connected()"
|
||||
>{{ connected() ? 'متصل' : 'متصل نشده' }}</span>
|
||||
</header>
|
||||
|
||||
<div class="ai-model-body space-y-4">
|
||||
<!-- Provider -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">ارائهدهنده</label>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().provider"
|
||||
(change)="onProviderChange($any($event.target).value)"
|
||||
>
|
||||
@for (provider of providers(); track provider.value) {
|
||||
<option [value]="provider.value">{{ provider.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Model -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">مدل</label>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().model"
|
||||
(change)="onModelChange($any($event.target).value)"
|
||||
>
|
||||
@for (model of modelsForProvider(); track model.value) {
|
||||
<option [value]="model.value">{{ model.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- API key -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">
|
||||
کلید API
|
||||
@if (apiKeyRequired()) { <span class="form-required" aria-hidden="true">*</span> }
|
||||
</label>
|
||||
<div class="relative">
|
||||
<input
|
||||
[type]="config().apiKeyVisible ? 'text' : 'password'"
|
||||
class="form-input w-full pe-10"
|
||||
[placeholder]="apiKeyPlaceholder()"
|
||||
[value]="config().apiKey"
|
||||
(input)="onApiKeyChange($any($event.target).value)"
|
||||
autocomplete="off"
|
||||
[attr.aria-label]="apiKeyAriaLabel()"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="form-visibility-toggle"
|
||||
[attr.aria-label]="config().apiKeyVisible ? 'پنهان کن' : 'نمایش بده'"
|
||||
(click)="toggleApiKeyVisibility()"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
@if (config().apiKeyVisible) {
|
||||
<path d="M1 1l22 22M10.5 10.5A2.5 2.5 0 0 0 13.5 13.5M9.9 9.9L4.15 18.5A9.92 9.92 0 0 1 1 12 11.5 11.5 0 0 1 9.9 9.9Zm10.2 10.2A11.5 11.5 0 0 0 23 12a11.5 11.5 0 0 1-3.35-7.75l2.1-2.1A11.33 11.33 0 0 1 23 12a11.5 11.5 0 0 0-3.35 7.75Z" />
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<line x1="1" y1="1" x2="23" y2="23" />
|
||||
} @else {
|
||||
<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<line x1="12" y1="1" x2="12" y2="12.01" />
|
||||
}
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-hint">
|
||||
@if (connected() && config().apiKey) {
|
||||
<span class="text-[var(--text-muted)]">تنظیم شده — مقدار فعلی نمایش داده نمیشود</span>
|
||||
} @else {
|
||||
<span class="text-[var(--text-muted)]">کلید در حافظه نگهداری میشود و ذخیره نمیشود</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Service URL -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">آدرس سرویس</label>
|
||||
<input
|
||||
type="url"
|
||||
class="form-input w-full"
|
||||
[value]="config().serviceUrl"
|
||||
(input)="onServiceUrlChange($any($event.target).value)"
|
||||
[disabled]="!serviceUrlEditable()"
|
||||
[attr.aria-label]="'آدرس سرویس ' + title()"
|
||||
/>
|
||||
@if (!serviceUrlEditable()) {
|
||||
<span class="text-[var(--text-muted)] mt-1 text-xs">آدرس استاندارد {{ config().provider === 'local' ? 'سرویس محلی' : 'سرویس' }} بهصورت پیشفرض به کار میرود</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="ai-model-actions flex gap-2 pt-2">
|
||||
<button type="button" class="btn btn--primary flex-1" (click)="save.emit()">ذخیره تنظیمات</button>
|
||||
<button type="button" class="btn btn--outline flex-1" (click)="testConnection.emit()">بررسی اتصال</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
styleUrl: './ai-model-config-card.component.css',
|
||||
})
|
||||
export class AiModelConfigCardComponent {
|
||||
readonly title = input.required<string>();
|
||||
readonly task = input.required<AiTask>();
|
||||
readonly config = input.required<AiModelConfig>();
|
||||
/** True when a provider API key has genuinely been persisted by the backend. */
|
||||
readonly connected = input<boolean>(false);
|
||||
|
||||
readonly configChange = output<AiModelConfig>();
|
||||
readonly save = output<void>();
|
||||
readonly testConnection = output<void>();
|
||||
|
||||
readonly providers = computed(() => PROVIDERS_BY_TASK[this.task()]);
|
||||
|
||||
readonly modelsForProvider = computed(() => {
|
||||
const models = MODELS_BY_TASK[this.task()]?.[this.config().provider];
|
||||
return models ?? [{ value: '', label: 'مدلی یافت نشد' }];
|
||||
});
|
||||
|
||||
readonly apiKeyRequired = computed(() => PROVIDERS[this.config().provider]?.needsApiKey ?? false);
|
||||
|
||||
readonly serviceUrlEditable = computed(() => this.config().provider === 'local');
|
||||
|
||||
private emitChange(patch: Partial<AiModelConfig>): void {
|
||||
this.configChange.emit({ ...this.config(), ...patch });
|
||||
}
|
||||
|
||||
onProviderChange(value: string): void {
|
||||
const next = value as AiProvider;
|
||||
const defaults = DEFAULT_CONFIG_FOR[next];
|
||||
this.emitChange({
|
||||
provider: next,
|
||||
model: defaults.model,
|
||||
serviceUrl: defaults.serviceUrl,
|
||||
});
|
||||
}
|
||||
|
||||
onModelChange(value: string): void {
|
||||
this.emitChange({ model: value });
|
||||
}
|
||||
|
||||
onApiKeyChange(value: string): void {
|
||||
this.emitChange({ apiKey: value, apiKeyVisible: this.config().apiKeyVisible });
|
||||
}
|
||||
|
||||
toggleApiKeyVisibility(): void {
|
||||
this.emitChange({ apiKeyVisible: !this.config().apiKeyVisible });
|
||||
}
|
||||
|
||||
onServiceUrlChange(value: string): void {
|
||||
this.emitChange({ serviceUrl: value });
|
||||
}
|
||||
|
||||
apiKeyPlaceholder(): string {
|
||||
return this.apiKeyRequired() ? 'کلید API خود را وارد کنید' : 'اختیاری';
|
||||
}
|
||||
|
||||
apiKeyAriaLabel(): string {
|
||||
return this.config().apiKeyVisible ? 'کلید API (قابل رؤیت)' : 'کلید API (مخفی)';
|
||||
}
|
||||
}
|
||||
|
||||
const PROVIDERS: Record<AiProvider, ProviderOption> = {
|
||||
openai: { value: 'openai', label: 'OpenAI', needsApiKey: true },
|
||||
gemini: { value: 'gemini', label: 'Gemini', needsApiKey: true },
|
||||
local: { value: 'local', label: 'Local', needsApiKey: false },
|
||||
};
|
||||
|
||||
/** Provider option shown for the self-hosted «مدلهای داخلی». */
|
||||
const INTERNAL_PROVIDER: ProviderOption = {
|
||||
value: 'local',
|
||||
label: 'سرویس داخلی',
|
||||
needsApiKey: false,
|
||||
};
|
||||
|
||||
const PROVIDCERS_BY_TASK_FALLBACK: Record<AiTask, ProviderOption[]> = {
|
||||
text: [PROVIDERS.openai, PROVIDERS.gemini, PROVIDERS.local],
|
||||
embedding: [PROVIDERS.openai, PROVIDERS.gemini, PROVIDERS.local],
|
||||
ocr: [PROVIDERS.openai, PROVIDERS.gemini, PROVIDERS.local],
|
||||
// «مدلهای داخلی» run on the organization's own infrastructure, so the only
|
||||
// provider option is the internal service endpoint.
|
||||
stt: [INTERNAL_PROVIDER],
|
||||
tts: [INTERNAL_PROVIDER],
|
||||
dialogue: [INTERNAL_PROVIDER],
|
||||
};
|
||||
|
||||
const PROVIDERS_BY_TASK: Record<AiTask, ProviderOption[]> = PROVIDCERS_BY_TASK_FALLBACK;
|
||||
|
||||
const DEFAULT_CONFIG_FOR: Record<AiProvider, { model: string; serviceUrl: string }> = {
|
||||
openai: { model: '', serviceUrl: 'https://api.openai.com/v1' },
|
||||
gemini: { model: '', serviceUrl: 'https://generativelanguage.googleapis.com/v1' },
|
||||
local: { model: '', serviceUrl: 'http://localhost:8000' },
|
||||
};
|
||||
|
||||
const MODEL_OPTION = (value: string, label: string): ModelOption => ({ value, label });
|
||||
|
||||
const MODELS_BY_TASK: Record<
|
||||
AiTask,
|
||||
Partial<Record<AiProvider, ModelOption[]>>
|
||||
> = {
|
||||
text: {
|
||||
openai: [
|
||||
MODEL_OPTION('gpt-4o', 'GPT-4o'),
|
||||
MODEL_OPTION('gpt-4o-mini', 'GPT-4o mini'),
|
||||
MODEL_OPTION('gpt-4-turbo', 'GPT-4 Turbo'),
|
||||
MODEL_OPTION('gpt-3.5-turbo', 'GPT-3.5 Turbo'),
|
||||
],
|
||||
gemini: [
|
||||
MODEL_OPTION('gemini-2.0-flash', 'Gemini 2.0 Flash'),
|
||||
MODEL_OPTION('gemini-2.5-pro', 'Gemini 2.5 Pro'),
|
||||
MODEL_OPTION('gemini-1.5-flash', 'Gemini 1.5 Flash'),
|
||||
MODEL_OPTION('gemini-1.5-pro', 'Gemini 1.5 Pro'),
|
||||
],
|
||||
local: [MODEL_OPTION('', 'سفارشی')],
|
||||
},
|
||||
embedding: {
|
||||
openai: [
|
||||
MODEL_OPTION('text-embedding-3-small', 'text-embedding-3-small'),
|
||||
MODEL_OPTION('text-embedding-3-large', 'text-embedding-3-large'),
|
||||
MODEL_OPTION('text-embedding-ada-002', 'text-embedding-ada-002'),
|
||||
],
|
||||
gemini: [MODEL_OPTION('text-embedding-004', 'text-embedding-004')],
|
||||
local: [MODEL_OPTION('', 'سفارشی')],
|
||||
},
|
||||
ocr: {
|
||||
openai: [
|
||||
MODEL_OPTION('gpt-4o', 'GPT-4o (چشمپوشی)'),
|
||||
MODEL_OPTION('gpt-4o-mini', 'GPT-4o mini (چشمپوشی)'),
|
||||
],
|
||||
gemini: [
|
||||
MODEL_OPTION('gemini-1.5-pro', 'Gemini 1.5 Pro (چشمپوشی)'),
|
||||
MODEL_OPTION('gemini-2.0-flash', 'Gemini 2.0 Flash (چشمپوشی)'),
|
||||
],
|
||||
local: [MODEL_OPTION('', 'سفارشی')],
|
||||
},
|
||||
// «مدلهای داخلی» — self-hosted speech and dialogue models of the call center.
|
||||
stt: {
|
||||
local: [
|
||||
MODEL_OPTION('whisper-large-v3', 'Whisper Large v3'),
|
||||
MODEL_OPTION('parrotnet-v2', 'ParrotNet v2 (فارسی)'),
|
||||
MODEL_OPTION('fastconformer-fa', 'FastConformer فارسی'),
|
||||
],
|
||||
},
|
||||
tts: {
|
||||
local: [
|
||||
MODEL_OPTION('xtts-v2', 'Coqui XTTS v2'),
|
||||
MODEL_OPTION('vits-fa', 'VITS فارسی'),
|
||||
MODEL_OPTION('piper-fa', 'Piper فارسی'),
|
||||
],
|
||||
},
|
||||
dialogue: {
|
||||
local: [
|
||||
MODEL_OPTION('llama-3.1-70b', 'Llama 3.1 70B'),
|
||||
MODEL_OPTION('dorna-8b', 'Dorna 8B (پارسی)'),
|
||||
MODEL_OPTION('qwen2.5-72b', 'Qwen2.5 72B'),
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -34,6 +34,31 @@ export class SidebarComponent {
|
||||
label: 'چت جدید',
|
||||
route: '/',
|
||||
},
|
||||
{
|
||||
icon: 'M4 4v16h16M8 20V11M12.5 20V6M17 20V9',
|
||||
label: 'گزارشات',
|
||||
route: '/reports',
|
||||
},
|
||||
{
|
||||
icon: 'M2 4h20v12H2zM8 20h8M12 16v4',
|
||||
label: 'والبورد',
|
||||
route: '/wallboard',
|
||||
},
|
||||
{
|
||||
icon: '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',
|
||||
label: 'ارتباط با کال سنتر',
|
||||
route: '/call-center',
|
||||
},
|
||||
{
|
||||
icon: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3',
|
||||
label: 'بازخوانی تماسها از کال سنتر',
|
||||
route: '/call-center/calls',
|
||||
},
|
||||
{
|
||||
icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z',
|
||||
label: 'سوالات چت سایت و اپلیکیشن',
|
||||
route: '/chat-questions',
|
||||
},
|
||||
{
|
||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
|
||||
label: 'تنظیمات',
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
:host {
|
||||
display: block;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.stream-panel {
|
||||
direction: rtl;
|
||||
--footer-h: 3.5rem;
|
||||
--orb-zone: 7.25rem;
|
||||
--orb-gap: 0.75rem;
|
||||
--reserve: calc(var(--footer-h) + var(--orb-gap) + var(--orb-zone) + var(--orb-gap));
|
||||
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
direction: rtl;
|
||||
background: transparent; /* was surface card */
|
||||
border: none; /* removed card border */
|
||||
border-radius: 0;
|
||||
box-shadow: none; /* removed card shadow */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ---------- Orb layer (behind the transcript) ---------- */
|
||||
.stream-orb-layer {
|
||||
position: absolute;
|
||||
bottom: calc(var(--footer-h) + var(--orb-gap));
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.25rem 1.25rem;
|
||||
background: var(--surface-bg);
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 1.5rem;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
|
||||
gap: 0.5rem;
|
||||
transition: opacity 0.45s ease, transform 0.45s ease;
|
||||
}
|
||||
|
||||
/* ---------- Orb ---------- */
|
||||
.orb-container {
|
||||
width: 170px;
|
||||
height: 170px;
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
max-width: 100%;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
@@ -35,6 +54,7 @@
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
/* Shown only when WebGL is unavailable */
|
||||
.orb-fallback {
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
@@ -59,12 +79,11 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
margin: 0;
|
||||
font-size: 0.9375rem;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
@@ -109,126 +128,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Transcript ---------- */
|
||||
/* ---------- Transcript (overlaid on top of the orb) ---------- */
|
||||
.stream-transcript {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
max-width: 640px;
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.25rem 0.25rem;
|
||||
/* Hide the scrollbar, keep wheel / trackpad / touch scrolling */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none; /* legacy Edge */
|
||||
padding: 1rem 0.75rem var(--reserve);
|
||||
scroll-behavior: smooth;
|
||||
transition: padding-bottom 0.45s ease;
|
||||
}
|
||||
|
||||
.stream-transcript::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
.stream-transcript::-webkit-scrollbar-thumb {
|
||||
background: var(--muted);
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.transcript-empty {
|
||||
margin: auto;
|
||||
font-size: 0.875rem;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* RTL: user bubbles sit on the right (start), assistant bubbles on the left (end). */
|
||||
.bubble-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.bubble-row.is-user {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
max-width: 85%;
|
||||
padding: 0.5rem 0.875rem;
|
||||
border-radius: 1.125rem;
|
||||
background: var(--sidebar-hover);
|
||||
color: var(--text-primary);
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1.7;
|
||||
text-align: right;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
border-end-end-radius: 0.375rem;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.bubble.is-user {
|
||||
background: var(--color-primary);
|
||||
color: #ffffff;
|
||||
border-end-end-radius: 1.125rem;
|
||||
border-end-start-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.bubble.is-partial {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.bubble.is-interrupted .bubble-text {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.bubble-tag {
|
||||
margin-inline-start: 0.375rem;
|
||||
font-size: 0.75rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* ---------- Sources (retrieved documents) ---------- */
|
||||
.source-list {
|
||||
list-style: none;
|
||||
margin: 0.375rem 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.source-chip {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 0.625rem;
|
||||
background: var(--surface-bg);
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.source-chip.is-unavailable {
|
||||
opacity: 0.55;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.source-ref {
|
||||
flex-shrink: 0;
|
||||
padding: 0 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--color-primary);
|
||||
color: #ffffff;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
display: none; /* Chrome, Safari, Edge */
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* ---------- Retryable server error ---------- */
|
||||
.stream-error {
|
||||
position: absolute;
|
||||
bottom: calc(var(--footer-h) + 0.5rem);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
max-width: 640px;
|
||||
width: min(100% - 1.5rem, 640px);
|
||||
box-sizing: border-box;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid rgba(239, 68, 68, 0.45);
|
||||
@@ -236,7 +170,6 @@
|
||||
color: #dc2626;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.6;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.stream-error span {
|
||||
@@ -263,14 +196,26 @@
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
/* ---------- Actions ---------- */
|
||||
/* ---------- Controls ---------- */
|
||||
.stream-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-bottom: 0.25rem;
|
||||
transition: opacity 0.45s ease, transform 0.45s ease;
|
||||
}
|
||||
|
||||
.stream-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.625rem;
|
||||
flex-wrap: wrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.stream-btn {
|
||||
@@ -328,6 +273,32 @@
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* ---------- Ended: orb + controls fade out, transcript stays ---------- */
|
||||
|
||||
/* The orb + footer reserve only exists while the call is live; collapsing it stops the
|
||||
bottom padding from forcing the panel (and the chat column) taller than the viewport. */
|
||||
.stream-panel.is-ended {
|
||||
--reserve: 0rem;
|
||||
}
|
||||
|
||||
.stream-panel.is-ended .stream-orb-layer {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(14px) scale(0.9);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.stream-panel.is-ended .stream-footer {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* The transcript keeps the full height of the chat column: no max-height, so it never
|
||||
collapses into a short nested scroll box — scrolling stays on the full-height area. */
|
||||
.stream-panel.is-ended .stream-transcript {
|
||||
padding: 1rem 0.75rem;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
@@ -344,7 +315,8 @@
|
||||
.status-dot,
|
||||
.orb-fallback,
|
||||
.stream-btn,
|
||||
.bubble,
|
||||
.stream-orb-layer,
|
||||
.stream-footer,
|
||||
.stream-transcript {
|
||||
animation: none !important;
|
||||
transition: none !important;
|
||||
@@ -354,21 +326,17 @@
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.stream-panel {
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 0.75rem 1rem;
|
||||
--footer-h: 3.25rem;
|
||||
--orb-zone: 6rem;
|
||||
--orb-gap: 0.5rem;
|
||||
}
|
||||
|
||||
.orb-container {
|
||||
width: 130px;
|
||||
height: 130px;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
max-width: 92%;
|
||||
font-size: 0.875rem;
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
|
||||
.stream-btn {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
<div class="stream-panel" role="region" aria-label="گفتگوی صوتی" [attr.data-state]="state()">
|
||||
<div
|
||||
class="stream-panel"
|
||||
role="region"
|
||||
aria-label="گفتگوی صوتی"
|
||||
[class.is-ended]="ended()"
|
||||
[attr.data-state]="state()"
|
||||
>
|
||||
<div class="sr-only" role="status" aria-live="polite">{{ statusText() }}</div>
|
||||
|
||||
<div class="orb-container" #orbContainer aria-hidden="true">
|
||||
@if (!orbAvailable()) {
|
||||
<div class="orb-fallback"></div>
|
||||
}
|
||||
<!-- Orb layer: behind the transcript, anchored just above the controls -->
|
||||
<div class="stream-orb-layer" aria-hidden="true">
|
||||
<div class="orb-container" #orbContainer>
|
||||
@if (!orbAvailable()) {
|
||||
<div class="orb-fallback"></div>
|
||||
}
|
||||
</div>
|
||||
<div class="stream-status" [attr.data-state]="state()">
|
||||
<span class="status-dot" aria-hidden="true"></span>
|
||||
<p class="status-text">{{ statusText() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stream-status" [attr.data-state]="state()">
|
||||
<span class="status-dot" aria-hidden="true"></span>
|
||||
<p class="status-text">{{ statusText() }}</p>
|
||||
<!-- Transcript: overlaid on top of the orb, keeps streaming while the call runs -->
|
||||
<div
|
||||
class="stream-transcript"
|
||||
#scroller
|
||||
role="log"
|
||||
aria-label="متن گفتگو"
|
||||
aria-live="polite"
|
||||
aria-relevant="additions"
|
||||
>
|
||||
<app-voice-transcript [messages]="messages()" />
|
||||
</div>
|
||||
|
||||
@if (streamError(); as errorText) {
|
||||
@@ -24,79 +44,45 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="stream-transcript" #scroller role="log" aria-label="متن گفتگو" aria-live="polite" aria-relevant="additions">
|
||||
@for (message of messages(); track message.role + message.id) {
|
||||
<div class="bubble-row" [class.is-user]="message.role === 'user'">
|
||||
<div
|
||||
class="bubble"
|
||||
[class.is-user]="message.role === 'user'"
|
||||
[class.is-partial]="!message.final"
|
||||
[class.is-interrupted]="message.interrupted"
|
||||
dir="rtl"
|
||||
>
|
||||
@if (message.text) {
|
||||
<span class="bubble-text">{{ message.text }}</span>
|
||||
}
|
||||
@if (message.interrupted) {
|
||||
<span class="bubble-tag">(قطع شد)</span>
|
||||
}
|
||||
@if (message.sources?.length) {
|
||||
<ul class="source-list" aria-label="منابع پاسخ">
|
||||
@for (source of message.sources ?? []; track source.source_ref + source.chunk_id) {
|
||||
<li
|
||||
class="source-chip"
|
||||
[class.is-unavailable]="source.available === false"
|
||||
[attr.title]="source.excerpt ?? null"
|
||||
>
|
||||
<span class="source-ref">{{ source.source_ref }}</span>
|
||||
<span class="source-label">{{ sourceLabel(source) }}</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
} @empty {
|
||||
<p class="transcript-empty">صحبت کنید؛ گفتگو اینجا نمایش داده میشود</p>
|
||||
}
|
||||
</div>
|
||||
<!-- Controls: fade out together with the orb when the call ends -->
|
||||
<div class="stream-footer">
|
||||
<div class="stream-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="stream-btn"
|
||||
[class.is-active]="muted()"
|
||||
[attr.aria-pressed]="muted()"
|
||||
[attr.aria-label]="muteLabel()"
|
||||
[attr.title]="muteLabel()"
|
||||
[disabled]="connection() !== 'connected'"
|
||||
(click)="toggleMute()"
|
||||
>
|
||||
@if (muted()) {
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<line x1="2" x2="22" y1="2" y2="22" />
|
||||
<path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2" />
|
||||
<path d="M5 10v2a7 7 0 0 0 12 5" />
|
||||
<path d="M15 9.34V5a3 3 0 0 0-5.68-1.33" />
|
||||
<path d="M9 9v3a3 3 0 0 0 5.12 2.12" />
|
||||
<line x1="12" x2="12" y1="19" y2="22" />
|
||||
</svg>
|
||||
} @else {
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<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>
|
||||
}
|
||||
<span>{{ muted() ? 'فعالسازی' : 'بیصدا' }}</span>
|
||||
</button>
|
||||
|
||||
<div class="stream-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="stream-btn"
|
||||
[class.is-active]="muted()"
|
||||
[attr.aria-pressed]="muted()"
|
||||
[attr.aria-label]="muteLabel()"
|
||||
[attr.title]="muteLabel()"
|
||||
[disabled]="connection() !== 'connected'"
|
||||
(click)="toggleMute()"
|
||||
>
|
||||
@if (muted()) {
|
||||
<button type="button" class="stream-btn is-end" aria-label="پایان گفتگوی صوتی" (click)="endCall()">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<line x1="2" x2="22" y1="2" y2="22" />
|
||||
<path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2" />
|
||||
<path d="M5 10v2a7 7 0 0 0 12 5" />
|
||||
<path d="M15 9.34V5a3 3 0 0 0-5.68-1.33" />
|
||||
<path d="M9 9v3a3 3 0 0 0 5.12 2.12" />
|
||||
<line x1="12" x2="12" y1="19" y2="22" />
|
||||
<line x1="18" x2="6" y1="6" y2="18" />
|
||||
<line x1="6" x2="18" y1="6" y2="18" />
|
||||
</svg>
|
||||
} @else {
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<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>
|
||||
}
|
||||
<span>{{ muted() ? 'فعالسازی' : 'بیصدا' }}</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="stream-btn is-end" aria-label="پایان گفتگوی صوتی" (click)="endCall()">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<line x1="18" x2="6" y1="6" y2="18" />
|
||||
<line x1="6" x2="18" y1="6" y2="18" />
|
||||
</svg>
|
||||
<span>پایان گفتگو</span>
|
||||
</button>
|
||||
<span>پایان گفتگو</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
} from '@angular/core';
|
||||
import { OrbMode, VoiceOrbService } from '../../../services/voice-orb/voice-orb.service';
|
||||
import { VoiceStreamService } from '../../../services/voice-stream/voice-stream.service';
|
||||
import { VoiceSource, VoiceStreamState } from '../../../services/voice-stream/voice-stream.types';
|
||||
import { VoiceStreamState } from '../../../services/voice-stream/voice-stream.types';
|
||||
import { VoiceTranscriptComponent } from '../voice-transcript/voice-transcript.component';
|
||||
|
||||
const ORB_MODE: Record<VoiceStreamState, OrbMode> = {
|
||||
IDLE: 'listening',
|
||||
@@ -22,10 +23,11 @@ const ORB_MODE: Record<VoiceStreamState, OrbMode> = {
|
||||
SPEAKING: 'speaking',
|
||||
};
|
||||
|
||||
/** Live call view: orb, status, running two-sided transcript, mute / end controls. */
|
||||
/** Live call view: orb behind an overlaid running transcript, mute / end controls. */
|
||||
@Component({
|
||||
selector: 'app-voice-stream-panel',
|
||||
standalone: true,
|
||||
imports: [VoiceTranscriptComponent],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './voice-stream-panel.component.html',
|
||||
styleUrl: './voice-stream-panel.component.css',
|
||||
@@ -40,9 +42,12 @@ export class VoiceStreamPanelComponent implements AfterViewInit, OnDestroy {
|
||||
readonly muted = this.voice.muted;
|
||||
readonly streamError = this.voice.streamError;
|
||||
readonly orbAvailable = signal(true);
|
||||
/** The call is over: the orb and controls fade out, the transcript stays. */
|
||||
readonly ended = computed(() => this.connection() === 'disconnected');
|
||||
|
||||
private readonly orbContainer = viewChild.required<ElementRef<HTMLDivElement>>('orbContainer');
|
||||
private readonly scroller = viewChild<ElementRef<HTMLDivElement>>('scroller');
|
||||
private orbRunning = false;
|
||||
|
||||
readonly statusText = computed(() => {
|
||||
if (this.connection() === 'connecting') return 'در حال اتصال...';
|
||||
@@ -76,6 +81,15 @@ export class VoiceStreamPanelComponent implements AfterViewInit, OnDestroy {
|
||||
if (el) el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
});
|
||||
|
||||
// The orb animates only while a call is live; it fades out (and stops) when the call ends.
|
||||
effect(() => {
|
||||
if (this.ended()) {
|
||||
this.orb.stopAnimation();
|
||||
} else if (this.orbRunning) {
|
||||
this.orb.startAnimation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
@@ -83,9 +97,10 @@ export class VoiceStreamPanelComponent implements AfterViewInit, OnDestroy {
|
||||
this.orbAvailable.set(ready);
|
||||
if (!ready) return;
|
||||
|
||||
this.orbRunning = true;
|
||||
this.orb.resetOrbGeometry();
|
||||
this.orb.setLevelProvider(() => this.voice.orbLevel());
|
||||
this.orb.startAnimation();
|
||||
if (!this.ended()) this.orb.startAnimation();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -94,14 +109,6 @@ export class VoiceStreamPanelComponent implements AfterViewInit, OnDestroy {
|
||||
this.orb.setMode('listening');
|
||||
}
|
||||
|
||||
/** "عنوان — صفحه ۱، بند ۲" */
|
||||
sourceLabel(source: VoiceSource): string {
|
||||
const parts: string[] = [];
|
||||
if (source.location?.page != null) parts.push(`صفحه ${source.location.page}`);
|
||||
if (source.location?.section) parts.push(source.location.section);
|
||||
return parts.length ? `${source.title} — ${parts.join('، ')}` : source.title;
|
||||
}
|
||||
|
||||
dismissError(): void {
|
||||
this.voice.dismissError();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* RTL: user bubbles sit on the right (start), assistant text on the left (end). */
|
||||
.bubble-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
animation: bubbleIn 0.3s ease;
|
||||
}
|
||||
|
||||
.bubble-row.is-user {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
/* Assistant: plain text on the page background (chat-style, no bubble). */
|
||||
.bubble {
|
||||
max-width: 88%;
|
||||
padding: 0.125rem 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1.8;
|
||||
text-align: right;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.bubble.is-user {
|
||||
max-width: 85%;
|
||||
padding: 0.5rem 0.875rem;
|
||||
border-radius: 1.125rem;
|
||||
background: var(--color-primary);
|
||||
color: #ffffff;
|
||||
border-end-end-radius: 1.125rem;
|
||||
border-end-start-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.bubble.is-partial {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.bubble.is-interrupted .bubble-text {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.bubble-tag {
|
||||
margin-inline-start: 0.375rem;
|
||||
font-size: 0.75rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
@keyframes bubbleIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Sources (retrieved documents) ---------- */
|
||||
.source-list {
|
||||
list-style: none;
|
||||
margin: 0.375rem 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.source-chip {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 0.625rem;
|
||||
background: var(--surface-bg);
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.source-chip.is-unavailable {
|
||||
opacity: 0.55;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.source-ref {
|
||||
flex-shrink: 0;
|
||||
padding: 0 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--color-primary);
|
||||
color: #ffffff;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.transcript-empty {
|
||||
margin: auto;
|
||||
font-size: 0.875rem;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.bubble-row {
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
transition: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.bubble {
|
||||
max-width: 94%;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.bubble.is-user {
|
||||
max-width: 92%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@for (message of messages(); track message.role + message.id) {
|
||||
<div class="bubble-row" [class.is-user]="message.role === 'user'">
|
||||
<div
|
||||
class="bubble"
|
||||
[class.is-user]="message.role === 'user'"
|
||||
[class.is-partial]="!message.final"
|
||||
[class.is-interrupted]="message.interrupted"
|
||||
dir="rtl"
|
||||
>
|
||||
@if (message.text) {
|
||||
<span class="bubble-text">{{ message.text }}</span>
|
||||
}
|
||||
@if (message.interrupted) {
|
||||
<span class="bubble-tag">(قطع شد)</span>
|
||||
}
|
||||
@if (message.sources?.length) {
|
||||
<ul class="source-list" aria-label="منابع پاسخ">
|
||||
@for (source of message.sources ?? []; track source.source_ref + source.chunk_id) {
|
||||
<li
|
||||
class="source-chip"
|
||||
[class.is-unavailable]="source.available === false"
|
||||
[attr.title]="source.excerpt ?? null"
|
||||
>
|
||||
<span class="source-ref">{{ source.source_ref }}</span>
|
||||
<span class="source-label">{{ sourceLabel(source) }}</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
} @empty {
|
||||
<p class="transcript-empty">صحبت کنید؛ گفتگو اینجا نمایش داده میشود</p>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
||||
import { VoiceMessage, VoiceSource } from '../../../services/voice-stream/voice-stream.types';
|
||||
|
||||
/** Read-only transcript bubbles (user / assistant), shared by the live call view and the ended-call chat box. */
|
||||
@Component({
|
||||
selector: 'app-voice-transcript',
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './voice-transcript.component.html',
|
||||
styleUrl: './voice-transcript.component.css',
|
||||
})
|
||||
export class VoiceTranscriptComponent {
|
||||
readonly messages = input.required<VoiceMessage[]>();
|
||||
|
||||
/** "عنوان — صفحه ۱، بند ۲" */
|
||||
sourceLabel(source: VoiceSource): string {
|
||||
const parts: string[] = [];
|
||||
if (source.location?.page != null) parts.push(`صفحه ${source.location.page}`);
|
||||
if (source.location?.section) parts.push(source.location.section);
|
||||
return parts.length ? `${source.title} — ${parts.join('، ')}` : source.title;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user