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-staff-banner bannerText="{{classLabel}} Configuration" i18n-bannerText>
13 <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}"></eg-admin-page>
17 export class BasicAdminPageComponent implements OnInit {
21 persistKeyPfx: string;
24 private route: ActivatedRoute,
25 private idl: IdlService
30 let schema = this.route.snapshot.paramMap.get('schema');
32 // Allow callers to pass the schema via static route data
33 const data = this.route.snapshot.data[0];
34 if (data) { schema = data.schema; }
36 const table = schema + '.' + this.route.snapshot.paramMap.get('table');
38 // Set the prefix to "server", "local", "workstation",
39 // extracted from the URL path.
40 this.persistKeyPfx = this.route.snapshot.parent.url[0].path;
41 if (this.persistKeyPfx === 'acq') {
42 // ACQ is a special case, becaus unlike 'server', 'local',
43 // 'workstation', the schema ('acq') is the root of the path.
44 this.persistKeyPfx = '';
47 Object.keys(this.idl.classes).forEach(class_ => {
48 const classDef = this.idl.classes[class_];
49 if (classDef.table === table) {
50 this.idlClass = class_;
51 this.classLabel = classDef.label;
56 throw new Error('Unable to find IDL class for table ' + table);