mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Save host only when apply (#2371)
[ADF-1581] Demo shell - Improve host setting configuration check
This commit is contained in:
parent
c9641da932
commit
e8c9c209dc
@ -51,7 +51,7 @@
|
|||||||
{{'SETTINGS.BACK' | translate }}
|
{{'SETTINGS.BACK' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button md-button onclick="window.location.href = '/'" color="primary">
|
<button md-button (click)="save($event)" [disabled]="urlFormControlBpm.hasError('pattern') || urlFormControlEcm.hasError('pattern')" color="primary">
|
||||||
{{'SETTINGS.APPLY' | translate }}
|
{{'SETTINGS.APPLY' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -29,23 +29,24 @@ export class SettingsComponent {
|
|||||||
HOST_REGEX: string = '^(http|https):\/\/.*[^/]$';
|
HOST_REGEX: string = '^(http|https):\/\/.*[^/]$';
|
||||||
|
|
||||||
ecmHost: string;
|
ecmHost: string;
|
||||||
|
ecmHostTmp: string;
|
||||||
bpmHost: string;
|
bpmHost: string;
|
||||||
|
bpmHostTmp: string;
|
||||||
urlFormControlEcm = new FormControl('', [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
urlFormControlEcm = new FormControl('', [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
||||||
urlFormControlBpm = new FormControl('', [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
urlFormControlBpm = new FormControl('', [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
||||||
|
|
||||||
constructor(private settingsService: AlfrescoSettingsService,
|
constructor(private settingsService: AlfrescoSettingsService,
|
||||||
private storage: StorageService,
|
private storage: StorageService,
|
||||||
private logService: LogService) {
|
private logService: LogService) {
|
||||||
this.ecmHost = storage.getItem('ecmHost') || this.settingsService.ecmHost;
|
this.ecmHostTmp = this.ecmHost = storage.getItem('ecmHost') || this.settingsService.ecmHost;
|
||||||
this.bpmHost = storage.getItem('bpmHost') || this.settingsService.bpmHost;
|
this.bpmHostTmp = this.bpmHost = storage.getItem('bpmHost') || this.settingsService.bpmHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangeECMHost(event: KeyboardEvent): void {
|
public onChangeECMHost(event: KeyboardEvent): void {
|
||||||
let value = (<HTMLInputElement>event.target).value.trim();
|
let value = (<HTMLInputElement>event.target).value.trim();
|
||||||
if (value && this.isValidUrl(value)) {
|
if (value && this.isValidUrl(value)) {
|
||||||
this.logService.info(`ECM host: ${value}`);
|
this.logService.info(`ECM host: ${value}`);
|
||||||
this.ecmHost = value;
|
this.ecmHostTmp = value;
|
||||||
this.storage.setItem(`ecmHost`, value);
|
|
||||||
} else {
|
} else {
|
||||||
console.error('Ecm address does not match the pattern');
|
console.error('Ecm address does not match the pattern');
|
||||||
}
|
}
|
||||||
@ -55,13 +56,22 @@ export class SettingsComponent {
|
|||||||
let value = (<HTMLInputElement>event.target).value.trim();
|
let value = (<HTMLInputElement>event.target).value.trim();
|
||||||
if (value && this.isValidUrl(value)) {
|
if (value && this.isValidUrl(value)) {
|
||||||
this.logService.info(`BPM host: ${value}`);
|
this.logService.info(`BPM host: ${value}`);
|
||||||
this.bpmHost = value;
|
this.bpmHostTmp = value;
|
||||||
this.storage.setItem(`bpmHost`, value);
|
|
||||||
} else {
|
} else {
|
||||||
console.error('Bpm address does not match the pattern');
|
console.error('Bpm address does not match the pattern');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public save(event: KeyboardEvent): void {
|
||||||
|
if (this.bpmHost !== this.bpmHostTmp) {
|
||||||
|
this.storage.setItem(`bpmHost`, this.bpmHostTmp);
|
||||||
|
}
|
||||||
|
if (this.ecmHost !== this.ecmHostTmp) {
|
||||||
|
this.storage.setItem(`ecmHost`, this.ecmHostTmp);
|
||||||
|
}
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
|
|
||||||
isValidUrl(url: string) {
|
isValidUrl(url: string) {
|
||||||
return /^(http|https):\/\/.*/.test(url);
|
return /^(http|https):\/\/.*/.test(url);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user