Skip to content

Commit

Permalink
#4
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoh committed Jul 15, 2024
1 parent 20d6e1f commit dce38e4
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ <h1 mat-dialog-title cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandl
</div>

<div class="app-mb-4">
<mat-form-field class="app-fxFlex" *ngIf="!datum">
<mat-label>{{ 'field.date' | translate}}</mat-label>
<input matInput [(ngModel)]="_letter.date" name="date" />
<mat-form-field class="app-fxFlex">
<mat-label>{{ 'field.date_marked' | translate}}</mat-label>
<input matInput [(ngModel)]="_letter.date_marked" name="date" />
</mat-form-field>

<mat-form-field class="app-fxFlex" *ngIf="datum">
<mat-form-field class="app-fxFlex">
<mat-label>{{ 'field.date' | translate}}</mat-label>
<input matInput [ngModel]="datum | date : 'dd.MM.yyyy'" (ngModelChange)="datum=$event" name="datum" />
<input matInput [ngModel]="_letter.date | date : 'dd.MM.yyyy'" (ngModelChange)="datum=$event" name="datum" />
</mat-form-field>

<mat-form-field class="app-fxFlex app-ml-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class AnalyzeDialogComponent {
this._letterAnalyzed.summary = analysis.summary;

this._letterAnalyzed.origin = analysis.location || analysis.place;
this._letterAnalyzed.date_marked = analysis.date_as_show_in_text;
this._letterAnalyzed.date = analysis.date;
if (this.isDate(this._letterAnalyzed.date)) {
this.datum = new Date(analysis.date);
Expand Down Expand Up @@ -286,6 +287,7 @@ export class AnalyzeDialogComponent {
console.log(this.datum)
}
this.data.letter.date = this._letterAnalyzed.date;
this.data.letter.date_marked = this._letterAnalyzed.date_marked;

this.data.letter.incipit = this._letterAnalyzed.incipit;
this.data.letter.explicit = this._letterAnalyzed.explicit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,100 @@ <h1 mat-dialog-title>{{ 'file_settings' | translate }}</h1>
</div>
<div class="app-fxLayout app-row app-center-v app-mb-4">
<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>Tenant</mat-label>
<mat-label>{{ 'tenant' | translate }}</mat-label>
<mat-select [(ngModel)]="fileConfig.tenant">
<mat-option *ngFor="let t of state.tenants" [value]="t">{{ t }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'def_author' | translate }}</mat-label>
<input matInput name="def_author" [(ngModel)]="fileConfig.def_author" [matAutocomplete]="auto" (keyup)="getAuthors(fileConfig.def_author)">

<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let a of authors_db" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>

<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'def_recipient' | translate }}</mat-label>
<input matInput name="def_recipient" [(ngModel)]="fileConfig.def_recipient" [matAutocomplete]="auto2" (keyup)="getAuthors(fileConfig.def_recipient)">

<mat-autocomplete #auto2="matAutocomplete">
<mat-option *ngFor="let a of authors_db" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
<div class="app-mb-4">
<mat-form-field class="app-w-100" appearance="outline">
<mat-label>{{ 'Columns' | translate }}</mat-label>
<input matInput type="number" name="columns" [(ngModel)]="fileConfig.columns">
</mat-form-field>
</div>

<div class="app-fxLayout app-row app-center-v app-mb-4">
<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'templates' | translate }}</mat-label>
<mat-select [(ngModel)]="selectedTemplate">
<mat-option *ngFor="let t of fileConfig.templates" [value]="t">{{ t.name }}</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'new_template_name' | translate }}</mat-label>
<input matInput type="text" name="new_template" [(ngModel)]="new_template" />
<button matSuffix mat-icon-button (click)="addTemplate()" [matTooltip]="'action.add_template' | translate">
<mat-icon>add</mat-icon>
</button>
</mat-form-field>

</div>

<fieldset *ngIf="selectedTemplate">
<legend>{{ 'field.template' | translate }} {{ selectedTemplate.name }}</legend>
<div class="app-fxLayout app-row app-center-v app-mb-4">

<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'def_author' | translate }}</mat-label>
<input matInput name="def_author" [(ngModel)]="selectedTemplate.def_author" [matAutocomplete]="auto" (keyup)="getAuthors(selectedTemplate.def_author)">

<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let a of authors_db" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>

<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>{{ 'def_recipient' | translate }}</mat-label>
<input matInput name="def_recipient" [(ngModel)]="selectedTemplate.def_recipient" [matAutocomplete]="auto2" (keyup)="getAuthors(selectedTemplate.def_recipient)">

<mat-autocomplete #auto2="matAutocomplete">
<mat-option *ngFor="let a of authors_db" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
<div class="app-fxLayout app-row app-center-v app-mb-4">

<mat-form-field class="app-fxFlex" >
<mat-label>{{ 'field.copies_repository' | translate }}</mat-label>
<input matInput [(ngModel)]="selectedTemplate.copies_repository" name="copies_repository"
[matAutocomplete]="autoRepos" (focus)="getLocations(selectedTemplate.copies_repository, 'repository')" (change)="getLocations(selectedTemplate.copies_repository, 'repository')" (keyup)="getLocations(selectedTemplate.copies_repository, 'repository')">
<mat-autocomplete #autoRepos="matAutocomplete">
<mat-option *ngFor="let a of repositories" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>


<mat-form-field class="app-fxFlex app-ml-3" >
<mat-label>{{ 'field.copies_archive' | translate}}</mat-label>
<input matInput [(ngModel)]="selectedTemplate.copies_archive" name="copies_archive"
[matAutocomplete]="autoArchives" (change)="getLocations(selectedTemplate.copies_archive, 'archive')" (keyup)="getLocations(selectedTemplate.copies_archive, 'archive')">
<mat-autocomplete #autoArchives="matAutocomplete">
<mat-option *ngFor="let a of archives" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>

<mat-form-field class="app-fxFlex app-ml-3" >
<mat-label>{{ 'field.copies_collection' | translate}}</mat-label>
<input matInput [(ngModel)]="selectedTemplate.copies_collection" name="copies_collection"
[matAutocomplete]="autoCollections" (change)="getLocations(selectedTemplate.copies_collection, 'collection')" (keyup)="getLocations(selectedTemplate.copies_collection, 'collection')">
<mat-autocomplete #autoCollections="matAutocomplete">
<mat-option *ngFor="let a of collections" [value]="a.name">
{{a.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
</fieldset>

<div class="app-fxLayout app-row app-center-v app-mb-4">
<mat-form-field class="app-fxFlex" appearance="outline">
<mat-label>chatGPT model</mat-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,33 @@ import { MatTabsModule } from '@angular/material/tabs';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { AngularSplitModule } from 'angular-split';
import { FileConfig } from 'src/app/shared/file-config';
import { FileConfig, FileTemplate } from 'src/app/shared/file-config';
import { AppService } from 'src/app/app.service';
import { AppState } from 'src/app/app-state';
import { MatSelectModule } from '@angular/material/select';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatTooltipModule } from '@angular/material/tooltip';

@Component({
selector: 'app-file-settings-dialog',
templateUrl: './file-settings-dialog.component.html',
styleUrls: ['./file-settings-dialog.component.scss'],
standalone: true,
imports: [FormsModule, AngularSplitModule, NgIf, NgFor, RouterModule, TranslateModule,
MatTabsModule, MatButtonModule, MatFormFieldModule, MatSelectModule,
MatTabsModule, MatButtonModule, MatFormFieldModule, MatSelectModule, MatTooltipModule,
MatInputModule, MatIconModule, MatDialogModule, MatListModule, MatAutocompleteModule]
})
export class FileSettingsDialogComponent {

authors_db: {id: string, tenant: string, name: string}[] = [];
selectedTemplate: FileTemplate;
new_template: string;


locations_db: {id: string, tenant: string, name: string, type: string}[] = [];
repositories: {id: string, tenant: string, name: string}[] = [];
archives: {id: string, tenant: string, name: string}[] = [];
collections: {id: string, tenant: string, name: string}[] = [];

constructor(
@Inject(MAT_DIALOG_DATA) public fileConfig: FileConfig,
Expand Down Expand Up @@ -58,4 +67,27 @@ getAuthors(e: string) {
save() {
this.service.saveFile(this.state.selectedFile.filename, this.fileConfig).subscribe(res => {});
}

addTemplate() {
const t: FileTemplate = new FileTemplate();
t.name = this.new_template;
if (!this.fileConfig.templates) {
this.fileConfig.templates = [];
}
this.fileConfig.templates.push(t);
}

getLocations(e: string, type: string) {
this.service.getLocations(e, this.state.fileConfig.tenant ? this.state.fileConfig.tenant : '', type).subscribe((resp: any) => {
this.locations_db = resp.locations;
switch(type) {
case 'repository': this.repositories = this.locations_db.filter(l => l.type === 'repository'); break;
case 'archive':this.archives = this.locations_db.filter(l => l.type === 'archive'); break;
case 'collection':this.collections = this.locations_db.filter(l => l.type === 'collection'); break;
}

// this.archives = this.locations_db.filter(l => l.type === 'archive');
// this.collections = this.locations_db.filter(l => l.type === 'collection');
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@
(yearSelected)="setMonthAndYear($event, dp2, datum)" startView="multi-year"></mat-datepicker>

</mat-form-field>

<mat-form-field class="app-fxFlex app-ml-3" >
<mat-label>{{ 'field.date_marked' | translate}}</mat-label>
<input matInput [(ngModel)]="_letter.date_marked" id="date_marked" name="date_marked" ><span matSuffix></span>
<ng-container matSuffix *ngTemplateOutlet="icons; context:{ field: 'date_marked' }"></ng-container>
</mat-form-field>

<mat-form-field class="app-fxFlex app-ml-3" >
<mat-label>{{ 'field.languages' | translate}}</mat-label>
<input matInput [(ngModel)]="_letter.languages" name="languages">
</mat-form-field>
</mat-form-field>
</div>

<div class="app-fxLayout app-row app-center-v app-mb-4">
Expand Down
5 changes: 4 additions & 1 deletion src/main/client/src/app/pages/editor/editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
</div>
<div>
<button mat-icon-button (click)="getLetters()" [matTooltip]="'action.refresh' | translate"><mat-icon>refresh</mat-icon></button>
<button mat-icon-button (click)="newLetter()" [matTooltip]="'action.new_letter' | translate"><mat-icon>add_circle</mat-icon></button>
<button mat-icon-button [matMenuTriggerFor]="menu" [matTooltip]="'action.new_letter' | translate"><mat-icon>add_circle</mat-icon></button>
<mat-menu #menu="matMenu">
<button mat-menu-item *ngFor="let t of state.fileConfig.templates" (click)="newLetter(t)">{{ t.name }}</button>
</mat-menu>
<button [disabled]="!letter" mat-icon-button (click)="saveLetter()" [matTooltip]="'action.save' | translate"><mat-icon>save</mat-icon></button>
<button mat-icon-button [disabled]="selectedResult === 0" (click)="prevLetter()" [matTooltip]="'action.previous_letter' | translate"><mat-icon>navigate_before</mat-icon></button>
<button mat-icon-button [disabled]="selectedResult === letters.length - 1" (click)="nextLetter()" [matTooltip]="'action.next_letter' | translate"><mat-icon>navigate_next</mat-icon></button>
Expand Down
16 changes: 10 additions & 6 deletions src/main/client/src/app/pages/editor/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { NgIf, NgTemplateOutlet, NgFor, DatePipe } from '@angular/common';
import { AngularSplitModule, SplitComponent } from 'angular-split';
import { MatToolbarModule } from '@angular/material/toolbar';
import { TranslateModule } from '@ngx-translate/core';
import { SearchParams } from 'src/app/shared/file-config';
import { FileTemplate, SearchParams } from 'src/app/shared/file-config';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatListModule } from '@angular/material/list';
import { LetterFieldsComponent } from 'src/app/components/letter-fields/letter-fields.component';
Expand All @@ -23,6 +23,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { AppState } from 'src/app/app-state';
import { MAT_DATE_LOCALE } from '@angular/material/core';
import { FileSettingsDialogComponent } from 'src/app/components/file-settings-dialog/file-settings-dialog.component';
import { MatMenuModule } from '@angular/material/menu';


@Component({
Expand All @@ -34,7 +35,7 @@ import { FileSettingsDialogComponent } from 'src/app/components/file-settings-di
{ provide: MAT_DATE_LOCALE, useValue: 'cs' },
],
imports: [FormsModule, AngularSplitModule, NgIf, ViewerComponent,
MatToolbarModule, RouterModule, TranslateModule, DatePipe,
MatToolbarModule, RouterModule, TranslateModule, DatePipe, MatMenuModule,
MatTabsModule, MatButtonModule, ReactiveFormsModule, MatFormFieldModule, MatListModule,
MatInputModule, NgTemplateOutlet, NgFor, MatIconModule, MatDialogModule, LetterFieldsComponent, MatTooltipModule, MatCheckboxModule]
})
Expand Down Expand Up @@ -134,11 +135,14 @@ export class EditorComponent {
}, 10)
}

newLetter() {
newLetter(t: FileTemplate) {
this.letter = new Letter();
this.letter.id = this.state.selectedFile.filename.substring(0, 3) + new Date().getTime();
this.letter.author = this.state.fileConfig.def_author;
this.letter.recipient = this.state.fileConfig.def_recipient;
this.letter.author = t.def_author;
this.letter.recipient = t.def_recipient;
this.letter.copies_repository = t.copies_repository;
this.letter.copies_archive = t.copies_archive;
this.letter.copies_collection = t.copies_collection;
this.letter.full_text = '';
this.view = 'fields';
}
Expand Down Expand Up @@ -404,7 +408,7 @@ export class EditorComponent {
this.gotoResult(res.response.docs[0], false, idx);

} else {
this.newLetter();
this.newLetter(this.state.fileConfig.templates[0]);
this.letter.id = id;
this.letter.startPage = this.state.currentPage;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/client/src/app/shared/file-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export interface AltoSelection { blocks: AltoBlock[], lines: AltoLine[], words:

export interface SearchParams { filename: string, page: number, selection: AltoSelection, onlyBox: boolean, twoCols: boolean };

export class FileTemplate { name: string; def_author: string; def_recipient: string; copies_repository: string; copies_archive: string; copies_collection: string};

export class FileConfig {
name: string;
columns: number;
Expand All @@ -17,4 +19,5 @@ export class FileConfig {
tenant: string;
prompt: string;
gptModel: string;
templates: FileTemplate[];
}
2 changes: 1 addition & 1 deletion src/main/client/src/app/shared/letter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Letter {
date_year: number;
date_month: number;
date_day: number;
date_marked: boolean;
date_marked: string;
date_uncertain: boolean;
date_approximate: boolean;
date_inferred: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/main/client/src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"model": "Model",
"price": "Cena"
} ,
"tenant": "Katalog",
"templates": "Šablony",
"new_template_name": "Nová šablona",

"field": {
"author": "Autor",
Expand All @@ -40,6 +43,7 @@
"recipient_db": "Příjemce v HIKO db",
"date": "Datum dopisu",
"date_year": "Rok dopisu",
"date_marked": "Datum označené v dopise",
"origin": "Místo odeslání",
"incipit": "Incipit",
"explicit": "Explicit",
Expand All @@ -66,6 +70,7 @@
"copies_archive": "Archiv",
"copies_collection": "Sbírka",
"copies_signature": "Signatura",
"template": "Šablona",
"locations": "Repozitáře"
},
"action": {
Expand Down Expand Up @@ -99,6 +104,7 @@
"AI": "Umělá Inteligence",
"process": "Zpracovat pomoci AI",
"keep_value": "Zachovat předchozí hodnotu",
"add_template": "Přidat šablonu",
"add_acronym": "Přidat akronym",
"remove_acronym": "Odstranit akronym",
"show_images": "Zobrazit výběr"
Expand Down
7 changes: 7 additions & 0 deletions src/main/client/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
"model": "Model",
"price": "Price"
} ,
"tenant": "Catalog",
"templates": "Templates",
"new_template_name": "New template",

"field": {
"author": "Author",
"recipient": "Recipient",
"date": "Date of Letter",
"date_year": "Year of Letter",
"date_marked": "Date found in letter",
"origin": "Origin",
"incipit": "Incipit",
"explicit": "Explicit",
Expand All @@ -63,6 +68,7 @@
"copies_archive": "Archive",
"copies_collection": "Collection",
"copies_signature": "Signature",
"template": "Template",
"locations": "Repositories"
},
"action": {
Expand Down Expand Up @@ -96,6 +102,7 @@
"AI": "Artificial intelligence",
"process": "Process with AI",
"keep_value": "Keep current value",
"add_template": "Add template",
"add_acronym": "Add acronym",
"remove_acronym": "Remove acronym",
"show_images": "Show selection"
Expand Down
Loading

0 comments on commit dce38e4

Please sign in to comment.