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 9dce1741d5..731ce0fe3d 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 @@ -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}] : []}; 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 10402ba903..333908a463 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 @@ -80,6 +80,8 @@ const TOOL_WORDS: Record = { 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 = { 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 = { 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'}, 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 84826cd0aa..31ad100b9d 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 @@ -89,7 +89,7 @@ const WELCOMES: Partial> = { [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']}, diff --git a/ui-ngx/src/app/modules/home/components/scheduler/scheduler-events.component.ts b/ui-ngx/src/app/modules/home/components/scheduler/scheduler-events.component.ts index 39ffeb560c..117dd2f34e 100644 --- a/ui-ngx/src/app/modules/home/components/scheduler/scheduler-events.component.ts +++ b/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(); } 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 76922406ab..ddc1c3c9e0 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/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", diff --git a/ui-ngx/src/theme/ai-theme.scss b/ui-ngx/src/theme/ai-theme.scss index e9f48c4c6d..ee0975322c 100644 --- a/ui-ngx/src/theme/ai-theme.scss +++ b/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;