Commit 82e35cc8 authored by Jie Yuan's avatar Jie Yuan
Browse files

modify the table component

parent 000458e5
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
  <mat-form-field>
  <mat-label>------DPMT------</mat-label>
  <mat-select>
    <mat-option *ngFor="let name of dpmtSiteNames" [value]="name" (click)="onDPMTSiteNameSelected(name)">
      {{name}}
    <mat-option *ngFor="let dpmtsite of dpmtSiteNameAndSources"  (click)="onSiteNameAndSourceSelected(dpmtsite)">
      {{dpmtsite.siteName}}
    </mat-option>
  </mat-select>
</mat-form-field>
@@ -28,8 +28,8 @@
  <mat-form-field>
  <mat-label>------GOCDB------</mat-label>
  <mat-select>
    <mat-option *ngFor="let namegoc of gocdbSiteNames" [value]="namegoc"(click)="onGOCDBSiteNameSelected(namegoc)">
      {{namegoc}}
    <mat-option *ngFor="let gocdbsite of gocdbSiteNameAndSources" (click)="onSiteNameAndSourceSelected(gocdbsite)">
      {{gocdbsite.siteName}}
    </mat-option>
  </mat-select>
</mat-form-field>
@@ -58,7 +58,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>
@@ -66,7 +66,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>
+7 −75
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {

  dataSource : MatTableDataSource<SiteShort>;
 
  eoscSiteNames: string[];
  gocdbSiteNames: string[];
  dpmtSiteNames: string[];

  eoscSiteNameAndSources: SitenameAndSource[];
  dpmtSiteNameAndSources: SitenameAndSource[];
@@ -139,51 +136,19 @@ export class TableComponent implements OnInit, DoCheck,AfterViewInit {
  }


  setNameLists(){
    this.setNameListsFromSource('dpmt');
    this.setNameListsFromSource('gocdb');
    this.setNameListsFromSource('eosc');
  }



  setNameSourceLists(){
    this.setNameListsFromSource('dpmt');
    this.setNameListsFromSource('gocdb');
    //this.setNameListsFromSource('dpmt');
    //this.setNameListsFromSource('gocdb');
    this.setNameAndSourceListsFromSource('dpmt');
    this.setNameAndSourceListsFromSource('gocdb');
    this.setNameAndSourceListsFromSource('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);
          });
 
    }
  }



@@ -257,39 +222,6 @@ onClick(serverData: SiteShort) {



onSiteNameSelected(name: string) {
  //console.log('Selected new site: ' , name);
  //sessionStorage.setItem('preSitePage','Site');
  this.siteService.getASite(name)
      .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);
        }
      );
}


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);