2025-08-14 12:18:20 +02:00
|
|
|
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
|
|
|
|
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
|
|
|
|
|
|
|
import {Copy} from 'sae-lib/buttons/copy/copy';
|
|
|
|
import {FeedbackButton} from '../feedback-button/feedback-button';
|
|
|
|
import {ChatbotMessage} from '../../services/chatbot.message.type';
|
2025-08-18 18:14:22 +02:00
|
|
|
import {NgClass} from '@angular/common';
|
|
|
|
import {Store} from '@ngrx/store';
|
2025-08-20 12:47:37 +02:00
|
|
|
import {ActionTypes, StateInterface} from '../../reducers';
|
2025-08-14 12:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
type MessageKind = "user" | "llm";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-message-box',
|
|
|
|
imports: [
|
|
|
|
Copy,
|
2025-08-18 18:14:22 +02:00
|
|
|
FeedbackButton,
|
|
|
|
NgClass
|
2025-08-14 12:18:20 +02:00
|
|
|
],
|
|
|
|
templateUrl: './message-box.html',
|
|
|
|
styleUrl: './message-box.scss'
|
|
|
|
})
|
|
|
|
export class MessageBox implements OnChanges {
|
|
|
|
|
|
|
|
@Input() kind: MessageKind = <"user" | "llm">""
|
|
|
|
@Input() conf: any = {}
|
|
|
|
@Input() content: any = ""
|
|
|
|
@Input() message: ChatbotMessage = {} as ChatbotMessage;
|
|
|
|
id: string = "00122121221312";
|
|
|
|
sanitizedContent: SafeHtml = "";
|
2025-08-19 14:42:29 +02:00
|
|
|
expanded: boolean = true;
|
2025-08-20 12:47:37 +02:00
|
|
|
displaySourcesPanelLarge: boolean = false;
|
|
|
|
|
|
|
|
constructor(private sanitizer: DomSanitizer,
|
|
|
|
public store: Store<StateInterface>) {
|
|
|
|
this.store.select(state => state.app.displaySourcesPanelLarge).subscribe(value => {
|
|
|
|
this.displaySourcesPanelLarge = value;
|
|
|
|
});
|
2025-08-14 12:18:20 +02:00
|
|
|
|
2025-08-18 18:14:22 +02:00
|
|
|
}
|
2025-08-14 12:18:20 +02:00
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
|
if (changes['content']) {
|
|
|
|
this.sanitizeContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sanitizeContent(): void {
|
|
|
|
this.sanitizedContent = this.sanitizer.bypassSecurityTrustHtml(this.content);
|
|
|
|
}
|
|
|
|
|
|
|
|
bookmark() {
|
|
|
|
console.log("TODO bookmark")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
generateResponse() {
|
|
|
|
console.log("TODO generateResponse")
|
|
|
|
}
|
|
|
|
|
|
|
|
editMessage() {
|
|
|
|
console.log("TODO editMessage")
|
|
|
|
}
|
2025-08-18 18:14:22 +02:00
|
|
|
|
|
|
|
toggleSources() {
|
|
|
|
console.log("TODO toggle sources")
|
|
|
|
this.store.dispatch({
|
2025-08-20 12:47:37 +02:00
|
|
|
type: ActionTypes.UPDATE_APP,
|
2025-08-18 18:14:22 +02:00
|
|
|
payload: {
|
2025-08-20 12:47:37 +02:00
|
|
|
displaySourcesPanelLarge: !this.displaySourcesPanelLarge
|
2025-08-18 18:14:22 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleFullScreen() {
|
|
|
|
console.log("TODO toggle fullscreen")
|
|
|
|
this.expanded = !this.expanded;
|
|
|
|
}
|
2025-08-14 12:18:20 +02:00
|
|
|
}
|