UI: Add mobile custom page validation

This commit is contained in:
Vladyslav_Prykhodko 2024-11-14 10:52:58 +02:00
parent 7398508c35
commit a0e4a7738e
4 changed files with 13 additions and 3 deletions

View File

@ -57,12 +57,20 @@
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
<mat-label translate>mobile.url</mat-label>
<input required matInput formControlName="url">
<mat-hint></mat-hint>
<mat-error *ngIf="customMobilePageForm.get('url').hasError('pattern')">
{{ 'mobile.url-pattern' | translate }}
</mat-error>
</mat-form-field>
</ng-container>
<ng-container *ngIf="customMobilePageForm.get('type').value === MobilePageType.CUSTOM">
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
<mat-label translate>mobile.path</mat-label>
<input required matInput formControlName="path">
<mat-hint></mat-hint>
<mat-error *ngIf="customMobilePageForm.get('path').hasError('pattern')">
{{ 'mobile.path-pattern' | translate }}
</mat-error>
</mat-form-field>
</ng-container>
</section>

View File

@ -63,8 +63,8 @@ export class CustomMobilePageComponent implements ControlValueAccessor, Validato
label: ['', Validators.required],
type: [MobilePageType.DASHBOARD],
dashboardId: ['', Validators.required],
url: [{value:'', disabled: true}, [Validators.required]],
path: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^((?!\s).)*$/)]]
url: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^(https?:\/\/)?(localhost|([\w\-]+\.)+[\w\-]+)(:\d+)?(\/[\w\-._~:\/?#[\]@!$&'()*+,;=%]*)?$/)]],
path: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^(\/[\w\-._~:\/?#[\]@!$&'()*+,;=%]*)?$/)]]
});
private propagateChange = (_val: any) => {};

View File

@ -53,7 +53,7 @@ export class MobileAppConfigurationDialogComponent extends DialogComponent<Mobil
this.showDontShowAgain = this.data.afterAdd;
this.configureApi.push(`static final thingsBoardApiEndpoint = '${window.location.origin}';`);
this.configureApi.push(`static const thingsBoardApiEndpoint = '${window.location.origin}';`);
this.configureApi.push(`static const thingsboardOAuth2AppSecret = '${this.data.appSecret}';`);
}

View File

@ -3477,7 +3477,9 @@
"custom": "Custom"
},
"url": "URL",
"url-pattern": "Invalid URL",
"path": "Path",
"path-pattern": "Path pattern",
"custom-page": "Custom page",
"edit-page": "Edit page",
"edit-custom-page": "Edit custom page",