1 import {Component, OnInit} from '@angular/core';
2 import {ActivatedRoute} from '@angular/router';
3 import {IdlService} from '@eg/core/idl.service';
6 * Generic IDL class editor page.
11 <eg-title i18n-prefix prefix="{{classLabel}} Administration">
13 <eg-staff-banner bannerText="{{classLabel}} Configuration" i18n-bannerText>
15 <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}"></eg-admin-page>
19 export class BasicAdminPageComponent implements OnInit {
23 persistKeyPfx: string;
26 private route: ActivatedRoute,
27 private idl: IdlService
32 let schema = this.route.snapshot.paramMap.get('schema');
34 // Allow callers to pass the schema via static route data
35 const data = this.route.snapshot.data[0];
36 if (data) { schema = data.schema; }
38 const table = schema + '.' + this.route.snapshot.paramMap.get('table');
40 // Set the prefix to "server", "local", "workstation",
41 // extracted from the URL path.
42 this.persistKeyPfx = this.route.snapshot.parent.url[0].path;
43 if (this.persistKeyPfx === 'acq') {
44 // ACQ is a special case, becaus unlike 'server', 'local',
45 // 'workstation', the schema ('acq') is the root of the path.
46 this.persistKeyPfx = '';
49 Object.keys(this.idl.classes).forEach(class_ => {
50 const classDef = this.idl.classes[class_];
51 if (classDef.table === table) {
52 this.idlClass = class_;
53 this.classLabel = classDef.label;
58 throw new Error('Unable to find IDL class for table ' + table);