#ADF-498 added check for valid settings addresses (#1834)

* #ADF-498 added check for valid settings addresses

* #ADF-498 added adf prefix to the new style class
This commit is contained in:
Vito
2017-04-21 04:16:56 -07:00
committed by Mario Romano
parent 1de625d960
commit 806874cdca
3 changed files with 44 additions and 10 deletions

View File

@@ -29,3 +29,7 @@
.table-row { .table-row {
display: table-row; display: table-row;
} }
.adf-setting-input-padding{
padding-top: 0px !important;
}

View File

@@ -10,18 +10,31 @@
Content Services host URL configuration Content Services host URL configuration
</div> </div>
<nav class="mdl-navigation"> <nav class="mdl-navigation">
<div class="icon material-icons icon-margin">link</div> <i class="icon material-icons icon-margin">link</i>
<input type="text" class="mdl-textfield__input" id="ecmHost" data-automation-id="ecmHost" <div class="mdl-textfield mdl-js-textfield adf-setting-input-padding">
tabindex="1" (change)="onChangeECMHost($event)" value="{{ecmHost}}"/> <input data-automation-id="ecmHost"
class="mdl-textfield__input" tabindex="1"
type="text" tabindex="1"
(change)="onChangeECMHost($event)"
pattern="^(http|https):\/\/.*" id="ecmHost" value="{{ecmHost}}">
<label class="mdl-textfield__label" for="ecmHost">ECM Host</label>
<span class="mdl-textfield__error">ECM host is not valid!</span>
</div>
</nav> </nav>
<div class="mdl-card__supporting-text"> <div class="mdl-card__supporting-text">
Process Services host URL configuration Process Services host URL configuration
</div> </div>
<nav class="mdl-navigation"> <nav class="mdl-navigation">
<div class="icon material-icons icon-margin">link</div> <i class="icon material-icons icon-margin">link</i>
<input type="text" class="mdl-textfield__input" id="bpmHost" data-automation-id="bpmHost" <div class="mdl-textfield mdl-js-textfield adf-setting-input-paddingg">
tabindex="1" (change)="onChangeBPMHost($event)" value="{{bpmHost}}"/> <input class="mdl-textfield__input"
type="text"
(change)="onChangeBPMHost($event)"
tabindex="2" pattern="^(http|https):\/\/.*" id="bpmHost" value="{{bpmHost}}">
<label class="mdl-textfield__label" for="bpmHost">BPM Host</label>
<span class="mdl-textfield__error">BPM host is not valid!</span>
</div>
</nav> </nav>
</div> </div>
<div class="mdl-card__actions mdl-card--border"> <div class="mdl-card__actions mdl-card--border">

View File

@@ -15,15 +15,17 @@
* limitations under the License. * limitations under the License.
*/ */
import { Component } from '@angular/core'; import { Component, AfterViewChecked } from '@angular/core';
import { AlfrescoSettingsService, StorageService, LogService } from 'ng2-alfresco-core'; import { AlfrescoSettingsService, StorageService, LogService } from 'ng2-alfresco-core';
declare var componentHandler: any;
@Component({ @Component({
selector: 'alfresco-setting-demo', selector: 'alfresco-setting-demo',
templateUrl: './setting.component.html', templateUrl: './setting.component.html',
styleUrls: ['./setting.component.css'] styleUrls: ['./setting.component.css']
}) })
export class SettingComponent { export class SettingComponent implements AfterViewChecked {
ecmHost: string; ecmHost: string;
bpmHost: string; bpmHost: string;
@@ -35,24 +37,39 @@ export class SettingComponent {
this.bpmHost = this.settingsService.bpmHost; this.bpmHost = this.settingsService.bpmHost;
} }
ngAfterViewChecked() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
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) { if (value && this.isValidUrl(value)) {
this.logService.info(`ECM host: ${value}`); this.logService.info(`ECM host: ${value}`);
this.ecmHost = value; this.ecmHost = value;
this.settingsService.ecmHost = value; this.settingsService.ecmHost = value;
this.storage.setItem(`ecmHost`, value); this.storage.setItem(`ecmHost`, value);
} else {
console.error('Ecm address does not match the pattern');
} }
} }
public onChangeBPMHost(event: KeyboardEvent): void { public onChangeBPMHost(event: KeyboardEvent): void {
let value = (<HTMLInputElement>event.target).value.trim(); let value = (<HTMLInputElement>event.target).value.trim();
if (value) { if (value && this.isValidUrl(value)) {
this.logService.info(`BPM host: ${value}`); this.logService.info(`BPM host: ${value}`);
this.bpmHost = value; this.bpmHost = value;
this.settingsService.bpmHost = value; this.settingsService.bpmHost = value;
this.storage.setItem(`bpmHost`, value); this.storage.setItem(`bpmHost`, value);
} else {
console.error('Bpm address does not match the pattern');
} }
} }
isValidUrl(url: string) {
return /^(http|https):\/\/.*/.test(url);
}
} }