Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82254876
tln-status.component.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 10, 10:19
Size
3 KB
Mime Type
text/x-java
Expires
Thu, Sep 12, 10:19 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20669903
Attached To
rNIETZSCHEBETAAPP Nietzsche-Beta-App
tln-status.component.ts
View Options
import { Component, Input, OnInit } from '@angular/core';
import { TlnQueryServiceInterface } from '../models';
import { TlnCacheQueryService} from '../tln-query.service';
import { DataHandler} from '../data_handler';
import { TlnStatus } from '../datatypes/status';
import { DATA_PROCESSING_STATUS } from '../constants';
/**
* Given a page or manuscript IRI, this component will request its status information and
* symbolize it with an icon.
**/
@Component({
selector: 'tln-status',
templateUrl: './tln-status.component.html',
styleUrls: ['./tln-status.component.css']
})
export class TlnStatusComponent implements OnInit {
@Input() currentIri: string;
/**
* OPTIONAL pass a queryService with method
* {@link /interfaces/TlnQueryServiceInterface.html#getData|getData}
* to TlnPageViewComponent.
**/
@Input() queryService: TlnQueryServiceInterface;
/**
* the data handler of this component that retrieves
* data and instantiates it according to their proper
* datatypes.
**/
dataHandler: DataHandler = new DataHandler(this);
private readonly icon_names: string[] = [ 'task_alt', 'data_saver_on', 'data_saver_off' ];
readonly descriptions: string[] = [ 'Textdaten vollständig erfasst', 'Textdaten teilweise erfasst', 'Ohne Textdaten' ]
private readonly DEFAULT: string = this.icon_names[0];
private readonly DEFAULT_DESCRIPTION: string = this.descriptions[0];
data_processing_dict = {}
iconDescriptions = {}
tlnStatus: TlnStatus;
constructor(private localQueryService: TlnCacheQueryService) { }
ngOnInit() {
if (this.currentIri != undefined && this.currentIri != null){
this.initDataProcessingDict();
this.localQueryService.use_cache = true;
let tlnQueryService = (this.queryService != null) ? this.queryService : this.localQueryService;
this.dataHandler.addHandler('tlnStatus', { 'handler': TlnStatus });
this.dataHandler.setQueryService(tlnQueryService);
this.dataHandler.getData('tlnStatus', this.currentIri);
}
}
private initDataProcessingDict() {
const data_processing_keys = Object.values(DATA_PROCESSING_STATUS);
for (let i = 0; i < this.icon_names.length; i++){
this.data_processing_dict[data_processing_keys[i]] = this.icon_names[i];
}
this.iconDescriptions = this.getIconDescriptions();
}
private getStatus(currentStatus: TlnStatus): string {
const status = (currentStatus != undefined) ? currentStatus.status : undefined;
return this.getSaveInformation(status, this.data_processing_dict, this.DEFAULT);
}
private getDescription(currentStatus: TlnStatus): string {
const icon = this.getStatus(currentStatus);
return this.getSaveInformation(icon, this.iconDescriptions, this.DEFAULT_DESCRIPTION);
}
private getSaveInformation(key: string, dictionary: Object, defaultValue: string): string {
if (key == undefined || key == null || dictionary[key] == undefined){
return defaultValue;
}
return dictionary[key];
}
public getIconDescriptions(): Object {
let iconDescriptions = {};
for (let i = 0; i < this.icon_names.length; i++){
iconDescriptions[this.icon_names[i]] = this.descriptions[i];
}
return iconDescriptions;
}
}
Event Timeline
Log In to Comment