prepared transformation inspector page
This commit is contained in:
parent
a2d144fb07
commit
bd302ab707
|
@ -14,6 +14,7 @@ import { IndexComponent } from './index/index.component';
|
|||
import { OaiComponent } from './oai/oai.component';
|
||||
import { SwaggerUiComponent } from './swagger/swagger-ui.component';
|
||||
import { OaiExplorerComponent } from './oai-explorer/oai-explorer.component';
|
||||
import { XsltTesterComponent } from './xslt-tester/xslt-tester.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
|
@ -35,6 +36,7 @@ const routes: Routes = [
|
|||
{ path: "mdstores/:mdId", component: MdstoresComponent },
|
||||
{ path: "mdrecords/:versionId/:limit", component: MdstoreInspectorComponent },
|
||||
{ path: "cleaner", component: CleanerTesterComponent },
|
||||
{ path: "xslt", component: XsltTesterComponent },
|
||||
{ path: "index", component: IndexComponent },
|
||||
{ path: "oai", component: OaiComponent },
|
||||
{ path: "oai-explorer", component: OaiExplorerComponent },
|
||||
|
|
|
@ -50,6 +50,7 @@ import { MatMenuModule } from '@angular/material/menu';
|
|||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatNativeDateModule } from '@angular/material/core';
|
||||
import { OaiExplorerComponent } from './oai-explorer/oai-explorer.component';
|
||||
import { XsltTesterComponent } from './xslt-tester/xslt-tester.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -82,6 +83,7 @@ import { OaiExplorerComponent } from './oai-explorer/oai-explorer.component';
|
|||
MDStoreVersionsDialog,
|
||||
AddMDStoreDialog,
|
||||
CleanerTesterComponent,
|
||||
XsltTesterComponent,
|
||||
WfConfsComponent,
|
||||
WfConfDialog,
|
||||
WfConfSingle,
|
||||
|
|
|
@ -38,7 +38,7 @@ export class CleanerTesterComponent {
|
|||
export class CleanerTesterClient extends ISClient {
|
||||
|
||||
loadCleaningRules(onSuccess: Function): void {
|
||||
this.httpGet<SimpleResource[]>("/proxy/byType/resource-manager/byType/cleaning_rule", onSuccess);
|
||||
this.httpGet<SimpleResource[]>("/proxy/byType/resource_manager/api/resources/byType/cleaning_rule", onSuccess);
|
||||
}
|
||||
|
||||
testCleaning(rule: string, xml: string, onSuccess: Function, relatedForm?: FormGroup): void {
|
||||
|
|
|
@ -72,8 +72,8 @@
|
|||
</mat-expansion-panel-header>
|
||||
<div>
|
||||
<a class="menu-item" routerLink="mdstores" *ngIf="isEnabled('mdstore_manager')">MDStore Inspector</a>
|
||||
<a class="menu-item" routerLink="cleaner" *ngIf="isEnabled('wf_manager')">Cleaner
|
||||
Tester</a>
|
||||
<a class="menu-item" routerLink="cleaner" *ngIf="isEnabled('wf_manager')">Cleaner Tester</a>
|
||||
<a class="menu-item" routerLink="xslt" *ngIf="isEnabled('wf_manager')">Xslt Tester</a>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<h2>Transformation Rule Tester (XSLT)</h2>
|
||||
|
||||
<form [formGroup]="xsltForm" (ngSubmit)="transformXslt()">
|
||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||
<mat-label>Transformation rule (XSLT)</mat-label>
|
||||
<mat-select matInput formControlName="rule">
|
||||
<mat-option *ngFor="let i of rules" [value]="i.name">{{i.name}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 50%;">
|
||||
<mat-label>Input Record</mat-label>
|
||||
<textarea matInput rows="10" formControlName="xmlIn"></textarea>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 50%;">
|
||||
<mat-label>Output Record</mat-label>
|
||||
<textarea matInput rows="10" formControlName="xmlOut" readonly></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
<button mat-stroked-button color="primary" type="submit" [disabled]="!xsltForm.valid">Submit</button>
|
||||
<mat-error *ngIf="xsltForm.errors?.['serverError']">
|
||||
{{ xsltForm.errors?.['serverError'] }}
|
||||
</mat-error>
|
||||
|
||||
</form>
|
|
@ -0,0 +1,49 @@
|
|||
import { Component, Injectable, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormControl, Validators } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ResourceType, SimpleResource } from '../common/is.model';
|
||||
import { ISClient } from '../common/is.client';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-xslt-tester',
|
||||
templateUrl: './xslt-tester.component.html',
|
||||
styleUrls: []
|
||||
})
|
||||
export class XsltTesterComponent {
|
||||
rules: SimpleResource[] = [];
|
||||
|
||||
xmlOutput: string = ''
|
||||
|
||||
xsltForm = new FormGroup({
|
||||
xmlIn: new FormControl('', [Validators.required]),
|
||||
rule: new FormControl('', [Validators.required]),
|
||||
xmlOut: new FormControl('')
|
||||
});
|
||||
|
||||
constructor(public client: XsltTesterClient, public route: ActivatedRoute, public dialog: MatDialog) {
|
||||
this.client.loadXsltRules((data: SimpleResource[]) => this.rules = data);
|
||||
}
|
||||
|
||||
transformXslt() {
|
||||
this.client.transformXslt(this.xsltForm.get("rule")?.value!, this.xsltForm.get("xmlIn")?.value!, (data: string) => this.xsltForm.get("xmlOut")?.setValue(data), this.xsltForm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class XsltTesterClient extends ISClient {
|
||||
|
||||
loadXsltRules(onSuccess: Function): void {
|
||||
this.httpGet<SimpleResource[]>("/proxy/byType/resource_manager/api/resources/byType/transformation_rule_xslt", onSuccess);
|
||||
}
|
||||
|
||||
transformXslt(rule: string, xml: string, onSuccess: Function, relatedForm?: FormGroup): void {
|
||||
var headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
|
||||
this.httpPostWithOptions('/proxy/byType/mapping/transformXslt?rule=' + encodeURIComponent(rule), xml, { headers, responseType: 'text' as 'json' }, onSuccess, relatedForm);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue