Updated libraries for creating/updating/deleting resources. Modified

tables to host new actions and view long data (with customized tooltips)
This commit is contained in:
Maria Teresa Paratore 2023-12-13 16:33:27 +01:00
parent dfa1eb3db2
commit 9b5df366c5
12 changed files with 129 additions and 32 deletions

View File

@ -290,6 +290,11 @@
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-client</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-publisher</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>

View File

@ -25,11 +25,14 @@ import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.Metadata;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
import org.gcube.informationsystem.serialization.ElementMapper;
import org.gcube.informationsystem.service.dto.ContextDTO;
import org.gcube.informationsystem.service.dto.ResourceTypeDTO;
@ -198,7 +201,7 @@ public class InformationSystemService {
/*
* per prendere tutti le istanze di un certo tipo (per riempire la tabella)
* Fetches the instance of a certain type for a given UUID
*/
public String getResource(String type, String uid) throws Exception {
String raw = "";
@ -218,9 +221,9 @@ public class InformationSystemService {
String currentCtx = SecretManagerProvider.instance.get().getContext();
List<Resource> instancesAsObject;
log.debug("getResourceInstances : [currentCtx=]",currentCtx);
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create(currentCtx);
resourceRegistryClient.setIncludeMeta(true);
//questo per prendere tutte le istanze (altrimenti il default è 10)
//this fetches all the instances (otherwise 10 is the default value)
resourceRegistryClient.setOffset(0);
resourceRegistryClient.setLimit(-1);
String instances = resourceRegistryClient.getInstances(resourceType, false);
@ -228,6 +231,29 @@ public class InformationSystemService {
return instancesAsObject;
}
//CRUD - 1
public void createResourceInstance(String resourceType) throws Exception {
String currentCtx = SecretManagerProvider.instance.get().getContext();
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
//publisher.createResource(new Resource)
}
//CRUD - 2
public void updateResourceInstance(String resourceType) throws Exception {
String currentCtx = SecretManagerProvider.instance.get().getContext();
//TODO: uso la getResource (riga 206)? Però restituisce una String (JSON)...
//publisher.update(resourceTypeString, jsonString);
}
//CRUD - 3
//TODO: vedi se questo va passato da un REST di JHipster
public void retrieveResourceInstance(String resourceType) throws Exception {
String currentCtx = SecretManagerProvider.instance.get().getContext();
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
//TODO: quale metodo usare per ottenere una risorsa partendo da UUID?
//publisher.delete(resourceType, uuidString);
}
}

View File

@ -30,9 +30,7 @@ import org.springframework.web.util.UriUtils;
import lombok.RequiredArgsConstructor;
import tech.jhipster.web.util.HeaderUtil;
/**
* REST controller for managing the current user's account.
*/
@RestController
@RequestMapping("/api/is")
@RequiredArgsConstructor
@ -102,7 +100,6 @@ public class InformationSystemResource {
return ResponseEntity.ok().body(sc);
} catch (Exception e) {
log.error("****ERROR*************");
e.printStackTrace();
log.error(e.getLocalizedMessage(), e);
return ResponseEntity.noContent()
.headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build();
@ -119,7 +116,6 @@ public class InformationSystemResource {
return ResponseEntity.ok().body(sc);
} catch (Exception e) {
log.error("****ERROR*************");
e.printStackTrace();
log.error(e.getLocalizedMessage(), e);
return ResponseEntity.noContent()
.headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build();
@ -127,7 +123,7 @@ public class InformationSystemResource {
}
/*
* ritorna le istanze delle risorse di un certo tipo
* returns all the instances of resources given a certain type
*/
@GetMapping("/resourceinstances")
public ResponseEntity<String> resourceInstances(@RequestParam @Nullable String currentContext, @RequestParam String resourceType) {
@ -145,7 +141,7 @@ public class InformationSystemResource {
}
}catch(Exception e) {
log.error("ERROR WHILE FILLING RESOURCEIMPL DTO");
e.printStackTrace();
//e.printStackTrace();
}
try {
ObjectMapper objectMapper = new ObjectMapper();
@ -156,7 +152,9 @@ public class InformationSystemResource {
return ResponseEntity.noContent()
.headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build();
}
}
}

View File

@ -29,6 +29,7 @@ import { RawjsonPaneComponent } from './rawjson-pane/rawjson-pane.component';
import { ClipboardModule } from '@angular/cdk/clipboard';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { SpinnercontrolInterceptor } from './shared/spinnercontrol.interceptor';
import { ResourcesCrudComponent } from './resources-crud/resources-crud.component';
@NgModule({
imports: [
@ -53,7 +54,7 @@ import { SpinnercontrolInterceptor } from './shared/spinnercontrol.interceptor';
{ provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter },
{provide:HTTP_INTERCEPTORS,useClass:SpinnercontrolInterceptor, multi: true}
],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent, ResourcesCrudComponent],
bootstrap: [MainComponent],
})
export class AppModule {

View File

@ -14,8 +14,8 @@
<button mat-raised-button color="primary"><mat-icon>edit</mat-icon> <span>Edit</span></button>
<button mat-raised-button color="primary"><mat-icon>explore</mat-icon> <span>View</span></button>
<button mat-raised-button color="primary"><mat-icon>help</mat-icon><span>Help</span></button>
<div id="restree" class="m-3">
<h4>Available Resources</h4>
<div id="restree" class="m-3 py-3">
<h4>Resource Types</h4>
<div class="col-md-3" id="tree-view">
<jhi-rsc-tree id="leftTree" (resourceTypeEm)="buildTableData($event)"></jhi-rsc-tree>
</div>

View File

@ -2,7 +2,7 @@
<div class="container-fluid">
<a class="navbar-brand logo" routerLink="/" (click)="collapseNavbar()">
<span class="logo-img"></span>
<span jhiTranslate="global.title" class="navbar-title">Myprojectoauth</span>
<span jhiTranslate="global.title" class="navbar-title"></span>
<span class="navbar-version">{{ version }}</span>
</a>
<a class="navbar-toggler d-lg-none" href="javascript:void(0);" data-toggle="collapse"
@ -17,10 +17,20 @@
<a class="nav-link" routerLink="/" (click)="collapseNavbar()">
<span>
<fa-icon icon="home"></fa-icon>
<span jhiTranslate="global.menu.home">Home</span>
<span>Home</span>
</span>
</a>
</li>
<!--
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }">
<a class="nav-link" routerLink="#" (click)="collapseNavbar()">
<span>
<fa-icon icon="cloud" [fixedWidth]="true"></fa-icon>
<span>Resources</span>
</span>
</a>
</li>
-->
<!-- jhipster-needle-add-element-to-menu - JHipster will add new menu items here -->
<!--
<li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer" display="dynamic"

View File

@ -47,13 +47,25 @@
<ng-container matColumnDef="endpoint">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Endpoint</th>
<td mat-cell *matCellDef="let item">{{ item.endpoint }}</td>
<td mat-cell *matCellDef="let item" matTooltip="{{ item.endpoint }}" matTooltipClass="tableTooltip" matTooltipPosition="after">{{ item.endpoint | slice:0:30 }}...</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Actions</th>
<ng-container matColumnDef="actions1">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>View JSON</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary" (click)="addTab(this.item.id)"><mat-icon>visibility</mat-icon></button>
<button mat-button color="primary" (click)="addTab(this.item.id)" matTooltip="view raw JSON" matTooltipPosition="below"><mat-icon>visibility</mat-icon></button>
</td>
</ng-container>
<ng-container matColumnDef="actions2">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Edit</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary" matTooltip="edit" matTooltipPosition="below"><mat-icon>edit</mat-icon></button>
</td>
</ng-container>
<ng-container matColumnDef="actions3">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Remove</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary" matTooltip="remove" matTooltipPosition="below"><mat-icon>delete</mat-icon></button>
</td>
</ng-container>
<!-- rows visualization -->

View File

@ -0,0 +1,24 @@
mat-option {
font-size: 14px;
width: 100%;
display:block
}
th.mat-header-cell, td.mat-cell, td.mat-footer-cell{
padding:18px;
}
.mat-header-cell {
font-size: 18px;
font-weight: 800;
}
::ng-deep .tableTooltip{
transform: scale(1.5)!important;
background-color: bisque!important;
position: relative !important;
font-size: 10px;
color: black!important;
font-weight: bold;
}

View File

@ -33,7 +33,7 @@ import { ResourcesImplService } from 'app/services/resources-impl.service';
export class TableScreenEsComponent implements OnInit, AfterViewInit, OnChanges {
//NB 'actions' CI DEVE ESSERE, altrimenti la tabella non viene visualizzata
//displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'artifact', 'group', 'version', 'endpoint','actions'];
displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'endpoint','actions'];
displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'endpoint','actions1','actions2','actions3'];
dataFromService: IEService[];
dataSource = new MatTableDataSource();
tableDetail: IEService;

View File

@ -1,7 +1,7 @@
<!-- Component for HostingNodes -->
<div class="p-3 mt-2">
<div class="p-3">
<h1>Type: {{resourceType}}</h1>
<mat-form-field>
<mat-form-field class="my-3">
<mat-label>Search by Name</mat-label>
<input matInput (keyup)="applyFilter($event)" placeholder="type in..." #input />
</mat-form-field>
@ -15,7 +15,7 @@
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Id</th>
<td mat-cell *matCellDef="let item">{{ item.id }}</td>
<td mat-cell *matCellDef="let item" >{{ item.id }} </td>
</ng-container>
<ng-container matColumnDef="status">
@ -38,10 +38,22 @@
<td mat-cell *matCellDef="let item">{{ item.hdSpace }}</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Actions</th>
<ng-container matColumnDef="actions1">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>View JSON</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary" (click)="addTab(this.item.id)"><mat-icon>visibility</mat-icon></button>
<button mat-button color="primary" (click)="addTab(this.item.id)" ><mat-icon>visibility</mat-icon></button>
</td>
</ng-container>
<ng-container matColumnDef="actions2">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Edit</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary"><mat-icon>edit</mat-icon></button>
</td>
</ng-container>
<ng-container matColumnDef="actions3">
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Remove</th>
<td mat-cell *matCellDef="let item">
<button mat-button color="primary"><mat-icon>delete</mat-icon></button>
</td>
</ng-container>
<!-- rows visualization -->

View File

@ -1,5 +1,3 @@
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700|Material+Icons');
mat-option {
font-size: 14px;
width: 100%;
@ -13,4 +11,15 @@ th.mat-header-cell, td.mat-cell, td.mat-footer-cell{
.mat-header-cell {
font-size: 18px;
font-weight: 800;
}
}
::ng-deep .tableTooltip{
/* your own custom styles here */
/* e.g. */
transform: scale(1.5)!important;
background-color: bisque!important;
position: relative !important;
font-size: 10px;
color: black!important;
font-weight: bold;
}

View File

@ -32,7 +32,7 @@ import { ResourcesImplService } from 'app/services/resources-impl.service';
export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
//NB 'actions' CI DEVE ESSERE, altrimenti la tabella non viene visualizzata
displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'avMemory', 'hdSpace', 'actions'];
displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'avMemory', 'hdSpace', 'actions1','actions2','actions3'];
dataFromService: IHostingNode[];
dataSource = new MatTableDataSource();
tableDetail: IHostingNode;