TSK-454 Move environment url to startup application instead of being a guard
This commit is contained in:
parent
cb20dd1ccb
commit
251257ac80
|
@ -141,8 +141,9 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classificationSavingSubscription = this.classificationsService.postClassification(this.classification)
|
||||
.subscribe((classification: ClassificationDefinition) => {
|
||||
this.classification = classification;
|
||||
this.afterRequest();
|
||||
this.classificationsService.selectClassification(classification.classificationId);
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${classification.key} was saved successfully`));
|
||||
this.afterRequest();
|
||||
},
|
||||
error => {
|
||||
this.errorModalService.triggerError(new ErrorModel('There was an error creating a classification', error))
|
||||
|
@ -153,7 +154,6 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
.putClassification(this.classification._links.self.href, this.classification)
|
||||
.subscribe((classification: ClassificationDefinition) => {
|
||||
this.classification = classification;
|
||||
this.classificationsService.selectClassification(classification.classificationId);
|
||||
this.afterRequest();
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${classification.key} was saved successfully`));
|
||||
}, error => {
|
||||
|
|
|
@ -19,16 +19,14 @@ import { ImportType } from 'app/models/import-type';
|
|||
selector: 'taskana-workbasket-list-toolbar',
|
||||
animations: [
|
||||
trigger('toggle', [
|
||||
state('*', style({ opacity: '1' })),
|
||||
state('void', style({ opacity: '0' })),
|
||||
transition('void => *', animate('300ms ease-in', keyframes([
|
||||
style({ opacity: 0, height: '0px' }),
|
||||
style({ opacity: 0.5, height: '50px' }),
|
||||
style({ opacity: 1, height: '*' })]))),
|
||||
style({ height: '0px' }),
|
||||
style({ height: '50px' }),
|
||||
style({ height: '*' })]))),
|
||||
transition('* => void', animate('300ms ease-out', keyframes([
|
||||
style({ opacity: 1, height: '*' }),
|
||||
style({ opacity: 0.5, height: '50px' }),
|
||||
style({ opacity: 0, height: '0px' })])))
|
||||
style({ height: '*' }),
|
||||
style({ height: '50px' }),
|
||||
style({ height: '0px' })])))
|
||||
]
|
||||
)],
|
||||
templateUrl: './workbasket-list-toolbar.component.html',
|
||||
|
|
|
@ -8,14 +8,13 @@ import { MasterAndDetailComponent } from './shared/master-and-detail/master-and-
|
|||
import { NoAccessComponent } from './administration/workbasket/details/noAccess/no-access.component';
|
||||
import { ClassificationListComponent } from './administration/classification/master/list/classification-list.component';
|
||||
import { ClassificationDetailsComponent } from 'app/administration/classification/details/classification-details.component';
|
||||
import { EnvironmentUrlGuard } from 'app/guards/environment-url-guard';
|
||||
import { DomainGuard } from 'app/guards/domain-guard';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: 'administration/workbaskets',
|
||||
component: MasterAndDetailComponent,
|
||||
canActivate: [EnvironmentUrlGuard, DomainGuard],
|
||||
canActivate: [DomainGuard],
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
|
@ -42,7 +41,7 @@ const appRoutes: Routes = [
|
|||
{
|
||||
path: 'administration/classifications',
|
||||
component: MasterAndDetailComponent,
|
||||
canActivate: [EnvironmentUrlGuard, DomainGuard],
|
||||
canActivate: [DomainGuard],
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Modules
|
||||
*/
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NgModule, APP_INITIALIZER } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
@ -58,6 +58,7 @@ import { ClassificationsService } from './services/classifications/classificatio
|
|||
import { TreeService } from './services/tree/tree.service';
|
||||
import { ClassificationTypesService } from './services/classification-types/classification-types.service';
|
||||
import { ClassificationCategoriesService } from 'app/services/classification-categories-service/classification-categories.service';
|
||||
import { StartupService } from 'app/services/startup-service/startup.service';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -72,7 +73,6 @@ import { DomainService } from './services/domain/domain.service';
|
|||
/**
|
||||
* Guards
|
||||
*/
|
||||
import { EnvironmentUrlGuard } from './guards/environment-url-guard';
|
||||
import { DomainGuard } from './guards/domain-guard';
|
||||
|
||||
const MODULES = [
|
||||
|
@ -118,6 +118,10 @@ const DECLARATIONS = [
|
|||
SpreadNumberPipe
|
||||
];
|
||||
|
||||
export function startupServiceFactory(startupService: StartupService): Function {
|
||||
return () => startupService.load();
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: DECLARATIONS,
|
||||
imports: MODULES,
|
||||
|
@ -143,8 +147,14 @@ const DECLARATIONS = [
|
|||
TreeService,
|
||||
ClassificationTypesService,
|
||||
ClassificationCategoriesService,
|
||||
EnvironmentUrlGuard,
|
||||
DomainGuard
|
||||
DomainGuard,
|
||||
StartupService,
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: startupServiceFactory,
|
||||
deps: [StartupService],
|
||||
multi: true
|
||||
}
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Router } from '@angular/router';
|
|||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { RequestInProgressService } from '../requestInProgress/request-in-progress.service';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
||||
|
||||
@Injectable()
|
||||
export class DomainService {
|
||||
|
@ -21,6 +22,7 @@ export class DomainService {
|
|||
private domainSelectedValue;
|
||||
private domainSelected = new BehaviorSubject<string>('');
|
||||
private domainSwitched = new Subject<string>();
|
||||
private dataObs$ = new ReplaySubject<Array<string>>(1);
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
|
@ -29,13 +31,24 @@ export class DomainService {
|
|||
}
|
||||
|
||||
// GET
|
||||
getDomains(): Observable<string[]> {
|
||||
return this.httpClient.get<string[]>(this.url, this.httpOptions).do(domains => {
|
||||
if (!this.domainSelectedValue && domains && domains.length > 0) {
|
||||
this.domainSelectedValue = domains[0];
|
||||
this.selectDomain(domains[0]);
|
||||
}
|
||||
});
|
||||
getDomains(forceRefresh = false): Observable<string[]> {
|
||||
if (!this.dataObs$.observers.length || forceRefresh) {
|
||||
this.httpClient.get<string[]>(this.url, this.httpOptions).subscribe(
|
||||
domains => {
|
||||
this.dataObs$.next(domains);
|
||||
if (!this.domainSelectedValue && domains && domains.length > 0) {
|
||||
this.domainSelectedValue = domains[0];
|
||||
this.selectDomain(domains[0]);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.dataObs$.error(error);
|
||||
this.dataObs$ = new ReplaySubject(1);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this.dataObs$;
|
||||
}
|
||||
|
||||
getSelectedDomain(): Observable<string> {
|
||||
|
|
|
@ -5,10 +5,9 @@ import { environment } from 'app/../environments/environment';
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class EnvironmentUrlGuard implements CanActivate {
|
||||
export class StartupService {
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
canActivate() {
|
||||
load(): Promise<any> {
|
||||
return this.httpClient.get<any>('environments/data-sources/environment-information.json').map(jsonFile => {
|
||||
if (jsonFile) {
|
||||
environment.taskanaWorkplaceUrl = jsonFile.taskanaWorkplaceUrl === '' ?
|
||||
|
@ -20,9 +19,9 @@ export class EnvironmentUrlGuard implements CanActivate {
|
|||
environment.taskanaRestUrl = jsonFile.taskanaRestUrl === '' ?
|
||||
environment.taskanaRestUrl : jsonFile.taskanaRestUrl;
|
||||
}
|
||||
return true;
|
||||
}).catch(() => {
|
||||
return Observable.of(true)
|
||||
});
|
||||
}).toPromise()
|
||||
.catch(() => {
|
||||
return Observable.of(true)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue