Browse Source

Naming improvement

pull/12467/head
mpetrov 2 years ago
parent
commit
9570abe2ce
  1. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.component.html
  2. 10
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.component.ts
  3. 15
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.models.ts
  4. 4
      ui-ngx/src/app/modules/home/components/widget/widget.component.ts
  5. 8
      ui-ngx/src/app/shared/models/widget.models.ts
  6. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.component.html

@ -36,7 +36,7 @@
</mat-form-field> </mat-form-field>
</div> </div>
<ng-container [formGroup]="mobileActionTypeFormGroup" [ngSwitch]="mobileActionFormGroup.get('type').value"> <ng-container [formGroup]="mobileActionTypeFormGroup" [ngSwitch]="mobileActionFormGroup.get('type').value">
<ng-template [ngSwitchCase]="mobileActionType.provisionDevice"> <ng-template [ngSwitchCase]="mobileActionType.deviceProvision">
<tb-js-func <tb-js-func
formControlName="handleProvisionSuccessFunction" formControlName="handleProvisionSuccessFunction"
functionName="handleProvisionSuccess" functionName="handleProvisionSuccess"

10
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.component.ts

@ -39,7 +39,7 @@ import {
getDefaultProcessLaunchResultFunction, getDefaultProcessLaunchResultFunction,
getDefaultProcessLocationFunction, getDefaultProcessLocationFunction,
getDefaultProcessQrCodeFunction, getDefaultProcessQrCodeFunction,
getDefaultProvisioningSuccessFunction getDefaultProvisionSuccessFunction
} from '@home/components/widget/lib/settings/common/action/mobile-action-editor.models'; } from '@home/components/widget/lib/settings/common/action/mobile-action-editor.models';
import { WidgetService } from '@core/http/widget.service'; import { WidgetService } from '@core/http/widget.service';
import { TbFunction } from '@shared/models/js-function.models'; import { TbFunction } from '@shared/models/js-function.models';
@ -255,12 +255,12 @@ export class MobileActionEditorComponent implements ControlValueAccessor, OnInit
this.fb.control(processLocationFunction, [Validators.required]) this.fb.control(processLocationFunction, [Validators.required])
); );
break; break;
case WidgetMobileActionType.provisionDevice: case WidgetMobileActionType.deviceProvision:
let handleProvisionSuccessFunction = action?.handleProvisionSuccessFunction; let handleProvisionSuccessFunction = action?.handleProvisionSuccessFunction;
if (changed) { if (changed) {
const defaultProvisioningSuccessFunction = getDefaultProvisioningSuccessFunction(); const defaultProvisionSuccessFunction = getDefaultProvisionSuccessFunction();
if (defaultProvisioningSuccessFunction !== handleProvisionSuccessFunction) { if (defaultProvisionSuccessFunction !== handleProvisionSuccessFunction) {
handleProvisionSuccessFunction = defaultProvisioningSuccessFunction; handleProvisionSuccessFunction = defaultProvisionSuccessFunction;
} }
} }
this.mobileActionTypeFormGroup.addControl( this.mobileActionTypeFormGroup.addControl(

15
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/mobile-action-editor.models.ts

@ -138,12 +138,13 @@ const processLocationFunction: TbFunction =
' }, 100);\n' + ' }, 100);\n' +
'}'; '}';
const provisioningSuccessFunction: TbFunction = const provisionSuccessFunction: TbFunction =
'// Function body to handle device provision success. \n' + '// Function body to handle device provision success. \n' +
'// - deviceName - name of device that was successfully provisioned.\n' + '// - deviceName - name of device that was successfully provisioned.\n' +
'showDeviceProvisioningSuccess(deviceName);\n' +
'\n' + '\n' +
'function showDeviceProvisioningSuccess(deviceName) {\n' + 'showDeviceProvisionSuccess(deviceName);\n' +
'\n' +
'function showDeviceProvisionSuccess(deviceName) {\n' +
' setTimeout(function() {\n' + ' setTimeout(function() {\n' +
' widgetContext.showSuccessToast(`Device ` + deviceName + ` was successfully provisioned`).subscribe();\n' + ' widgetContext.showSuccessToast(`Device ` + deviceName + ` was successfully provisioned`).subscribe();\n' +
' }, 100);\n' + ' }, 100);\n' +
@ -252,7 +253,7 @@ export const getDefaultProcessQrCodeFunction = () => processQrCodeFunction;
export const getDefaultProcessLocationFunction = () => processLocationFunction; export const getDefaultProcessLocationFunction = () => processLocationFunction;
export const getDefaultProvisioningSuccessFunction = () => provisioningSuccessFunction; export const getDefaultProvisionSuccessFunction = () => provisionSuccessFunction;
export const getDefaultGetLocationFunction = () => getLocationFunctionTemplate; export const getDefaultGetLocationFunction = () => getLocationFunctionTemplate;
@ -285,8 +286,8 @@ export const getDefaultHandleEmptyResultFunction = (type: WidgetMobileActionType
case WidgetMobileActionType.takeScreenshot: case WidgetMobileActionType.takeScreenshot:
message = 'Take screenshot action was cancelled!'; message = 'Take screenshot action was cancelled!';
break; break;
case WidgetMobileActionType.provisionDevice: case WidgetMobileActionType.deviceProvision:
message = 'Provisioning device was not invoked!'; message = 'Device provision was not invoked!';
break; break;
} }
return handleEmptyResultFunctionTemplate.replace('--MESSAGE--', message); return handleEmptyResultFunctionTemplate.replace('--MESSAGE--', message);
@ -319,7 +320,7 @@ export const getDefaultHandleErrorFunction = (type: WidgetMobileActionType): TbF
case WidgetMobileActionType.takeScreenshot: case WidgetMobileActionType.takeScreenshot:
title = 'Failed to take screenshot'; title = 'Failed to take screenshot';
break; break;
case WidgetMobileActionType.provisionDevice: case WidgetMobileActionType.deviceProvision:
title = 'Failed to make device provision'; title = 'Failed to make device provision';
break; break;
} }

4
ui-ngx/src/app/modules/home/components/widget/widget.component.ts

@ -1203,7 +1203,7 @@ export class WidgetComponent extends PageComponent implements OnInit, OnChanges,
case WidgetMobileActionType.scanQrCode: case WidgetMobileActionType.scanQrCode:
case WidgetMobileActionType.getLocation: case WidgetMobileActionType.getLocation:
case WidgetMobileActionType.takeScreenshot: case WidgetMobileActionType.takeScreenshot:
case WidgetMobileActionType.provisionDevice: case WidgetMobileActionType.deviceProvision:
argsObservable = of([]); argsObservable = of([]);
break; break;
case WidgetMobileActionType.mapDirection: case WidgetMobileActionType.mapDirection:
@ -1293,7 +1293,7 @@ export class WidgetComponent extends PageComponent implements OnInit, OnChanges,
); );
} }
break; break;
case WidgetMobileActionType.provisionDevice: case WidgetMobileActionType.deviceProvision:
const deviceName = actionResult.deviceName; const deviceName = actionResult.deviceName;
if (isNotEmptyTbFunction(mobileAction.handleProvisionSuccessFunction)) { if (isNotEmptyTbFunction(mobileAction.handleProvisionSuccessFunction)) {
compileTbFunction(this.http, mobileAction.handleProvisionSuccessFunction, 'deviceName', '$event', 'widgetContext', 'entityId', compileTbFunction(this.http, mobileAction.handleProvisionSuccessFunction, 'deviceName', '$event', 'widgetContext', 'entityId',

8
ui-ngx/src/app/shared/models/widget.models.ts

@ -588,7 +588,7 @@ export enum WidgetMobileActionType {
makePhoneCall = 'makePhoneCall', makePhoneCall = 'makePhoneCall',
getLocation = 'getLocation', getLocation = 'getLocation',
takeScreenshot = 'takeScreenshot', takeScreenshot = 'takeScreenshot',
provisionDevice = 'provisionDevice', deviceProvision = 'deviceProvision',
} }
export const widgetActionTypes = Object.keys(WidgetActionType) as WidgetActionType[]; export const widgetActionTypes = Object.keys(WidgetActionType) as WidgetActionType[];
@ -616,7 +616,7 @@ export const widgetMobileActionTypeTranslationMap = new Map<WidgetMobileActionTy
[ WidgetMobileActionType.makePhoneCall, 'widget-action.mobile.make-phone-call' ], [ WidgetMobileActionType.makePhoneCall, 'widget-action.mobile.make-phone-call' ],
[ WidgetMobileActionType.getLocation, 'widget-action.mobile.get-location' ], [ WidgetMobileActionType.getLocation, 'widget-action.mobile.get-location' ],
[ WidgetMobileActionType.takeScreenshot, 'widget-action.mobile.take-screenshot' ], [ WidgetMobileActionType.takeScreenshot, 'widget-action.mobile.take-screenshot' ],
[ WidgetMobileActionType.provisionDevice, 'widget-action.mobile.provision-device' ] [ WidgetMobileActionType.deviceProvision, 'widget-action.mobile.device-provision' ]
] ]
); );
@ -638,7 +638,7 @@ export interface MobileLocationResult {
longitude: number; longitude: number;
} }
export interface MobileDeviceProvisioningResult { export interface MobileDeviceProvisionResult {
deviceName: string; deviceName: string;
} }
@ -646,7 +646,7 @@ export type MobileActionResult = MobileLaunchResult &
MobileImageResult & MobileImageResult &
MobileQrCodeResult & MobileQrCodeResult &
MobileLocationResult & MobileLocationResult &
MobileDeviceProvisioningResult; MobileDeviceProvisionResult;
export interface WidgetMobileActionResult<T extends MobileActionResult> { export interface WidgetMobileActionResult<T extends MobileActionResult> {
result?: T; result?: T;

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -6536,7 +6536,7 @@
"URL": "URL", "URL": "URL",
"url-required": "URL is required.", "url-required": "URL is required.",
"mobile": { "mobile": {
"provision-device": "Provision device", "device-provision": "Device provision",
"action-type": "Mobile action type", "action-type": "Mobile action type",
"select-action-type": "Select mobile action type", "select-action-type": "Select mobile action type",
"action-type-required": "Mobile action type is required", "action-type-required": "Mobile action type is required",

Loading…
Cancel
Save