TSK-1376: Fixed taskana admin not displaying correctly when using custom domain (#1240)

* TSK-1376: fixed issues where custom domain is loaded after the webapp is finished initializing

* TSK-1376: added comment explaining

* TSK-1376: webapp now uses values from environment-information.json as default data
This commit is contained in:
Chi Nguyen 2020-08-24 17:50:52 +02:00 committed by GitHub
parent f99c437fdc
commit 338fedf49f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 116 additions and 32 deletions

View File

@ -19,6 +19,9 @@ import { TypeAheadComponent } from '../../../shared/components/type-ahead/type-a
import { TypeaheadModule } from 'ngx-bootstrap';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Direction, Sorting } from '../../../shared/models/sorting';
import { StartupService } from '../../../shared/services/startup/startup.service';
import { TaskanaEngineService } from '../../../shared/services/taskana-engine/taskana-engine.service';
import { WindowRefService } from '../../../shared/services/window/window.service';
import { engineConfigurationMock } from '../../../shared/store/mock-data/mock-store';
const isFieldValidFn = jest.fn().mockReturnValue(true);
@ -76,7 +79,10 @@ describe('AccessItemsManagementComponent', () => {
{ provide: FormsValidatorService, useClass: formValidatorServiceSpy },
{ provide: NotificationService, useClass: notificationServiceSpy },
RequestInProgressService,
ClassificationCategoriesService
ClassificationCategoriesService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();

View File

@ -16,6 +16,10 @@ import { SelectedRouteService } from '../../../shared/services/selected-route/se
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatDialogModule } from '@angular/material/dialog';
import { selectedWorkbasketMock } from '../../../shared/store/mock-data/mock-store';
import { ClassificationCategoriesService } from '../../../shared/services/classification-categories/classification-categories.service';
import { StartupService } from '../../../shared/services/startup/startup.service';
import { TaskanaEngineService } from '../../../shared/services/taskana-engine/taskana-engine.service';
import { WindowRefService } from '../../../shared/services/window/window.service';
@Component({ selector: 'taskana-shared-spinner', template: '' })
class SpinnerStub {
@ -79,7 +83,16 @@ describe('WorkbasketDetailsComponent', () => {
WorkbasketDistributionTargetsStub,
WorkbasketInformationStub
],
providers: [DomainService, ImportExportService, WorkbasketService, RequestInProgressService, SelectedRouteService]
providers: [
DomainService,
ImportExportService,
WorkbasketService,
RequestInProgressService,
SelectedRouteService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();
fixture = TestBed.createComponent(WorkbasketDetailsComponent);

View File

@ -31,6 +31,9 @@ import {
engineConfigurationMock,
workbasketReadStateMock
} from '../../../shared/store/mock-data/mock-store';
import { StartupService } from '../../../shared/services/startup/startup.service';
import { TaskanaEngineService } from '../../../shared/services/taskana-engine/taskana-engine.service';
import { WindowRefService } from '../../../shared/services/window/window.service';
@Component({ selector: 'taskana-shared-spinner', template: '' })
class SpinnerStub {
@ -119,7 +122,10 @@ describe('WorkbasketInformationComponent', () => {
RequestInProgressService,
DomainService,
SelectedRouteService,
ClassificationCategoriesService
ClassificationCategoriesService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();

View File

@ -13,6 +13,10 @@ import { SelectedRouteService } from '../../../shared/services/selected-route/se
import { NotificationService } from '../../../shared/services/notifications/notification.service';
import { ActivatedRoute } from '@angular/router';
import { CreateWorkbasket, SelectWorkbasket } from '../../../shared/store/workbasket-store/workbasket.actions';
import { ClassificationCategoriesService } from '../../../shared/services/classification-categories/classification-categories.service';
import { StartupService } from '../../../shared/services/startup/startup.service';
import { TaskanaEngineService } from '../../../shared/services/taskana-engine/taskana-engine.service';
import { WindowRefService } from '../../../shared/services/window/window.service';
const showDialogFn = jest.fn().mockReturnValue(true);
const NotificationServiceSpy = jest.fn().mockImplementation(
@ -66,7 +70,10 @@ describe('WorkbasketOverviewComponent', () => {
{ provide: ActivatedRoute, useValue: mockActivatedRoute },
DomainService,
RequestInProgressService,
SelectedRouteService
SelectedRouteService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();
@ -123,7 +130,10 @@ describe('WorkbasketOverviewComponent Alternative Params ID', () => {
{ provide: ActivatedRoute, useValue: mockActivatedRouteAlternative },
DomainService,
RequestInProgressService,
SelectedRouteService
SelectedRouteService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();
fixture = TestBed.createComponent(WorkbasketOverviewComponent);
@ -156,7 +166,10 @@ describe('WorkbasketOverviewComponent No Params', () => {
{ provide: ActivatedRoute, useValue: mockActivatedRouteNoParams },
DomainService,
RequestInProgressService,
SelectedRouteService
SelectedRouteService,
StartupService,
TaskanaEngineService,
WindowRefService
]
}).compileComponents();
fixture = TestBed.createComponent(WorkbasketOverviewComponent);

View File

@ -1,14 +1,17 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from 'app/../environments/environment';
import { TaskanaDate } from 'app/shared/util/taskana.date';
import { BlobGenerator } from 'app/shared/util/blob-generator';
import { Classification } from '../../shared/models/classification';
import { StartupService } from '../../shared/services/startup/startup.service';
@Injectable()
export class ClassificationDefinitionService {
url = `${environment.taskanaRestUrl}/v1/classification-definitions`;
constructor(private httpClient: HttpClient) {}
constructor(private httpClient: HttpClient, private startupService: StartupService) {}
get url(): string {
return this.startupService.getTaskanaRestUrl() + '/v1/classification-definitions';
}
// GET
async exportClassifications(domain: string) {

View File

@ -7,14 +7,17 @@ import { Direction } from 'app/shared/models/sorting';
import { Observable, of } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { environment } from 'environments/environment';
import { StartupService } from '../../../shared/services/startup/startup.service';
@Injectable({
providedIn: 'root'
})
export class TaskQueryService {
private url = environment.taskanaRestUrl;
constructor(private httpClient: HttpClient, private startupService: StartupService) {}
constructor(private httpClient: HttpClient) {}
get url(): string {
return this.startupService.getTaskanaRestUrl();
}
queryTask(
orderBy: string = 'created',

View File

@ -2,12 +2,16 @@ import { TestBed, inject } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { AccessIdsService } from './access-ids.service';
import { SelectedRouteService } from '../selected-route/selected-route';
import { StartupService } from '../startup/startup.service';
import { TaskanaEngineService } from '../taskana-engine/taskana-engine.service';
import { WindowRefService } from '../window/window.service';
describe('ValidateAccessItemsService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule],
providers: [AccessIdsService]
providers: [AccessIdsService, StartupService, TaskanaEngineService, WindowRefService]
});
});

View File

@ -7,13 +7,17 @@ import { AccessItemWorkbasketResource } from 'app/shared/models/access-item-work
import { TaskanaQueryParameters } from 'app/shared/util/query-parameters';
import { Sorting } from 'app/shared/models/sorting';
import { QueryParameters } from 'app/shared/models/query-parameters';
import { StartupService } from '../startup/startup.service';
@Injectable({
providedIn: 'root'
})
export class AccessIdsService {
private url = `${environment.taskanaRestUrl}/v1/access-ids`;
constructor(private httpClient: HttpClient) {}
constructor(private httpClient: HttpClient, private startupService: StartupService) {}
get url(): string {
return this.startupService.getTaskanaRestUrl() + '/v1/access-ids';
}
searchForAccessId(accessId: string): Observable<AccessIdDefinition[]> {
if (!accessId || accessId.length < 3) {

View File

@ -1,8 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from 'environments/environment';
import { Observable, Subject } from 'rxjs';
import { map, mergeMap, tap } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { mergeMap, tap } from 'rxjs/operators';
import { Classification } from 'app/shared/models/classification';
@ -11,14 +10,22 @@ import { DomainService } from 'app/shared/services/domain/domain.service';
import { TaskanaQueryParameters } from 'app/shared/util/query-parameters';
import { Direction } from 'app/shared/models/sorting';
import { QueryParameters } from 'app/shared/models/query-parameters';
import { StartupService } from '../startup/startup.service';
@Injectable()
export class ClassificationsService {
private url = `${environment.taskanaRestUrl}/v1/classifications/`;
private classificationResourcePromise: Promise<ClassificationPagingList>;
private lastDomain: string;
constructor(private httpClient: HttpClient, private domainService: DomainService) {}
constructor(
private httpClient: HttpClient,
private domainService: DomainService,
private startupService: StartupService
) {}
get url(): string {
return this.startupService.getTaskanaRestUrl() + '/v1/classifications/';
}
private static classificationParameters(domain: string, type?: string): QueryParameters {
const parameters = new QueryParameters();

View File

@ -7,6 +7,9 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
import { DomainService } from './domain.service';
import { RequestInProgressService } from '../request-in-progress/request-in-progress.service';
import { SelectedRouteService } from '../selected-route/selected-route';
import { StartupService } from '../startup/startup.service';
import { TaskanaEngineService } from '../taskana-engine/taskana-engine.service';
import { WindowRefService } from '../window/window.service';
@Component({
selector: 'taskana-dummy-detail',
@ -20,7 +23,15 @@ describe('DomainService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule.withRoutes(routes)],
providers: [HttpClient, DomainService, RequestInProgressService, SelectedRouteService],
providers: [
HttpClient,
DomainService,
RequestInProgressService,
SelectedRouteService,
StartupService,
TaskanaEngineService,
WindowRefService
],
declarations: [DummyDetailComponent]
});
});

View File

@ -2,14 +2,12 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, ReplaySubject } from 'rxjs';
import { Router } from '@angular/router';
import { environment } from '../../../../environments/environment';
import { RequestInProgressService } from '../request-in-progress/request-in-progress.service';
import { SelectedRouteService } from '../selected-route/selected-route';
import { StartupService } from '../startup/startup.service';
@Injectable()
export class DomainService {
url = `${environment.taskanaRestUrl}/v1/domains`;
private domainRestValue: Array<string> = new Array<string>();
private domainValue: Array<string> = new Array<string>();
private domainSelectedValue: string;
@ -21,7 +19,8 @@ export class DomainService {
private httpClient: HttpClient,
private router: Router,
private requestInProgressService: RequestInProgressService,
private selectedRouteService: SelectedRouteService
private selectedRouteService: SelectedRouteService,
private startupService: StartupService
) {
this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
if (value.indexOf('workbaskets') === 0) {
@ -37,6 +36,11 @@ export class DomainService {
});
}
// url loads rest url value from startUpService which is a http call to ensure url it is always loaded from environment-information.json
get url(): string {
return this.startupService.getTaskanaRestUrl() + '/v1/domains';
}
// GET
getDomains(forceRefresh = false): Observable<string[]> {
if (!this.dataObs$.observers.length || forceRefresh) {

View File

@ -43,6 +43,14 @@ export class StartupService {
.catch(() => of(true));
}
getTaskanaRestUrl() {
return environment.taskanaRestUrl;
}
getTaskanaLogoutUrl() {
return environment.taskanaLogoutUrl;
}
private loadEnvironment() {
return this.getEnvironmentFilePromise()
.then(() => this.taskanaEngineService.getUserInformation())

View File

@ -2,22 +2,24 @@ import { Task } from 'app/workplace/models/task';
import { Observable, Subject } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
import { TaskResource } from 'app/workplace/models/task-resource';
import { Direction } from 'app/shared/models/sorting';
import { TaskanaQueryParameters } from 'app/shared/util/query-parameters';
import { QueryParameters } from 'app/shared/models/query-parameters';
import { StartupService } from '../../shared/services/startup/startup.service';
@Injectable()
export class TaskService {
url = `${environment.taskanaRestUrl}/v1/tasks`;
private taskChangedSource = new Subject<Task>();
taskChangedStream = this.taskChangedSource.asObservable();
private taskSelectedSource = new Subject<Task>();
taskSelectedStream = this.taskSelectedSource.asObservable();
constructor(private httpClient: HttpClient) {}
constructor(private httpClient: HttpClient, private startupService: StartupService) {}
get url(): string {
return this.startupService.getTaskanaRestUrl() + '/v1/tasks';
}
publishUpdatedTask(task?: Task) {
this.taskChangedSource.next(task);

View File

@ -1,4 +1,4 @@
{
"taskanaRestUrl": "",
"taskanaLogoutUrl": ""
"taskanaRestUrl": "http://localhost:8080/taskana/api",
"taskanaLogoutUrl": "http://localhost:8080/taskana/logout"
}

View File

@ -5,6 +5,6 @@
export const environment = {
production: false,
taskanaRestUrl: 'http://localhost:8080/taskana/api',
taskanaLogoutUrl: 'http://localhost:8080/taskana/logout'
taskanaRestUrl: '',
taskanaLogoutUrl: ''
};