2025-09-09 15:42:23 +02:00
|
|
|
import {Component, EventEmitter, Output} from '@angular/core';
|
2025-08-08 10:57:00 +02:00
|
|
|
import {FormsModule} from '@angular/forms';
|
2025-09-10 16:02:31 +02:00
|
|
|
import {Index} from '../index';
|
2025-08-08 10:57:00 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'sae-translate-texts',
|
|
|
|
standalone: true,
|
2025-09-10 16:02:31 +02:00
|
|
|
imports: [FormsModule, Index],
|
2025-08-08 10:57:00 +02:00
|
|
|
templateUrl: './translate-texts.html',
|
2025-08-22 11:57:56 +02:00
|
|
|
styleUrl: './translate-texts.scss'
|
2025-08-08 10:57:00 +02:00
|
|
|
})
|
|
|
|
export class TranslateTexts {
|
|
|
|
public fromText: string = ''
|
2025-09-09 15:42:23 +02:00
|
|
|
public toText: string = 'résumé ici'
|
|
|
|
public loadingResume: boolean = false;
|
|
|
|
public mode: string = 'demo';
|
|
|
|
public debounceEnabled: boolean = false;
|
|
|
|
public fromTimeout: any;
|
|
|
|
public debounceDuration: number = 1000;
|
|
|
|
@Output() updateFilters: EventEmitter<any> = new EventEmitter();
|
|
|
|
|
|
|
|
|
|
|
|
onToTextChanged(e: any): void {
|
|
|
|
console.log('text changed toText', e)
|
|
|
|
// launch request
|
|
|
|
// in demo mode, fill some filters
|
|
|
|
if (this.mode !== 'production') {
|
|
|
|
|
|
|
|
// Clear any existing timeout to reset the debounce
|
|
|
|
if (this.fromTimeout) {
|
|
|
|
clearTimeout(this.fromTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a new timeout
|
|
|
|
this.fromTimeout = setTimeout(() => {
|
|
|
|
// in demo mode, load demo filters
|
|
|
|
console.log('demo mode')
|
|
|
|
|
|
|
|
const newFilters = [
|
|
|
|
['filter demo 1', 'filter demo 2'],
|
|
|
|
['filter demo 3'],
|
|
|
|
['filter demo 4', 'filter demo ABCD'],
|
|
|
|
['filter demo 5'],
|
|
|
|
]
|
|
|
|
this.updateFilters.emit(newFilters);
|
|
|
|
this.loadingResume = false;
|
|
|
|
}, this.debounceDuration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onFromTextChanged(e?: any): void {
|
|
|
|
|
|
|
|
console.log('text changed fromText', e)
|
|
|
|
// run research after a delay
|
|
|
|
if (this.mode !== 'production') {
|
|
|
|
this.loadingResume = true;
|
|
|
|
|
|
|
|
// Clear any existing timeout to reset the debounce
|
|
|
|
if (this.fromTimeout) {
|
|
|
|
clearTimeout(this.fromTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a new timeout
|
|
|
|
this.fromTimeout = setTimeout(() => {
|
|
|
|
// in demo mode, make a fake resume
|
|
|
|
console.log('demo mode')
|
|
|
|
this.toText = "Résumé de démo à titre d'exemple"
|
|
|
|
this.loadingResume = false;
|
|
|
|
},
|
|
|
|
this.debounceDuration);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2025-08-08 10:57:00 +02:00
|
|
|
|
|
|
|
emptyText(someText: 'fromText' | 'toText') {
|
|
|
|
this[someText] = '';
|
|
|
|
}
|
2025-08-22 11:57:56 +02:00
|
|
|
|
|
|
|
onFileSelected($event: Event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clickFileUpload(fileUpload: HTMLInputElement) {
|
|
|
|
|
|
|
|
fileUpload.click();
|
|
|
|
|
|
|
|
}
|
2025-08-08 10:57:00 +02:00
|
|
|
}
|