Added path to contexts in dropdown widget
This commit is contained in:
parent
a3e84a3185
commit
b2786fb527
|
@ -19,6 +19,7 @@ import org.gcube.common.authorization.utils.secret.Secret;
|
|||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
|
@ -85,6 +86,30 @@ public class InformationSystemService {
|
|||
|
||||
}
|
||||
|
||||
private String extractPath(Context ctx) {
|
||||
String res = "/"+ctx.getName();
|
||||
if(ctx.getParent()==null) {
|
||||
return res;
|
||||
}
|
||||
Context dad = ctx.getParent().getSource();
|
||||
res = "/"+ctx.getParent().getSource().getName()+res;
|
||||
if(dad.getParent()==null) {
|
||||
return res;
|
||||
}
|
||||
Context gdad = dad.getParent().getSource();
|
||||
res = "/"+dad.getParent().getSource().getName()+res;
|
||||
if(gdad.getParent()==null) {
|
||||
return res;
|
||||
}
|
||||
Context g2dad = gdad.getParent().getSource();
|
||||
res = "/"+gdad.getParent().getSource().getName()+res;
|
||||
if(g2dad.getParent()==null) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<ContextDTO> getAllContexts() throws Exception {
|
||||
ArrayList<ContextDTO> res = new ArrayList<ContextDTO>();
|
||||
|
@ -92,9 +117,18 @@ public class InformationSystemService {
|
|||
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create();
|
||||
List<Context>contexts=resourceRegistryClient.getAllContext();
|
||||
for(Context ctx:contexts) {
|
||||
String pnt = " - "; //for the root
|
||||
//TODO: da dove tiro fuori il path?
|
||||
ContextDTO dto = new ContextDTO();
|
||||
dto.setId(ctx.getID().toString());
|
||||
dto.setName(ctx.getName());
|
||||
if(ctx.getParent()!=null) {
|
||||
if(ctx.getParent().getSource()!=null) {
|
||||
pnt = ctx.getParent().getSource().getName();
|
||||
}
|
||||
}
|
||||
dto.setParent(pnt);
|
||||
dto.setPath(extractPath(ctx));
|
||||
res.add(dto);
|
||||
}
|
||||
log.debug("AllContexts: {}",contexts);
|
||||
|
|
|
@ -10,4 +10,6 @@ import lombok.NoArgsConstructor;
|
|||
public class ContextDTO {
|
||||
private String id;
|
||||
private String name;
|
||||
private String parent;
|
||||
private String path;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
<jhi-rsc-tree id="leftTree" (resourceTypeEm)="buildTableData($event)"></jhi-rsc-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
|
@ -25,7 +23,7 @@
|
|||
<span id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message"
|
||||
[translateValues]="{ username: account.login }">You are logged in as user "{{account.login}}".</span>
|
||||
</div>
|
||||
<!--
|
||||
<!--
|
||||
<div class="d-inline-block my-3">
|
||||
<mat-form-field>
|
||||
<mat-label>Your Contexts</mat-label>
|
||||
|
@ -36,8 +34,7 @@
|
|||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
-->
|
||||
|
||||
-->
|
||||
<div>
|
||||
<div class="d-inline-block my-3" ngbDropdown #myDrop="ngbDropdown" ></div>
|
||||
|
||||
|
@ -52,12 +49,9 @@
|
|||
[formControl]="namefield"
|
||||
/>
|
||||
<mat-error>Please, enter a valid name!</mat-error>
|
||||
<mat-autocomplete #auto="matAutocomplete" [panelWidth]=400
|
||||
[displayWith]="displayFn.bind(this)">
|
||||
<mat-autocomplete #auto="matAutocomplete" [panelWidth]=350 [displayWith]="displayFn.bind(this)">
|
||||
<mat-option *ngFor="let fctx of filteredContexts | async" [value]="fctx">
|
||||
<span>{{ fctx.name }}
|
||||
<small> | ID: {{ fctx.id }}</small>
|
||||
</span>
|
||||
<span>{{ fctx.path }}</span>
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
|
@ -68,6 +62,9 @@
|
|||
<button mat-button (click)="copyUid(namefield)" color="primary" matTooltip="copy UUID" matTooltipPosition="below">
|
||||
<mat-icon class="icon-wide2">content_copy</mat-icon>
|
||||
</button>
|
||||
<button mat-button color="primary" matTooltip="locate" matTooltipPosition="below">
|
||||
<mat-icon class="icon-wide2">location_searching</mat-icon>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
|
|
@ -88,6 +88,24 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
getContexts(): string[] {
|
||||
if (this.account != null && this.account.resourceAccessDTO != null) {
|
||||
// eslint-disable-next-line no-console
|
||||
var sc=this.account.resourceAccessDTO.resourceAccess;
|
||||
var contexts=Array.from(Object.keys(sc));
|
||||
contexts=contexts.filter(element=>
|
||||
element!==null&&element.startsWith("%2F"));
|
||||
contexts=contexts.sort();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(contexts);
|
||||
return contexts;
|
||||
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO: CHECK WHY UNSUBSCRIBE DOES NOT WORK
|
||||
ngOnDestroy(): void {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export interface IContextNode{
|
||||
name: string;
|
||||
id: string;
|
||||
parent: string;
|
||||
path: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue