diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index be1959f081..35ba0f140d 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -2556,7 +2556,7 @@ queue: # Statistics printing interval for Edge services print-interval-ms: "${TB_QUEUE_EDGE_STATS_PRINT_INTERVAL_MS:60000}" integration: - # Name of hash function used for consistent hash ring in Cluster Mode. See architecture docs for more details. Valid values - murmur3_32, murmur3_128 or sha256 + # Number of partitions in each integration queue; there is one queue per integration type. Must match TB_QUEUE_INTEGRATION_PARTITIONS on the Integration Executors, otherwise downlinks, integration validation and Check connection may not reach the executor that runs the integration. partitions: "${TB_QUEUE_INTEGRATION_PARTITIONS:3}" # For high-priority notifications that require minimum latency and processing time notifications_topic: "${TB_QUEUE_INTEGRATION_NOTIFICATIONS_TOPIC:tb_integration_executor.notifications}" diff --git a/integration/executor/src/main/resources/tb-integration-executor.yml b/integration/executor/src/main/resources/tb-integration-executor.yml index 171efc630e..fad781696b 100644 --- a/integration/executor/src/main/resources/tb-integration-executor.yml +++ b/integration/executor/src/main/resources/tb-integration-executor.yml @@ -334,7 +334,7 @@ queue: pause-between-retries: "${TB_QUEUE_RE_SQ_PROCESSING_STRATEGY_RETRY_PAUSE:5}" # Time in seconds to wait in consumer thread before retries; max-pause-between-retries: "${TB_QUEUE_RE_SQ_PROCESSING_STRATEGY_MAX_RETRY_PAUSE:5}" # Max allowed time in seconds for pause between retries. integration: - # Name of hash function used for consistent hash ring in Cluster Mode. See architecture docs for more details. Valid values - murmur3_32, murmur3_128 or sha256 + # Number of partitions in each integration queue; there is one queue per integration type. Integrations that run on only one executor at a time (MQTT, OPC-UA, Kafka and similar) are distributed across executors by partition, so executors above this number stay idle for those types. When you add executors, set it to at least the number of executors that run the same integration types, and use the same value on the ThingsBoard nodes. partitions: "${TB_QUEUE_INTEGRATION_PARTITIONS:3}" # For high-priority notifications that require minimum latency and processing time notifications_topic: "${TB_QUEUE_INTEGRATION_NOTIFICATIONS_TOPIC:tb_integration_executor.notifications}" diff --git a/ui-ngx/src/app/core/auth/auth.service.ts b/ui-ngx/src/app/core/auth/auth.service.ts index edd852247c..1c4c57431e 100644 --- a/ui-ngx/src/app/core/auth/auth.service.ts +++ b/ui-ngx/src/app/core/auth/auth.service.ts @@ -10,7 +10,7 @@ import { catchError, map, mergeMap, tap } from 'rxjs/operators'; import { setEdqsEnabled, setNullsOrderStrategy } from '@shared/models/page/page-link'; import { LoginRequest, LoginResponse, PublicLoginRequest } from '@shared/models/login.models'; -import { Router, UrlTree } from '@angular/router'; +import { PRIMARY_OUTLET, Router, UrlTree } from '@angular/router'; import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from '../http/http-utils'; import { UserService } from '../http/user.service'; import { Store } from '@ngrx/store'; @@ -281,24 +281,12 @@ export class AuthService { } else if (authState.authUser.authority === Authority.MFA_CONFIGURATION_TOKEN) { result = this.router.parseUrl('login/force-mfa'); } else if (!path || path === 'login' || this.forceDefaultPlace(authState, path, params)) { - if (this.redirectUrl) { - const redirectUrl = this.redirectUrl; - this.redirectUrl = null; + const redirectUrl = this.redirectUrl; + this.redirectUrl = null; + if (redirectUrl && !authState.authUser.isPublic && this.isDeepLink(redirectUrl)) { result = this.router.parseUrl(redirectUrl); } else { - result = this.router.parseUrl('home'); - } - if (authState.authUser.authority === Authority.TENANT_ADMIN || authState.authUser.authority === Authority.CUSTOMER_USER) { - if (this.userHasDefaultDashboard(authState)) { - const dashboardId = authState.userDetails.additionalInfo.defaultDashboardId; - if (authState.forceFullscreen) { - result = this.router.parseUrl(`dashboard/${dashboardId}`); - } else { - result = this.router.parseUrl(`dashboards/${dashboardId}`); - } - } else if (authState.authUser.isPublic && authState.lastPublicDashboardId) { - result = this.router.parseUrl(`dashboard/${authState.lastPublicDashboardId}`); - } + result = this.defaultPlaceUrl(authState); } } } else { @@ -339,6 +327,23 @@ export class AuthService { })); } + private defaultPlaceUrl(authState: AuthState): UrlTree { + if (authState.authUser.authority === Authority.TENANT_ADMIN || authState.authUser.authority === Authority.CUSTOMER_USER) { + if (this.userHasDefaultDashboard(authState)) { + const dashboardId = authState.userDetails.additionalInfo.defaultDashboardId; + return this.router.parseUrl(authState.forceFullscreen ? `dashboard/${dashboardId}` : `dashboards/${dashboardId}`); + } else if (authState.authUser.isPublic && authState.lastPublicDashboardId) { + return this.router.parseUrl(`dashboard/${authState.lastPublicDashboardId}`); + } + } + return this.router.parseUrl('home'); + } + + private isDeepLink(url: string): boolean { + const segments = this.router.parseUrl(url).root.children[PRIMARY_OUTLET]?.segments.map(segment => segment.path) ?? []; + return segments.length > 0 && segments[0] !== 'login' && !(segments.length === 1 && segments[0] === 'home'); + } + private loadUser(doTokenRefresh): Observable { const authUser = getCurrentAuthUser(this.store); if (!authUser) { diff --git a/ui-ngx/src/app/core/services/ai-chats.service.ts b/ui-ngx/src/app/core/services/ai-chats.service.ts index d35116c93e..e57a2ea93a 100644 --- a/ui-ngx/src/app/core/services/ai-chats.service.ts +++ b/ui-ngx/src/app/core/services/ai-chats.service.ts @@ -144,7 +144,7 @@ export class AiChatsService { }); } - levelOf(chat: ChatInfo): ChatLevel | null { + levelOf(chat: ChatInfo, ignoreOpen = false): ChatLevel | null { if (this._waiting().has(chat.id)) { return 'needs'; } @@ -154,7 +154,7 @@ export class AiChatsService { if (this._failed().has(chat.id)) { return 'error'; } - if (this._open().has(chat.id)) { + if (!ignoreOpen && this._open().has(chat.id)) { return chat.status === 'FAILED' ? 'error' : null; } return chat.status === 'NEEDS_YOU' ? 'needs' : chat.status === 'NO_DATA' ? 'nodata' : chat.status === 'RUNNING' ? 'running' : chat.status === 'FAILED' ? 'error' : null; diff --git a/ui-ngx/src/app/core/services/ai-slash.service.ts b/ui-ngx/src/app/core/services/ai-slash.service.ts index 1cd795dcf0..4d74aa93a1 100644 --- a/ui-ngx/src/app/core/services/ai-slash.service.ts +++ b/ui-ngx/src/app/core/services/ai-slash.service.ts @@ -50,7 +50,8 @@ export class AiSlashService { private onKeydown(event: KeyboardEvent): void { if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey || event.defaultPrevented || this.dialog.openDialogs.length - || (event.target as HTMLElement)?.closest?.('input, textarea, select, [contenteditable]')) { + || (event.target as HTMLElement)?.closest?.('input, textarea, select, [contenteditable], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"]') + || document.querySelector('.cdk-overlay-container .mat-mdc-select-panel, .cdk-overlay-container .mat-mdc-menu-panel, .cdk-overlay-container .mat-mdc-autocomplete-panel')) { return; } const visible = Array.from(this.composers) diff --git a/ui-ngx/src/app/core/services/ai-solutions.service.ts b/ui-ngx/src/app/core/services/ai-solutions.service.ts index 7a709f69cf..7e7888876b 100644 --- a/ui-ngx/src/app/core/services/ai-solutions.service.ts +++ b/ui-ngx/src/app/core/services/ai-solutions.service.ts @@ -35,6 +35,7 @@ export class AiSolutionsService { private _running = signal>(new Set()); readonly running = this._running.asReadonly(); private _failed = signal>(new Map()); + private _needs = signal>(new Set()); private api = inject(SolutionsCreatorService); private dialog = inject(DialogService); @@ -110,11 +111,29 @@ export class AiSolutionsService { ).subscribe(); } + setNeeds(solutionId: string | undefined, needs: boolean): void { + if (!solutionId || this._needs().has(solutionId) === needs) { + return; + } + if (needs && !['FAILED', 'RUNNING'].includes(this.find(solutionId)?.status)) { + this.update(solutionId, {status: 'NEEDS_YOU', statusReason: undefined}); + } + this._needs.update(set => { + const next = new Set(set); + if (needs) { + next.add(solutionId); + } else { + next.delete(solutionId); + } + return next; + }); + } + setRunning(solutionId: string | undefined, running: boolean): void { if (!solutionId || this._running().has(solutionId) === running) { return; } - if (running) { + if (running && this.find(solutionId)?.status !== 'RUNNING') { this.update(solutionId, {status: undefined, statusReason: undefined}); } this._running.update(set => { @@ -126,6 +145,9 @@ export class AiSolutionsService { } return next; }); + if (!running && this.find(solutionId)?.status === 'RUNNING') { + this.followRunning(); + } } isRunning(solutionId: string): boolean { @@ -155,7 +177,7 @@ export class AiSolutionsService { return 'error'; } if (open) { - return solution.status === 'FAILED' ? 'error' : null; + return solution.status === 'FAILED' ? 'error' : this._needs().has(solution.id) ? 'needs' : null; } return solution.status === 'NEEDS_YOU' ? 'needs' : solution.status === 'RUNNING' ? 'running' : solution.status === 'FAILED' ? 'error' : null; } diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html index 92b784a2e3..939c25ddff 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html @@ -52,25 +52,49 @@ } } @case ('values') { - @if (block.label) { + @if (block.entity) { +

{{ entityName(block.entity) }}

+ } @else if (block.label) {
{{ say(block.label) }}
} -
+
@for (row of block.rows; track $index) { - {{ row.key }}{{ row.value }} +
{{ row.key }}
+
{{ row.value }}
} -
+ } @case ('series') { -
- @for (row of block.rows; track row.key) { -
- {{ row.key }} - - {{ 'ai-assistant.detail.series' | translate:{points: row.points, min: number(row.min), max: number(row.max), last: number(row.last)} }} -
- } -
+ @if (block.entity) { +

{{ entityName(block.entity) }}

+ } + + + + + + + + + + + @for (row of block.rows; track row.key) { + + + + + + + } + +
{{ 'ai-assistant.detail.history-key' | translate }}{{ 'ai-assistant.detail.history-curve' | translate }}{{ 'ai-assistant.detail.history-last' | translate }}{{ 'ai-assistant.detail.history-range' | translate }}
{{ row.key }} + + {{ row.lastText ?? number(row.last) }}{{ row.changes !== undefined + ? ('ai-assistant.detail.history-changes' | translate: {count: row.changes}) + : ('ai-assistant.detail.history-span' | translate: {min: number(row.min), max: number(row.max)}) }}
} @case ('keys') { @if (block.label) { @@ -83,8 +107,43 @@ } @case ('facts') { + @if (changeRows(block.rows); as changes) { + @if (changes.length) { +
+ @for (change of changes; track $index) { +
+
{{ label(change) }}
+ @if (change.images; as pair) { +
+ @if (pair.current) { + + } @else { + + } + + {{ 'ai-assistant.review.changes-to' | translate }} + @if (pair.value) { + + } @else { + + } +
+ } @else { +
+ {{ change.was }} + + {{ 'ai-assistant.review.changes-to' | translate }} + {{ factValue(change) }} +
+ } +
+ } +
+ } + } + @if (plainRows(block.rows).length) {
- @for (fact of block.rows; track $index) { + @for (fact of plainRows(block.rows); track $index) {
{{ label(fact) }}
@if (fact.images; as pair) { @@ -121,6 +180,7 @@
}
+ } } @case ('list') { @if (block.label) { @@ -139,7 +199,7 @@ @if (block.title) {
{{ ('ai-assistant.action.' + block.title) | translate }}
} -
{{ block.text }}
+
{{ block.text }}
} @case ('links') {