add API model
This commit is contained in:
parent
f776c2ca68
commit
90d7b7626f
|
@ -112,6 +112,23 @@ export interface Api {
|
|||
aggrTotal: number
|
||||
}
|
||||
|
||||
export interface ApiParam {
|
||||
param:string,
|
||||
value:string
|
||||
}
|
||||
|
||||
export interface ApiInsert {
|
||||
id: string,
|
||||
protocol: string,
|
||||
datasource: string,
|
||||
contentdescription: string,
|
||||
removable: boolean,
|
||||
compatibility: string,
|
||||
metadataIdentifierPath: string,
|
||||
baseurl: string,
|
||||
apiParams: ApiParam[]
|
||||
};
|
||||
|
||||
export interface Organization {
|
||||
name:string,
|
||||
country:string
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { Page, BrowseTerm, Datasource, KeyValue, DsmConf, ProtocolParam } from '../common/is.model';
|
||||
import { Page, BrowseTerm, Datasource, KeyValue, DsmConf, ProtocolParam, Api, ApiInsert } from '../common/is.model';
|
||||
import { ISService } from '../common/is.service';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
@ -165,6 +165,7 @@ export class DsmAddApiDialog {
|
|||
selectedProtocol:string = '';
|
||||
|
||||
apiPrefix:string = '';
|
||||
paramPrefix:string = '__PARAM_';
|
||||
|
||||
protocols:string[] = [];
|
||||
compatibilityLevels:string[] = [];
|
||||
|
@ -172,7 +173,6 @@ export class DsmAddApiDialog {
|
|||
|
||||
protocolsMap:any = {};
|
||||
selProtParams:ProtocolParam[] = [];
|
||||
paramPrefix:string = '__PARAM_';
|
||||
|
||||
apiIdControl = new FormControl('', [Validators.required]);
|
||||
addApiForm:FormGroup = new FormGroup({
|
||||
|
@ -214,10 +214,31 @@ export class DsmAddApiDialog {
|
|||
}
|
||||
|
||||
onSubmit():void {
|
||||
//const api = this.addApiForm.value;
|
||||
//api.apiId = this.apiPrefix + api.apiId; IMPORTANT
|
||||
let api:ApiInsert = {
|
||||
id: this.apiPrefix + this.apiIdControl.value,
|
||||
protocol: this.selectedProtocol,
|
||||
datasource: this.data.dsId,
|
||||
contentdescription: this.addApiForm.get('contentdescription')?.value,
|
||||
removable: true,
|
||||
compatibility: this.addApiForm.get('compatibility')?.value,
|
||||
metadataIdentifierPath: this.addApiForm.get('metadataIdentifierPath')?.value,
|
||||
baseurl: this.addApiForm.get('baseurl')?.value,
|
||||
apiParams : []
|
||||
};
|
||||
|
||||
Object.keys(this.addApiForm.controls).forEach(k => {
|
||||
if (k.startsWith(this.paramPrefix)) {
|
||||
let val = this.addApiForm.get(k)?.value;
|
||||
if (val) {
|
||||
api.apiParams.push({
|
||||
param: k.substring(this.paramPrefix.length),
|
||||
value: val
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(api);
|
||||
//this.service.dsmAddApi(api, (data: void) => this.dialogRef.close(1), this.metadataForm);
|
||||
console.log(this.addApiForm.value);
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
|
|
Loading…
Reference in New Issue