diff --git a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java index abb722b..4220460 100644 --- a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java +++ b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java @@ -132,10 +132,17 @@ public class InformationSystemService { String desc = rt.getDescription(); boolean abst = rt.isAbstract(); ResourceTypeDTO dto = new ResourceTypeDTO(name, id, desc, abst); - return dto; } + public String getResourceTypeJson(String typeName) throws Exception { + String currentCtx = SecretManagerProvider.instance.get().getContext(); + ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); + String jsonResult = resourceRegistryClient.getType(typeName, true); + return jsonResult; + } + + public List getAllContexts() throws Exception { ArrayList res = new ArrayList(); //log.debug("GetAllContext: [rootCtx=]",rootCtx); @@ -234,6 +241,8 @@ public class InformationSystemService { } + + /* * Fetches all the resource instances for a given type */ 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 49d5109..89a5895 100644 --- a/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java +++ b/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java @@ -124,19 +124,22 @@ public class InformationSystemResource { return ResponseEntity.noContent() .headers(HeaderUtil.createAlert(applicationName, e.getMessage(), "ERRORE")).build(); } - /* + } + + @GetMapping("/resourcetypejson") + // e.g. http://localhost:8081/api/is/resourcetype?typeName=HostingNode + public ResponseEntity resourceTypeJson(@RequestParam String typeName,@RequestParam @Nullable String currentContext) { try { - ArrayList treeNode = informationSystemService.getResourceTypesTree(); - ObjectMapper objectMapper = new ObjectMapper(); - String sc = objectMapper.writeValueAsString(treeNode); - return ResponseEntity.ok().body(sc); + informationSystemService.setUma(createUmaToken(currentContext)); + String raw= informationSystemService.getResourceTypeJson(typeName); + return ResponseEntity.ok().body(raw); } catch (Exception e) { + e.printStackTrace(); log.error("****ERROR*************"); - log.error(e.getLocalizedMessage(), e); + log.error(e.getMessage(), e); return ResponseEntity.noContent() - .headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build(); + .headers(HeaderUtil.createAlert(applicationName, e.getMessage(), "ERRORE")).build(); } - */ } @GetMapping("/resourcejson") diff --git a/src/main/webapp/app/generic-json/generic-json.component.html b/src/main/webapp/app/generic-json/generic-json.component.html new file mode 100644 index 0000000..bb32a6e --- /dev/null +++ b/src/main/webapp/app/generic-json/generic-json.component.html @@ -0,0 +1,3 @@ +
+
{{ data.fetchedRawData | json }}
+
diff --git a/src/main/webapp/app/generic-json/generic-json.component.scss b/src/main/webapp/app/generic-json/generic-json.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/generic-json/generic-json.component.ts b/src/main/webapp/app/generic-json/generic-json.component.ts new file mode 100644 index 0000000..30c5d41 --- /dev/null +++ b/src/main/webapp/app/generic-json/generic-json.component.ts @@ -0,0 +1,14 @@ +/* eslint-disable @angular-eslint/no-empty-lifecycle-method */ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; + +@Component({ + selector: 'jhi-generic-json', + templateUrl: './generic-json.component.html', + styleUrls: ['./generic-json.component.scss'] +}) +export class GenericJsonComponent{ + + constructor(@Inject(MAT_DIALOG_DATA) public data: {fetchedRawData: string}) { } + +} diff --git a/src/main/webapp/app/generic-json/generic-json.module.ts b/src/main/webapp/app/generic-json/generic-json.module.ts new file mode 100644 index 0000000..d3f586a --- /dev/null +++ b/src/main/webapp/app/generic-json/generic-json.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { GenericJsonComponent } from './generic-json.component'; + + + +@NgModule({ + declarations: [ + GenericJsonComponent + ], + imports: [ + CommonModule + ] +}) +export class GenericJsonModule { } diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index bbdbe77..b02026b 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -51,14 +51,14 @@
-
+

Resource Types

-
+
diff --git a/src/main/webapp/app/home/home.component.scss b/src/main/webapp/app/home/home.component.scss index 3205426..0536887 100644 --- a/src/main/webapp/app/home/home.component.scss +++ b/src/main/webapp/app/home/home.component.scss @@ -31,3 +31,5 @@ Main page styles z-index: 99; } + + diff --git a/src/main/webapp/app/rsc-tree/rsc-tree.component.html b/src/main/webapp/app/rsc-tree/rsc-tree.component.html index af01ddf..e370f88 100644 --- a/src/main/webapp/app/rsc-tree/rsc-tree.component.html +++ b/src/main/webapp/app/rsc-tree/rsc-tree.component.html @@ -2,9 +2,12 @@ - A + @@ -16,8 +19,13 @@
diff --git a/src/main/webapp/app/rsc-tree/rsc-tree.component.scss b/src/main/webapp/app/rsc-tree/rsc-tree.component.scss index 4421800..c616e5a 100644 --- a/src/main/webapp/app/rsc-tree/rsc-tree.component.scss +++ b/src/main/webapp/app/rsc-tree/rsc-tree.component.scss @@ -43,4 +43,8 @@ padding-left: 25px; } +.abstr{ + font-style:italic; +} + diff --git a/src/main/webapp/app/services/restypes.service.ts b/src/main/webapp/app/services/restypes.service.ts index 07bcf06..46f38a2 100644 --- a/src/main/webapp/app/services/restypes.service.ts +++ b/src/main/webapp/app/services/restypes.service.ts @@ -30,6 +30,13 @@ export class RestypesService { queryParams = queryParams.append("typeName",name); return this.http.get(resourceUrl,{params:queryParams}); } + + fetchRawJson(name:string): Observable { + const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourcetypejson'); + let queryParams = new HttpParams(); + queryParams = queryParams.append("typeName",name); + return this.http.get(resourceUrl,{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 04f009f..835db98 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.html +++ b/src/main/webapp/app/table-screen/table-screen.component.html @@ -6,7 +6,7 @@ info
diff --git a/src/main/webapp/app/table-screen/table-screen.component.ts b/src/main/webapp/app/table-screen/table-screen.component.ts index dda7ccd..2d3006b 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.ts +++ b/src/main/webapp/app/table-screen/table-screen.component.ts @@ -28,13 +28,15 @@ import { ResourceAddComponent } from 'app/resource-add/resource-add.component'; import { GenericInfoComponent } from 'app/generic-info/generic-info.component'; import { IResource } from 'app/services/i-resource'; import { IResourceType } from 'app/services/i-resource-type'; +import { GenericJsonComponent } from 'app/generic-json/generic-json.component'; +import { RestypesService } from 'app/services/restypes.service'; @Component({ selector: 'jhi-table-screen', templateUrl: './table-screen.component.html', styleUrls: ['./table-screen.component.scss'], - providers: [ResourcesImplService], + providers: [ResourcesImplService, RestypesService], }) export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { @@ -45,6 +47,7 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { tableDetail: IHostingNode; dialogAddRef: MatDialogRef |undefined; dialogInfoRef: MatDialogRef |undefined; + dialogJsonRef: MatDialogRef |undefined; @Input() currentCtx: IContextNode; //fetching event from parent @Input() currentCtxPath: string; //fetching event from parent @@ -63,10 +66,11 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { selectedIdx = 0; chosenIds: string[] = []; //TODO: a regime questa sarà la nuova resource creata (visualizzerò il titolo) - dummyRes: string; + rawJson: string; + dummyRes :string; ////////// fine tabbed view - constructor(private myDataService: ResourcesImplService, private myDialog: MatDialog) { + constructor(private myDataService: ResourcesImplService, private myTypesService: RestypesService, private myDialog: MatDialog) { this.currentCtx = {} as IContextNode; this.tableDetail = {} as IHostingNode; this.dataFromService = []; @@ -75,6 +79,7 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { //this.resourceType = ''; this.typeObject = {} as IResourceType; this.currentCtxPath = ''; + this.rawJson = ''; this.dummyRes = ''; } @@ -100,6 +105,11 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { return record.name.indexOf(filter)!==-1; } }); + + this.myTypesService.fetchRawJson(this.typeObject.name).subscribe(res => { + this.rawJson = res; + return res; + }); } @@ -186,6 +196,11 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { data: {description: this.typeObject.description} }); } + openDialogJson(): void { + this.dialogJsonRef = this.myDialog.open(GenericJsonComponent, { + data: {fetchedRawData: this.rawJson} + }); + } /*