Commit b3847b7e authored by Jie Yuan's avatar Jie Yuan

add new method to fetch site info within sidebar

parent 41a59d56
......@@ -17,7 +17,7 @@
<mat-form-field>
<mat-label>------DPMT------</mat-label>
<mat-select>
<mat-option *ngFor="let name of dpmtSiteNames" [value]="name" (click)="onSiteNameSelected(name)">
<mat-option *ngFor="let name of dpmtSiteNames" [value]="name" (click)="onDPMTSiteNameSelected(name)">
{{name}}
</mat-option>
</mat-select>
......@@ -28,7 +28,7 @@
<mat-form-field>
<mat-label>------GOCDB------</mat-label>
<mat-select>
<mat-option *ngFor="let namegoc of gocdbSiteNames" [value]="namegoc"(click)="onSiteNameSelected(namegoc)">
<mat-option *ngFor="let namegoc of gocdbSiteNames" [value]="namegoc"(click)="onGOCDBSiteNameSelected(namegoc)">
{{namegoc}}
</mat-option>
</mat-select>
......@@ -39,8 +39,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>
......
......@@ -9,6 +9,7 @@ import {SiteShortService} from '../../site-short.service';
import {SharedService} from '../../shared-service';
import {Site} from '../../model/site';
import {SitenameAndSource} from '../../model/sitenameAndSource';
import { AuthService } from 'src/app/auth.service';
import { DataSource } from '@angular/cdk/table';
......@@ -35,6 +36,11 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {
eoscSiteNames: string[];
gocdbSiteNames: string[];
dpmtSiteNames: string[];
eoscSiteNameAndSources: SitenameAndSource[];
dpmtSiteNameAndSources: SitenameAndSource[];
gocdbSiteNameAndSources: SitenameAndSource[];
username: string;
tableLength: number;
defaultPageSizeOptions: number[] =[10,20,40,80];
......@@ -107,7 +113,7 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {
}
);
this.setNameLists();
this.setNameSourceLists();
sessionStorage.setItem('preSitePage','Site');
......@@ -139,6 +145,14 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {
this.setNameListsFromSource('eosc');
}
setNameSourceLists(){
this.setNameListsFromSource('dpmt');
this.setNameListsFromSource('gocdb');
this.setNameAndSourceListsFromSource('eosc');
}
setNameListsFromSource(source: string){
const stmp = 'JsonSiteNameList' + source.toUpperCase();
const ltmp = sessionStorage.getItem(stmp) ;
......@@ -169,6 +183,43 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {
});
}
}
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);
});
}
}
......@@ -207,8 +258,8 @@ onClick(serverData: SiteShort) {
onSiteNameSelected(name: string) {
console.log('Selected new site: ' , name);
sessionStorage.setItem('preSitePage','Site');
//console.log('Selected new site: ' , name);
//sessionStorage.setItem('preSitePage','Site');
this.siteService.getASite(name)
.then(
(asite: Site) => {
......@@ -223,6 +274,45 @@ onSiteNameSelected(name: string) {
);
}
onDPMTSiteNameSelected(name: string) {
console.log('Selected new dpmt site: ' , name);
sessionStorage.setItem('preSitePage','Site');
const tmp = "DPMT"+name ;
this.onSiteNameSelected(tmp);
}
onGOCDBSiteNameSelected(name: string) {
console.log('Selected new gocdb site: ' , name);
sessionStorage.setItem('preSitePage','Site');
const tmp = "GOCDB"+name;
this.onSiteNameSelected(tmp);
}
onSiteNameAndSourceSelected(siteNameSource: SitenameAndSource) {
console.log('Selected new eosc site: ' , siteNameSource.siteName + ' from ' + siteNameSource.siteSource);
sessionStorage.setItem('preSitePage','Site');
//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);
}
);
}
public onClickSite(source: string) {
console.log('site clicked with');
......
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