mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-07 18:25:09 +00:00
[ADF-2245] Setting Component - Emit an event to detect the changed url (#2907)
* [ADF-2245] Setting Component - Emit an event to detect the changed url * Added change event emitters * * Updated documentation
This commit is contained in:
parent
0f6ac42e4c
commit
05659b3837
@ -22,3 +22,5 @@ Validates the URLs for ACS and APS and saves them in the user's local storage
|
|||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---- | ---- | ----------- |
|
| ---- | ---- | ----------- |
|
||||||
| error | `EventEmitter<string>` | Emitted when the URL is invalid. |
|
| error | `EventEmitter<string>` | Emitted when the URL is invalid. |
|
||||||
|
| ecmHostChange | `EventEmitter<string>` | Emitted when the ECM host url is changed. |
|
||||||
|
| bpmHostChange | `EventEmitter<string>` | Emitted when the BPM host url is changed. |
|
||||||
|
@ -56,10 +56,26 @@ describe('HostSettingsComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
let ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
const ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
||||||
ecmUrlInput.value = 'wrong_url';
|
ecmUrlInput.value = 'wrong_url';
|
||||||
|
|
||||||
let event: any = {};
|
const event: any = {};
|
||||||
|
event.target = ecmUrlInput;
|
||||||
|
component.onChangeECMHost(event);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should emit ecmHostChange when the ECM url inserted is correct', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
const url = 'http://localhost:9999/ecm';
|
||||||
|
component.ecmHostChange.subscribe((message: string) => {
|
||||||
|
expect(message).toEqual(url);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
const ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
||||||
|
ecmUrlInput.value = url;
|
||||||
|
|
||||||
|
const event: any = {};
|
||||||
event.target = ecmUrlInput;
|
event.target = ecmUrlInput;
|
||||||
component.onChangeECMHost(event);
|
component.onChangeECMHost(event);
|
||||||
});
|
});
|
||||||
@ -72,21 +88,38 @@ describe('HostSettingsComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
let bpmUrlInput: any = fixture.nativeElement.querySelector('#bpmHost');
|
const bpmUrlInput: any = fixture.nativeElement.querySelector('#bpmHost');
|
||||||
bpmUrlInput.value = 'wrong_url';
|
bpmUrlInput.value = 'wrong_url';
|
||||||
|
|
||||||
let event: any = {};
|
const event: any = {};
|
||||||
event.target = bpmUrlInput;
|
event.target = bpmUrlInput;
|
||||||
component.onChangeBPMHost(event);
|
component.onChangeBPMHost(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should emit bpmHostChange when the BPM url inserted is correct', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
const url = 'http://localhost:9999/bpm';
|
||||||
|
|
||||||
|
component.ecmHostChange.subscribe((message: string) => {
|
||||||
|
expect(message).toEqual(url);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
const ecmUrlInput = fixture.nativeElement.querySelector('#bpmHost');
|
||||||
|
ecmUrlInput.value = url;
|
||||||
|
|
||||||
|
const event: any = {};
|
||||||
|
event.target = ecmUrlInput;
|
||||||
|
component.onChangeECMHost(event);
|
||||||
|
});
|
||||||
|
|
||||||
it('should not render the ECM url config if setting provider is BPM', () => {
|
it('should not render the ECM url config if setting provider is BPM', () => {
|
||||||
component.providers = 'BPM';
|
component.providers = 'BPM';
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
let bpmUrlInput = fixture.nativeElement.querySelector('#bpmHost');
|
const bpmUrlInput = fixture.nativeElement.querySelector('#bpmHost');
|
||||||
let ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
const ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
||||||
expect(ecmUrlInput).toEqual(null);
|
expect(ecmUrlInput).toEqual(null);
|
||||||
expect(bpmUrlInput).toBeDefined();
|
expect(bpmUrlInput).toBeDefined();
|
||||||
});
|
});
|
||||||
@ -96,8 +129,8 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
let ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
const ecmUrlInput = fixture.nativeElement.querySelector('#ecmHost');
|
||||||
let bpmUrlInput = fixture.nativeElement.querySelector('#bpmHost');
|
const bpmUrlInput = fixture.nativeElement.querySelector('#bpmHost');
|
||||||
expect(bpmUrlInput).toEqual(null);
|
expect(bpmUrlInput).toEqual(null);
|
||||||
expect(ecmUrlInput).toBeDefined();
|
expect(ecmUrlInput).toBeDefined();
|
||||||
});
|
});
|
||||||
|
@ -50,6 +50,14 @@ export class HostSettingsComponent {
|
|||||||
@Output()
|
@Output()
|
||||||
error = new EventEmitter<string>();
|
error = new EventEmitter<string>();
|
||||||
|
|
||||||
|
/** Emitted when the ecm host URL is changed. */
|
||||||
|
@Output()
|
||||||
|
ecmHostChange = new EventEmitter<string>();
|
||||||
|
|
||||||
|
/** Emitted when the bpm host URL is changed. */
|
||||||
|
@Output()
|
||||||
|
bpmHostChange = new EventEmitter<string>();
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private storage: StorageService,
|
private storage: StorageService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
@ -63,6 +71,7 @@ export class HostSettingsComponent {
|
|||||||
if (value && this.isValidUrl(value)) {
|
if (value && this.isValidUrl(value)) {
|
||||||
this.logService.info(`ECM host: ${value}`);
|
this.logService.info(`ECM host: ${value}`);
|
||||||
this.ecmHostTmp = value;
|
this.ecmHostTmp = value;
|
||||||
|
this.ecmHostChange.emit(value);
|
||||||
} else {
|
} else {
|
||||||
this.translationService.get('CORE.HOST_SETTING.CS_URL_ERROR').subscribe((message) => {
|
this.translationService.get('CORE.HOST_SETTING.CS_URL_ERROR').subscribe((message) => {
|
||||||
this.error.emit(message);
|
this.error.emit(message);
|
||||||
@ -75,6 +84,7 @@ export class HostSettingsComponent {
|
|||||||
if (value && this.isValidUrl(value)) {
|
if (value && this.isValidUrl(value)) {
|
||||||
this.logService.info(`BPM host: ${value}`);
|
this.logService.info(`BPM host: ${value}`);
|
||||||
this.bpmHostTmp = value;
|
this.bpmHostTmp = value;
|
||||||
|
this.bpmHostChange.emit(value);
|
||||||
} else {
|
} else {
|
||||||
this.translationService.get('CORE.HOST_SETTING.PS_URL_ERROR').subscribe((message) => {
|
this.translationService.get('CORE.HOST_SETTING.PS_URL_ERROR').subscribe((message) => {
|
||||||
this.error.emit(message);
|
this.error.emit(message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user