hide missing components in ui

This commit is contained in:
Michele Artini 2023-11-21 15:36:01 +01:00
parent b8e0c369a5
commit e2c6287822
7 changed files with 59 additions and 52 deletions

View File

@ -1,6 +1,7 @@
package eu.dnetlib.is.controller;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@ -69,4 +70,9 @@ public class ApiController extends DnetRestController {
return registry.availableServices();
}
@GetMapping("/service-types")
public Set<String> serviceTypes() {
return registry.availableServiceTypes();
}
}

View File

@ -5,7 +5,9 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
@ -45,4 +47,12 @@ public class ServiceRegistry {
.toList();
}
public Set<String> availableServiceTypes() {
return map.values()
.stream()
.map(ServiceStatus::getType)
.map(ServiceType::toString)
.collect(Collectors.toSet());
}
}

View File

@ -1,18 +0,0 @@
import { Injectable } from '@angular/core';
import { Service } from './is.model';
@Injectable({ providedIn: 'root' })
export class SharedInfoService {
private runningServiceTypes = new Set<string>();
constructor() { }
getRunningServiceTypes() {
return this.runningServiceTypes;
}
addRunningServiceType(serviceType: string) {
this.runningServiceTypes.add(serviceType);
}
}

View File

@ -5,7 +5,6 @@ import { ActivatedRoute } from '@angular/router';
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Module, Service } from '../common/is.model';
import { InfoClient } from './info.client';
import { SharedInfoService } from '../common/shared-info.service';
export interface KeyValueDatasource {
name: string;
@ -25,7 +24,7 @@ export class InfoComponent {
@ViewChild(MatSort) sort: MatSort | undefined
constructor(public client: InfoClient, public sharedInfo: SharedInfoService, public route: ActivatedRoute, public dialog: MatDialog) {
constructor(public client: InfoClient, public route: ActivatedRoute, public dialog: MatDialog) {
}
ngOnInit() {
@ -38,10 +37,7 @@ export class InfoComponent {
reload() {
this.client.availableServices((data: Service[]) => {
data.forEach(service => {
this.sharedInfo.addRunningServiceType(service.type);
service.status = 0;
});
data.forEach(service => service.status = 0);
this.servicesDatasource.data = data;
});
}

View File

@ -15,4 +15,7 @@ export class MainMenuPanelsClient extends ISClient {
this.httpGet<WfSection[]>("/proxy/byType/wf_manager/api/sections", onSuccess)
}
availableServiceTypes(onSuccess: Function) {
this.httpGet<string[]>("/ajax-is/service-types", onSuccess)
}
}

View File

@ -4,13 +4,15 @@
</div>
<mat-accordion multi>
<mat-expansion-panel>
<mat-expansion-panel *ngIf="isEnabled('is_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Home</mat-panel-title>
</mat-expansion-panel-header>
<a class="menu-item" routerLink="">Home</a>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="sharedInfo.getRunningServiceTypes().has('datasource_manager')">
<mat-expansion-panel *ngIf="isEnabled('datasource_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Datasources</mat-panel-title>
</mat-expansion-panel-header>
@ -19,7 +21,7 @@
</div>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="sharedInfo.getRunningServiceTypes().has('resource_manager')">
<mat-expansion-panel *ngIf="isEnabled('resource_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Simple Resources</mat-panel-title>
</mat-expansion-panel-header>
@ -33,25 +35,23 @@
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel
*ngIf="isEnabled('context_manager') || isEnabled('datasource_manager') || isEnabled('vocabulary_manager') || isEnabled('index_manager') || isEnabled('oai_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Advanced Resources</mat-panel-title>
<mat-panel-title>Other Resources</mat-panel-title>
</mat-expansion-panel-header>
<div>
<a class="menu-item" [routerLink]="['contexts']"
*ngIf="sharedInfo.getRunningServiceTypes().has('context_manager')">Contexts</a>
<a class="menu-item" [routerLink]="['protocols']"
*ngIf="sharedInfo.getRunningServiceTypes().has('datasource_manager')">Protocols</a>
<a class="menu-item" [routerLink]="['vocabularies']"
*ngIf="sharedInfo.getRunningServiceTypes().has('vocabulary_manager')">Vocabularies</a>
<a class="menu-item" [routerLink]="['index']"
*ngIf="sharedInfo.getRunningServiceTypes().has('index_manager')">Index Configurations</a>
<a class="menu-item" [routerLink]="['oai']" *ngIf="sharedInfo.getRunningServiceTypes().has('oai_manager')">Oai
<a class="menu-item" [routerLink]="['contexts']" *ngIf="isEnabled('context_manager')">Contexts</a>
<a class="menu-item" [routerLink]="['protocols']" *ngIf="isEnabled('datasource_manager')">Protocols</a>
<a class="menu-item" [routerLink]="['vocabularies']" *ngIf="isEnabled('vocabulary_manager')">Vocabularies</a>
<a class="menu-item" [routerLink]="['index']" *ngIf="isEnabled('index_manager')">Index
Configurations</a>
<a class="menu-item" [routerLink]="['oai']" *ngIf="isEnabled('oai_manager')">Oai
Configuration</a>
</div>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="sharedInfo.getRunningServiceTypes().has('wf_manager')">
<mat-expansion-panel *ngIf="isEnabled('wf_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Workflows</mat-panel-title>
</mat-expansion-panel-header>
@ -62,19 +62,18 @@
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel *ngIf="isEnabled('mdstore_manager') || isEnabled('wf_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Tools</mat-panel-title>
</mat-expansion-panel-header>
<div>
<a class="menu-item" routerLink="mdstores"
*ngIf="sharedInfo.getRunningServiceTypes().has('mdstore_manager')">MDStore Inspector</a>
<a class="menu-item" routerLink="cleaner" *ngIf="sharedInfo.getRunningServiceTypes().has('wf_manager')">Cleaner
<a class="menu-item" routerLink="mdstores" *ngIf="isEnabled('mdstore_manager')">MDStore Inspector</a>
<a class="menu-item" routerLink="cleaner" *ngIf="isEnabled('wf_manager')">Cleaner
Tester</a>
</div>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="sharedInfo.getRunningServiceTypes().has('wf_manager')">
<mat-expansion-panel *ngIf="isEnabled('wf_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Logs</mat-panel-title>
</mat-expansion-panel-header>
@ -83,13 +82,12 @@
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel *ngIf="isEnabled('is_manager')">
<mat-expansion-panel-header>
<mat-panel-title>Info</mat-panel-title>
</mat-expansion-panel-header>
<div>
<a class="menu-item" routerLink="info" *ngIf="sharedInfo.getRunningServiceTypes().has('is_manager')">Container
Info</a>
<a class="menu-item" routerLink="info">Container Info</a>
</div>
</mat-expansion-panel>
</mat-accordion>

View File

@ -2,8 +2,6 @@ import { Component, ViewChild } from '@angular/core';
import { KeyValue, ResourceType, WfSection } from '../common/is.model';
import { MatAccordion } from '@angular/material/expansion';
import { MainMenuPanelsClient } from './main-menu-panels.client';
import { SharedInfoService } from '../common/shared-info.service';
@Component({
selector: 'app-main-menu-panels',
@ -18,8 +16,22 @@ export class MainMenuPanelsComponent {
resTypes: ResourceType[] = [];
wfSections: WfSection[] = [];
constructor(public client: MainMenuPanelsClient, public sharedInfo: SharedInfoService) {
client.loadResourceTypes((data: ResourceType[]) => this.resTypes = data);
client.loadWfSections((data: WfSection[]) => this.wfSections = data);
runningServiceTypes = new Set<string>();
constructor(public client: MainMenuPanelsClient) {
client.availableServiceTypes((data: string[]) => {
data.forEach((type) => this.runningServiceTypes.add(type));
if (this.isEnabled('resource_manager')) {
client.loadResourceTypes((data: ResourceType[]) => this.resTypes = data);
}
if (this.isEnabled('wf_manager')) {
client.loadWfSections((data: WfSection[]) => this.wfSections = data);
}
});
}
isEnabled(serviceType: string) {
return this.runningServiceTypes.has(serviceType);
}
}