mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-2948] Add API to fetch the bpm properties (#5610)
* Add the api to fetch the bpm properties * remove useless map * Use latest api * Use the BehaviorSubject * filter the status true
This commit is contained in:
@@ -34,7 +34,7 @@ export class AlfrescoApiServiceMock extends AlfrescoApiService {
|
||||
|
||||
initialize(): Promise<any> {
|
||||
return new Promise((resolve) => {
|
||||
this.alfrescoApiInitializedSubject.next();
|
||||
this.alfrescoApiInitializedSubject.next(true);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import {
|
||||
AlfrescoApiCompatibility, AlfrescoApiConfig
|
||||
} from '@alfresco/js-api';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { Subject, Observable } from 'rxjs';
|
||||
import { Subject, Observable, BehaviorSubject } from 'rxjs';
|
||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@@ -40,7 +40,7 @@ export class AlfrescoApiService {
|
||||
*/
|
||||
nodeUpdated = new Subject<Node>();
|
||||
|
||||
protected alfrescoApiInitializedSubject: Subject<any>;
|
||||
protected alfrescoApiInitializedSubject: BehaviorSubject<any>;
|
||||
alfrescoApiInitialized: Observable<any>;
|
||||
|
||||
protected alfrescoApi: AlfrescoApiCompatibility;
|
||||
@@ -102,7 +102,7 @@ export class AlfrescoApiService {
|
||||
constructor(
|
||||
protected appConfig: AppConfigService,
|
||||
protected storageService: StorageService) {
|
||||
this.alfrescoApiInitializedSubject = new Subject();
|
||||
this.alfrescoApiInitializedSubject = new BehaviorSubject(null);
|
||||
this.alfrescoApiInitialized = this.alfrescoApiInitializedSubject.asObservable();
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export class AlfrescoApiService {
|
||||
await this.appConfig.load().then(() => {
|
||||
this.storageService.prefix = this.appConfig.get<string>(AppConfigValues.STORAGE_PREFIX, '');
|
||||
this.initAlfrescoApi();
|
||||
this.alfrescoApiInitializedSubject.next();
|
||||
this.alfrescoApiInitializedSubject.next(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { DiscoveryApiService } from './discovery-api.service';
|
||||
import { setupTestBed } from '../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { SystemPropertiesRepresentation } from '@alfresco/js-api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -87,6 +88,18 @@ const fakeBPMDiscoveryResponse: any = {
|
||||
'minorVersion': '6'
|
||||
};
|
||||
|
||||
const fakeBPMDiscoverySystemPropertyResponse: any = {
|
||||
'allowInvolveByEmail': true,
|
||||
'disableJavaScriptEventsInFormEditor': false,
|
||||
'logoutDisabled': false,
|
||||
'authConfiguration': {
|
||||
'authUrl': 'fakeAuthUrl',
|
||||
'realm': 'fakeRealm',
|
||||
'clientId': 'fakeClient',
|
||||
'useBrowserLogout': true
|
||||
}
|
||||
};
|
||||
|
||||
describe('Discovery Api Service', () => {
|
||||
|
||||
let service;
|
||||
@@ -172,5 +185,42 @@ describe('Discovery Api Service', () => {
|
||||
status: 403
|
||||
});
|
||||
});
|
||||
|
||||
it('Should retrieve the system properties for BPM', (done) => {
|
||||
service.getBPMSystemProperties().subscribe((data: SystemPropertiesRepresentation) => {
|
||||
expect(data).not.toBeNull();
|
||||
expect(data.allowInvolveByEmail).toBe(true);
|
||||
expect(data.disableJavaScriptEventsInFormEditor).toBe(false);
|
||||
expect(data.logoutDisabled).toBe(false);
|
||||
expect(data.authConfiguration.authUrl).toBe('fakeAuthUrl');
|
||||
expect(data.authConfiguration.realm).toBe('fakeRealm');
|
||||
expect(data.authConfiguration.clientId).toBe('fakeClient');
|
||||
expect(data.authConfiguration.useBrowserLogout).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: fakeBPMDiscoverySystemPropertyResponse
|
||||
});
|
||||
});
|
||||
|
||||
it('Should retrieve the system properties for BPM', (done) => {
|
||||
service.getBPMSystemProperties().subscribe(
|
||||
() => {
|
||||
fail('expected an error, bpm not running');
|
||||
},
|
||||
(error) => {
|
||||
expect(error.response.statusCode).toEqual(404);
|
||||
expect(error.response.statusText).toEqual('Not Found');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404,
|
||||
statusText: 'Not Found'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -20,6 +20,10 @@ import { from, throwError, Observable } from 'rxjs';
|
||||
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import {
|
||||
SystemPropertiesRepresentation,
|
||||
Activiti
|
||||
} from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -51,4 +55,15 @@ export class DiscoveryApiService {
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private get systemPropertiesApi(): Activiti.SystemPropertiesApi {
|
||||
return this.apiService.getInstance().activiti.systemPropertiesApi;
|
||||
}
|
||||
|
||||
public getBPMSystemProperties(): Observable<SystemPropertiesRepresentation> {
|
||||
return from(this.systemPropertiesApi.getProperties())
|
||||
.pipe(
|
||||
catchError((err) => throwError(err.error))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import { Observable, BehaviorSubject } from 'rxjs';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { LanguageItem } from '../language-menu/language.interface';
|
||||
import { StorageService } from './storage.service';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, map, filter } from 'rxjs/operators';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
|
||||
export enum UserPreferenceValues {
|
||||
@@ -51,7 +51,7 @@ export class UserPreferencesService {
|
||||
private appConfig: AppConfigService,
|
||||
private storage: StorageService,
|
||||
private alfrescoApiService: AlfrescoApiService) {
|
||||
this.alfrescoApiService.alfrescoApiInitialized.subscribe(this.initUserPreferenceStatus.bind(this));
|
||||
this.alfrescoApiService.alfrescoApiInitialized.pipe(filter(status => status)).subscribe(this.initUserPreferenceStatus.bind(this));
|
||||
this.onChangeSubject = new BehaviorSubject(this.userPreferenceStatus);
|
||||
this.onChange = this.onChangeSubject.asObservable();
|
||||
}
|
||||
|
Reference in New Issue
Block a user