Browse Source

UI: fixed mob qr code admin settings not applying, extra small screen layout imprvmts, qr code clickble in mobile mode

pull/10838/head
rusikv 2 years ago
parent
commit
de0b9760bb
  1. 9
      ui-ngx/src/app/core/auth/auth.actions.ts
  2. 3
      ui-ngx/src/app/core/auth/auth.reducer.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/mobile-app-qrcode-widget.component.html
  4. 11
      ui-ngx/src/app/modules/home/components/widget/lib/mobile-app-qrcode-widget.component.ts
  5. 4
      ui-ngx/src/app/modules/home/pages/admin/mobile-app-settings.component.html
  6. 67
      ui-ngx/src/app/modules/home/pages/admin/mobile-app-settings.component.ts
  7. 5
      ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts
  8. 2
      ui-ngx/src/assets/dashboard/sys_admin_home_page.json
  9. 2
      ui-ngx/src/assets/dashboard/tenant_admin_home_page.json

9
ui-ngx/src/app/core/auth/auth.actions.ts

@ -27,6 +27,7 @@ export enum AuthActionTypes {
UPDATE_AUTH_USER = '[Auth] Update Auth User', UPDATE_AUTH_USER = '[Auth] Update Auth User',
UPDATE_LAST_PUBLIC_DASHBOARD_ID = '[Auth] Update Last Public Dashboard Id', UPDATE_LAST_PUBLIC_DASHBOARD_ID = '[Auth] Update Last Public Dashboard Id',
UPDATE_HAS_REPOSITORY = '[Auth] Change Has Repository', UPDATE_HAS_REPOSITORY = '[Auth] Change Has Repository',
UPDATE_MOBILE_QR_ENABLED = '[Auth] Update Mobile QR Enabled',
UPDATE_OPENED_MENU_SECTION = '[Preferences] Update Opened Menu Section', UPDATE_OPENED_MENU_SECTION = '[Preferences] Update Opened Menu Section',
PUT_USER_SETTINGS = '[Preferences] Put user settings', PUT_USER_SETTINGS = '[Preferences] Put user settings',
DELETE_USER_SETTINGS = '[Preferences] Delete user settings', DELETE_USER_SETTINGS = '[Preferences] Delete user settings',
@ -72,6 +73,12 @@ export class ActionAuthUpdateHasRepository implements Action {
constructor(readonly payload: { hasRepository: boolean }) {} constructor(readonly payload: { hasRepository: boolean }) {}
} }
export class ActionUpdateMobileQrCodeEnabled implements Action {
readonly type = AuthActionTypes.UPDATE_MOBILE_QR_ENABLED;
constructor(readonly payload: { mobileQrEnabled: boolean }) {}
}
export class ActionPreferencesUpdateOpenedMenuSection implements Action { export class ActionPreferencesUpdateOpenedMenuSection implements Action {
readonly type = AuthActionTypes.UPDATE_OPENED_MENU_SECTION; readonly type = AuthActionTypes.UPDATE_OPENED_MENU_SECTION;
@ -93,4 +100,4 @@ export class ActionPreferencesDeleteUserSettings implements Action {
export type AuthActions = ActionAuthAuthenticated | ActionAuthUnauthenticated | export type AuthActions = ActionAuthAuthenticated | ActionAuthUnauthenticated |
ActionAuthLoadUser | ActionAuthUpdateUserDetails | ActionAuthUpdateLastPublicDashboardId | ActionAuthUpdateHasRepository | ActionAuthLoadUser | ActionAuthUpdateUserDetails | ActionAuthUpdateLastPublicDashboardId | ActionAuthUpdateHasRepository |
ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings | ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings |
ActionAuthUpdateAuthUser; ActionAuthUpdateAuthUser | ActionUpdateMobileQrCodeEnabled;

3
ui-ngx/src/app/core/auth/auth.reducer.ts

@ -70,6 +70,9 @@ export const authReducer = (
case AuthActionTypes.UPDATE_HAS_REPOSITORY: case AuthActionTypes.UPDATE_HAS_REPOSITORY:
return { ...state, ...action.payload}; return { ...state, ...action.payload};
case AuthActionTypes.UPDATE_MOBILE_QR_ENABLED:
return { ...state, ...action.payload};
case AuthActionTypes.UPDATE_OPENED_MENU_SECTION: case AuthActionTypes.UPDATE_OPENED_MENU_SECTION:
const openedMenuSections = new Set(state.userSettings.openedMenuSections); const openedMenuSections = new Set(state.userSettings.openedMenuSections);
if (action.payload.opened) { if (action.payload.opened) {

2
ui-ngx/src/app/modules/home/components/widget/lib/mobile-app-qrcode-widget.component.html

@ -19,7 +19,7 @@
<div class="tb-flex row align-center shrink" <div class="tb-flex row align-center shrink"
[class.row]="mobileAppSettings?.qrCodeConfig.badgePosition === badgePosition.RIGHT" [class.row]="mobileAppSettings?.qrCodeConfig.badgePosition === badgePosition.RIGHT"
[class.row-reverse]="mobileAppSettings?.qrCodeConfig.badgePosition === badgePosition.LEFT"> [class.row-reverse]="mobileAppSettings?.qrCodeConfig.badgePosition === badgePosition.LEFT">
<canvas #canvas class="tb-qrcode"></canvas> <canvas #canvas class="tb-qrcode" (click)="navigateByDeepLink($event)"></canvas>
<div class="tb-flex column" *ngIf="mobileAppSettings?.qrCodeConfig.badgeEnabled && showBadgeContainer"> <div class="tb-flex column" *ngIf="mobileAppSettings?.qrCodeConfig.badgeEnabled && showBadgeContainer">
<img *ngIf="mobileAppSettings.iosConfig.enabled" src="assets/android-ios-stores-badges/ios_store_en_black_badge.svg"> <img *ngIf="mobileAppSettings.iosConfig.enabled" src="assets/android-ios-stores-badges/ios_store_en_black_badge.svg">
<img *ngIf="mobileAppSettings.androidConfig.enabled" src="assets/android-ios-stores-badges/android_store_en_black_badge.svg"> <img *ngIf="mobileAppSettings.androidConfig.enabled" src="assets/android-ios-stores-badges/android_store_en_black_badge.svg">

11
ui-ngx/src/app/modules/home/components/widget/lib/mobile-app-qrcode-widget.component.ts

@ -58,6 +58,7 @@ export class MobileAppQrcodeWidgetComponent extends PageComponent implements OnI
showBadgeContainer = true; showBadgeContainer = true;
private mobileAppSettingsValue: MobileAppSettings | MobileAppQrCodeWidgetSettings; private mobileAppSettingsValue: MobileAppSettings | MobileAppQrCodeWidgetSettings;
private deepLink: string;
private deepLinkTTL: number; private deepLinkTTL: number;
private deepLinkTTLTimeoutID: NodeJS.Timeout; private deepLinkTTLTimeoutID: NodeJS.Timeout;
@ -101,12 +102,22 @@ export class MobileAppQrcodeWidgetComponent extends PageComponent implements OnI
clearTimeout(this.deepLinkTTLTimeoutID); clearTimeout(this.deepLinkTTLTimeoutID);
} }
navigateByDeepLink($event) {
if ($event) {
$event.stopPropagation();
}
if (this.ctx.isMobile) {
window.open(this.deepLink, '_blank');
}
}
private initMobileAppQRCode() { private initMobileAppQRCode() {
if (this.deepLinkTTLTimeoutID) { if (this.deepLinkTTLTimeoutID) {
clearTimeout(this.deepLinkTTLTimeoutID); clearTimeout(this.deepLinkTTLTimeoutID);
this.deepLinkTTLTimeoutID = null; this.deepLinkTTLTimeoutID = null;
} }
this.mobileAppService.getMobileAppDeepLink().subscribe(link => { this.mobileAppService.getMobileAppDeepLink().subscribe(link => {
this.deepLink = link;
this.deepLinkTTL = Number(this.utilsService.getQueryParam('ttl', link)) * MINUTE; this.deepLinkTTL = Number(this.utilsService.getQueryParam('ttl', link)) * MINUTE;
this.updateQRCode(link); this.updateQRCode(link);
this.deepLinkTTLTimeoutID = setTimeout(() => this.initMobileAppQRCode(), this.deepLinkTTL); this.deepLinkTTLTimeoutID = setTimeout(() => this.initMobileAppQRCode(), this.deepLinkTTL);

4
ui-ngx/src/app/modules/home/pages/admin/mobile-app-settings.component.html

@ -27,7 +27,7 @@
<mat-card-content style="padding-top: 16px"> <mat-card-content style="padding-top: 16px">
<div class="tb-form-panel no-border no-padding" [formGroup]="mobileAppSettingsForm"> <div class="tb-form-panel no-border no-padding" [formGroup]="mobileAppSettingsForm">
<div class="tb-form-panel"> <div class="tb-form-panel">
<div fxLayout="row" fxLayoutAlign="space-between center"> <div class="tb-form-row column-xs no-border no-padding space-between">
<div class="tb-form-panel-title" translate>admin.mobile-app.applications</div> <div class="tb-form-panel-title" translate>admin.mobile-app.applications</div>
<tb-toggle-select formControlName="useDefaultApp"> <tb-toggle-select formControlName="useDefaultApp">
<tb-toggle-option [value]="true">{{ 'admin.mobile-app.default' | translate }}</tb-toggle-option> <tb-toggle-option [value]="true">{{ 'admin.mobile-app.default' | translate }}</tb-toggle-option>
@ -104,7 +104,7 @@
</div> </div>
</div> </div>
<div class="tb-form-panel" formGroupName="qrCodeConfig"> <div class="tb-form-panel" formGroupName="qrCodeConfig">
<div class="tb-flex row space-between align-center"> <div class="tb-form-row column-xs no-border no-padding space-between">
<div class="tb-form-panel-title" translate>admin.mobile-app.appearance-on-home-page</div> <div class="tb-form-panel-title" translate>admin.mobile-app.appearance-on-home-page</div>
<tb-toggle-select formControlName="showOnHomePage"> <tb-toggle-select formControlName="showOnHomePage">
<tb-toggle-option [value]="true">{{ 'admin.mobile-app.enabled' | translate }}</tb-toggle-option> <tb-toggle-option [value]="true">{{ 'admin.mobile-app.enabled' | translate }}</tb-toggle-option>

67
ui-ngx/src/app/modules/home/pages/admin/mobile-app-settings.component.ts

@ -27,6 +27,7 @@ import {
badgePositionTranslationsMap, badgePositionTranslationsMap,
MobileAppSettings MobileAppSettings
} from '@shared/models/mobile-app.models'; } from '@shared/models/mobile-app.models';
import { ActionUpdateMobileQrCodeEnabled } from '@core/auth/auth.actions';
@Component({ @Component({
selector: 'tb-mobile-app-settings', selector: 'tb-mobile-app-settings',
@ -77,26 +78,41 @@ export class MobileAppSettingsComponent extends PageComponent implements HasConf
).subscribe(value => { ).subscribe(value => {
this.iosEnableChanged(value); this.iosEnableChanged(value);
}); });
this.mobileAppSettingsForm.get('qrCodeConfig.showOnHomePage').valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe(value => {
if (value) {
this.mobileAppSettingsForm.get('qrCodeConfig').enable({emitEvent: false});
} else {
this.mobileAppSettingsForm.get('qrCodeConfig').disable({emitEvent: false});
this.mobileAppSettingsForm.get('qrCodeConfig.showOnHomePage').enable({emitEvent: false});
}
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').updateValueAndValidity({onlySelf: true});
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabelEnabled').updateValueAndValidity({onlySelf: true});
});
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').valueChanges.pipe( this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').valueChanges.pipe(
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe(value => { ).subscribe(value => {
if (value) { if (value) {
if (this.mobileAppSettingsForm.get('androidConfig.enabled').value || this.mobileAppSettingsForm.get('iosConfig.enabled').value) { if (this.mobileAppSettingsForm.get('androidConfig.enabled').value || this.mobileAppSettingsForm.get('iosConfig.enabled').value) {
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').enable({emitEvent: false});
this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').enable({emitEvent: false}); this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').enable({emitEvent: false});
} else {
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').disable({emitEvent: false});
this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').disable({emitEvent: false});
} }
} else { } else {
this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').disable({emitEvent: false}); this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').disable({emitEvent: false});
} }
}); });
this.mobileAppSettingsForm.get('qrCodeConfig.showOnHomePage').valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe(value => {
this.updateLabelControl(value);
});
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabelEnabled').valueChanges.pipe( this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabelEnabled').valueChanges.pipe(
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe(value => { ).subscribe(value => {
this.updateLabelControl(value); if (value && this.mobileAppSettingsForm.get('qrCodeConfig.showOnHomePage').value) {
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabel').enable({emitEvent: false});
} else {
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabel').disable({emitEvent: false});
}
}); });
} }
@ -121,7 +137,7 @@ export class MobileAppSettingsComponent extends PageComponent implements HasConf
qrCodeConfig: this.fb.group({ qrCodeConfig: this.fb.group({
showOnHomePage: [true], showOnHomePage: [true],
badgeEnabled: [true], badgeEnabled: [true],
badgePosition: [{value: BadgePosition.RIGHT, disabled: true}], badgePosition: [BadgePosition.RIGHT],
qrCodeLabelEnabled: [true], qrCodeLabelEnabled: [true],
qrCodeLabel: ['', [Validators.required, Validators.maxLength(50)]] qrCodeLabel: ['', [Validators.required, Validators.maxLength(50)]]
}) })
@ -143,7 +159,7 @@ export class MobileAppSettingsComponent extends PageComponent implements HasConf
this.mobileAppSettingsForm.get('androidConfig.appPackage').disable({emitEvent: false}); this.mobileAppSettingsForm.get('androidConfig.appPackage').disable({emitEvent: false});
this.mobileAppSettingsForm.get('androidConfig.sha256CertFingerprints').disable({emitEvent: false}); this.mobileAppSettingsForm.get('androidConfig.sha256CertFingerprints').disable({emitEvent: false});
} }
this.updateBadgeControls(value); this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').updateValueAndValidity({onlySelf: true});
} }
private iosEnableChanged(value: boolean): void { private iosEnableChanged(value: boolean): void {
@ -154,37 +170,20 @@ export class MobileAppSettingsComponent extends PageComponent implements HasConf
} else { } else {
this.mobileAppSettingsForm.get('iosConfig.appId').disable({emitEvent: false}); this.mobileAppSettingsForm.get('iosConfig.appId').disable({emitEvent: false});
} }
this.updateBadgeControls(value); this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').updateValueAndValidity({onlySelf: true});
}
private updateBadgeControls(value: boolean) {
if (this.mobileAppSettingsForm.get('qrCodeConfig.showOnHomePage').value) {
if (value) {
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').enable({emitEvent: false});
if (this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').value) {
this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').enable({emitEvent: false});
}
} else {
if (!this.mobileAppSettingsForm.get('iosConfig.enabled').value && !this.mobileAppSettingsForm.get('androidConfig.enabled').value) {
this.mobileAppSettingsForm.get('qrCodeConfig.badgeEnabled').disable({emitEvent: false});
this.mobileAppSettingsForm.get('qrCodeConfig.badgePosition').disable({emitEvent: false});
}
}
}
}
private updateLabelControl(value: boolean) {
if (value) {
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabel').enable({emitEvent: false});
} else {
this.mobileAppSettingsForm.get('qrCodeConfig.qrCodeLabel').disable({emitEvent: false});
}
} }
save(): void { save(): void {
const showOnHomePagePreviousValue = this.mobileAppSettings.qrCodeConfig.showOnHomePage;
this.mobileAppSettings = {...this.mobileAppSettings, ...this.mobileAppSettingsForm.getRawValue()}; this.mobileAppSettings = {...this.mobileAppSettings, ...this.mobileAppSettingsForm.getRawValue()};
this.mobileAppService.saveMobileAppSettings(this.mobileAppSettings) this.mobileAppService.saveMobileAppSettings(this.mobileAppSettings)
.subscribe((settings) => this.processMobileAppSettings(settings)); .subscribe((settings) => {
const showOnHomePageValue = settings.qrCodeConfig.showOnHomePage;
if (showOnHomePagePreviousValue !== showOnHomePageValue) {
this.store.dispatch(new ActionUpdateMobileQrCodeEnabled({mobileQrEnabled: showOnHomePageValue}));
}
this.processMobileAppSettings(settings);
});
} }
confirmForm(): FormGroup { confirmForm(): FormGroup {

5
ui-ngx/src/app/modules/home/pages/home-links/home-links-routing.module.ts

@ -33,6 +33,7 @@ import {
} from '@core/auth/auth.selectors'; } from '@core/auth/auth.selectors';
import { EntityKeyType } from '@shared/models/query/query.models'; import { EntityKeyType } from '@shared/models/query/query.models';
import { ResourcesService } from '@core/services/resources.service'; import { ResourcesService } from '@core/services/resources.service';
import { isDefinedAndNotNull } from '@core/utils';
const sysAdminHomePageJson = '/assets/dashboard/sys_admin_home_page.json'; const sysAdminHomePageJson = '/assets/dashboard/sys_admin_home_page.json';
const tenantAdminHomePageJson = '/assets/dashboard/tenant_admin_home_page.json'; const tenantAdminHomePageJson = '/assets/dashboard/tenant_admin_home_page.json';
@ -83,12 +84,12 @@ const applySystemParametersToHomeDashboard = (store: Store<AppState>,
} }
} }
} }
if (params.mobileQrEnabled) { if (isDefinedAndNotNull(params.mobileQrEnabled)) {
for (const widgetId of Object.keys(dashboard.configuration.widgets)) { for (const widgetId of Object.keys(dashboard.configuration.widgets)) {
if (dashboard.configuration.widgets[widgetId].config.title === 'Select show mobile QR code') { if (dashboard.configuration.widgets[widgetId].config.title === 'Select show mobile QR code') {
dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction = dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction =
(dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction as string) (dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction as string)
.replace('\'${mobileQrEnabled}\'', String(true)); .replace(/\${mobileQrEnabled:([^}]+)}/, `\${mobileQrEnabled:${String(params.mobileQrEnabled)}}`);
break; break;
} }
} }

2
ui-ngx/src/assets/dashboard/sys_admin_home_page.json

@ -2670,7 +2670,7 @@
"settings": { "settings": {
"useMarkdownTextFunction": true, "useMarkdownTextFunction": true,
"markdownTextPattern": "### Markdown/HTML card\n - **Current entity**: ${entityName}.\n - **Current value**: ${Random}.", "markdownTextPattern": "### Markdown/HTML card\n - **Current entity**: ${entityName}.\n - **Current value**: ${Random}.",
"markdownTextFunction": "let html = '<div style=\"width: 100%; height: 100%;\">';\nlet supportMobile = '${mobileQrEnabled}' || false;\nif (supportMobile && typeof supportMobile === 'boolean') {\n ctx.dashboardWidget.widgetLayout.mobileHide = false;\n html += '<tb-dashboard-state stateId=\"mobile_app_qr_code\" [ctx]=\"ctx\"></tb-dashboard-state>';\n} else {\n ctx.dashboardWidget.widgetLayout.mobileHide = true;\n html += '<tb-getting-started-widget style=\"padding: 16px;\"></tb-getting-started-widget>';\n}\nhtml += '</div>';\nreturn html;", "markdownTextFunction": "let html = '<div style=\"width: 100%; height: 100%;\">';\nlet supportMobile = '${mobileQrEnabled:valuePlaceholder}';\nlet supportMobileValue = supportMobile.match(/\\${mobileQrEnabled:([^}]+)}/)[1];\nif (supportMobileValue === 'true') {\n ctx.dashboardWidget.widgetLayout.mobileHide = false;\n html += '<tb-dashboard-state stateId=\"mobile_app_qr_code\" [ctx]=\"ctx\"></tb-dashboard-state>';\n} else {\n ctx.dashboardWidget.widgetLayout.mobileHide = true;\n html += '<tb-getting-started-widget style=\"padding: 16px;\"></tb-getting-started-widget>';\n}\nhtml += '</div>';\nreturn html;",
"applyDefaultMarkdownStyle": false, "applyDefaultMarkdownStyle": false,
"markdownCss": "" "markdownCss": ""
}, },

2
ui-ngx/src/assets/dashboard/tenant_admin_home_page.json

@ -1125,7 +1125,7 @@
"settings": { "settings": {
"useMarkdownTextFunction": true, "useMarkdownTextFunction": true,
"markdownTextPattern": "### Markdown/HTML card\n - **Current entity**: ${entityName}.\n - **Current value**: ${Random}.", "markdownTextPattern": "### Markdown/HTML card\n - **Current entity**: ${entityName}.\n - **Current value**: ${Random}.",
"markdownTextFunction": "let html = '<div style=\"width: 100%; height: 100%;\">';\nlet supportMobile = '${mobileQrEnabled}' || false;\nif (supportMobile && typeof supportMobile === 'boolean') {\n ctx.dashboardWidget.widgetLayout.mobileHide = false;\n html += '<tb-dashboard-state stateId=\"mobile_app_qr_code\" [ctx]=\"ctx\"></tb-dashboard-state>';\n} else {\n ctx.dashboardWidget.widgetLayout.mobileHide = true;\n html += '<tb-getting-started-widget style=\"padding: 16px;\"></tb-getting-started-widget>';\n}\nhtml += '</div>';\nreturn html;", "markdownTextFunction": "let html = '<div style=\"width: 100%; height: 100%;\">';\nlet supportMobile = '${mobileQrEnabled:valuePlaceholder}';\nlet supportMobileValue = supportMobile.match(/\\${mobileQrEnabled:([^}]+)}/)[1];\nif (supportMobileValue === 'true') {\n ctx.dashboardWidget.widgetLayout.mobileHide = false;\n html += '<tb-dashboard-state stateId=\"mobile_app_qr_code\" [ctx]=\"ctx\"></tb-dashboard-state>';\n} else {\n ctx.dashboardWidget.widgetLayout.mobileHide = true;\n html += '<tb-getting-started-widget style=\"padding: 16px;\"></tb-getting-started-widget>';\n}\nhtml += '</div>';\nreturn html;",
"applyDefaultMarkdownStyle": false, "applyDefaultMarkdownStyle": false,
"markdownCss": "" "markdownCss": ""
}, },

Loading…
Cancel
Save