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