mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-24 14:31:41 +00:00
fix app config stream in storing service
fix app config stream for sub property
This commit is contained in:
@@ -20,9 +20,14 @@ import { StorageService } from '../common/services/storage.service';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
export function loadAppConfig(appConfigService: AppConfigService, storageService: StorageService, adfHttpClient: AdfHttpClient) {
|
||||
|
||||
const init = () => {
|
||||
adfHttpClient.disableCsrf = appConfigService.get<boolean>(AppConfigValues.DISABLECSRF, true);
|
||||
storageService.prefix = appConfigService.get<string>(AppConfigValues.STORAGE_PREFIX, '');
|
||||
|
||||
appConfigService.select(AppConfigValues.STORAGE_PREFIX).subscribe((property) => {
|
||||
storageService.prefix = property
|
||||
});
|
||||
};
|
||||
return () => appConfigService.load(init);
|
||||
};
|
||||
|
@@ -99,7 +99,7 @@ export class AppConfigService {
|
||||
select(property: string): Observable<any> {
|
||||
return this.onLoadSubject
|
||||
.pipe(
|
||||
map((config) => config[property]),
|
||||
map((config) => ObjectUtils.getValue(config, property)),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
}
|
||||
|
@@ -19,12 +19,14 @@ import { Injectable } from '@angular/core';
|
||||
import { AppConfigService, Status } from '../../app-config/app-config.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ExtensionService } from '@alfresco/adf-extensions';
|
||||
|
||||
@Injectable()
|
||||
export class AppConfigServiceMock extends AppConfigService {
|
||||
|
||||
config: any = {
|
||||
application: {
|
||||
name: 'Alfresco ADF Application'
|
||||
name: 'Alfresco ADF Application',
|
||||
storagePrefix: 'ADF_APP'
|
||||
},
|
||||
ecmHost: 'http://{hostname}{:port}/ecm',
|
||||
bpmHost: 'http://{hostname}{:port}/bpm',
|
||||
@@ -35,11 +37,12 @@ export class AppConfigServiceMock extends AppConfigService {
|
||||
super(http, extensionService);
|
||||
}
|
||||
|
||||
load(): Promise<any> {
|
||||
load(callback?: (...args: any[]) => any): Promise<any> {
|
||||
return new Promise((resolve) => {
|
||||
this.status = Status.LOADED;
|
||||
this.onDataLoaded();
|
||||
callback?.();
|
||||
resolve(this.config);
|
||||
this.onDataLoaded();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import { StorageService } from '../../common/services/storage.service';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CoreModule } from '../../core.module';
|
||||
|
||||
describe('StorageService', () => {
|
||||
|
||||
@@ -34,8 +33,6 @@ describe('StorageService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
@@ -87,6 +84,7 @@ describe('StorageService', () => {
|
||||
]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
|
||||
appConfig.config = {
|
||||
application: {
|
||||
storagePrefix: ''
|
||||
|
Reference in New Issue
Block a user