diff --git a/nietzsche-beta-app/package.json b/nietzsche-beta-app/package.json index cc99d8d..bc5dc48 100644 --- a/nietzsche-beta-app/package.json +++ b/nietzsche-beta-app/package.json @@ -1,60 +1,60 @@ { "name": "nietzsche-app-beta", - "version": "0.7.0.0", + "version": "0.7.1.1", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "compodoc": "./node_modules/.bin/compodoc -p tsconfig.app.json", "sparqljs": "./node_modules/sparqljs/sparql.js" }, "private": true, "dependencies": { "@angular/animations": "~8.2.14", "@angular/cdk": "~8.2.3", "@angular/common": "~8.2.14", "@angular/compiler": "~8.2.14", "@angular/core": "~8.2.14", "@angular/forms": "~8.2.14", "@angular/material": "^8.2.3", "@angular/platform-browser": "~8.2.14", "@angular/platform-browser-dynamic": "~8.2.14", "@angular/router": "~8.2.14", "@ctrl/ngx-codemirror": "^5.0.0", "@types/rdf-js": "^2.0.11", "codemirror": "^5.62.0", "lodash": "^4.17.20", "n3": "^1.10.0", "ngx-csv": "^0.3.2", "ngx-mat-standoff-markup": "^0.7.3", "rdfjs": "^0.0.1", "rxjs": "~6.4.0", "sparqljs": "^3.0.1", "tslib": "^1.10.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/build-angular": "^0.803.25", "@angular/cli": "~8.3.24", "@angular/compiler-cli": "~8.2.14", "@angular/language-service": "~8.2.14", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.5.3" } } diff --git a/nietzsche-beta-app/src/app/tln-edition/datatypes/imprint.ts b/nietzsche-beta-app/src/app/tln-edition/datatypes/imprint.ts new file mode 100644 index 0000000..5175cf2 --- /dev/null +++ b/nietzsche-beta-app/src/app/tln-edition/datatypes/imprint.ts @@ -0,0 +1,62 @@ +import { BasicResultBindingElement, FusekiResults } from './basic_datatype'; +import { Line } from '../models'; +/** + * This is the 'editor comment' stub instantiation of an element of {@link /interfaces/FusekiResults.html|FusekiResults}. + **/ +export class TlnImprint extends BasicResultBindingElement { + static readonly default_key: string = 'page'; + static readonly query_key: string = 'page'; + /** + * the SPARQL-query of this datatype. + **/ + static readonly query: string = ` + PREFIX tln: + PREFIX rdf: + PREFIX rdfs: + + SELECT ?id ?reference ?line ?lineNumber WHERE { + ?page a tln:Page; + tln:hasImprints/rdf:rest*/rdf:first ?id. + ?id tln:imprintHasReference ?reference. + OPTIONAL { ?id tln:imprintRefersToLines/rdf:rest*/rdf:first ?line. + ?line tln:lineHasNumber ?lineNumber . + } + }`; + reference: string; + lines: Line[] = []; + /** + * The constructor creates a datatype from the data. + * + * @param id if omitted the id will be retrieved from data + **/ + constructor(data: any, id?: string, service?: any){ + super(data, id, service) + this.reference = this.getData4Key('reference'); + } + + public static convertData(this: T, data: FusekiResults, id?: string, service?: any): Array> { + let elements = []; + let content = this.getContent(data); + for (var i = 0; i < content.length; i++){ + let element = new TlnImprint(content[i], id, service); + if(content[i]['line'] != undefined && content[i]['line'] != null) { + element.lines.push({ + id: content[i]['line']['value'], + number: Number(content[i]['lineNumber']['value']), + bottom: -1, + top: -1 + }); + } + if (elements.length > 0 && elements[elements.length-1].id == element.id + && element.lines.length > 0){ + elements[elements.length-1].lines.push(element.lines[0]) + } else { + elements.push(element) + } + } + console.log(elements) + return elements; + } + +} + diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-edition.module.ts b/nietzsche-beta-app/src/app/tln-edition/tln-edition.module.ts index c6e77a4..bafe9a1 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tln-edition.module.ts +++ b/nietzsche-beta-app/src/app/tln-edition/tln-edition.module.ts @@ -1,110 +1,111 @@ import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { HttpClientModule } from "@angular/common/http"; import { NgModule, ModuleWithProviders } from '@angular/core'; import { MatBadgeModule, MatSnackBarModule, MatSlideToggleModule, MatTreeModule, MatSliderModule,MatProgressSpinnerModule,MatBottomSheetModule,MatButtonModule,MatCheckboxModule,MatDialogModule,MatExpansionModule,MatFormFieldModule,MatInputModule,MatListModule,MatPaginatorModule,MatRadioModule,MatSelectModule,MatSidenavModule,MatSortModule,MatTableModule,MatToolbarModule,MatButtonToggleModule,MatCardModule,MatIconModule,MatMenuModule,MatTabsModule,MatTooltipModule } from '@angular/material'; import { CodemirrorModule } from '@ctrl/ngx-codemirror'; import { NgxMatStandoffMarkupModule} from "ngx-mat-standoff-markup"; import { PageViewService } from '../page-view/page-view.service'; import { PageViewModule } from '../page-view/page-view.module'; import { OntologyViewerModule } from '../ontology-viewer/ontology-viewer.module'; import { TlnPageViewComponent } from './tln-page-view.component'; import { TlnQueryService, TlnCacheQueryService } from './tln-query.service'; import { ToolTipComponent } from './tooltip/tool-tip.component'; import { TlnViewerNavigation } from './tln-viewer-navigation/tln-viewer-navigation.component'; import { TlnInformationComponent } from './tln-information/tln-information.component'; import { TlnCrossrefComponent } from './tln-crossref/tln-crossref.component'; import { VersionViewComponent } from './tln-crossref/version-view/version-view.component'; import { PageVersionViewComponent } from './tln-crossref/page-version-view/page-version-view.component'; import { NavigationComponent } from './tln-crossref/navigation/navigation.component'; import { GeneticOrderFilterPipe} from './tln-crossref/page-version-view/filter.pipe'; import { TlnPageVersionViewComponent } from './tln-crossref/page-version-view/tln-page-version-view.component'; import { TlnManuscriptViewComponent } from './tln-manuscript-view/tln-manuscript-view.component'; import { TlnFulltextComponent } from './tln-fulltext/tln-fulltext.component'; import { FulltextNavigationComponent } from './tln-fulltext/navigation/navigation.component'; import { ResultPipePipe } from './tln-fulltext/result-pipe.pipe'; import { PageResultFilterPipe} from './common/page-result-filter.pipe'; import { SearchComponent } from './tln-navigation-elements/search.component'; import { ToggleNavigationComponent } from './tln-navigation-elements/toggle-navigation.component'; import { ZoomComponent } from './tln-navigation-elements/zoom.component'; import { ZoomPipe } from './tln-navigation-elements/zoom.pipe'; import { OpenInViewerComponent } from './tln-navigation-elements/open-in-viewer.component'; import { DebugPipe } from './debug.pipe'; import { TlnHeightDirective } from './tln-height.directive'; import { TlnQuantComponent } from './tln-quant/tln-quant.component'; import { TlnTableComponent } from './tln-quant/tln-table.component'; import { ResultPipe } from './tln-quant/result.pipe'; import { WordPresentationComponent } from './tln-quant/word-presentation.component'; import { ToIdsPipe } from './tln-quant/2-ids.pipe'; import { SortByLinePipe } from './tln-quant/sort-by-line.pipe'; import { QueryErrorComponent } from './tln-quant/query-error.component'; import { ExportComponent } from './tln-quant/export.component'; import { FusekiTableComponent } from './tln-quant/fuseki-table.component'; import { TlnOntologyViewerComponent } from './tln-quant/tln-ontology-viewer.component'; import { EditorCommentComponent } from './tooltip/editor-comment.component'; import { MergeEditorCommentPipe } from './tooltip/merge-editor-comment.pipe'; import { OverwrittenComponent } from './tooltip/overwritten.component'; import { FootnoteComponent } from './tln-information/footnote.component'; +import { ImprintComponent } from './tln-information/imprint.component'; @NgModule({ - declarations: [FulltextNavigationComponent, TlnPageViewComponent, ToolTipComponent, TlnViewerNavigation, TlnInformationComponent, TlnCrossrefComponent, VersionViewComponent, PageVersionViewComponent, NavigationComponent, GeneticOrderFilterPipe, TlnPageVersionViewComponent, TlnManuscriptViewComponent, TlnFulltextComponent, PageResultFilterPipe, ResultPipePipe, SearchComponent, ToggleNavigationComponent, ZoomComponent, ZoomPipe, OpenInViewerComponent, DebugPipe, TlnHeightDirective, TlnQuantComponent, TlnTableComponent, ResultPipe, WordPresentationComponent, ToIdsPipe, SortByLinePipe, QueryErrorComponent, ExportComponent, FusekiTableComponent, TlnOntologyViewerComponent, EditorCommentComponent, MergeEditorCommentPipe, OverwrittenComponent, FootnoteComponent], + declarations: [FulltextNavigationComponent, TlnPageViewComponent, ToolTipComponent, TlnViewerNavigation, TlnInformationComponent, TlnCrossrefComponent, VersionViewComponent, PageVersionViewComponent, NavigationComponent, GeneticOrderFilterPipe, TlnPageVersionViewComponent, TlnManuscriptViewComponent, TlnFulltextComponent, PageResultFilterPipe, ResultPipePipe, SearchComponent, ToggleNavigationComponent, ZoomComponent, ZoomPipe, OpenInViewerComponent, DebugPipe, TlnHeightDirective, TlnQuantComponent, TlnTableComponent, ResultPipe, WordPresentationComponent, ToIdsPipe, SortByLinePipe, QueryErrorComponent, ExportComponent, FusekiTableComponent, TlnOntologyViewerComponent, EditorCommentComponent, MergeEditorCommentPipe, OverwrittenComponent, FootnoteComponent, ImprintComponent], imports: [ CodemirrorModule, MatBadgeModule, MatSnackBarModule, MatSlideToggleModule, MatSliderModule, MatBottomSheetModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatDialogModule, MatExpansionModule, MatFormFieldModule, MatIconModule, MatInputModule, MatListModule, MatMenuModule, MatProgressSpinnerModule, MatPaginatorModule, MatRadioModule, MatSelectModule, MatSidenavModule, MatSortModule, MatTableModule, MatTabsModule, MatTreeModule, MatToolbarModule, MatTooltipModule, BrowserModule, CommonModule, FormsModule, NgxMatStandoffMarkupModule, PageViewModule, OntologyViewerModule ], exports: [ DebugPipe, FulltextNavigationComponent, NavigationComponent, ToggleNavigationComponent, ToolTipComponent, TlnCrossrefComponent, TlnHeightDirective, TlnManuscriptViewComponent, TlnPageViewComponent, TlnViewerNavigation, TlnQuantComponent ], providers: [ PageViewService, //TlnQueryService ], entryComponents: [TlnInformationComponent, QueryErrorComponent] }) export class TlnEditionModule { } diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.css b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.css new file mode 100644 index 0000000..e69de29 diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.html b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.html new file mode 100644 index 0000000..936dd73 --- /dev/null +++ b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.html @@ -0,0 +1,5 @@ +
+ {{imprintReference}} +
diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.scss b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.spec.ts b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.spec.ts new file mode 100644 index 0000000..49b68ae --- /dev/null +++ b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ImprintComponent } from './imprint.component'; + +describe('ImprintComponent', () => { + let component: ImprintComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ImprintComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ImprintComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.ts b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.ts new file mode 100644 index 0000000..7a27971 --- /dev/null +++ b/nietzsche-beta-app/src/app/tln-edition/tln-information/imprint.component.ts @@ -0,0 +1,89 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { MatBottomSheetRef} from '@angular/material/bottom-sheet'; +import { PageViewService } from '../services'; +import { Line } from '../models'; +import { TlnImprint } from '../datatypes/imprint'; +import { Mapping } from '../route-reader'; +import { RouteUpdater } from '../route-updater'; +import { TLN_SELECTED_LINES_PARAM } from '../constants'; + +interface Range { + start: number; + end?: number; +} + +@Component({ + selector: 'imprint', + templateUrl: './imprint.component.html', + styleUrls: ['./imprint.component.css'] +}) +export class ImprintComponent extends RouteUpdater implements OnInit { + @Input() imprint: TlnImprint; + @Input() bottomSheetRef: MatBottomSheetRef; + @Input() parentActivatedRoute: ActivatedRoute; + @Input() targetRoute: string; + protected currentRoute: string;// = TLN_CROSSREF_ROUTE; + highlighted: boolean = false; + imprintReference: string; + selectedLines: string[] = []; + protected mapping: Mapping = { + selectedLines: { param: TLN_SELECTED_LINES_PARAM, type: "string" } + }; + + constructor(private pageViewService: PageViewService, protected router: Router, protected activatedRoute: ActivatedRoute ){ + super(router, activatedRoute); + } + + ngOnInit() { + this.imprintReference = this.getLineReference() + this.imprint.reference; + } + private getLineReference(): string { + let lineString = ''; + if (this.imprint.lines.length == 0){ + return lineString + } + const ranges = this.numbers2ConsecutiveRanges(this.imprint.lines.map(line =>line.number)); + ranges.forEach(range =>{ + if (lineString != ''){ + lineString = lineString + ',' + } + lineString = (range.end != undefined) ? lineString + range.start + '-' + range.end : lineString + range.start; + }); + return lineString + ': '; + } + private numbers2ConsecutiveRanges(lines: number[]): Range[] { + if (lines.length == 0) { + return [] + } else if (lines.length < 2){ + return [ { start: lines[0] } ]; + } else if (lines.length == 2) { + return (lines[1] - lines[0] > 1) ? [ { start: lines[0] }, { start: lines[1] } ] : [ { start: lines[0], end: lines[1] } ]; + } else { + const index = Math.round((lines.length-1)/2) + let leftRanges = this.numbers2ConsecutiveRanges(lines.slice(0, index)) + let rightRanges = this.numbers2ConsecutiveRanges(lines.slice(index)) + if (leftRanges.length == 0){ + return rightRanges + } + if (rightRanges.length == 0){ + return leftRanges + } + if ((leftRanges[leftRanges.length-1].end != undefined && rightRanges[0].start - leftRanges[leftRanges.length-1].end == 1) + || rightRanges[0].start - leftRanges[leftRanges.length-1].start == 1){ + leftRanges[leftRanges.length-1].end = rightRanges[0].end + return [...leftRanges,...rightRanges.slice(1)]; + } + return [...leftRanges,...rightRanges]; + } + } +private hoverChanged(hover: boolean){ + this.highlighted = hover; + if (this.imprint != null){ + this.imprint.lines.forEach(line =>{ + this.pageViewService.onClickedLine.emit(line); + }) + } + } + +} diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.html b/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.html index d7306a2..d96dc90 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.html +++ b/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.html @@ -1,11 +1,15 @@

{{data.page.title}} {{data.page.number}}:

-

Fussnote{{ data.editor_comments.length == 1 ? '' : 'n' }}:

+

Druckort{{ data.imprints.length == 1 ? '' : 'e' }}:

+ +

Kritische Anmerkung{{ data.editor_comments.length == 1 ? '' : 'en' }}:

Querverweise:

diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.ts b/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.ts index e504295..51e5d62 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.ts +++ b/nietzsche-beta-app/src/app/tln-edition/tln-information/tln-information.component.ts @@ -1,64 +1,66 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; import { MAT_BOTTOM_SHEET_DATA, MatBottomSheetRef} from '@angular/material/bottom-sheet'; import { EditorComment, ManuscriptUnity, NavigationPage} from '../models'; import { Mapping, RouteReader } from '../route-reader'; import { RouteUpdater } from '../route-updater'; import { TlnTextGeneticOrder} from '../datatypes/text_version'; import { TlnEditorComment } from '../datatypes/editor_comment'; +import { TlnImprint } from '../datatypes/imprint'; import { TLN_PAGE_PARAM, TLN_MANUSCRIPT_PARAM, TLN_TEXT_GENETIC_ORDER_PARAM, TLN_CROSSREF_ROUTE, TLN_VIEWER_ROUTE } from '../constants'; import { TlnViewerNavigation } from '../tln-viewer-navigation/tln-viewer-navigation.component'; export interface ParentInformation { editor_comments: EditorComment[]; + imprints: TlnImprint[]; geneticOrders: TlnTextGeneticOrder[]; page: NavigationPage; manuscript_iri: string; parentActivatedRoute?: ActivatedRoute; } @Component({ selector: 'app-tln-information', templateUrl: './tln-information.component.html', styleUrls: ['./tln-information.component.css'] }) export class TlnInformationComponent extends RouteUpdater implements OnInit { /** * IRI of the current page TODO: for later use **/ current_iri: string; /** * IRI of the current manuscript TODO: for later use **/ current_manuscript_iri: string; /** * IRI of the current geneticOrder TODO: for later use **/ current_genetic_order: string; /** * the route to the crossref app **/ private crossrefRoute: string = TLN_CROSSREF_ROUTE; /** * the route to the viewer app **/ private viewerRoute: string = TLN_VIEWER_ROUTE; /** * the param mapping TODO: for later use **/ protected mapping: Mapping = { current_iri: { param: TLN_PAGE_PARAM, type: "string" }, current_manuscript_iri: { param: TLN_MANUSCRIPT_PARAM, type: "string" }, current_genetic_order: { param: TLN_TEXT_GENETIC_ORDER_PARAM, type: "string" } } constructor(@Inject(MAT_BOTTOM_SHEET_DATA) private data: ParentInformation, private bottomSheetRef: MatBottomSheetRef, protected router: Router, protected activatedRoute: ActivatedRoute ){ super(router, activatedRoute); } /*ngOnInit() { //TODO: for later use super.ngOnInit(); }*/ } diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-query.service.ts b/nietzsche-beta-app/src/app/tln-edition/tln-query.service.ts index d6e57bb..349fb37 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tln-query.service.ts +++ b/nietzsche-beta-app/src/app/tln-edition/tln-query.service.ts @@ -1,76 +1,76 @@ import { Injectable, EventEmitter, OnInit } from '@angular/core'; import {HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; import { EMPTY, Observable, throwError } from 'rxjs'; import { catchError, shareReplay } from 'rxjs/operators'; import { TlnQueryServiceInterface } from './models'; import { MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition, } from '@angular/material/snack-bar'; import {MatDialog, MatDialogConfig} from '@angular/material/dialog'; /** * This is the internal query service * that communicates with the SPARQL-endpoint. * */ @Injectable({ providedIn: 'root'}) export class TlnQueryService implements TlnQueryServiceInterface { - // baseUrl = 'http://localhost:3030/nietzsche/query'; - baseUrl = 'https://nietzsche.fuseki.services.dasch.swiss/nietzsche' + // baseUrl = 'http://localhost:3030/nietzsche/query'; + baseUrl = 'https://nietzsche.fuseki.services.dasch.swiss/nietzsche' reset_data = new EventEmitter(); error_emitter = new EventEmitter(); use_cache: boolean = false; cache = {}; constructor(private http: HttpClient, private _snackBar: MatSnackBar) { } public resetData(key: string){ this.reset_data.emit(key); } /** * Gets the data from an endpoint via http post * * @param query: The query to run. * @returns response */ public getData(query: string): Observable { let httpOptions = { headers: new HttpHeaders( { 'Content-Type': 'application/sparql-query', 'Accept': 'application/sparql-results+json; charset=UTF-8'} ) }; if (this.use_cache && this.cache[query]){ console.log('Returning cached value!') return this.cache[query]; } if (!this.use_cache){ return this.http.post(this.baseUrl, query, httpOptions).pipe(catchError(this.handleError)); } this.cache[query] = this.http.post(this.baseUrl, query, httpOptions).pipe( shareReplay(1), catchError(error =>{ delete this.cache[query]; this.handleError(error); return EMPTY }) ); return this.cache[query] } private handleError(error: HttpErrorResponse) { this.error_emitter.emit(error); switch (error.status){ case 0: // A client-side or network error occurred. Handle it accordingly. console.error('The backend data server is offline:', error.error); this._snackBar.open('The backend data server ' + this.baseUrl + ' is offline!'); break; default: console.error( `Backend returned code ${error.status}, ` + `body was: ${error.error}`); } return throwError( 'Something bad happened; please try again later.'); } } @Injectable({ providedIn: 'root'}) export class TlnCacheQueryService extends TlnQueryService { use_cache: boolean = true; } diff --git a/nietzsche-beta-app/src/app/tln-edition/tln-viewer-navigation/tln-viewer-navigation.component.ts b/nietzsche-beta-app/src/app/tln-edition/tln-viewer-navigation/tln-viewer-navigation.component.ts index 294e474..2f5bbee 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tln-viewer-navigation/tln-viewer-navigation.component.ts +++ b/nietzsche-beta-app/src/app/tln-edition/tln-viewer-navigation/tln-viewer-navigation.component.ts @@ -1,180 +1,187 @@ import { Component, OnInit, OnDestroy, HostListener, Input, ElementRef } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; import {MatBottomSheet, MatBottomSheetRef} from '@angular/material/bottom-sheet'; import { EditorComment, TlnQueryServiceInterface, Reference, ManuscriptUnity, NavigationPage } from '../models'; import { TlnManuscriptUnity, TlnNavigationPage} from '../datatypes/navigation'; import { DEFAULT_VIEW_OPTION, TLN_VIEWER_ROUTE, TLN_FULLSCREEN_PARAM, TLN_FIND_PARAM, TLN_NAV_BAR_OPEN_STATE_PARAM, TLN_PAGE_PARAM, TLN_MANUSCRIPT_PARAM, TLN_SELECTED_LINES_PARAM, TLN_SELECTED_WORDS_PARAM, TLN_VIEW_OPTION_PARAM, TLN_ZOOM_PARAM, VIEW_OPTIONS, ONTOLOTY_PREFIX } from '../constants'; import { IsReconstructedKonvolut } from '../datatypes/basic_datatype'; import { TlnLine} from '../datatypes/line'; import { TlnWord} from '../datatypes/word'; import { TlnTextGeneticOrder} from '../datatypes/text_version'; import { TlnEditorComment, TlnLineEditorComment } from '../datatypes/editor_comment'; +import { TlnImprint } from '../datatypes/imprint'; import { Mapping } from '../route-reader'; import { RouteUpdater } from '../route-updater'; import { ComplexKeyIriMapping, DataHandler, KeyIriMapping } from '../data_handler'; import { PageViewService, TlnCacheQueryService } from '../services'; import { TlnInformationComponent, ParentInformation } from '../tln-information/tln-information.component'; import { PageInformation } from '../tln-information/page-information'; @Component({ selector: 'tln-viewer-navigation', templateUrl: './tln-viewer-navigation.component.html', providers: [ TlnCacheQueryService ], styleUrls: ['./tln-viewer-navigation.component.css'] }) export class TlnViewerNavigation extends RouteUpdater implements OnDestroy { /** * OPTIONAL pass a queryService with method * {@link /interfaces/TlnQueryServiceInterface.html#getData|getData} * to TlnPageViewComponent. **/ @Input() queryService: TlnQueryServiceInterface; /** * whether or not to show page view in fullscreen mode. **/ fullscreen: boolean = false; findText: string; current_iri: string; current_manuscript_iri: string; manuscript_unity: ManuscriptUnity; current_page: NavigationPage; pageInformation: PageInformation; previous_page: NavigationPage; /** * editor comments **/ editor_comments: TlnEditorComment[] = []; /** * line editor comments **/ line_comments: TlnLineEditorComment[] = []; + /** + * page imprints + **/ + imprints: TlnImprint[] = []; next_page: NavigationPage; navBarOpenState: boolean; showArchivalManuscriptUnity: boolean = false; dataHandler: DataHandler = new DataHandler(this); geneticOrders: TlnTextGeneticOrder[] = []; selectedLines: string[] = []; selectedWords: string[] = []; private readonly increment: number = 0.333; private readonly decrement: number = this.increment*-1; //protected currentRoute: string = TLN_VIEWER_ROUTE; protected mapping: Mapping = { findText: { param: TLN_FIND_PARAM, type: "string" }, current_iri: { param: TLN_PAGE_PARAM, type: "string" }, navBarOpenState: { param: TLN_NAV_BAR_OPEN_STATE_PARAM, type: "boolean" }, current_manuscript_iri: { param: TLN_MANUSCRIPT_PARAM, type: "string" }, fullscreen: { param: TLN_FULLSCREEN_PARAM, type: "boolean" }, selectedViewOption: { param: TLN_VIEW_OPTION_PARAM, type: "string" }, selectedWords: { param: TLN_SELECTED_WORDS_PARAM, type: "string" }, selectedLines: { param: TLN_SELECTED_LINES_PARAM, type: "string" } } routerParams: Params; selectedViewOption: string = DEFAULT_VIEW_OPTION updating: boolean = false; viewOptions: string[] = [ VIEW_OPTIONS.TRANSKRIPTION, VIEW_OPTIONS.FAKSIMILE, VIEW_OPTIONS.SYNOPSIS, VIEW_OPTIONS.SYNOPSIS_B ]; subscriptions: any[] = []; constructor(el: ElementRef, private bottomSheet: MatBottomSheet, private pageViewService: PageViewService, private localQueryService: TlnCacheQueryService, protected router: Router, protected activatedRoute: ActivatedRoute ) { super(router, activatedRoute); } ngOnInit() { let tlnQueryService = (this.queryService != null) ? this.queryService : this.localQueryService; this.dataHandler.addHandler('manuscript_unity', { 'handler': TlnManuscriptUnity, 'next_key': 'navigation_page'}); - this.dataHandler.addHandler('navigation_page', ['current_page', 'geneticOrders', 'editor_comments', 'line_comments'] ); + this.dataHandler.addHandler('navigation_page', ['current_page', 'geneticOrders', 'editor_comments', 'line_comments', 'imprints'] ); this.dataHandler.addHandler('current_page', { 'handler': TlnNavigationPage }); this.dataHandler.addHandler('geneticOrders', { 'handler': TlnTextGeneticOrder}); this.dataHandler.addHandler('editor_comments', { 'handler': TlnEditorComment}); this.dataHandler.addHandler('line_comments', { 'handler': TlnLineEditorComment}); + this.dataHandler.addHandler('imprints', { 'handler': TlnImprint}); this.dataHandler.setQueryService(tlnQueryService); this.subscriptions.push(this.dataHandler.start_processing.subscribe( (started: boolean) =>{ this.updating = true; })); this.subscriptions.push(this.dataHandler.processing_finished.subscribe( (finished: boolean) =>{ this.updating = false; })); super.ngOnInit(); this.subscriptions.push(this.pageViewService.reference.subscribe( (newReference: Reference) => { this.updatePageToReference(newReference) })); this.subscriptions.push(this.pageViewService.onClickedLine.subscribe( (clickedLine: TlnLine) => { let index = this.selectedLines.indexOf(clickedLine.id) if (index > -1){ this.selectedLines.splice(index, 1); } else { this.selectedLines.push(clickedLine.id); } this.updateParams(); })); this.subscriptions.push(this.pageViewService.onClickedWord.subscribe( (clickedWord: TlnWord) => { this.clickWord(clickedWord) })); } ngOnDestroy() { this.subscriptions.forEach(subscription => subscription.unsubscribe()); } private clearFindText() { this.findText = ''; this.updateParams(); } private clickWord(clickedWord: TlnWord){ let wordIndex = this.selectedWords.indexOf(clickedWord.id) let lineIndex = this.selectedLines.indexOf(clickedWord.line) if (wordIndex > -1){ this.selectedWords.splice(wordIndex, 1); } else if (lineIndex > -1){ this.selectedLines.splice(lineIndex, 1); } else { this.selectedWords.push(clickedWord.id); } this.updateParams(); } private getPageTitle(page?: NavigationPage, numPages?: number): string { if (page == null){ return ''; } let indexPrefix = (numPages != null) ? page.index + '/' + numPages : page.index; return indexPrefix + ': ' + page.title + ' ' + page.number; } protected readParams(params: Params){ super.readParams(params); if (this.dataHandler.ready && (this.current_page == null || this.current_page.id != this.current_iri)){ this.dataHandler.resetData('navigation_page') if(this.current_manuscript_iri != null){ //this.dataHandler.debug = true; /*this.dataHandler.conditionalAddHandler(IsReconstructedKonvolut.getQuery(this.current_manuscript_iri), 'current_page',{ handler: TlnNavigationPage}, { handler: TlnNavigationPage});*/ this.dataHandler.getData('manuscript_unity', this.current_manuscript_iri, this.current_iri); } else { this.dataHandler.getData('current_page', this.current_iri); } } } private setCurrentIri(pageIri: string, manuscriptIir?: string){ this.dataHandler.stop_processing.emit(true); this.current_iri = pageIri; this.updateParams(); } private showInformation() { let parentData: ParentInformation = { editor_comments: this.line_comments.concat(this.editor_comments).sort((a, b)=>{ return (a.tLine.number < b.tLine.number) ? -1 : 1; }), + imprints: this.imprints, geneticOrders: this.geneticOrders, page: this.current_page, manuscript_iri: this.current_manuscript_iri, parentActivatedRoute: this.activatedRoute.parent } this.bottomSheet.open(TlnInformationComponent, { data: parentData, backdropClass: (parentData.editor_comments.length > 0) ? 'backdropNonFadingClass' : '' }); } private updatePageToReference(reference: Reference){ this.current_iri = reference.page.id; this.selectedLines = [ reference.line.id ] this.updateParams(); } }