From ec5392a66507683eb4cdaa8778ae59cf769a3002 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 16 Nov 2026 15:15:30 +0200 Subject: [PATCH] feat: AI assistant label, action details and review fields for the two-factor settings tool, a welcome example on the two-factor authentication page, and the page reloads when the assistant saves the settings --- .../core/services/ai-assistant-panel.service.ts | 2 +- .../components/ai/ai-action-detail.models.ts | 4 ++++ .../home/components/ai/ai-action.models.ts | 2 ++ .../components/ai/ai-approval-card.component.ts | 2 +- .../home/components/ai/ai-chat.component.ts | 3 +++ .../home/components/ai/ai-welcome.models.ts | 2 +- .../admin/two-factor-auth-settings.component.ts | 13 ++++++++++++- .../assets/locale/locale.constant-en_US.json | 17 +++++++++++++++++ 8 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/core/services/ai-assistant-panel.service.ts b/ui-ngx/src/app/core/services/ai-assistant-panel.service.ts index 4f19f649b9..8a366fe0b7 100644 --- a/ui-ngx/src/app/core/services/ai-assistant-panel.service.ts +++ b/ui-ngx/src/app/core/services/ai-assistant-panel.service.ts @@ -20,7 +20,7 @@ import { AppState } from '@core/core.state'; import { selectAuthUser } from '@core/auth/auth.selectors'; export interface AiCustomizationSaved { - kind: 'MAIL_TEMPLATES' | 'TRANSLATION' | 'MENU' | 'MOBILE_QR_CODE'; + kind: 'MAIL_TEMPLATES' | 'TRANSLATION' | 'MENU' | 'MOBILE_QR_CODE' | 'TWO_FACTOR'; locale?: string; menuId?: string; deleted?: boolean; diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts index 731ce0fe3d..82b02101eb 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts @@ -1339,6 +1339,10 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail } return {hood: text('read-scheduler-event', {name: str(result.name) ?? '—'}), blocks: json('event', result)}; } + case 'save_two_factor_settings': { + const rows = facts(values); + return {hood: text('save-two-factor-settings'), blocks: rows.length ? [{type: 'facts', rows}] : []}; + } case 'save_scheduler_event': { const rows = facts(values, ['eventId']); return {hood: str(values.eventId) ? text('save-scheduler-event') : text('create-scheduler-event', {name: str(values.name) ?? '—'}), diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts b/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts index 333908a463..44630949f9 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts @@ -82,6 +82,7 @@ const TOOL_WORDS: Record = { save_mobile_qr_code: 'save-mobile-qr-code', read_scheduler_events: 'read-scheduler-events', save_scheduler_event: 'save-scheduler-event', + save_two_factor_settings: 'save-two-factor-settings', save_custom_menu: 'save-custom-menu', save_ota_package: 'save-ota-package', assign_ota_package: 'assign-ota-package', @@ -480,6 +481,7 @@ const ENTITY_KINDS: Record = { MOBILE_BUNDLE: {icon: 'phonelink_setup', palette: 'device'}, MOBILE_QR_CODE: {icon: 'qr_code_2', palette: 'device'}, SCHEDULER_EVENT: {icon: 'schedule', palette: 'rule'}, + TWO_FACTOR_SETTINGS: {icon: 'phonelink_lock', palette: 'people'}, IMAGE: {icon: 'image', palette: 'view'}, TB_RESOURCE: {icon: 'image', palette: 'view'}, CUSTOMER: {icon: 'supervisor_account', palette: 'people'}, diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts index 55db88593a..803c03f231 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts @@ -52,7 +52,7 @@ const VALUE_TOKENS: Record = { const CODE_FIELDS = new Set(['arguments', 'expression', 'output']); -const OWN_TYPE_LABELS = new Set(['DASHBOARD_WIDGET', 'DASHBOARD_STATE', 'DASHBOARD_ENTITY_ALIAS', 'DASHBOARD_FILTER', 'NOTIFICATION', 'NOTIFICATION_SETTINGS', 'NOTIFICATION_PREFERENCES', 'IMAGE', 'PLATFORM_SETTINGS', 'RELATION', 'VERSION', 'WHITE_LABELING', 'MAIL_TEMPLATE', 'CUSTOM_TRANSLATION', 'CUSTOM_MENU', 'MOBILE_APP', 'MOBILE_BUNDLE', 'MOBILE_QR_CODE']); +const OWN_TYPE_LABELS = new Set(['DASHBOARD_WIDGET', 'DASHBOARD_STATE', 'DASHBOARD_ENTITY_ALIAS', 'DASHBOARD_FILTER', 'NOTIFICATION', 'NOTIFICATION_SETTINGS', 'NOTIFICATION_PREFERENCES', 'IMAGE', 'PLATFORM_SETTINGS', 'RELATION', 'VERSION', 'WHITE_LABELING', 'MAIL_TEMPLATE', 'CUSTOM_TRANSLATION', 'CUSTOM_MENU', 'MOBILE_APP', 'MOBILE_BUNDLE', 'MOBILE_QR_CODE', 'TWO_FACTOR_SETTINGS']); const PROFILE_TYPES = new Set([EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE]); diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts index b1250d288e..f2cc83d7ff 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts @@ -1075,6 +1075,9 @@ export class AiChatComponent implements OnInit, OnDestroy { case 'save_mobile_qr_code': this.panelService.emitCustomizationSaved({kind: 'MOBILE_QR_CODE'}); break; + case 'save_two_factor_settings': + this.panelService.emitCustomizationSaved({kind: 'TWO_FACTOR'}); + break; case 'save_custom_menu': case 'delete': if (tool === 'delete' && values.targetType !== 'CUSTOM_MENU') { diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts b/ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts index 31ad100b9d..2f33ab5a63 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts @@ -81,7 +81,7 @@ const WELCOMES: Partial> = { [AiAssistantViewType.IMAGES]: {key: 'images', examples: ['icon']}, [AiAssistantViewType.JAVASCRIPT_LIBRARY]: {key: 'javascript-library', examples: ['module']}, [AiAssistantViewType.RESOURCES_LIBRARY]: {key: 'resources-library'}, - [AiAssistantViewType.TWO_FACTOR_AUTH]: {key: 'two-factor-auth', examples: ['review', 'enforce']}, + [AiAssistantViewType.TWO_FACTOR_AUTH]: {key: 'two-factor-auth', examples: ['review', 'methods', 'enforce']}, [AiAssistantViewType.OAUTH2_DOMAINS]: {key: 'oauth2-domains', examples: ['missing']}, [AiAssistantViewType.OAUTH2_CLIENTS]: {key: 'oauth2-clients', examples: ['review']}, [AiAssistantViewType.SELF_REGISTRATION]: {key: 'self-registration', examples: ['review']}, diff --git a/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts index a920170114..fd2a5bc17b 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts @@ -24,6 +24,8 @@ import { UserPermissionsService } from '@core/http/user-permissions.service'; import { NotificationTargetConfigType, NotificationTargetConfigTypeInfoMap } from '@shared/models/notification.models'; import { EntityType } from '@shared/models/entity-type.models'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { filter } from 'rxjs/operators'; +import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service'; @Component({ selector: 'tb-2fa-settings', @@ -59,12 +61,21 @@ export class TwoFactorAuthSettingsComponent extends PageComponent implements OnI private twoFaService: TwoFactorAuthenticationService, private userPermissionsService: UserPermissionsService, private fb: UntypedFormBuilder, - private destroyRef: DestroyRef) { + private destroyRef: DestroyRef, + private aiAssistantPanelService: AiAssistantPanelService) { super(store); } ngOnInit() { this.build2faSettingsForm(); + this.loadSettings(); + this.aiAssistantPanelService.customizationSaved$.pipe( + filter(event => event.kind === 'TWO_FACTOR' && !this.twoFaFormGroup.dirty), + takeUntilDestroyed(this.destroyRef) + ).subscribe(() => this.loadSettings()); + } + + private loadSettings() { this.twoFaService.getTwoFaSettings().subscribe((setting) => { this.setAuthConfigFormValue(setting); this.twoFaFormGroup.markAsUntouched(); diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index ddc1c3c9e0..dc9d09ffd8 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -917,6 +917,7 @@ "read-security-settings": "Read the security settings", "read-mobile-center": "Read the mobile center", "read-scheduler-events": "Read the scheduler", + "save-two-factor-settings": "Changed the two-factor authentication settings", "read-scheduler-event": "Read the scheduler event {{name}}", "no-scheduler-events": "No scheduler events yet.", "save-scheduler-event": "Changed the scheduler event", @@ -1414,6 +1415,10 @@ "run": "Saving the scheduler event", "done": "Saved the scheduler event" }, + "save-two-factor-settings": { + "run": "Saving the two-factor settings", + "done": "Saved the two-factor settings" + }, "save-custom-menu": { "run": "Saving the custom menu", "done": "Saved the custom menu" @@ -1822,6 +1827,16 @@ "persistent": "Persistent", "package": "Package", "enabled": "Enabled", + "methods": "Methods", + "issuerName": "Name in the app", + "smsTemplate": "SMS text", + "smsCodeLifetime": "SMS code valid, s", + "emailCodeLifetime": "Email code valid, s", + "backupCodes": "Backup codes", + "resendPeriod": "New code after, s", + "maxFailures": "Lockout after failures", + "totalTime": "Time to verify, s", + "checkRateLimit": "Code checks limit", "useSystemSettings": "System settings", "url": "URL", "tag": "Tag", @@ -1911,6 +1926,7 @@ "MOBILE_APP": "Mobile app", "MOBILE_BUNDLE": "Mobile bundle", "MOBILE_QR_CODE": "Mobile app QR code", + "TWO_FACTOR_SETTINGS": "Security settings", "RELATION": "Relations", "PLATFORM_SETTINGS": "Platform settings", "ENTITY_GROUP": "Group", @@ -2651,6 +2667,7 @@ "suggestion": "How do I require two-factor authentication for my users?", "example": { "review": {"label": "Check our 2FA", "message": "Which two-factor methods are allowed, and is it enforced for anyone?"}, + "methods": {"label": "Allow app and backup codes", "message": "Let users verify only with an authenticator app or backup codes."}, "enforce": {"label": "Require it for admins", "message": "How do I require two-factor authentication for tenant administrators?"} } },