TSK-651 - [UI] Add spinner when domain is changed

This commit is contained in:
Jose Ignacio Recuerda Cambil 2018-12-26 17:01:58 +01:00 committed by Martin Rojas Miguel Angel
parent 20fa83f3c9
commit 55c7453034
2 changed files with 13 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable , BehaviorSubject , ReplaySubject } from 'rxjs'; import { Observable, ReplaySubject } from 'rxjs';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { RequestInProgressService } from '../requestInProgress/request-in-progress.service'; import { RequestInProgressService } from '../requestInProgress/request-in-progress.service';
@ -13,7 +13,7 @@ export class DomainService {
private domainRestValue: Array<string> = new Array<string>(); private domainRestValue: Array<string> = new Array<string>();
private domainValue: Array<string> = new Array<string>(); private domainValue: Array<string> = new Array<string>();
private domainSelectedValue; private domainSelectedValue: string;
private domainSelected = new ReplaySubject<string>(1); private domainSelected = new ReplaySubject<string>(1);
private dataObs$ = new ReplaySubject<Array<string>>(1); private dataObs$ = new ReplaySubject<Array<string>>(1);
private hasMasterDomain = false; private hasMasterDomain = false;
@ -64,17 +64,15 @@ export class DomainService {
return this.domainSelected.asObservable(); return this.domainSelected.asObservable();
} }
selectDomain(value: string) {
// this.requestInProgressService.setRequestInProgress(true);
this.domainSelectedValue = value;
this.domainSelected.next(value);
}
switchDomain(value: string) { switchDomain(value: string) {
this.requestInProgressService.setRequestInProgress(true);
this.selectDomain(value); this.selectDomain(value);
this.router.navigate([this.getNavigationUrl()]); this.router.navigate([this.getNavigationUrl()]);
} }
/*
This function should be called after getSelectedDomain inner subscriptions have been finished
*/
domainChangedComplete() { domainChangedComplete() {
this.requestInProgressService.setRequestInProgress(false); this.requestInProgressService.setRequestInProgress(false);
} }
@ -96,13 +94,17 @@ export class DomainService {
} }
} }
private selectDomain(value: string) {
this.domainSelectedValue = value;
this.domainSelected.next(value);
}
private addEmptyDomain(domains: Array<string>): Array<string> { private addEmptyDomain(domains: Array<string>): Array<string> {
this.domainValue = Object.assign([], domains); this.domainValue = Object.assign([], domains);
this.domainValue.push(''); this.domainValue.push('');
return this.domainValue; return this.domainValue;
} }
private getNavigationUrl(): string { private getNavigationUrl(): string {
if (this.router.url.indexOf('workbaskets') !== -1) { if (this.router.url.indexOf('workbaskets') !== -1) {
return 'administration/workbaskets'; return 'administration/workbaskets';