Commit 151a10d2 authored by Jie Yuan's avatar Jie Yuan

add site name and source in fulltable

parent 550c52df
......@@ -14,19 +14,19 @@
<mat-form-field>
<mat-label>------DPMT------</mat-label>
<mat-select>
<mat-option *ngFor="let name of dpmtSiteNames" [value]="name" (click)="onSiteNameSelected(name)">
{{name}}
<mat-option *ngFor="let dpmtsite of dpmtSiteNameAndSources" (click)="onSiteNameAndSourceSelected(dpmtsite)">
{{dpmtsite.siteName}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div >
<div class="form-div">
<mat-form-field>
<mat-label>------GOCDB------</mat-label>
<mat-select>
<mat-option *ngFor="let namegoc of gocdbSiteNames" [value]="namegoc"(click)="onSiteNameSelected(namegoc)">
{{namegoc}}
<mat-option *ngFor="let gocdbsite of gocdbSiteNameAndSources" (click)="onSiteNameAndSourceSelected(gocdbsite)">
{{gocdbsite.siteName}}
</mat-option>
</mat-select>
</mat-form-field>
......@@ -36,8 +36,8 @@
<mat-form-field>
<mat-label>------EOSC------</mat-label>
<mat-select>
<mat-option *ngFor="let name2 of eoscSiteNames" [value]="name2" (click)="onSiteNameSelected(name2)">
{{name2}}
<mat-option *ngFor="let asite of eoscSiteNameAndSources" (click)="onSiteNameAndSourceSelected(asite)">
{{asite.siteName + "--" + asite.siteSource}}
</mat-option>
</mat-select>
</mat-form-field>
......@@ -55,7 +55,7 @@
<span class="example-fill-remaining-space"></span>
<button class="menu-button" mat-button [matMenuTriggerFor]="menusite">Site</button>
<button class="menu-button" mat-button [matMenuTriggerFor]="menusite">Sites</button>
<mat-menu #menusite="matMenu">
<button mat-menu-item (click)="onClickSite('dpmt')">DPMT</button>
<button mat-menu-item (click)="onClickSite('gocdb')">GOCDB</button>
......@@ -63,7 +63,7 @@
</mat-menu>
&nbsp; &nbsp;
<button class="menu-button" mat-button [matMenuTriggerFor]="menuservice">Service</button>
<button class="menu-button" mat-button [matMenuTriggerFor]="menuservice">Services</button>
<mat-menu #menuservice="matMenu">
<button mat-menu-item (click)="onClickService('dpmt')">DPMT</button>
<button mat-menu-item (click)="onClickService('gocdb')">GOCDB</button>
......
......@@ -12,6 +12,7 @@ import {ServiceComponentRow} from '../../model/service-component-row';
import {HostName} from '../../model/hostname';
import {ServiceComponent} from '../../model/service-component';
import { AuthService } from 'src/app/auth.service';
import {SitenameAndSource} from '../../model/sitenameAndSource';
......@@ -32,9 +33,9 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
serverList: Site[];
dataSource: MatTableDataSource<ServiceComponentRow>;
eoscSiteNames: string[];
gocdbSiteNames: string[];
dpmtSiteNames: string[];
eoscSiteNameAndSources: SitenameAndSource[];
dpmtSiteNameAndSources: SitenameAndSource[];
gocdbSiteNameAndSources: SitenameAndSource[];
username: string;
defaultPageSizeOptions: number[] =[10,20,40,80];
......@@ -105,7 +106,7 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
}
);
this.setNameLists();
this.setNameSourceLists();
sessionStorage.setItem('preSitePage', 'Service');
......@@ -310,45 +311,8 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
}
setNameLists(){
this.setNameListsFromSource('dpmt');
this.setNameListsFromSource('gocdb');
this.setNameListsFromSource('eosc');
}
setNameListsFromSource(source: string){
const stmp = 'JsonSiteNameList' + source.toUpperCase();
const ltmp = sessionStorage.getItem(stmp) ;
if( ltmp !== null) {
const ldata = JSON.parse(ltmp);
if ( source === 'dpmt') {
this.dpmtSiteNames = ldata;
} else if (source === 'gocdb') {
this.gocdbSiteNames = ldata;
} else if (source === 'eosc') {
this.eoscSiteNames = ldata;
}
} else {
this.siteService.getSiteNameListFromSource(source)
.then((ldata: string[]) => {
if ( source === 'dpmt') {
this.dpmtSiteNames = ldata;
} else if (source === 'gocdb') {
this.gocdbSiteNames = ldata;
} else if (source === 'eosc') {
this.eoscSiteNames = ldata;
}
const tmp = 'JsonSiteNameList' + source.toUpperCase();
sessionStorage.setItem(tmp, JSON.stringify(ldata));
}
).catch((error) => {
console.log('Loading server list from DPMT: ', error);
});
}
}
onSiteNameSelected(name: string) {
console.log('Selected new site: ' , name);
this.siteService.getASite(name)
......@@ -365,6 +329,78 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
);
}
onSiteNameAndSourceSelected(siteNameSource: SitenameAndSource) {
console.log('Selected new eosc site: ' , siteNameSource.siteName + ' from ' + siteNameSource.siteSource);
sessionStorage.setItem('preSitePage','Service');
//const tmp = siteNameSource.siteSource.toUpperCase() + siteNameSource.siteName;
//this.onSiteNameSelected(tmp);
this.siteService.getASiteById(siteNameSource.siteId)
.then(
(asite: Site) => {
sessionStorage.setItem('currentSelectedSite', JSON.stringify(asite) );
this.router.navigate(['/dashboard/site'], { relativeTo: this.route });
}
).catch(
error => {
console.log('Error while loading sites ');
console.log(error);
}
);
}
setNameSourceLists(){
//this.setNameListsFromSource('dpmt');
//this.setNameListsFromSource('gocdb');
this.setNameAndSourceListsFromSource('dpmt');
this.setNameAndSourceListsFromSource('gocdb');
this.setNameAndSourceListsFromSource('eosc');
}
setNameAndSourceListsFromSource(source: string){
const stmp = 'JsonSiteNameSourceList' + source.toUpperCase();
const ltmp = sessionStorage.getItem(stmp) ;
if( ltmp !== null) {
const ldata = JSON.parse(ltmp);
if ( source === 'dpmt') {
this.dpmtSiteNameAndSources = ldata;
} else if (source === 'gocdb') {
this.gocdbSiteNameAndSources = ldata;
} else if (source === 'eosc') {
this.eoscSiteNameAndSources = ldata;
}
} else {
this.siteService.getSiteNameAndSourceListFromSource(source)
.then((ldata: SitenameAndSource[]) => {
if ( source === 'dpmt') {
this.dpmtSiteNameAndSources = ldata;
} else if (source === 'gocdb') {
this.gocdbSiteNameAndSources = ldata;
} else if (source === 'eosc') {
this.eoscSiteNameAndSources = ldata;
}
const tmp = 'JsonSiteNameSourceList' + source.toUpperCase();
sessionStorage.setItem(tmp, JSON.stringify(ldata));
}
).catch((error) => {
console.log('Loading server list from DPMT: ', error);
});
}
}
public onServiceComponentSelected(serviceComponent: ServiceComponentRow) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment