Browse Source

feat: AI assistant labels, action details and review fields for the scheduler tools, welcome examples on the Scheduler page, and the Scheduler page reloads when the assistant changes an event; long values in approval reviews wrap instead of running off the card

pull/16833/head
Igor Kulikov 3 weeks ago
parent
commit
cb5ca777a4
  1. 17
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  2. 6
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  3. 2
      ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts
  4. 10
      ui-ngx/src/app/modules/home/components/scheduler/scheduler-events.component.ts
  5. 35
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  6. 7
      ui-ngx/src/theme/ai-theme.scss

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

@ -1327,6 +1327,23 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
}
return {hood: str(values.bundleId) ? text('save-mobile-bundle') : text('create-mobile-bundle', {name: str(values.title) ?? '—'}), blocks};
}
case 'read_scheduler_events': {
if (!isObject(result)) {
return {hood: text('read-scheduler-events'), blocks: generic(result, 'result')};
}
if (Array.isArray(result.events)) {
const rows = result.events.filter(isObject).slice(0, MAX_ROWS)
.map(event => [event.name, event.schedule, event.enabled === false ? '⏸' : undefined].filter(Boolean).join(' · '));
return {hood: text('read-scheduler-events'),
blocks: rows.length ? [{type: 'list', rows}] : [{type: 'note', text: text('no-scheduler-events')}]};
}
return {hood: text('read-scheduler-event', {name: str(result.name) ?? '—'}), blocks: json('event', result)};
}
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) ?? '—'}),
blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'save_mobile_qr_code': {
const rows = facts(values);
return {hood: text('save-mobile-qr-code'), blocks: rows.length ? [{type: 'facts', rows}] : []};

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

@ -80,6 +80,8 @@ const TOOL_WORDS: Record<string, string> = {
save_mobile_app: 'save-mobile-app',
save_mobile_bundle: 'save-mobile-bundle',
save_mobile_qr_code: 'save-mobile-qr-code',
read_scheduler_events: 'read-scheduler-events',
save_scheduler_event: 'save-scheduler-event',
save_custom_menu: 'save-custom-menu',
save_ota_package: 'save-ota-package',
assign_ota_package: 'assign-ota-package',
@ -158,7 +160,8 @@ const DELETED_TARGETS: Record<string, string> = {
RESOURCE: 'delete-resource',
CUSTOM_MENU: 'delete-custom-menu',
MOBILE_APP: 'delete-mobile-app',
MOBILE_BUNDLE: 'delete-mobile-bundle'
MOBILE_BUNDLE: 'delete-mobile-bundle',
SCHEDULER_EVENT: 'delete-scheduler-event'
};
const ACTION_PREFIX = 'ai-assistant.action.';
@ -476,6 +479,7 @@ const ENTITY_KINDS: Record<string, AiEntityKind> = {
MOBILE_APP: {icon: 'smartphone', palette: 'device'},
MOBILE_BUNDLE: {icon: 'phonelink_setup', palette: 'device'},
MOBILE_QR_CODE: {icon: 'qr_code_2', palette: 'device'},
SCHEDULER_EVENT: {icon: 'schedule', palette: 'rule'},
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-welcome.models.ts

@ -89,7 +89,7 @@ const WELCOMES: Partial<Record<AiAssistantViewType, AiWelcomeKind>> = {
[AiAssistantViewType.AUDIT_LOGS]: {key: 'audit-logs', examples: ['changes', 'logins']},
[AiAssistantViewType.VERSION_CONTROL]: {key: 'version-control', examples: ['save', 'history']},
[AiAssistantViewType.TASK_MANAGER]: {key: 'task-manager', examples: ['failed']},
[AiAssistantViewType.SCHEDULER]: {key: 'scheduler'},
[AiAssistantViewType.SCHEDULER]: {key: 'scheduler', examples: ['night', 'week']},
[AiAssistantViewType.HOME_SETTINGS]: {key: 'home-settings', examples: ['set']},
[AiAssistantViewType.MAIL_SERVER_SETTINGS]: {key: 'mail-server-settings', examples: ['setup']},
[AiAssistantViewType.NOTIFICATION_SETTINGS]: {key: 'notification-settings', examples: ['slack', 'sms']},

10
ui-ngx/src/app/modules/home/components/scheduler/scheduler-events.component.ts

@ -88,6 +88,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { DomSanitizer } from "@angular/platform-browser";
import { TbAnchorComponent } from '@shared/components/tb-anchor.component';
import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service';
@Component({
selector: 'tb-scheduler-events',
@ -181,9 +182,14 @@ export class SchedulerEventsComponent extends PageComponent implements OnInit, A
private popoverService: TbPopoverService,
private viewContainerRef: ViewContainerRef,
private destroyRef: DestroyRef,
private sanitizer: DomSanitizer
private sanitizer: DomSanitizer,
private aiAssistantPanelService: AiAssistantPanelService
) {
super();
this.aiAssistantPanelService.updatedData$.pipe(
filter(entities => entities.some(entityId => entityId.entityType === EntityType.SCHEDULER_EVENT)),
takeUntilDestroyed()
).subscribe(() => this.reloadSchedulerEvents());
}
ngOnInit(): void {
@ -406,7 +412,7 @@ export class SchedulerEventsComponent extends PageComponent implements OnInit, A
reloadSchedulerEvents(): void {
if (this.mode === 'calendar') {
this.calendarApi.refetchEvents();
this.calendarApi?.refetchEvents();
} else {
this.updateData();
}

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

@ -916,6 +916,11 @@
"read-custom-menus": "Read the custom menus",
"read-security-settings": "Read the security settings",
"read-mobile-center": "Read the mobile center",
"read-scheduler-events": "Read the scheduler",
"read-scheduler-event": "Read the scheduler event {{name}}",
"no-scheduler-events": "No scheduler events yet.",
"save-scheduler-event": "Changed the scheduler event",
"create-scheduler-event": "Created the scheduler event {{name}}",
"mobile-apps": "Apps",
"no-mobile-apps": "No mobile apps yet.",
"no-mobile-bundles": "No mobile bundles yet, so the apps show the standard menu.",
@ -1401,6 +1406,14 @@
"run": "Saving the QR code",
"done": "Saved the QR code"
},
"read-scheduler-events": {
"run": "Reading the scheduler",
"done": "Read the scheduler"
},
"save-scheduler-event": {
"run": "Saving the scheduler event",
"done": "Saved the scheduler event"
},
"save-custom-menu": {
"run": "Saving the custom menu",
"done": "Saved the custom menu"
@ -1425,6 +1438,10 @@
"run": "Deleting the mobile bundle",
"done": "Deleted the mobile bundle"
},
"delete-scheduler-event": {
"run": "Deleting the scheduler event",
"done": "Deleted the scheduler event"
},
"delete-custom-menu": {
"run": "Deleting the custom menu",
"done": "Deleted the custom menu"
@ -1795,6 +1812,16 @@
"showOnHomePage": "On the home page",
"badges": "Store badges",
"badgePosition": "Badge position",
"eventType": "Event type",
"target": "Target",
"schedule": "Schedule",
"method": "RPC method",
"params": "Parameters",
"oneway": "One-way",
"timeout": "Timeout, ms",
"persistent": "Persistent",
"package": "Package",
"enabled": "Enabled",
"useSystemSettings": "System settings",
"url": "URL",
"tag": "Tag",
@ -2687,8 +2714,12 @@
},
"scheduler": {
"title": "Ask about the scheduler",
"line": "Run actions on a schedule: update attributes, send commands, generate reports.",
"suggestion": "How do I send a command to my devices every night?"
"line": "Run actions on a schedule: update attributes, send commands, roll out firmware.",
"suggestion": "How do I send a command to my devices every night?",
"example": {
"night": {"label": "Night mode on weekdays", "message": "Every weekday at 22:00, set the shared attribute mode to night on my devices."},
"week": {"label": "What runs this week?", "message": "Which scheduler events run in the next 7 days, and when?"}
}
},
"home-settings": {
"title": "Ask about the home page",

7
ui-ngx/src/theme/ai-theme.scss

@ -1297,7 +1297,14 @@
color: var(--tb-text-secondary);
}
td.k-diff-was, td.k-diff-now {
white-space: normal;
overflow-wrap: anywhere;
}
.k-diff-now span {
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
margin-left: -6px;
padding: 1px 6px;
border-radius: 4px;

Loading…
Cancel
Save