Page MenuHomec4science

models.ts
No OneTemporary

File Metadata

Created
Sat, May 4, 03:21

models.ts

// class for Everything: extended by NavigationEntity, Manuscript, Page, Word with all common properties
import {SafeUrl} from '@angular/platform-browser';
export class TlnEntity {
id: string; // Short id, iri in most cases
iri: string; // iri
type: string; // rdfs:type
navIndex: number;
label?: string;
constructor(id: string, iri: string, type: string, navIndex: number, label?: string) {
this.id = id;
this.iri = iri;
this.type = type;
this.navIndex = navIndex;
this.label = label;
}
}
export class TlnQueryParams {
navBarOpenState: boolean;
navTabIndex: number;
manuscript: string;
page: string;
selectedLines: string;
selectedWords: string;
viewMode: string;
fullscreen: boolean;
zoom: number;
constructor(navBarOpenState: boolean, navTabIndex: number, manuscript: string, page: string, selectedLines: string, selectedWords: string, viewMode: string, fullscreen: boolean, zoom: number ) {
this.navBarOpenState = navBarOpenState;
this.navTabIndex = navTabIndex;
this.manuscript = manuscript;
this.page = page;
this.selectedLines = selectedLines;
this.selectedWords = selectedWords;
this.viewMode = viewMode;
this.fullscreen = fullscreen;
this.zoom = zoom;
}
setParam(prop: string, val: string) {
this[prop] = val;
}
}
// The navigation entries in each tree for each viewtab (TlnManuscript, TlnPage, PositionalEntity) used by navigation
// TODO: add several idxes? Or choosing another order will reload all, hence there is only one idx
//
export class NavigationEntity {
idx: number;
tlnEntity: TlnEntity;
thumb?: SafeUrl; // url of image (Thumbnail)
img?: SafeUrl; // full image url
svg?: SafeUrl; // svg url
constructor(idx: number, tlnEntity: TlnEntity, thumb?: string, img?, svg?: SafeUrl ) {
this.idx = idx;
this.tlnEntity = tlnEntity;
this.thumb = thumb;
this.img = img;
this.svg = svg;
}
}
export interface NavTreeDef {
id: number;
label: string;
qParam: string;
entries: NavigationEntity[];
description?: string;
apiDef?: ApiDef;
isActive?: boolean;
}
export class Annotation {
id: string;
text: string;
styles: Array<string>;
}
// Only relevant if we create an svg ourselves?
export interface PositionalEntity { // used for word rectangles as well as for line numbering
id: string;
text: string;
left: number;
top: number;
width: number;
height: number;
row?: number;
iri?: string; // TODO, change this. will be the id later when change data source to rdf ...
}
export class ApiDef {
type: number; // 0 === sparql 1.1., 1 === nietzscheSource API, 2 === existDB
baseUrl: string;
dataArray: string;
query?: string;
mapping?: TlnEntityMapping; // positive Filter ids: only these id's should be loaded into manuscript nav tree
constructor( type: number, baseUrl: string, dataArray: string, query?: string, mapping?: TlnEntityMapping) {
this.type = type;
this.baseUrl = baseUrl;
this.dataArray = dataArray;
this.query = query;
this.mapping = mapping;
}
}
export class TlnEntityMapping { // Is used for mapping the response from any given apiDef/response to a TlnEntity Instance
id: string; // Short id, iri in most cases
iri?: string; // iri
idx?: string;
type?: string; // rdfs:type
label?: string;
img?: string;
svg?: string;
thumb?: string;
constructor(id: string, iri?: string, idx?: string, type?: string, label?: string, img?: string, svg?: string, thumb?: string) {
this.id = id; this.iri = iri; this.idx = idx; this.type = type; this.label = label; this.img = img; this.svg = svg, this.thumb = thumb;
}
}

Event Timeline