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

change the site fetch behavior and show only eosc related hosts in site view in eosc site

parent e44a27a7
......@@ -246,15 +246,15 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let hostName of site.hostNames">
<td>{{hostName.name}}</td>
<td>{{hostName.url}}</td>
<td>{{hostName.hostNameStatus}}</td>
<td>
<tr *ngFor="let hostName of site.hostNames" >
<td *ngIf = "hostName.scopeList.indexOf('cms') !== -1">{{hostName.name}}</td>
<td *ngIf = "hostName.scopeList.indexOf('cms') !== -1">{{hostName.url}}</td>
<td *ngIf = "hostName.scopeList.indexOf('cms') !== -1">{{hostName.hostNameStatus}}</td>
<td *ngIf = "hostName.scopeList.indexOf('cms') !== -1">
<i *ngIf="hostName.nodeMonitored" class="material-icons centerIcon">done</i>
<i *ngIf="!hostName.nodeMonitored" class="material-icons centerIcon">error</i>
</td>
<td>{{hostName.scopeList}}</td>
<td *ngIf = "hostName.scopeList.indexOf('cms') !== -1">{{hostName.scopeList}}</td>
</tr>
</tbody>
</table>
......
......@@ -235,18 +235,10 @@ export class SidebarComponent implements OnInit, AfterViewInit , DoCheck {
onServerNameSelected(name: string) {
console.log('Selected new site: ' , name);
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);
}
);
sessionStorage.setItem('currentSelectedSiteName', name );
this.siteService.setCurrentSelectedSiteBySiteName();
this.router.navigate(['/dashboard/site'], { relativeTo: this.route });
}
onGOCDBListSelected() {
......
......@@ -21,6 +21,7 @@ export class SiteService {
siteNamesList: string[];
/** Site that is currently shown on the site page **/
currentSelectedSite: Site;
currentSelectedSiteName: string;
siteSubscription: EventEmitter<Site>;
/** Subscription to know if the user is using another source of the sites **/
siteSourceSubscription: EventEmitter<Site[]>;
......@@ -155,6 +156,38 @@ export class SiteService {
sessionStorage.setItem('currentSelectedSite', JSON.stringify(this.currentSelectedSite));
this.siteSubscription.emit(newSelectedSite);
}
setSelectedSiteName(newSelectedSiteName: string) {
const tmp = sessionStorage.getItem('currentSelectedSiteName');
if ( newSelectedSiteName !== undefined && newSelectedSiteName !== null && newSelectedSiteName !== tmp){
this.currentSelectedSiteName = tmp;
sessionStorage.setItem('currentSelectedSiteName', this.currentSelectedSiteName);
}
}
setCurrentSelectedSiteBySiteName() {
if (this.currentSelectedSiteName !== null && this.currentSelectedSiteName !== undefined) {
sessionStorage.setItem('currentSelectedSiteName', this.currentSelectedSiteName);
this.currentSelectedSiteName = null;
}
const tmp = sessionStorage.getItem('currentSelectedSiteName');
if ( tmp !== null && tmp !== '' && tmp !== undefined) {
this.getASite(tmp).then( (asite: Site) => {
this.currentSelectedSite = asite;
sessionStorage.setItem('currentSelectedSite', JSON.stringify(this.currentSelectedSite));
this.siteSubscription.emit(asite);
}
)
.catch(
errot => {
console.log('can not get a site');
}
)
}
}
getCurrentSelectedSite() {
if (this.currentSelectedSite !== null && this.currentSelectedSite !== undefined) {
......
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