diff --git a/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java b/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java index 5308a3d..6d83818 100644 --- a/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java +++ b/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java @@ -143,7 +143,6 @@ public class InformationSystemResource { informationSystemService.setUma(createUmaToken(currentContext)); ResourceTypeDTO dto = informationSystemService.getResourceType(typeName); ResourceBuilderDTO builderDto = new ResourceBuilderDTO(dto.getName(), dto.getDescription(), dto.isAstratto()); - ArrayList result = new ArrayList(); for(FacetTypeDTO ft : dto.getFacetTypes()) { FacetSpecDTO fs = informationSystemService.getFacetSpecification(ft.getTarget()); @@ -153,10 +152,8 @@ public class InformationSystemResource { facetSpecs.add(fs); } builderDto.setFacetSpecs(facetSpecs); - result.add(builderDto); ObjectMapper objectMapper = new ObjectMapper(); - //devo ritornare un array con un elemento per costruire la GUI correttamente - String sc = objectMapper.writeValueAsString(result); + String sc = objectMapper.writeValueAsString(builderDto); return ResponseEntity.ok().body(sc); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/webapp/app/facet-composer/facet-composer.component.html b/src/main/webapp/app/facet-composer/facet-composer.component.html index 8530391..9b13fd5 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.html +++ b/src/main/webapp/app/facet-composer/facet-composer.component.html @@ -1,55 +1,41 @@

FacetComposer: New {{titleType}} ({{titlePath}})

- -

{{itemDesc}}

+

{{typeSpec.description}}

- --> - - +
+ - {{fct.relation}} + + {{fct.name}} - +

{{fct.description}}

+
+ formGroup per la facet {{ind}} +
- --> - + + + + - + - --> \ No newline at end of file diff --git a/src/main/webapp/app/facet-composer/facet-composer.component.ts b/src/main/webapp/app/facet-composer/facet-composer.component.ts index 01188d2..1243e11 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.ts +++ b/src/main/webapp/app/facet-composer/facet-composer.component.ts @@ -6,12 +6,13 @@ import { FormArray, FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Va import { MAT_DIALOG_DATA, MatDialogActions, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { IContextNode } from 'app/services/i-context-node'; import { IResource } from 'app/services/i-resource'; -import { IFacetComposer } from './i-facet-composer'; +import { IFacetComposer, IFacetGui } from './i-facet-composer'; import { FacetComposerService, ITypeSpecification } from './facet-composer.service'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatButtonModule } from '@angular/material/button'; import { MatInputModule } from '@angular/material/input'; import { MatExpansionModule } from '@angular/material/expansion'; +import { IFacetProp } from 'app/services/i-facet'; @@ -32,7 +33,19 @@ export class FacetComposerComponent implements OnInit { titlePath: string; composerForm: FormGroup | any; //form complessiva - composerFields: ITypeSpecification[]; + typeSpec: ITypeSpecification; + facetItem: IFacetProp[] = []; + + facetPropsForm: FormGroup[] =[]; //form per le props di una singola facet + + defaultFacetItem = { + name: '', + description: '', + mandatory:false, + notnull:false, + regexp:'', + propertyType:'' + }; // eslint-disable-next-line @typescript-eslint/member-ordering @@ -41,38 +54,85 @@ export class FacetComposerComponent implements OnInit { @Inject(MAT_DIALOG_DATA) data: {type: IResource ,context:IContextNode}){ this.titleType = data.type.name; this.titlePath = data.context.path; - this.composerFields = {} as ITypeSpecification[]; + this.typeSpec = {} as ITypeSpecification; } ngOnInit(): void { this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { - this.composerFields = res; - //this.composerForm = this.gener + this.typeSpec = res; }); - this.composerForm = this.generateFacetsForm(); + //this.composerForm = this.generateFacetsForm(); + } - generateFacetsForm(): FormGroup { - const baseForm = this.fb.group({}); - this.composerFields.forEach((field) => { - baseForm.addControl(field.name, this.generateFormGroup(baseForm, field)); - }); - console.log(baseForm); - return baseForm; - } + /* + export interface IFacetGui { + type: string; + label: string; + name: string; + value: string; + pattern: string; + propDescription: string; + validations: IValidation[] + } + */ + + private createFacetForm(props: IFacetProp,i:number){ + this.facetPropsForm[i] = this.fb.group( + { + name : ['',props.], + + } + ) + + + } + + + + + + /* + get itemsArray() { + return this.toDoListForm.get('facetItems'); + }*/ - generateFormGroup(baseForm: FormGroup, field: ITypeSpecification): FormGroup | FormControl { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (field.facetSpecs) { - const formGroup = this.fb.group({}); - field.facetSpecs.forEach((item) => { - formGroup.addControl(item.name, this.generateFormGroup(formGroup, item.controls)); - }); - return formGroup; + //TODO: vedi qua + //https://copyprogramming.com/howto/typescript-angular-9-programmatically-add-control-to-form + /* + { + "type": "text", + "label": "Unit", + "name": "unit", + "value": "", + "validations": [ + { + "name": "pattern", + "validator": "pattern", + "message": "Wrong field format, required is: ^(Byte|kB|MB|GB|TB|PB|EB|ZB|YB)$" + } + ], + "pattern": null, + "propDescription": "" + } + */ + + //chiude e basta + close():void { + this.dialogRef.close({event:'cancel'}); } - return new FormControl(''); - } + /* + //chiude e passa i dati al component chiamante + doAction():void { + this.dialogRef.close({event:'add',data:this.composerForm.value}); + } + + + onSubmit():void { + console.log(this.composerForm.value); + } + */ } diff --git a/src/main/webapp/app/facet-composer/facet-composer.service.ts b/src/main/webapp/app/facet-composer/facet-composer.service.ts index d792490..0bc467e 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.service.ts +++ b/src/main/webapp/app/facet-composer/facet-composer.service.ts @@ -25,13 +25,11 @@ export class FacetComposerService { //TODO: paginate (when pagination APIs will be ready) //resourcespecification - getFormStructure(ctxPath:string, type:string): Observable { + getFormStructure(ctxPath:string, type:string): Observable { const serviceUrl = this.applicationConfigService.getEndpointFor('api/is/facetspecifications'); let queryParams = new HttpParams(); queryParams = queryParams.append("typeName",type).append("currentContext",ctxPath); - return this.http.get(serviceUrl,{params:queryParams}); + return this.http.get(serviceUrl,{params:queryParams}); } - - } diff --git a/src/main/webapp/app/table-screen/table-screen.component.html b/src/main/webapp/app/table-screen/table-screen.component.html index f60cb58..00abeaa 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.html +++ b/src/main/webapp/app/table-screen/table-screen.component.html @@ -19,10 +19,9 @@ + --> +