Loading src/app/site-short.service.ts +61 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import {AuthService} from './auth.service'; import {HostName} from './model/hostname'; import {ServiceComponent} from './model/service-component'; import {Site} from './model/site'; import { SitenameAndSource } from './model/sitenameAndSource'; @Injectable() export class SiteShortService { Loading Loading @@ -136,6 +137,33 @@ export class SiteShortService { } getASiteById(siteId: string) { console.log('fetch a site with its name'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ const getUrl = this.sharedService.siteURL + '/id/' + siteId; if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( sessionStorage.getItem('authHeader') ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<Site>(getUrl , {headers : headers }) .subscribe( (asite: Site) => { resolve(asite); }, (error) => { reject(error); } ); } }); return promise; } /** Loading Loading @@ -341,4 +369,37 @@ export class SiteShortService { } getSiteNameAndSourceListFromSource(source: String) { console.log('Fetching server name lists from backend with source'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ let getUrl; if (source === 'all') { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/all'; } else { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/' + source + '/all'; } if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( true ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<SitenameAndSource[]>(getUrl , {headers : headers }) .subscribe( (nameList: SitenameAndSource[]) => { resolve(nameList); }, (error) => { reject(error); } ); } }); return promise; } } No newline at end of file src/app/site.service.ts +33 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import {Subscription} from 'rxjs/Subscription'; import { Site } from './model/site'; import {SitenameAndSource} from './model/sitenameAndSource'; import {AuthService} from './auth.service'; import {SharedService} from './shared-service'; Loading Loading @@ -148,6 +149,38 @@ export class SiteService { return promise; } getSiteNameAndSourceListFromSource(source: String) { console.log('Fetching server name lists from backend with source'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ let getUrl; if (source === 'all') { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/all'; } else { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/' + source + '/all'; } if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( true ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<SitenameAndSource[]>(getUrl , {headers : headers }) .subscribe( (nameList: SitenameAndSource[]) => { resolve(nameList); }, (error) => { reject(error); } ); } }); return promise; } setSelectedSite(newSelectedSite: Site) { this.currentSelectedSite = newSelectedSite; Loading Loading
src/app/site-short.service.ts +61 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import {AuthService} from './auth.service'; import {HostName} from './model/hostname'; import {ServiceComponent} from './model/service-component'; import {Site} from './model/site'; import { SitenameAndSource } from './model/sitenameAndSource'; @Injectable() export class SiteShortService { Loading Loading @@ -136,6 +137,33 @@ export class SiteShortService { } getASiteById(siteId: string) { console.log('fetch a site with its name'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ const getUrl = this.sharedService.siteURL + '/id/' + siteId; if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( sessionStorage.getItem('authHeader') ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<Site>(getUrl , {headers : headers }) .subscribe( (asite: Site) => { resolve(asite); }, (error) => { reject(error); } ); } }); return promise; } /** Loading Loading @@ -341,4 +369,37 @@ export class SiteShortService { } getSiteNameAndSourceListFromSource(source: String) { console.log('Fetching server name lists from backend with source'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ let getUrl; if (source === 'all') { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/all'; } else { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/' + source + '/all'; } if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( true ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<SitenameAndSource[]>(getUrl , {headers : headers }) .subscribe( (nameList: SitenameAndSource[]) => { resolve(nameList); }, (error) => { reject(error); } ); } }); return promise; } } No newline at end of file
src/app/site.service.ts +33 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import {Subscription} from 'rxjs/Subscription'; import { Site } from './model/site'; import {SitenameAndSource} from './model/sitenameAndSource'; import {AuthService} from './auth.service'; import {SharedService} from './shared-service'; Loading Loading @@ -148,6 +149,38 @@ export class SiteService { return promise; } getSiteNameAndSourceListFromSource(source: String) { console.log('Fetching server name lists from backend with source'); const promise = new Promise( (resolve, reject) => { /** Gets the sites from the source specified (GOCDB or DPMT) **/ let getUrl; if (source === 'all') { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/all'; } else { getUrl = this.sharedService.siteURL + '/siteNamesAndSources/' + source + '/all'; } if ( sessionStorage.getItem('authHeader') !== '') { const headers = new HttpHeaders( true ? { 'Authorization' : sessionStorage.getItem('authHeader'), 'Content-Type' : 'application/json' } : {} ); this.httpClient.get<SitenameAndSource[]>(getUrl , {headers : headers }) .subscribe( (nameList: SitenameAndSource[]) => { resolve(nameList); }, (error) => { reject(error); } ); } }); return promise; } setSelectedSite(newSelectedSite: Site) { this.currentSelectedSite = newSelectedSite; Loading