Commit d4f1447f authored by Jie Yuan's avatar Jie Yuan
Browse files

add cors to siteshort to fetch a site information

parent 75e68ddd
import {EventEmitter, Injectable} from '@angular/core';
import { SiteShort } from '../../models/SiteShort';
import {Site} from '../../models/Site';
import {HostName} from '../../models/HostName';
import {HostNameShort} from '../../models/HostNameShort';
import {ServiceComponent} from '../../models/ServiceComponent';
......@@ -71,6 +72,33 @@ export class SiteShortService {
}
getASite(sitename: 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 + '/' + sitename;
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;
}
getHosts() {
console.log('Fetching host lists from ' + this.currentSite);
const promise = new Promise(
......
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