Browse Source

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

pull/16833/head
Igor Kulikov 3 weeks ago
parent
commit
ec5392a665
  1. 2
      ui-ngx/src/app/core/services/ai-assistant-panel.service.ts
  2. 4
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  3. 2
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  4. 2
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  5. 3
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts
  6. 2
      ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts
  7. 13
      ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts
  8. 17
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
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;

4
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) ?? '—'}),

2
ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts

@ -82,6 +82,7 @@ const TOOL_WORDS: Record<string, string> = {
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<string, AiEntityKind> = {
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'},

2
ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts

@ -52,7 +52,7 @@ const VALUE_TOKENS: Record<string, string[]> = {
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<string>([EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE]);

3
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') {

2
ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts

@ -81,7 +81,7 @@ const WELCOMES: Partial<Record<AiAssistantViewType, AiWelcomeKind>> = {
[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']},

13
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();

17
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?"}
}
},

Loading…
Cancel
Save