Browse Source

feat: AI assistant for reporting: Configure with AI in the report template list and page with PDF/CSV badges on template cards, labels, action details and review fields for the report template, scheduled report and report tools, records linking to Reports and Scheduling, welcome examples on the Scheduling and Reports pages, generated files download on click, and the report tables reload after the assistant's changes

pull/16833/head
Igor Kulikov 3 weeks ago
parent
commit
cf19bb8bf9
  1. 2
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html
  2. 178
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  3. 5
      ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts
  4. 26
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  5. 2
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.html
  6. 7
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  7. 33
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts
  8. 21
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts
  9. 16
      ui-ngx/src/app/modules/home/components/ai/ai-file.models.ts
  10. 3
      ui-ngx/src/app/modules/home/components/ai/ai-record-card.component.ts
  11. 24
      ui-ngx/src/app/modules/home/components/ai/ai-record-loader.service.ts
  12. 5
      ui-ngx/src/app/modules/home/components/ai/ai-record.component.ts
  13. 1
      ui-ngx/src/app/modules/home/components/ai/ai-record.models.ts
  14. 2
      ui-ngx/src/app/modules/home/components/ai/ai-records.component.ts
  15. 4
      ui-ngx/src/app/modules/home/components/ai/ai-run-summary.component.ts
  16. 6
      ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts
  17. 81
      ui-ngx/src/app/modules/home/pages/reporting/template/report-template-page.component.ts
  18. 45
      ui-ngx/src/app/modules/home/pages/reporting/template/report-templates-table-config.resolver.ts
  19. 7
      ui-ngx/src/app/shared/models/ai-chat.models.ts
  20. 248
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  21. 67
      ui-ngx/src/theme/ai-theme.scss

2
ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html

@ -12,7 +12,7 @@
@case ('hub') {
<div class="k-detail-recs k-detail-hub tb-list-body" role="list">
@for (rec of shown(hub(), 'hub'); track rec.key) {
<tb-ai-record role="listitem" [entityType]="rec.entityType" [alarmRule]="rec.alarmRule" [name]="rec.name" [url]="rec.url"
<tb-ai-record role="listitem" [entityType]="rec.entityType" [alarmRule]="rec.alarmRule" [name]="rec.name" [badge]="rec.badge" [url]="rec.url"
[hub]="rec.hub"></tb-ai-record>
}
@if (hub().length > LIST_SHOWN) {

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

@ -545,6 +545,78 @@ function aliasFilter(filter: unknown, names: AiDetailNames): AiDetailFact[] {
return rows;
}
function reportTemplateOverview(result: Values): AiDetailBlock[] {
const blocks: AiDetailBlock[] = [];
const settings = isObject(result.settings) ? result.settings : {};
const page = isObject(settings.page) ? settings.page : null;
const rows: AiDetailFact[] = [{label: K + 'fact.format', value: [str(result.format), result.templateType === 'SUB_REPORT' ? text('sub-report') : null].filter(Boolean).join(' · ')}];
if (page) {
rows.push({label: K + 'fact.page', value: [page.size, aiHumanize(String(page.orientation ?? ''))].filter(Boolean).join(' · ')});
}
if (str(settings.fileName)) {
rows.push({label: K + 'fact.file-name', value: settings.fileName, mono: true});
}
const sections = ['header', 'footer'].filter(section => isObject(settings[section]) && settings[section].enabled);
if (page) {
rows.push({label: K + 'fact.header-footer', value: sections.length ? sections.map(section => aiHumanize(section)).join(', ') : '—'});
}
blocks.push({type: 'facts', rows});
const components = isObject(result.components) ? Object.entries(result.components) : [];
blocks.push({
type: 'list', label: text('report-components'),
rows: components.length ? components.slice(0, MAX_ROWS).map(([path, line]) => {
const item = isObject(line) ? line : {};
return [path, aiHumanize(String(item.type ?? '')), str(item.is), str(item.alias)].filter(Boolean).join(' · ');
}) : ['—']
});
const aliases = (Array.isArray(result.entityAliases) ? result.entityAliases : []).filter(isObject);
if (aliases.length) {
blocks.push({type: 'list', label: text('aliases'), rows: aliases.map(alias => [str(alias.name) ?? alias.id, alias.filter?.type ? aiHumanize(alias.filter.type) : null].filter(Boolean).join(' · '))});
}
const filters = (Array.isArray(result.filters) ? result.filters : []).filter(isObject);
if (filters.length) {
blocks.push({type: 'list', label: text('filters'), rows: filters.map(item => String(item.name ?? item.id))});
}
const problems = (Array.isArray(result.problems) ? result.problems : []).map(String);
if (problems.length) {
blocks.push({type: 'list', label: text('report-problems'), rows: problems});
}
return blocks;
}
function reportComponentFacts(component: Values): AiDetailFact[] {
const rows: AiDetailFact[] = [{label: K + 'fact.component', value: aiHumanize(String(component.type ?? ''))}];
rows.push({label: K + 'fact.path', value: String(component.path ?? '—'), mono: true});
const config = isObject(component.config) ? component.config : {};
const title = str(config.title) ?? str(config.text);
if (title) {
rows.push({label: K + 'fact.title', value: title});
}
if (str(component.entityAlias) || str(component.entityAliasId)) {
rows.push(str(component.entityAlias) ? {label: K + 'fact.alias', value: component.entityAlias}
: {label: K + 'fact.alias', value: component.entityAliasId, mono: true});
}
const entries = [config.keys, config.columns, config.series, config.latestColumns].filter(Array.isArray).flat();
const keys = entries.map((item: any) => typeof item === 'string' ? item : item?.key).filter(Boolean);
if (str(config.key)) {
keys.push(config.key);
}
if (keys.length) {
rows.push({label: K + 'fact.keys', value: [...new Set(keys)].join(', '), mono: true});
}
const history = isObject(config.timewindow) && isObject(config.timewindow.history) ? config.timewindow.history : null;
if (history) {
const window = history.interval ?? history.last ?? (isObject(history.range) ? `${history.range.from} – ${history.range.to}` : null);
const aggregation = isObject(config.timewindow.aggregation) && config.timewindow.aggregation.type && config.timewindow.aggregation.type !== 'NONE'
? `${config.timewindow.aggregation.type}${config.timewindow.aggregation.grouping ? ' per ' + config.timewindow.aggregation.grouping : ''}` : null;
rows.push({label: K + 'fact.time-window', value: [window ? aiHumanize(String(window)) : null, aggregation].filter(Boolean).join(' · ')});
}
if (typeof config.height === 'number') {
rows.push({label: K + 'fact.height', value: `${config.height} px`});
}
return rows;
}
function widgetFacts(widget: Values, names: AiDetailNames): AiDetailFact[] {
const rows: AiDetailFact[] = [];
if (str(widget.title)) {
@ -1304,7 +1376,7 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
blocks.push({type: 'list', label: text('mobile-bundle-menu', {name: str(bundle.title) ?? '—'}), rows: pages});
}
if (isObject(result.qrCode)) {
blocks.push(...json('QR code', result.qrCode));
blocks.push(...json('qr-code', result.qrCode));
}
return {hood: text('read-mobile-center'), blocks};
}
@ -1340,7 +1412,7 @@ 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 'read_mail_server':
return {hood: text('read-mail-server'), blocks: json('mail server', result)};
return {hood: text('read-mail-server'), blocks: json('mail-server', result)};
case 'save_mail_server': {
const rows = facts(values);
return {hood: text('save-mail-server'), blocks: rows.length ? [{type: 'facts', rows}] : []};
@ -1367,6 +1439,108 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
const rows = facts(values);
return {hood: text('save-two-factor-settings'), blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'create_report_template':
case 'update_report_template': {
const rows = facts(values, ['templateId']);
return {hood: tool === 'create_report_template' ? text('create-report-template', {name: str(values.name) ?? '—'}) : text('update-report-template'),
blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'read_report_template': {
if (!isObject(result)) {
return {hood: text(str(values.path) ? 'read-report-component' : 'read-report-template', {path: str(values.path) ?? '—', name: '—'}), blocks: generic(result, 'result')};
}
if (str(values.path)) {
return {hood: text('read-report-component', {path: str(result.path) ?? str(values.path), name: str(result.template) ?? '—'}),
blocks: [{type: 'facts', rows: reportComponentFacts(result)}]};
}
return {hood: text('read-report-template', {name: str(result.name) ?? '—'}), blocks: reportTemplateOverview(result)};
}
case 'add_report_components': {
const rows = (Array.isArray(values.components) ? values.components.filter(isObject) : []).slice(0, MAX_ROWS).map(component => {
const config = isObject(component.config) ? component.config : {};
const title = str(config.title) ?? str(config.text);
return [str(component.in), aiHumanize(String(component.type)), title].filter(Boolean).join(' · ');
});
return {hood: text('add-report-components'), blocks: rows.length ? [{type: 'list', rows}] : []};
}
case 'update_report_component': {
const rows = facts(isObject(values.config) ? values.config as Values : {});
return {hood: text('update-report-component', {path: str(values.path) ?? '—'}), blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'move_report_component':
return {hood: text('move-report-component', {path: str(values.path) ?? '—', target: str(values.in) ?? '—'}), blocks: []};
case 'save_report_entity_alias':
case 'save_report_filter': {
const rows = facts(values, ['templateId', 'aliasId', 'filterId']);
return {hood: text(tool === 'save_report_filter' ? 'save-report-filter' : 'save-report-alias', {name: str(values.name) ?? '—'}),
blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'test_report_template': {
if (!isObject(result)) {
return {hood: text('test-report-template'), blocks: generic(result, 'result')};
}
const errors = (Array.isArray(result.errors) ? result.errors.filter(isObject) : [])
.map(error => [error.page !== undefined ? `p. ${error.page}` : error.row !== undefined ? `row ${error.row}` : undefined, str(error.message)]
.filter(Boolean).join(' · '));
const pdf = result.pages !== undefined;
const count = Number(pdf ? result.pages : result.rows ?? 0);
const size = text((pdf ? 'report-pages' : 'report-rows') + (errors.length ? '' : '-clean'), {count});
return {hood: text('test-report-template'),
blocks: [{type: 'note', text: size},
...(errors.length ? [{type: 'list' as const, label: text('report-errors'), rows: errors.slice(0, MAX_ROWS)}] : [])]};
}
case 'read_reports': {
if (!isObject(result)) {
return {hood: text('read-reports'), blocks: generic(result, 'result')};
}
if (Array.isArray(result.templates)) {
const rows = result.templates.filter(isObject).slice(0, MAX_ROWS)
.map(item => [item.name, item.format, item.templateType === 'SUB_REPORT' ? 'Sub-report' : undefined].filter(Boolean).join(' · '));
return {hood: text('read-report-templates'),
blocks: rows.length ? [{type: 'list', rows}] : [{type: 'note', text: text('no-report-templates')}]};
}
if (Array.isArray(result.scheduledReports)) {
const rows = result.scheduledReports.filter(isObject).slice(0, MAX_ROWS)
.map(item => [item.name, item.template, item.schedule, item.enabled === false ? '⏸' : undefined].filter(Boolean).join(' · '));
return {hood: text('read-scheduled-reports'),
blocks: rows.length ? [{type: 'list', rows}] : [{type: 'note', text: text('no-scheduled-reports')}]};
}
if (Array.isArray(result.reports)) {
const rows = result.reports.filter(isObject).slice(0, MAX_ROWS)
.map(item => [item.file, item.template, item.generated].filter(Boolean).join(' · '));
return {hood: text('read-generated-reports'),
blocks: rows.length ? [{type: 'list', rows}] : [{type: 'note', text: text('no-generated-reports')}]};
}
if (isObject(result.file)) {
return {hood: text('attach-report', {name: str(result.file.name) ?? '—'}), blocks: []};
}
const rows = facts(result, ['eventId', 'templateId', 'rawSchedule', 'recipients', 'notificationTemplate', 'name']);
const recipients = Array.isArray(result.recipients) ? result.recipients.filter(isObject).map(item => str(item.name)).filter(Boolean) : [];
if (recipients.length) {
rows.push({label: aiHumanize('recipients'), raw: true, value: recipients.join(', ')});
}
return {hood: text('read-scheduled-report', {name: str(result.name) ?? '—'}), blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'save_scheduled_report': {
const rows = facts(values, ['eventId', 'templateId', 'userId', 'recipientIds', 'notificationTemplateId']);
return {hood: str(values.eventId) ? text('save-scheduled-report') : text('create-scheduled-report', {name: str(values.name) ?? '—'}),
blocks: rows.length ? [{type: 'facts', rows}] : []};
}
case 'generate_report': {
const raw = typeof result === 'string' && /^OK: [^\n]*\n/.test(result) ? aiParse(result.slice(result.indexOf('\n') + 1)) : result;
if (!isObject(raw)) {
return {hood: text('generate-report'), blocks: generic(raw, 'result')};
}
const name = isObject(raw.file) ? str(raw.file.name) : str(raw.file);
const rows: AiDetailFact[] = [];
if (name) {
rows.push({label: aiHumanize('file'), raw: true, value: name});
}
if (str(raw.sentTo)) {
rows.push({label: aiHumanize('sent to'), raw: true, value: str(raw.sentTo)});
}
return {hood: text('generate-report'), blocks: rows.length ? [{type: 'facts', rows}] : [{type: 'note', text: text('report-still-running')}]};
}
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) ?? '—'}),

5
ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts

@ -75,16 +75,17 @@ export class AiActionLineComponent {
? affected.find(item => item.entityType === EntityType.ENTITY_GROUP) ?? affected[0]
: affected[0];
const text = this.outcome();
const match = entity && this.action().status === 'SUCCESS' ? /'([^']{1,120})'/.exec(text) : null;
const match = entity && this.action().status === 'SUCCESS' ? /(?:^|\s)'(.{1,120}?)'(?=$|[\s.,:;!?)])/.exec(text) : null;
if (!match) {
return null;
}
const start = match.index + match[0].indexOf('\'');
const alarmRule = entity.entityType === EntityType.CALCULATED_FIELD && this.isAlarmRule();
const kind = aiEntityKind(entity.entityType, alarmRule);
const base = alarmRule ? '/alarms/alarm-rules' : baseDetailsPageByEntityType.get(entity.entityType as EntityType);
const groupUrl = entity.entityType === EntityType.ENTITY_GROUP ? this.groupView()?.url : undefined;
return {
before: text.slice(0, match.index),
before: text.slice(0, start),
name: match[1],
after: text.slice(match.index + match[0].length),
icon: kind.icon,

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

@ -82,6 +82,17 @@ 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',
create_report_template: 'create-report-template',
update_report_template: 'update-report-template',
add_report_components: 'add-report-components',
update_report_component: 'update-report-component',
move_report_component: 'move-report-component',
save_report_entity_alias: 'save-report-alias',
save_report_filter: 'save-report-filter',
test_report_template: 'test-report-template',
read_reports: 'read-reports',
save_scheduled_report: 'save-scheduled-report',
generate_report: 'generate-report',
save_two_factor_settings: 'save-two-factor-settings',
save_oauth2_domain: 'save-oauth2-domain',
read_my_account: 'read-my-account',
@ -169,7 +180,12 @@ const DELETED_TARGETS: Record<string, string> = {
CUSTOM_MENU: 'delete-custom-menu',
MOBILE_APP: 'delete-mobile-app',
MOBILE_BUNDLE: 'delete-mobile-bundle',
SCHEDULER_EVENT: 'delete-scheduler-event'
SCHEDULER_EVENT: 'delete-scheduler-event',
REPORT_TEMPLATE: 'delete-report-template',
REPORT_COMPONENT: 'delete-report-component',
REPORT_ENTITY_ALIAS: 'delete-report-alias',
REPORT_FILTER: 'delete-report-filter',
REPORT: 'delete-report'
};
const ACTION_PREFIX = 'ai-assistant.action.';
@ -346,6 +362,8 @@ export function aiActionWords(tool: string, args: unknown): AiActionWords {
switch (tool) {
case 'add_dashboard_widgets':
return {key: ACTION_PREFIX + (Array.isArray(values.widgets) && values.widgets.length === 1 ? 'add-widget' : 'add-widgets'), kind: 'think'};
case 'read_report_template':
return {key: ACTION_PREFIX + (typeof values.path === 'string' && values.path ? 'read-report-component' : 'read-report-template'), kind: 'think'};
case 'search_entities':
return {key: ACTION_PREFIX + searchedWords(values), kind: 'think'};
case 'update_alarms':
@ -488,6 +506,12 @@ 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'},
REPORT_TEMPLATE: {icon: 'description', palette: 'view'},
REPORT_COMPONENT: {icon: 'view_agenda', palette: 'view'},
REPORT_ENTITY_ALIAS: {icon: 'label', palette: 'view'},
REPORT_FILTER: {icon: 'filter_list', palette: 'view'},
SCHEDULED_REPORT: {icon: 'event_repeat', palette: 'rule'},
REPORT: {icon: 'summarize', palette: 'view'},
TWO_FACTOR_SETTINGS: {icon: 'phonelink_lock', palette: 'people'},
DOMAIN: {icon: 'language', palette: 'people'},
MY_PROFILE: {icon: 'account_circle', palette: 'people'},

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

@ -35,7 +35,7 @@
</dl>
}
@if (changes.length) {
<table class="k-diff">
<table class="k-diff" [class.k-diff-stacked]="stackedDiff">
<thead>
<tr>
<td></td>

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

@ -52,7 +52,8 @@ 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', 'TWO_FACTOR_SETTINGS', 'MY_PROFILE', 'MY_TWO_FACTOR', 'MAIL_SERVER']);
const STACK_AT = 24;
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', 'MY_PROFILE', 'MY_TWO_FACTOR', 'MAIL_SERVER', 'REPORT_COMPONENT', 'REPORT_ENTITY_ALIAS', 'REPORT_FILTER', 'SCHEDULED_REPORT']);
const PROFILE_TYPES = new Set<string>([EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE]);
@ -234,6 +235,10 @@ export class AiApprovalCardComponent implements OnChanges {
];
}
get stackedDiff(): boolean {
return this.changes.some(change => (change.current?.length ?? 0) > STACK_AT || (change.value?.length ?? 0) > STACK_AT);
}
get changes(): AiReviewRow[] {
return this.rows('CHANGE');
}

33
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts

@ -37,7 +37,7 @@ import { AiPlanRun } from '@home/components/ai/ai-plan.component';
import { aiRecordKey, AiShownRecords, aiShownRecordsOf, SHOW_RECORDS_TOOL } from '@home/components/ai/ai-record.models';
import { AiCardAction } from '@home/components/ai/ai-card-actions.component';
import { decorateSections } from '@home/components/ai/ai-disclosure.component';
import { AiFile, aiFileMark, aiFileName, aiFileOf, AiMadeFile, aiMadeFileOf, CREATE_FILE_TOOL, WRITE_FILE_TOOL } from '@home/components/ai/ai-file.models';
import { AiFile, aiFileMark, aiFileName, aiFileOf, AiMadeFile, aiMadeFileOf, FILE_MAKING_TOOLS, WRITE_FILE_TOOL } from '@home/components/ai/ai-file.models';
import { MatDialog } from '@angular/material/dialog';
import { AiResourceService } from '@core/http/ai-resource.service';
import {
@ -133,6 +133,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
streaming = false;
files: Record<number, AiFile> = {};
madeFiles: Record<number, AiMadeFile> = {};
private handledMadeFiles = new Set<string>();
quotes: Record<number, {name: string; icon: string; from: number; to: number; message: string}> = {};
sources: Record<number, AiSource[]> = {};
@ -183,26 +184,23 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
maxWidth: '92vw',
data: {resource: file.resource}
});
} else if (file.preview === 'pdf') {
const tab = window.open('', '_blank');
this.aiResourceService.getUrl(file.resource.id).subscribe({
next: url => {
if (tab) {
tab.location.href = url;
} else {
window.open(url, '_blank');
}
},
error: error => {
tab?.close();
this.resourceError.emit(error);
}
});
} else {
this.downloadMadeFile(file);
}
}
private downloadRequestedFiles(): void {
for (const file of Object.values(this.madeFiles)) {
if (this.handledMadeFiles.has(file.executionId)) {
continue;
}
this.handledMadeFiles.add(file.executionId);
if (file.download && this.loading) {
this.downloadMadeFile(file);
}
}
}
downloadMadeFile(file: AiMadeFile): void {
this.aiResourceService.download(file.resource).subscribe({
error: error => this.resourceError.emit(error)
@ -400,6 +398,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
this.files = this.findFiles();
this.latestFiles = new Map(Object.values(this.files).map(file => [file.name, file]));
this.madeFiles = this.findMadeFiles();
this.downloadRequestedFiles();
this.quotes = this.findQuotes();
this.sources = this.findSources();
this.records = this.findRecords();
@ -780,7 +779,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
private findMadeFiles(): Record<number, AiMadeFile> {
const files: Record<number, AiMadeFile> = {};
this.messages.forEach((message, index) => {
if (message.from === 'ACTION' && message.data.tool === CREATE_FILE_TOOL && message.data.status === 'SUCCESS') {
if (message.from === 'ACTION' && FILE_MAKING_TOOLS.has(message.data.tool) && message.data.status === 'SUCCESS') {
const file = aiMadeFileOf(message.data.executionId, message.data.result);
if (file) {
files[index] = file;

21
ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts

@ -69,11 +69,14 @@ import { ClipboardService } from 'ngx-clipboard';
import { AnswerRatingEvent, AnswerReportEvent } from '@home/components/ai/ai-chat-messages.component';
import { EntityId } from '@shared/models/id/entity-id';
import { EntityType } from '@shared/models/entity-type.models';
import { AiAssistantViewType } from '@shared/models/ai-chat.models';
import { AiChatTitleComponent } from '@home/components/ai/ai-chat-title.component';
import { AiPromptInputComponent } from '@home/components/ai/ai-prompt-input.component';
export type AiChatVariant = 'page' | 'panel';
const LIVE_EDITED_TYPES = new Set<EntityType>([EntityType.DASHBOARD, EntityType.REPORT_TEMPLATE]);
@Component({
selector: 'tb-ai-chat',
templateUrl: './ai-chat.component.html',
@ -968,6 +971,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
&& message.data.executionId === event.data.executionId);
if (call?.from === 'APPROVAL' || call?.from === 'ACTION') {
this.applySideEffects(event.data.executionId, call.data.tool, call.data.arguments);
this.openCreatedReportTemplate(call.data.tool, event.data.affectedEntities);
}
}
if (event.data.affectedEntities?.length) {
@ -1051,10 +1055,21 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.messages.update(list => [...list, {from: 'ACTION', data: action}]);
}
private openCreatedReportTemplate(tool: string | undefined, affected: EntityId[] | undefined): void {
const chatId = this.chatId();
const created = affected?.find(entity => entity.entityType === EntityType.REPORT_TEMPLATE);
if (tool !== 'create_report_template' || !created || !chatId
|| this.panelService.clientContext()?.view?.type !== AiAssistantViewType.REPORT_TEMPLATE_LIST) {
return;
}
this.panelService.carryChat(chatId);
this.router.navigate(['/reporting/templates', created.id]);
}
private emitDashboards(entities: EntityId[]): void {
const dashboards = entities.filter(entity => entity.entityType === EntityType.DASHBOARD);
if (dashboards.length) {
this.panelService.emitUpdatedData(dashboards);
const edited = entities.filter(entity => LIVE_EDITED_TYPES.has(entity.entityType as EntityType));
if (edited.length) {
this.panelService.emitUpdatedData(edited);
}
}

16
ui-ngx/src/app/modules/home/components/ai/ai-file.models.ts

@ -5,6 +5,7 @@ import { AiResourceInfo } from '@shared/models/ai-chat.models';
export const WRITE_FILE_TOOL = 'write_file';
export const CREATE_FILE_TOOL = 'create_file';
export const FILE_MAKING_TOOLS = new Set<string>([CREATE_FILE_TOOL, 'test_report_template', 'generate_report', 'read_reports']);
export interface AiMadeFile {
executionId: string;
@ -12,12 +13,14 @@ export interface AiMadeFile {
label: string;
icon: string;
size: string;
preview: 'image' | 'pdf' | null;
preview: 'image' | null;
download: boolean;
}
const MADE_KINDS: Record<string, {label: string; icon: string; preview: 'image' | 'pdf' | null}> = {
const MADE_KINDS: Record<string, {label: string; icon: string; preview: 'image' | null}> = {
'image/png': {label: 'PNG', icon: 'image', preview: 'image'},
'application/pdf': {label: 'PDF', icon: 'picture_as_pdf', preview: 'pdf'},
'application/pdf': {label: 'PDF', icon: 'picture_as_pdf', preview: null},
'text/csv': {label: 'CSV', icon: 'table_chart', preview: null},
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': {label: 'Word', icon: 'description', preview: null},
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {label: 'Excel', icon: 'table_chart', preview: null}
};
@ -25,13 +28,15 @@ const MADE_KINDS: Record<string, {label: string; icon: string; preview: 'image'
export function aiMadeFileOf(executionId: string, result: unknown): AiMadeFile | null {
let parsed: unknown = result;
if (typeof result === 'string') {
const text = /^OK: [^\n]*\n/.test(result) ? result.slice(result.indexOf('\n') + 1) : result;
try {
parsed = JSON.parse(result);
parsed = JSON.parse(text);
} catch {
return null;
}
}
const file = (parsed as {file?: Partial<AiResourceInfo>})?.file;
const download = (parsed as {download?: unknown})?.download === true;
if (!file || typeof file.id !== 'string' || typeof file.name !== 'string' || typeof file.mediaType !== 'string') {
return null;
}
@ -43,7 +48,8 @@ export function aiMadeFileOf(executionId: string, result: unknown): AiMadeFile |
label: kind.label,
icon: kind.icon,
size: formatSize(bytes),
preview: kind.preview
preview: kind.preview,
download
};
}

3
ui-ngx/src/app/modules/home/components/ai/ai-record-card.component.ts

@ -56,6 +56,9 @@ export function aiDashboardThumb(cards: number): string {
} @else {
<b class="tb-rec-title">{{ rec.name }}</b>
}
@if (rec.badge) {
<span class="tb-rec-badge" [attr.data-badge]="rec.badge.toLowerCase()">{{ rec.badge }}</span>
}
<span class="tb-rec-meta">
@if (rec.hub; as listing) {
<span class="tb-hub-ic tight-only" [matTooltip]="'ai-assistant.detail.on-iot-hub' | translate" matTooltipPosition="above"><mat-icon class="tb-mat-16" aria-hidden="true">hub</mat-icon></span>

24
ui-ngx/src/app/modules/home/components/ai/ai-record-loader.service.ts

@ -1,5 +1,7 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { ReportTemplateService } from '@core/http/report-template.service';
import { ReportTemplateType } from '@shared/models/report.models';
import { inject, Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { forkJoin, Observable, of } from 'rxjs';
@ -65,6 +67,7 @@ export class AiRecordLoaderService {
private iotHubApi = inject(IotHubApiService);
private translate = inject(TranslateService);
private http = inject(HttpClient);
private reportTemplateService = inject(ReportTemplateService);
loadAll(refs: AiRecordRef[], options: AiRecordLoadOptions = {}): Observable<AiRecordView[]> {
if (!refs.length) {
@ -174,6 +177,27 @@ export class AiRecordLoaderService {
case EntityType.NOTIFICATION_TEMPLATE:
return this.notificationService.getNotificationTemplateById(entity.id, CONFIG)
.pipe(map(template => this.simple(key, entityType, template.name, NOTIFICATION_PAGES[entityType])));
case EntityType.REPORT_TEMPLATE:
return this.reportTemplateService.getReportTemplateInfo(entity.id, CONFIG).pipe(map(template => ({
key, entityType, alarmRule: false, name: template.name, url: `/reporting/templates/${entity.id}`,
badge: template.format,
meta: this.translate.instant(template.type === ReportTemplateType.SUB_REPORT ? 'ai-assistant.record.sub-report' : 'ai-assistant.record.report')
})));
case EntityType.REPORT:
return this.http.get<{name: string; format?: string; templateInfo?: {name?: string}}>(`/api/v2/report/${entity.id}`, defaultHttpOptionsFromConfig(CONFIG))
.pipe(map(report => ({
key, entityType, alarmRule: false, name: report.name, url: '/reporting/reports', badge: report.format,
meta: report.templateInfo?.name
})));
case EntityType.SCHEDULER_EVENT:
return this.http.get<{name: string; type?: string}>(`/api/schedulerEvent/${entity.id}`, defaultHttpOptionsFromConfig(CONFIG))
.pipe(map(event => {
const report = event.type === 'generateReport' || event.type === 'generateDashboardReport';
return {
key, entityType, alarmRule: false, name: event.name, url: report ? '/reporting/scheduling' : url,
meta: report ? this.translate.instant('ai-assistant.record.scheduled-report') : undefined
};
}));
default:
return this.entityService.getEntity(entityType, entity.id, CONFIG).pipe(map(found => {
const view = this.simple(key, entityType, found?.name ?? (found as {title?: string})?.title, NOTIFICATION_PAGES[entityType] ?? url);

5
ui-ngx/src/app/modules/home/components/ai/ai-record.component.ts

@ -15,6 +15,9 @@ export { AiRecordState } from '@home/components/ai/ai-record.models';
} @else {
<span class="tb-rec-name" [matTooltip]="name()" matTooltipPosition="above" [matTooltipShowDelay]="600">{{ name() }}</span>
}
@if (badge(); as label) {
<span class="tb-rec-badge" [attr.data-badge]="label.toLowerCase()">{{ label }}</span>
}
@if (hub(); as listing) {
<span class="tb-rec-meta">
<span class="tb-hub-ic" [matTooltip]="'ai-assistant.detail.on-iot-hub' | translate" matTooltipPosition="above"><mat-icon class="tb-mat-16" aria-hidden="true">hub</mat-icon></span>
@ -52,6 +55,8 @@ export class AiRecordComponent {
meta = input<string>();
badge = input<string>();
url = input<string>();
state = input<AiRecordState>();

1
ui-ngx/src/app/modules/home/components/ai/ai-record.models.ts

@ -36,6 +36,7 @@ export interface AiRecordView {
alarmRule: boolean;
name: string;
meta: string;
badge?: string;
url?: string;
state?: AiRecordState;
alarm?: AiAlarmState;

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

@ -33,7 +33,7 @@ const TARGETED_HUB_TYPES = new Set<string>([ItemType.CALCULATED_FIELD, ItemType.
<div class="tb-list-body" role="list" [attr.aria-label]="listLabel()">
@for (rec of shownViews(); track rec.key) {
<tb-ai-record role="listitem" [entityType]="rec.entityType" [alarmRule]="rec.alarmRule" [name]="rec.name"
[meta]="sameKind() ? lineMeta(rec) : rec.meta" [url]="rec.url" [state]="rec.state" [alarm]="rec.alarm"
[meta]="sameKind() ? lineMeta(rec) : rec.meta" [badge]="rec.badge" [url]="rec.url" [state]="rec.state" [alarm]="rec.alarm"
[hub]="rec.hub"></tb-ai-record>
}
@if (views().length > LIST_SHOWN) {

4
ui-ngx/src/app/modules/home/components/ai/ai-run-summary.component.ts

@ -27,7 +27,7 @@ import { AiRecordLoaderService } from '@home/components/ai/ai-record-loader.serv
<div class="tb-list-body" role="list" [attr.aria-label]="'ai-assistant.summary.made' | translate">
@for (row of shownRows(); track row.key) {
<tb-ai-record role="listitem" [entityType]="row.entityType" [alarmRule]="row.alarmRule" [name]="row.name"
[meta]="row.meta" [url]="row.url" [state]="row.state" [alarm]="row.alarm"></tb-ai-record>
[meta]="row.meta" [badge]="row.badge" [url]="row.url" [state]="row.state" [alarm]="row.alarm"></tb-ai-record>
}
@if (rest().length > LIST_SHOWN) {
<button type="button" class="tb-more" [attr.aria-expanded]="allShown()" (click)="allShown.set(!allShown())">
@ -42,7 +42,7 @@ import { AiRecordLoaderService } from '@home/components/ai/ai-record-loader.serv
<div class="k-recs" role="list" [attr.aria-label]="'ai-assistant.summary.made' | translate">
@for (row of rest(); track row.key) {
<tb-ai-record role="listitem" [entityType]="row.entityType" [alarmRule]="row.alarmRule" [name]="row.name"
[meta]="row.meta" [url]="row.url" [state]="row.state" [alarm]="row.alarm"></tb-ai-record>
[meta]="row.meta" [badge]="row.badge" [url]="row.url" [state]="row.state" [alarm]="row.alarm"></tb-ai-record>
}
</div>
}

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

@ -21,6 +21,10 @@ interface AiWelcomeKind {
const WELCOMES: Partial<Record<AiAssistantViewType, AiWelcomeKind>> = {
[AiAssistantViewType.DASHBOARD_LIST]: {key: 'dashboards', examples: ['build', 'find']},
[AiAssistantViewType.DASHBOARD]: {key: 'dashboard', entity: true},
[AiAssistantViewType.REPORT_TEMPLATE_LIST]: {key: 'report-templates', examples: ['fleet', 'export']},
[AiAssistantViewType.REPORT_TEMPLATE]: {key: 'report-template', entity: true},
[AiAssistantViewType.SCHEDULED_REPORTS]: {key: 'scheduled-reports', examples: ['weekly', 'next']},
[AiAssistantViewType.REPORTS]: {key: 'reports', examples: ['latest', 'now']},
[AiAssistantViewType.DEVICE_LIST]: {key: 'devices', examples: ['inactive']},
[AiAssistantViewType.DEVICE]: {key: 'device', entity: true, examples: ['telemetry', 'alarm', 'dashboard']},
[AiAssistantViewType.DEVICE_GROUP_LIST]: {key: 'device-groups', owned: true},
@ -113,7 +117,7 @@ export function aiWelcome(view: AiChatView | undefined, name: string | null, con
if (!kind) {
return {title: config?.title, line: config?.subTitle, examples: configExamples, suggestion: config?.suggestion ?? shortExample(configExamples)};
}
const base = 'ai-assistant.welcome.' + kind.key;
const base = 'ai-assistant.welcome.' + (config?.welcomeKey ?? kind.key);
const own = (kind.examples ?? []).map(example => ({
label: translate.instant(`${base}.example.${example}.label`),
message: translate.instant(`${base}.example.${example}.message`)

81
ui-ngx/src/app/modules/home/pages/reporting/template/report-template-page.component.ts

@ -80,7 +80,16 @@ import {
EntityAliasDialogComponent,
EntityAliasDialogData
} from '@home/components/alias/entity-alias-dialog.component';
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
import { buffer, debounceTime, distinctUntilChanged, map, tap } from 'rxjs/operators';
import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service';
import { AiAssistantViewType } from '@shared/models/ai-chat.models';
import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { UserPermissionsService } from '@core/http/user-permissions.service';
import { Operation, Resource } from '@shared/models/security.models';
const AI_RELOAD_DEBOUNCE_MS = 1000;
import { FilterDialogComponent, FilterDialogData } from '@home/components/filter/filter-dialog.component';
import { getDefaultTimezone } from '@shared/models/time/time.models';
import { DatePipe } from '@angular/common';
@ -233,10 +242,17 @@ export class ReportTemplatePageComponent extends PageComponent
private popoverService: TbPopoverService,
private viewContainerRef: ViewContainerRef,
private breadcrumbService: BreadcrumbService,
private panelService: AiAssistantPanelService,
private appStore: Store<AppState>,
private userPermissionsService: UserPermissionsService,
public homeService: HomeService) {
super();
}
get aiAssistantAvailable(): boolean {
return getCurrentAuthState(this.appStore).aiEnabled && this.userPermissionsService.hasGenericPermission(Resource.AI, Operation.ALL);
}
ngOnInit() {
this.homeService.setHideMainToolbar(true);
this.reportComponentContext = {
@ -277,6 +293,62 @@ export class ReportTemplatePageComponent extends PageComponent
this.init(reportTemplate);
}
);
this.setupAiAssistant();
}
private setupAiAssistant() {
if (!this.aiAssistantAvailable) {
return;
}
this.panelService.setEnabled(true);
this.updateAiConfig();
this.panelService.updatedData$.pipe(
buffer(this.panelService.updatedData$.pipe(debounceTime(AI_RELOAD_DEBOUNCE_MS))),
map(batches => batches.flat()),
takeUntilDestroyed(this.destroyRef)
).subscribe(affected => {
if (this.reportTemplate && affected.some(entityId => entityId.entityType === EntityType.REPORT_TEMPLATE
&& entityId.id === this.reportTemplate.id.id)) {
this.reportTemplateService.getReportTemplate(this.reportTemplate.id.id).subscribe(reportTemplate => this.init(reportTemplate));
}
});
}
private updateAiConfig() {
const blank = !this.hasReportComponents();
const examples = blank ? ['fleet', 'export'] : ['check', 'per-device'];
this.panelService.setConfig({
welcomeKey: blank ? 'report-template-new' : undefined,
title: this.translate.instant('report-template.ai-assistant-title'),
initialPromptPlaceholder: this.translate.instant('report-template.ai-assistant-initial-prompt-placeholder'),
suggestion: this.translate.instant('report-template.ai-assistant-suggestion'),
fill: true,
promptExamples: examples.map(example => ({
label: this.translate.instant(`report-template.ai-assistant-example-${example}-label`),
message: this.translate.instant(`report-template.ai-assistant-example-${example}-message`)
}))
});
}
private hasReportComponents(): boolean {
const configuration = this.reportTemplate?.configuration as PdfReportTemplateConfig;
if (!configuration) {
return false;
}
const sections = [configuration.header, configuration.header?.firstPage, configuration.footer, configuration.footer?.firstPage];
return !!configuration.components?.length || sections.some(section => !!section?.components?.length);
}
private updateAiClientContext() {
if (!this.aiAssistantAvailable || !this.reportTemplate?.id) {
return;
}
this.updateAiConfig();
this.panelService.setClientContextForView({
type: AiAssistantViewType.REPORT_TEMPLATE,
entityId: {entityType: EntityType.REPORT_TEMPLATE, id: this.reportTemplate.id.id}
});
this.panelService.setViewName(this.reportTemplate.name);
}
ngAfterViewInit() {
@ -287,6 +359,9 @@ export class ReportTemplatePageComponent extends PageComponent
this.layoutResize$.observe(this.reportTemplateLayoutEl().nativeElement);
this.viewInited = true;
});
if (this.aiAssistantAvailable && this.route.snapshot.queryParamMap.get('action') === 'aiAssistant') {
this.panelService.openPanel();
}
const reportTemplateContent = this.reportTemplateContentEl();
if (reportTemplateContent) {
reportTemplateContent.elementScrolled().pipe(
@ -312,6 +387,9 @@ export class ReportTemplatePageComponent extends PageComponent
if (this.layoutResize$) {
this.layoutResize$.disconnect();
}
if (this.aiAssistantAvailable) {
this.panelService.teardown();
}
}
saveReportTemplate() {
@ -770,6 +848,7 @@ export class ReportTemplatePageComponent extends PageComponent
}
this.isDirty = false;
this.updateBreadcrumbs.emit();
this.updateAiClientContext();
this.cd.markForCheck();
}

45
ui-ngx/src/app/modules/home/pages/reporting/template/report-templates-table-config.resolver.ts

@ -19,20 +19,24 @@ import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared
import { EntityAction } from '@home/models/entity/entity-component.models';
import { UserPermissionsService } from '@core/http/user-permissions.service';
import {
defaultPdfReportTemplateConfig,
ReportConfig,
ReportTemplate,
ReportTemplateFilter,
ReportTemplateInfo,
ReportTemplateQuery,
ReportTemplateType,
reportTemplateTypeTranslationMap
reportTemplateTypeTranslationMap,
TbReportFormat
} from '@shared/models/report.models';
import { AiAssistantViewType } from '@shared/models/ai-chat.models';
import { deepClone } from '@core/utils';
import { ReportTemplateService } from '@core/http/report-template.service';
import { mergeMap } from 'rxjs/operators';
import { UtilsService } from '@core/services/utils.service';
import { AuthUser } from '@shared/models/user.model';
import { Authority } from '@shared/models/authority.enum';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { getCurrentAuthState, getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { ReportTemplateTableHeaderComponent } from '@home/pages/reporting/template/report-template-table-header.component';
@ -101,6 +105,12 @@ export class ReportTemplatesTableConfigResolver {
};
config.columns = this.configureColumns(authUser, config);
if (this.aiAvailable()) {
config.aiAssistantConfig = {
view: {listView: AiAssistantViewType.REPORT_TEMPLATE_LIST, entityView: AiAssistantViewType.REPORT_TEMPLATE},
initialPromptPlaceholder: this.translate.instant('report-template.ai-assistant-initial-prompt-placeholder')
};
}
this.configureEntityFunctions(config);
config.cellActionDescriptors = this.configureCellActions(config);
config.groupActionDescriptors = this.configureGroupActions(config);
@ -231,9 +241,40 @@ export class ReportTemplatesTableConfigResolver {
onAction: ($event) => this.importReportTemplate($event, config)
}
);
if (this.aiAvailable()) {
actions.push({
name: this.translate.instant('ai-assistant.configure-with-ai'),
icon: 'mdi:creation',
isEnabled: () => true,
onAction: ($event) => this.configureWithAi($event, config)
});
}
return actions;
}
private aiAvailable(): boolean {
return getCurrentAuthState(this.store).aiEnabled && this.userPermissionsService.hasGenericPermission(Resource.AI, Operation.ALL);
}
configureWithAi($event: Event, config: EntityTableConfig<ReportTemplateInfo>) {
if ($event) {
$event.stopPropagation();
}
const reportTemplate = {
name: this.translate.instant('report-template.new-report-template-name'),
format: TbReportFormat.PDF,
type: ReportTemplateType.REPORT,
configuration: deepClone(defaultPdfReportTemplateConfig)
} as ReportTemplate;
this.reportTemplateService.saveReportTemplate(reportTemplate).subscribe((saved) => {
const url = this.router.createUrlTree([saved.id.id], {
relativeTo: config.getTable().route,
queryParams: {action: 'aiAssistant'}
});
this.router.navigateByUrl(url);
});
}
openReportTemplate($event: Event, reportTemplate: ReportTemplateInfo, config: EntityTableConfig<ReportTemplateInfo>) {
if ($event) {
$event.stopPropagation();

7
ui-ngx/src/app/shared/models/ai-chat.models.ts

@ -128,6 +128,7 @@ export interface AiAssistantPanelConfig {
fill?: boolean;
promptExamples?: AiAssistantPromptExample[];
suggestion?: string;
welcomeKey?: string;
}
export interface BaseChatToolEventData {
@ -251,6 +252,10 @@ export enum AiAssistantViewType {
DASHBOARD_LIST = 'DASHBOARD_LIST',
DASHBOARD_GROUP_LIST = 'DASHBOARD_GROUP_LIST',
DASHBOARD_GROUP = 'DASHBOARD_GROUP',
REPORT_TEMPLATE_LIST = 'REPORT_TEMPLATE_LIST',
REPORT_TEMPLATE = 'REPORT_TEMPLATE',
SCHEDULED_REPORTS = 'SCHEDULED_REPORTS',
REPORTS = 'REPORTS',
ALARM_RULE = 'ALARM_RULE',
ALARM_RULE_LIST = 'ALARM_RULE_LIST',
ALARM_LIST = 'ALARM_LIST',
@ -355,6 +360,8 @@ const AI_PAGE_VIEWS: Array<[string, AiAssistantViewType]> = [
['/features/vc', AiAssistantViewType.VERSION_CONTROL],
['/features/taskManager', AiAssistantViewType.TASK_MANAGER],
['/features/scheduler', AiAssistantViewType.SCHEDULER],
['/reporting/scheduling', AiAssistantViewType.SCHEDULED_REPORTS],
['/reporting/reports', AiAssistantViewType.REPORTS],
['/settings/home', AiAssistantViewType.HOME_SETTINGS],
['/settings/outgoing-mail', AiAssistantViewType.MAIL_SERVER_SETTINGS],
['/settings/notifications', AiAssistantViewType.NOTIFICATION_SETTINGS],

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

@ -917,6 +917,24 @@
"read-security-settings": "Read the security settings",
"read-mobile-center": "Read the mobile center",
"read-scheduler-events": "Read the scheduler",
"create-report-template": "Created the report template {{name}}",
"update-report-template": "Changed the report template",
"read-report-template": "Read the layout of '{{name}}'",
"read-report-component": "Read the component {{path}} of '{{name}}'",
"sub-report": "Sub-report",
"report-components": "Components",
"report-problems": "Problems",
"add-report-components": "Added report components",
"update-report-component": "Changed the component {{path}}",
"move-report-component": "Moved {{path}} to {{target}}",
"save-report-alias": "Saved the entity alias {{name}}",
"save-report-filter": "Saved the filter {{name}}",
"test-report-template": "Checked the report",
"report-pages": "{ count, plural, =1 {1 page} other {# pages} }",
"report-rows": "{ count, plural, =1 {1 row} other {# rows} }",
"report-pages-clean": "{ count, plural, =1 {1 page} other {# pages} }, no errors",
"report-rows-clean": "{ count, plural, =1 {1 row} other {# rows} }, no errors",
"report-errors": "Errors",
"save-two-factor-settings": "Changed the two-factor authentication settings",
"save-oauth2-domain": "Changed OAuth 2.0 sign-in on the domain",
"read-my-account": "Read your account",
@ -930,6 +948,19 @@
"no-scheduler-events": "No scheduler events yet.",
"save-scheduler-event": "Changed the scheduler event",
"create-scheduler-event": "Created the scheduler event {{name}}",
"read-reports": "Read the reports",
"read-report-templates": "Read the report templates",
"no-report-templates": "No report templates",
"read-scheduled-reports": "Read the scheduled reports",
"read-generated-reports": "Read the generated reports",
"no-scheduled-reports": "No scheduled reports",
"no-generated-reports": "No generated reports",
"attach-report": "Attached {{name}}",
"read-scheduled-report": "Read the scheduled report {{name}}",
"save-scheduled-report": "Changed the scheduled report",
"create-scheduled-report": "Scheduled the report {{name}}",
"generate-report": "Generated the report",
"report-still-running": "Still generating; it will appear on the Reports page",
"mobile-apps": "Apps",
"no-mobile-apps": "No mobile apps yet.",
"no-mobile-bundles": "No mobile bundles yet, so the apps show the standard menu.",
@ -1081,6 +1112,13 @@
"size": "Size",
"theme": "Theme",
"time-window": "Time window",
"format": "Format",
"page": "Page",
"file-name": "File name",
"header-footer": "Header and footer",
"component": "Component",
"path": "Path",
"height": "Height",
"state-id": "State ID",
"type": "Type",
"on": "On",
@ -1483,6 +1521,78 @@
"run": "Deleting the scheduler event",
"done": "Deleted the scheduler event"
},
"create-report-template": {
"run": "Creating the report template",
"done": "Created the report template"
},
"update-report-template": {
"run": "Saving the report template",
"done": "Saved the report template"
},
"read-report-template": {
"run": "Reading the report template",
"done": "Read the report template"
},
"read-report-component": {
"run": "Reading the component",
"done": "Read the component"
},
"add-report-components": {
"run": "Adding report components",
"done": "Added report components"
},
"update-report-component": {
"run": "Changing a report component",
"done": "Changed a report component"
},
"move-report-component": {
"run": "Moving a report component",
"done": "Moved a report component"
},
"save-report-alias": {
"run": "Saving the entity alias",
"done": "Saved the entity alias"
},
"save-report-filter": {
"run": "Saving the filter",
"done": "Saved the filter"
},
"test-report-template": {
"run": "Generating a test report",
"done": "Checked the report"
},
"read-reports": {
"run": "Reading the reports",
"done": "Read the reports"
},
"save-scheduled-report": {
"run": "Saving the scheduled report",
"done": "Saved the scheduled report"
},
"generate-report": {
"run": "Generating the report",
"done": "Generated the report"
},
"delete-report": {
"run": "Deleting the report",
"done": "Deleted the report"
},
"delete-report-template": {
"run": "Deleting the report template",
"done": "Deleted the report template"
},
"delete-report-component": {
"run": "Deleting the report component",
"done": "Deleted the report component"
},
"delete-report-alias": {
"run": "Deleting the entity alias",
"done": "Deleted the entity alias"
},
"delete-report-filter": {
"run": "Deleting the filter",
"done": "Deleted the filter"
},
"delete-custom-menu": {
"run": "Deleting the custom menu",
"done": "Deleted the custom menu"
@ -1752,6 +1862,11 @@
"details": "Details",
"request": "Request",
"result": "Result",
"template": "Template",
"event": "Event",
"account": "Account",
"mail-server": "Mail server",
"qr-code": "QR code",
"settings": "Settings",
"try-again": "Try again",
"try-again-prompt": "Try that again"
@ -1936,6 +2051,63 @@
"appliesTo": "Applies to",
"permissions": "Permissions",
"description": "Description",
"report-title": "Title",
"report-text": "Text",
"report-html": "Text",
"report-keys": "Keys",
"report-columns": "Columns",
"report-latestColumns": "Extra columns",
"report-series": "Series",
"report-key": "Key",
"report-timewindow": "Time window",
"report-thresholds": "Thresholds",
"report-legend": "Legend",
"report-axes": "Axes",
"report-height": "Height",
"report-chart": "Chart",
"report-url": "Image",
"report-templateId": "Sub-report",
"report-statuses": "Statuses",
"report-severities": "Severities",
"report-types": "Alarm types",
"report-sortOrder": "Sort order",
"report-states": "States",
"report-ranges": "Ranges",
"report-size": "Text size",
"report-bold": "Bold",
"report-italic": "Italic",
"report-color": "Color",
"report-align": "Alignment",
"report-verticalAlign": "Vertical alignment",
"report-keepTogether": "Keep together",
"report-units": "Units",
"report-decimals": "Decimals",
"reportTemplate": "Report template",
"reportUser": "Generated as",
"reportTimezone": "Report time zone",
"notificationTemplate": "Notification template",
"reportFor": "Generated for",
"report-settings": "Also changes",
"report-alias": "Entity alias",
"report-filter": "Filter",
"report-position": "Position",
"report-resolves": "Resolves to",
"report-conditions": "Conditions",
"report-name": "Name",
"report-description": "Description",
"report-format": "Format",
"report-page-size": "Page",
"report-page-orientation": "Orientation",
"report-page-margins": "Margins",
"report-page-background": "Page background",
"report-fileName": "File name",
"report-timeFormat": "Time format",
"report-header-enabled": "Header",
"report-header-firstPage": "First-page header",
"report-footer-enabled": "Footer",
"report-footer-firstPage": "First-page footer",
"format": "Format",
"templateType": "Template type",
"added": "Added",
"removed": "Removed",
"name": "Name",
@ -1994,12 +2166,19 @@
"DASHBOARD_STATE": "Dashboard state",
"DASHBOARD_ENTITY_ALIAS": "Entity alias",
"DASHBOARD_FILTER": "Dashboard filter",
"REPORT_COMPONENT": "Report component",
"REPORT_ENTITY_ALIAS": "Report entity alias",
"REPORT_FILTER": "Report filter",
"SCHEDULED_REPORT": "Scheduled report",
"NOTIFICATION": "Notification",
"NOTIFICATION_SETTINGS": "Notification delivery",
"NOTIFICATION_PREFERENCES": "Notification preferences"
}
},
"record": {
"report": "Report",
"sub-report": "Sub-report",
"scheduled-report": "Scheduled report",
"group-of": "{{type}} group",
"on": "on {{name}}",
"on-profile": "on profile {{name}}",
@ -2788,6 +2967,63 @@
"failed": {"label": "Failed tasks", "message": "Which tasks failed recently, and why?"}
}
},
"report-templates": {
"title": "Ask about your report templates",
"line": "Design PDF and CSV reports, or change an existing one.",
"suggestion": "Build a weekly PDF report of my devices.",
"example": {
"fleet": {
"label": "Weekly fleet report",
"message": "Build a weekly PDF report of my devices: a chart of their main readings over the previous week, a table of their latest values and their critical alarms."
},
"export": {
"label": "Data export",
"message": "Make a CSV export of yesterday's telemetry of my devices, one row per hour."
}
}
},
"report-template-new": {
"title": "Design this report",
"title-unnamed": "Design this report",
"line": "Say what it should show, for which devices and period, and how often it goes out.",
"suggestion": "Build a weekly PDF report of my devices."
},
"report-template": {
"title": "Ask about {{name}}",
"title-unnamed": "Ask about this report template",
"line": "What is in it, what to change, or what to add.",
"suggestion": "Is this report ready to send?"
},
"scheduled-reports": {
"title": "Ask about scheduled reports",
"line": "Send reports on a schedule: daily, weekly or monthly, to the people who need them.",
"suggestion": "Send my weekly report to the operations team every Monday.",
"example": {
"weekly": {
"label": "Weekly report every Monday",
"message": "Generate one of my report templates every Monday at 07:00 and send it to me."
},
"next": {
"label": "What goes out next?",
"message": "Which reports are scheduled, when do they run next and who gets them?"
}
}
},
"reports": {
"title": "Ask about your reports",
"line": "Find, get or clean up the reports generated so far, or generate one now.",
"suggestion": "Show me the latest report.",
"example": {
"latest": {
"label": "Latest report",
"message": "Show me the latest generated report in the chat."
},
"now": {
"label": "Generate one now",
"message": "Generate a report from one of my templates now and keep it here."
}
}
},
"scheduler": {
"title": "Ask about the scheduler",
"line": "Run actions on a schedule: update attributes, send commands, roll out firmware.",
@ -11345,6 +11581,18 @@
"copy-public-link": "Copy link"
},
"report-template": {
"ai-assistant-title": "Ask about this report template",
"ai-assistant-initial-prompt-placeholder": "Describe the report you need...",
"ai-assistant-suggestion": "Is this report ready to send?",
"ai-assistant-example-fleet-label": "Weekly fleet report",
"ai-assistant-example-fleet-message": "Build a weekly PDF report of my devices: a chart of their main readings over the previous week, a table of their latest values and their critical alarms.",
"ai-assistant-example-export-label": "Data export",
"ai-assistant-example-export-message": "Make a CSV export of yesterday's telemetry of my devices, one row per hour.",
"ai-assistant-example-check-label": "Check the report",
"ai-assistant-example-check-message": "Generate a test report and tell me what is wrong or empty in it.",
"ai-assistant-example-per-device-label": "One section per device",
"ai-assistant-example-per-device-message": "Give every device its own section with its chart and table, each starting on a new page.",
"new-report-template-name": "New report template",
"report-template": "Report template",
"report-templates": "Report templates",
"add": "Add report template",

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

@ -696,6 +696,31 @@
&[data-pal="solution"] .tb-rec-tile { background: var(--entity-solution-bg); color: var(--entity-solution-fg); }
}
.tb-rec-badge {
flex: none;
display: inline-flex;
align-items: center;
height: 18px;
margin-left: 6px;
padding: 0 6px;
border-radius: 4px;
font: 600 10px/16px var(--tb-mono);
letter-spacing: .5px;
color: var(--tb-ink-54);
background: var(--tb-ink-12);
vertical-align: middle;
&[data-badge="pdf"] {
color: var(--tb-crit);
background: color-mix(in srgb, var(--tb-crit) 10%, transparent);
}
&[data-badge="csv"] {
color: var(--tb-ok-text);
background: var(--tb-ok-tint);
}
}
.tb-rec-tile {
display: inline-flex;
align-items: center;
@ -1280,6 +1305,11 @@
color: var(--tb-text-muted);
text-align: left;
vertical-align: baseline;
code {
white-space: nowrap;
overflow-wrap: normal;
}
}
td {
@ -1299,7 +1329,7 @@
td.k-diff-was, td.k-diff-now {
white-space: normal;
overflow-wrap: anywhere;
overflow-wrap: break-word;
}
.k-diff-now span {
@ -1931,6 +1961,41 @@ code.k-ent[data-pal="solution"] .k-ent-ic { color: var(--entity-solution-fg); }
}
}
@mixin k-diff-stacked {
thead {
display: none;
}
tr {
display: block;
padding: 4px 0;
}
tbody th {
display: block;
padding: 0;
}
td {
display: inline;
padding: 0;
}
.k-diff-now::before {
content: '→';
margin: 0 12px 0 8px;
color: var(--tb-ink-38);
}
}
.k-diff.k-diff-stacked {
@include k-diff-stacked;
td.k-diff-was:not(:empty) {
text-decoration: line-through;
}
}
@container k-chat (max-width: 420px) {
.k-diff {
thead {

Loading…
Cancel
Save