Browse Source

Merge pull request #16870 from thingsboard/rc

Merge rc into master
pull/16830/merge
Vladyslav Prykhodko 2 days ago
committed by GitHub
parent
commit
ff2ed5bc1b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultAlarmQueryRepository.java
  2. 36
      dao/src/test/java/org/thingsboard/server/dao/service/AlarmServiceTest.java
  3. 4
      ui-ngx/src/app/core/http/ai-chat.service.ts
  4. 58
      ui-ngx/src/app/core/services/ai-assistant-panel.service.ts
  5. 5
      ui-ngx/src/app/modules/home/components/agent/_agent-shared.scss
  6. 32
      ui-ngx/src/app/modules/home/components/agent/agent-deploy-status.component.scss
  7. 4
      ui-ngx/src/app/modules/home/components/agent/component/agent-compose-diff.component.scss
  8. 11
      ui-ngx/src/app/modules/home/components/agent/component/agent-compose-diff.component.ts
  9. 6
      ui-ngx/src/app/modules/home/components/agent/component/agent-compose-editor.component.scss
  10. 59
      ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.html
  11. 9
      ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.scss
  12. 3
      ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.ts
  13. 2
      ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.service.ts
  14. 284
      ui-ngx/src/app/modules/home/components/agent/wizard/_agent-wizard.scss
  15. 601
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.html
  16. 10
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.scss
  17. 87
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.ts
  18. 22
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard-dialog.ts
  19. 5
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard.component.scss
  20. 1
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard.component.ts
  21. 72
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.html
  22. 2
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.scss
  23. 14
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.ts
  24. 294
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.html
  25. 2
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.scss
  26. 35
      ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.ts
  27. 2
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html
  28. 9
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  29. 1
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  30. 9
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  31. 2
      ui-ngx/src/app/modules/home/components/ai/ai-artifact-pane.component.html
  32. 30
      ui-ngx/src/app/modules/home/components/ai/ai-artifact-pane.component.ts
  33. 5
      ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.scss
  34. 40
      ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts
  35. 4
      ui-ngx/src/app/modules/home/components/ai/ai-attachments.component.html
  36. 2
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html
  37. 4
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.scss
  38. 6
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts
  39. 5
      ui-ngx/src/app/modules/home/components/ai/ai-chat-title.component.html
  40. 6
      ui-ngx/src/app/modules/home/components/ai/ai-chat-title.component.scss
  41. 24
      ui-ngx/src/app/modules/home/components/ai/ai-chat-title.component.ts
  42. 64
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html
  43. 1
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.scss
  44. 51
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts
  45. 8
      ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.html
  46. 7
      ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.ts
  47. 12
      ui-ngx/src/app/modules/home/components/ai/ai-core.module.ts
  48. 13
      ui-ngx/src/app/modules/home/components/ai/ai-credits.component.scss
  49. 71
      ui-ngx/src/app/modules/home/components/ai/ai-dashboard-generation.service.ts
  50. 15
      ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.html
  51. 34
      ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.scss
  52. 61
      ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.ts
  53. 6
      ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.html
  54. 4
      ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.ts
  55. 4
      ui-ngx/src/app/modules/home/components/ai/ai-plan.component.html
  56. 2
      ui-ngx/src/app/modules/home/components/ai/ai-plan.component.ts
  57. 2
      ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.html
  58. 62
      ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.ts
  59. 36
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.html
  60. 16
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts
  61. 2
      ui-ngx/src/app/modules/home/components/ai/ai-record-card.component.ts
  62. 4
      ui-ngx/src/app/modules/home/components/ai/ai-record.component.ts
  63. 4
      ui-ngx/src/app/modules/home/components/ai/ai-secret-field.component.html
  64. 1
      ui-ngx/src/app/modules/home/components/ai/ai-secret-field.component.ts
  65. 2
      ui-ngx/src/app/modules/home/components/ai/ai-started-from.component.ts
  66. 12
      ui-ngx/src/app/modules/home/components/ai/ai-text.ts
  67. 70
      ui-ngx/src/app/modules/home/components/ai/ai-tooltip.ts
  68. 22
      ui-ngx/src/app/modules/home/components/ai/ai.models.ts
  69. 12
      ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.html
  70. 10
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.html
  71. 10
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.scss
  72. 200
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.ts
  73. 9
      ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts
  74. 1
      ui-ngx/src/app/modules/home/components/group/entity-groups-table-config.resolver.ts
  75. 10
      ui-ngx/src/app/modules/home/components/group/entity-groups-table-config.ts
  76. 9
      ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
  77. 2
      ui-ngx/src/app/modules/home/home.component.html
  78. 3
      ui-ngx/src/app/modules/home/pages/agent/agent-app-profile.component.ts
  79. 13
      ui-ngx/src/app/modules/home/pages/agent/agent-app-profiles-table-config.resolver.ts
  80. 46
      ui-ngx/src/app/modules/home/pages/agent/agent-application.component.ts
  81. 54
      ui-ngx/src/app/modules/home/pages/agent/agent-applications-table-config.resolver.ts
  82. 31
      ui-ngx/src/app/modules/home/pages/agent/agent-deploy-dialog.service.ts
  83. 13
      ui-ngx/src/app/modules/home/pages/agent/agent-executions-side-panel.component.ts
  84. 11
      ui-ngx/src/app/modules/home/pages/agent/agent-install-instructions-dialog.component.scss
  85. 2
      ui-ngx/src/app/modules/home/pages/agent/agent-profile-create-dialog.service.ts
  86. 32
      ui-ngx/src/app/modules/home/pages/agent/agent-profile-created-dialog.component.html
  87. 49
      ui-ngx/src/app/modules/home/pages/agent/agent-profile-created-dialog.component.scss
  88. 5
      ui-ngx/src/app/modules/home/pages/agent/agent-profile-merged-profiles.component.ts
  89. 2
      ui-ngx/src/app/modules/home/pages/agent/agent-profiles-table-config.resolver.ts
  90. 2
      ui-ngx/src/app/modules/home/pages/agent/agents-table-config.resolver.ts
  91. 30
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-assign-compare-dialog.component.html
  92. 2
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-assign-compare-dialog.component.scss
  93. 15
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-event-progress-dialog.component.html
  94. 53
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-event-progress-dialog.component.scss
  95. 41
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-profile-upgrade-dialog.component.html
  96. 2
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-profile-upgrade-dialog.component.scss
  97. 18
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-version-warning-dialog.component.html
  98. 53
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-version-warning-dialog.component.scss
  99. 9
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-profile-assign-profile-dialog.component.scss
  100. 15
      ui-ngx/src/app/modules/home/pages/agent/dialog/agent-profile-assign-profile-dialog.component.ts

6
dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultAlarmQueryRepository.java

@ -46,6 +46,9 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
private static final Map<String, String> alarmFieldColumnMap = new HashMap<>();
private static final String SEVERITY_RANK = "case a." + ModelConstants.ALARM_SEVERITY_PROPERTY
+ " when 'CRITICAL' then 0 when 'MAJOR' then 1 when 'MINOR' then 2 when 'WARNING' then 3 when 'INDETERMINATE' then 4 else 5 end";
private static final Set<String> ALARM_TABLE_SORT_COLUMNS = Set.of(ModelConstants.CREATED_TIME_PROPERTY, ModelConstants.ALARM_ACK_TS_PROPERTY,
ModelConstants.ALARM_CLEAR_TS_PROPERTY, ModelConstants.ALARM_ASSIGN_TS_PROPERTY, ModelConstants.ALARM_END_TS_PROPERTY,
ModelConstants.ALARM_START_TS_PROPERTY, ModelConstants.ALARM_ACKNOWLEDGED_PROPERTY, ModelConstants.ALARM_CLEARED_PROPERTY,
@ -211,7 +214,8 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
if ("status".equalsIgnoreCase(sortOrderKey)) {
selectPart.append(", a.status as status ");
}
sortPart.append(alarmFieldColumnMap.getOrDefault(sortOrderKey, sortOrderKey))
String sortColumn = alarmFieldColumnMap.getOrDefault(sortOrderKey, sortOrderKey);
sortPart.append(ModelConstants.ALARM_SEVERITY_PROPERTY.equals(sortColumn) ? SEVERITY_RANK : sortColumn)
.append(" ").append(sortOrder.getDirection().name());
if (ownerScoped) {
sortPart.append(", a.created_time desc, a.id desc");

36
dao/src/test/java/org/thingsboard/server/dao/service/AlarmServiceTest.java

@ -800,6 +800,42 @@ public class AlarmServiceTest extends AbstractServiceTest {
Assert.assertTrue(firstPage.hasNext());
}
@Test
public void testSortAlarmDataBySeverityPriority() {
Device device = new Device();
device.setName("TestSeverityDevice");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
long ts = System.currentTimeMillis();
List<AlarmId> ids = new ArrayList<>();
for (AlarmSeverity severity : List.of(AlarmSeverity.INDETERMINATE, AlarmSeverity.CRITICAL, AlarmSeverity.WARNING, AlarmSeverity.MAJOR, AlarmSeverity.MINOR)) {
ids.add(alarmService.createAlarm(AlarmCreateOrUpdateActiveRequest.builder()
.tenantId(tenantId)
.originator(device.getId())
.type("Severity " + severity)
.severity(severity)
.startTs(ts).build()).getAlarm().getId());
}
List<AlarmId> byPriority = List.of(ids.get(1), ids.get(3), ids.get(4), ids.get(2), ids.get(0));
AlarmDataPageLink pageLink = new AlarmDataPageLink();
pageLink.setPage(0);
pageLink.setPageSize(10);
pageLink.setSortOrder(new EntityDataSortOrder(new EntityKey(EntityKeyType.ALARM_FIELD, "severity"), EntityDataSortOrder.Direction.ASC));
AlarmDataQuery ownerQuery = new AlarmDataQuery(null, pageLink, null, null, null, Collections.emptyList());
Assert.assertEquals(byPriority, alarmService.findAlarmDataByQuery(tenantId, null, mergedUserPermissions, ownerQuery)
.getData().stream().map(AlarmData::getId).toList());
Assert.assertEquals(byPriority, alarmService.findAlarmDataByQueryForEntities(tenantId, mergedUserPermissions, toQuery(pageLink), List.of(device.getId()))
.getData().stream().map(AlarmData::getId).toList());
pageLink.setSortOrder(new EntityDataSortOrder(new EntityKey(EntityKeyType.ALARM_FIELD, "severity"), EntityDataSortOrder.Direction.DESC));
Assert.assertEquals(byPriority.reversed(), alarmService.findAlarmDataByQuery(tenantId, null, mergedUserPermissions, ownerQuery)
.getData().stream().map(AlarmData::getId).toList());
}
private AlarmDataQuery toQuery(AlarmDataPageLink pageLink) {
return toQuery(pageLink, Collections.emptyList());
}

4
ui-ngx/src/app/core/http/ai-chat.service.ts

@ -50,10 +50,6 @@ export class AiChatService {
return this.http.get<Array<ChatMessage>>(`/api/ai/chats/${chatId}/messages`, defaultHttpOptionsFromConfig(config))
}
public generateDashboard(deviceId: string, timeseriesKeys?: string[], config?: RequestConfig): Observable<string> {
return this.http.post<string>(`/api/ai/devices/${deviceId}/dashboard`, { timeseriesKeys }, defaultHttpOptionsFromConfig(config));
}
public resolveToolApproval(result: ApprovalResult, config?: RequestConfig): Observable<ToolApprovalResult> {
return this.http.post<ToolApprovalResult>('/api/ai/tools/resolve-approval', result, defaultHttpOptionsFromConfig(config))
}

58
ui-ngx/src/app/core/services/ai-assistant-panel.service.ts

@ -215,6 +215,9 @@ export class AiAssistantPanelService implements OnDestroy {
}
toggle(): void {
if (this._suppressed() && !this._open()) {
return;
}
this._restored.set(false);
this._open.update(open => !open);
}
@ -317,6 +320,37 @@ export class AiAssistantPanelService implements OnDestroy {
}
});
private static readonly STARTED_KEY = 'tb-ai-panel-started';
private static readonly STARTED_MAX = 20;
private _startedByContext = signal<Record<string, string[]>>(AiAssistantPanelService.readStarted());
private static readStarted(): Record<string, string[]> {
try {
const stored = JSON.parse(AiAssistantPanelService.readSession(AiAssistantPanelService.STARTED_KEY) ?? '{}');
return stored && typeof stored === 'object' ? stored : {};
} catch {
return {};
}
}
noteStartedHere(chatId: string): void {
const key = this.contextKey();
if (!key) {
return;
}
this._startedByContext.update(started => {
const next = {...started, [key]: [chatId, ...(started[key] ?? []).filter(id => id !== chatId)].slice(0, AiAssistantPanelService.STARTED_MAX)};
AiAssistantPanelService.writeSession(AiAssistantPanelService.STARTED_KEY, JSON.stringify(next));
return next;
});
}
chatsStartedHere(): string[] {
const key = this.contextKey();
return key ? this._startedByContext()[key] ?? [] : [];
}
setLastChatId(id: string | undefined): void {
const key = this.contextKey();
if (!key) {
@ -341,10 +375,34 @@ export class AiAssistantPanelService implements OnDestroy {
}
openPanel(): void {
if (this._suppressed()) {
return;
}
this._restored.set(false);
this._open.set(true);
}
private _composed = signal<{text: string; fresh: boolean} | null>(null);
readonly composed = this._composed.asReadonly();
compose(text: string): void {
if (this._suppressed()) {
return;
}
this._composed.set({text, fresh: !this._open()});
this.openPanel();
}
composesFresh(): boolean {
return !!this._composed()?.fresh;
}
takeComposed(): {text: string; fresh: boolean} | null {
const composed = this._composed();
this._composed.set(null);
return composed;
}
setEnabled(enabled: boolean): void {
this._enabled.set(enabled);
if (enabled) {

5
ui-ngx/src/app/modules/home/components/agent/_agent-shared.scss

@ -93,10 +93,11 @@ $agent-type-generic-fg: #6a1b9a;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 4px 0;
font-size: 13px;
.label { color: $agent-text-secondary; }
.value { color: $agent-text-primary; font-weight: 500; }
.label { flex: none; color: $agent-text-secondary; }
.value { min-width: 0; color: $agent-text-primary; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
}
}

32
ui-ngx/src/app/modules/home/components/agent/agent-deploy-status.component.scss

@ -21,6 +21,12 @@
border: 1px solid $agent-divider-light;
border-radius: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
@media #{$mat-lt-sm} {
flex-wrap: wrap;
gap: 12px 16px;
padding: 16px;
}
}
.tb-deploy-card-icon {
@ -33,11 +39,22 @@
justify-content: center;
background: color-mix(in srgb, var(--tb-primary-500) 14%, transparent);
@media #{$mat-lt-sm} {
width: 44px;
height: 44px;
}
mat-icon {
color: var(--tb-primary-600, var(--tb-primary-500));
font-size: 32px;
width: 32px;
height: 32px;
@media #{$mat-lt-sm} {
font-size: 24px;
width: 24px;
height: 24px;
}
}
}
@ -58,6 +75,10 @@
font-size: 20px;
font-weight: 600;
color: $agent-text-primary;
@media #{$mat-lt-sm} {
font-size: 17px;
}
}
.tb-deploy-card-desc {
@ -85,6 +106,13 @@
align-items: flex-end;
gap: 6px;
flex-shrink: 0;
@media #{$mat-lt-sm} {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
width: 100%;
}
}
.tb-deploy-pill {
@ -181,6 +209,10 @@
transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
text-align: left;
@media #{$mat-lt-sm} {
padding: 16px;
}
&:hover {
border-color: color-mix(in srgb, var(--tb-primary-500) 40%, transparent);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

4
ui-ngx/src/app/modules/home/components/agent/component/agent-compose-diff.component.scss

@ -8,7 +8,7 @@ tb-agent-compose-diff {
.diff-viewer {
position: relative;
overflow: hidden;
height: clamp(220px, calc(85vh - 280px), 520px);
height: clamp(220px, calc(75vh - 240px), 520px);
width: 100%;
.acediff__wrap {
@ -32,7 +32,7 @@ tb-agent-compose-diff {
.ace_editor {
font-family: $agent-mono-font !important;
}
.ace_gutter { width: 44px !important; background: #f5f5f5; color: rgba(0, 0, 0, 0.42); }
.ace_gutter { width: 44px !important; background: $agent-surface-soft; color: $agent-ink-42; }
.ace_gutter-layer { width: 44px !important; }
.acediff__right .ace_gutter {

11
ui-ngx/src/app/modules/home/components/agent/component/agent-compose-diff.component.ts

@ -221,15 +221,20 @@ export class AgentComposeDiffComponent implements AfterViewInit, OnChanges, OnDe
requestAnimationFrame(() => this.whenReady(cb, frames - 1));
}
private scheduleRebuild(): void {
private scheduleRebuild(frames = 60): void {
if (this.rebuildHandle != null || this.destroyed) {
return;
}
this.rebuildHandle = requestAnimationFrame(() => {
this.rebuildHandle = null;
if (!this.destroyed) {
this.build();
if (this.destroyed) {
return;
}
if (this.differ && !this.ready && frames > 0) {
this.scheduleRebuild(frames - 1);
return;
}
this.build();
});
}

6
ui-ngx/src/app/modules/home/components/agent/component/agent-compose-editor.component.scss

@ -8,7 +8,7 @@ tb-agent-compose-editor {
.yaml-editor {
width: 100%; box-sizing: border-box; padding: 12px 14px;
border: 1px solid $agent-divider; border-radius: 4px;
background: $agent-surface-muted; color: #1f2328;
background: $agent-surface-muted; color: $agent-editor-fg;
font-family: $agent-mono-font;
font-size: 12px; line-height: 1.55; letter-spacing: 0;
tab-size: 2; -moz-tab-size: 2;
@ -16,7 +16,7 @@ tb-agent-compose-editor {
.yaml-editor-ace {
padding: 0;
height: clamp(220px, calc(85vh - 280px), 520px);
height: clamp(220px, calc(75vh - 240px), 520px);
overflow: hidden;
overscroll-behavior: contain;
.ace_editor {
@ -28,6 +28,6 @@ tb-agent-compose-editor {
.ace_content {
overscroll-behavior: contain;
}
.ace_gutter { background: #f5f5f5; color: rgba(0, 0, 0, 0.42); }
.ace_gutter { background: $agent-surface-soft; color: $agent-ink-42; }
}
}

59
ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.html

@ -4,18 +4,17 @@
SPDX-License-Identifier: BUSL-1.1
-->
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<div class="tb-install-wizard-toolbar-content">
<h2>{{ titleKey | translate }}</h2>
</div>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<h2>{{ titleKey | translate }}</h2>
<span class="flex-1"></span>
<div tb-help="agentProfileAutoProvision"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div mat-dialog-content class="tb-install-wizard-body">
<mat-stepper linear #stepper [labelPosition]="(stepperLabelPosition | async)">
<div mat-dialog-content>
<mat-stepper linear #stepper [labelPosition]="(stepperLabelPosition | async)"
(selectionChange)="selectedIndex = $event.selectedIndex">
<mat-step [completed]="canProceed()"
[label]="stepSelectKey | translate">
@ -98,16 +97,6 @@
}
</div>
</form>
<div class="step-footer">
<button mat-button type="button" (click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button color="primary" type="button"
[disabled]="!canProceed() || loading"
(click)="proceedToScript()">
<span>{{ 'action.next' | translate }}</span>
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
<mat-step [label]="stepScriptKey | translate">
@ -146,16 +135,30 @@
<span translate>edge.auto-provision-no-script</span>
</div>
}
<div class="step-footer">
<button mat-button type="button" (click)="cancel()">{{ 'action.close' | translate }}</button>
<button mat-raised-button color="primary" type="button" (click)="goToProfile()">
<mat-icon>open_in_new</mat-icon>
<span translate>agent.go-to-profile</span>
</button>
</div>
</mat-step>
</mat-stepper>
</div>
<div mat-dialog-actions>
@if (selectedIndex === 0) {
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end">
<button mat-stroked-button
color="primary"
[disabled]="!canProceed() || loading"
(click)="proceedToScript()">{{ 'action.next-with-label' | translate: { label: (stepScriptKey | translate) } }}</button>
</div>
<mat-divider class="w-full"></mat-divider>
}
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end gap-2">
<button mat-button
(click)="cancel()">{{ (selectedIndex === 0 ? 'action.cancel' : 'action.close') | translate }}</button>
@if (selectedIndex > 0) {
<button mat-raised-button
color="primary"
(click)="goToProfile()">
<mat-icon>open_in_new</mat-icon>
<span translate>agent.go-to-profile</span>
</button>
}
</div>
</div>

9
ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.scss

@ -2,14 +2,7 @@
// SPDX-License-Identifier: BUSL-1.1
@use '../wizard/agent-wizard' as *;
@include wizard-chrome;
:host {
display: block;
width: min(800px, 95vw);
min-width: 0;
max-width: 95vw;
}
@include wizard-stepper-dialog(800px);
.select-form {
display: block;

3
ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.component.ts

@ -58,6 +58,7 @@ export class AgentAutoProvisionDialogComponent
searchText = '';
loading = false;
selectedIndex = 0;
@ViewChild('stepper', { static: false }) stepper: MatStepper;
@ViewChild(MatAutocompleteTrigger) private autocompleteTrigger: MatAutocompleteTrigger;
@ -221,7 +222,7 @@ export class AgentAutoProvisionDialogComponent
return this.dialog.open<AgentProfileAssignProfileDialogComponent, AgentProfileAssignProfileDialogData, string[]>(
AgentProfileAssignProfileDialogComponent, {
disableClose: true,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: { selectedIds, lockedAppType: this.appType }
}
).afterClosed();

2
ui-ngx/src/app/modules/home/components/agent/dialog/agent-auto-provision-dialog.service.ts

@ -20,7 +20,7 @@ export class AgentAutoProvisionDialogService {
return this.dialog.open<AgentAutoProvisionDialogComponent, AgentAutoProvisionDialogData, boolean>(
AgentAutoProvisionDialogComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: { appType }
}
).afterClosed();

284
ui-ngx/src/app/modules/home/components/agent/wizard/_agent-wizard.scss

@ -4,96 +4,76 @@
@forward '../agent-shared';
@use '../agent-shared' as *;
@mixin wizard-chrome {
@mixin wizard-dialog($width) {
:host {
display: block;
width: min(1280px, 95vw);
min-width: 0;
max-width: 95vw;
height: 100%;
width: $width;
max-width: 100%;
display: grid;
grid-template-rows: min-content minmax(0, 1fr) min-content;
grid-template-columns: minmax(0, 1fr);
}
.tb-install-wizard-toolbar {
display: flex; align-items: center; gap: 8px;
padding: 0 16px;
min-height: 56px;
.tb-install-wizard-toolbar-content {
flex: 1; min-width: 0;
display: flex; flex-direction: row; align-items: center; gap: 8px;
h2 { font-size: 20px; font-weight: 400; margin: 0; color: inherit; }
span { font-size: 20px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:host-context(.mat-mdc-dialog-container) {
@media #{$mat-gt-xs} {
max-height: calc(100vh - 32px);
}
}
.tb-install-wizard-body.tb-install-wizard-embedded {
max-height: none !important;
overflow-y: visible !important;
padding: 8px 0 !important;
}
.mat-mdc-dialog-content {
overscroll-behavior: contain;
.tb-install-wizard-body {
// No vertical padding: the sticky stepper header sits flush at the top and the
// sticky footer flush at the bottom, with the content carrying its own spacing.
padding: 0 24px !important;
// Cap the dialog body to the viewport. Allow vertical scroll so tall step
// content (e.g. update/upgrade step 2 with config sections + summary card +
// info box + footer) can reach its buttons. The ace editors inside are
// clamped so they don't contribute unbounded height, and .acediff__wrap has
// its own overflow killed — so the only outer scrollbar that appears here
// is a legitimate chrome scroll when the step content genuinely overflows.
max-height: 85vh;
overflow-y: auto;
// Contain horizontal overscroll so two-finger trackpad swipes inside the
// ace editors / diff panes don't bubble up to the browser's back/forward
// page navigation. Also block vertical bounce from escaping the dialog.
overscroll-behavior: contain;
@media #{$mat-gt-xs} {
max-height: 75vh;
}
}
}
}
:host ::ng-deep .mat-horizontal-stepper-wrapper {
margin-top: 0;
}
@mixin wizard-stepper-dialog($width) {
@include wizard-dialog($width);
:host ::ng-deep .mat-horizontal-stepper-header-container {
margin-top: 0;
// Keep the step indicators (1)…(N) pinned at the top while content scrolls.
position: sticky;
top: 0;
z-index: 5;
background: #fff;
:host {
.dialog-actions-row {
padding: 8px;
}
}
:host ::ng-deep .mat-horizontal-stepper-header {
padding: 0 12px;
}
:host-context(.mat-mdc-dialog-container) {
.mat-mdc-dialog-content {
padding: 0;
scrollbar-gutter: stable;
}
:host ::ng-deep .mat-horizontal-content-container {
padding: 12px 0;
// Material defaults this to `overflow: hidden`, which makes it a scroll
// container and anchors the sticky `.step-footer` here (content height, so it
// never sticks). `clip` still clips the sliding steps but is NOT a scroll
// container, so the footer anchors to the scrolling `.tb-install-wizard-body`.
overflow: clip;
max-width: 100%;
.mat-mdc-dialog-actions {
padding: 0;
}
}
:host-context(.tb-fullscreen-dialog .mat-mdc-dialog-container) {
max-width: 100%;
:host ::ng-deep {
.mat-horizontal-stepper-header-container {
position: sticky;
top: 0;
z-index: 5;
background: #fff;
}
.tb-install-wizard-body {
max-width: 100%;
overflow-x: hidden;
.mat-horizontal-content-container,
.mat-vertical-content {
padding-top: 4px;
}
}
:host ::ng-deep .mat-step-header {
// Kill the hover/focus background — navigation works, but no visual fill.
&:hover,
&.cdk-program-focused,
&.cdk-mouse-focused,
&.cdk-focused {
background-color: transparent !important;
.mat-step-header {
&:hover,
&.cdk-program-focused,
&.cdk-mouse-focused,
&.cdk-focused {
background-color: transparent !important;
}
}
}
}
@mixin wizard-steps-locked {
:host ::ng-deep .tb-steps-locked .mat-step-header[aria-selected="false"] {
pointer-events: none;
cursor: default;
@ -107,22 +87,6 @@
color: $agent-text-hint !important;
}
}
.step-footer {
display: flex; align-items: center; justify-content: flex-end; gap: 8px;
padding: 12px 0; border-top: 1px solid $agent-divider-light; margin-top: 16px;
button mat-icon { font-size: 18px; width: 18px; height: 18px; }
}
// Pin the footer to the bottom of the scrolling body so its action buttons stay
// visible while tall step content scrolls. Skipped in embedded mode, where the
// body doesn't scroll (the host dialog does) and a sticky footer would misbehave.
.tb-install-wizard-body:not(.tb-install-wizard-embedded) .step-footer {
position: sticky;
bottom: 0;
z-index: 15;
background: #fff;
}
}
@mixin wizard-step-basics {
@ -172,23 +136,20 @@
mat-icon { font-size: 36px; width: 36px; height: 36px; color: var(--tb-primary-500); margin-bottom: 8px; }
h4 { font-size: 16px; font-weight: 500; margin: 0 0 4px; }
p { font-size: 13px; color: $agent-text-secondary; margin: 0; }
}
}
@mixin wizard-yaml-editor {
// Defensive: also contain overscroll on the editor hosts themselves, so even
// if a swipe lands directly on an ace editor (not on the body), it won't be
// interpreted as page navigation.
.diff-viewer,
.yaml-editor-ace {
overscroll-behavior: contain;
::ng-deep .ace_editor,
::ng-deep .ace_scroller,
::ng-deep .ace_content {
overscroll-behavior: contain;
@media #{$mat-lt-sm} {
display: grid;
grid-template-columns: 32px minmax(0, 1fr);
column-gap: 12px;
align-items: center;
padding: 12px 16px;
text-align: left;
mat-icon { grid-row: span 2; font-size: 32px; width: 32px; height: 32px; margin: 0; }
}
}
}
@mixin wizard-yaml-editor {
.tb-compose-panel {
box-shadow: none !important;
border: 1px solid $agent-divider;
@ -198,33 +159,6 @@
}
}
.yaml-editor {
width: 100%; box-sizing: border-box; padding: 12px 14px;
border: 1px solid $agent-divider; border-radius: 4px;
background: $agent-surface-muted; color: $agent-editor-fg;
font-family: $agent-mono-font;
font-size: 12px; line-height: 1.55; letter-spacing: 0;
tab-size: 2; -moz-tab-size: 2;
resize: vertical;
&:focus {
outline: none; border-color: var(--tb-primary-400);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--tb-primary-400) 15%, transparent);
}
}
// Ace-backed single editor (install mode and detail view) sits in the same
// .yaml-editor box but needs padding removed and a fixed height for ace layout.
.yaml-editor-ace {
padding: 0;
height: clamp(220px, calc(85vh - 280px), 520px);
overflow: hidden;
::ng-deep .ace_editor {
font-family: $agent-mono-font !important;
background: transparent;
}
::ng-deep .ace_gutter { background: $agent-surface-soft; color: $agent-ink-42; }
}
.pull-images { display: block; margin-top: 12px; }
// Compact, content-width toggle (Material defaults the group to full width).
@ -283,6 +217,8 @@
.diff-header {
flex: 1 1 50%; box-sizing: border-box; padding: 8px 12px; font-size: 12px; font-weight: 500;
letter-spacing: 0.3px;
min-width: 0; overflow-wrap: anywhere;
@media #{$mat-lt-sm} { padding: 6px 8px; font-size: 11px; }
& + .diff-header { border-left: 1px solid $agent-divider; padding-right: 36px; }
&.added { background: $agent-success-surface; color: $agent-color-success-dark; }
&.removed { background: #fce4ec; color: $agent-color-error-dark; }
@ -350,102 +286,6 @@
}
}
.diff-viewer {
position: relative;
overflow: hidden;
// Fit within the wizard body (which no longer scrolls). Chrome above/below
// the editor (toolbar + stepper header + name field + footer + padding) is
// roughly 280px; the clamp floors at 220px so very short viewports still
// show a usable editor and cap at 520px on large displays.
height: clamp(220px, calc(85vh - 280px), 520px);
width: 100%;
// ace-diff ships with `.acediff__wrap { overflow: auto }`. That creates an
// extra scrollbar wrapping the two editors + center gutter — the outer
// scrollbar the user sees. Force it hidden; each ace editor has its own
// internal scrollbar for the YAML content and that's the only one we want.
::ng-deep .acediff__wrap {
overflow: hidden !important;
}
border: 1px solid $agent-divider;
border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;
background: $agent-surface-muted;
// ace-diff overrides: narrow center gutter, unified monospace styling, tight gutters.
// flex: 0 0 60px is ace-diff's default — must override flex-basis, not just width,
// otherwise the element stays 60px and its grey background leaks around the arrows.
::ng-deep .acediff__gutter {
flex: 0 0 40px !important;
width: 40px !important;
background: #ffffff !important;
border-left: 1px solid $agent-divider-light !important;
border-right: 1px solid $agent-divider-light !important;
overflow: visible !important;
contain: layout paint style;
will-change: transform;
svg { width: 40px !important; background: transparent !important; }
}
::ng-deep .ace_editor {
font-family: $agent-mono-font !important;
}
::ng-deep .ace_gutter { width: 44px !important; background: $agent-surface-soft; color: $agent-ink-42; }
::ng-deep .ace_gutter-layer { width: 44px !important; }
// Flip the right pane's gutter to the right edge. Ace lays out .ace_gutter
// and .ace_scroller with absolute positioning (gutter: left 0; scroller: left
// <gutterWidth>). Overriding both moves the line numbers against the outer
// edge of the right pane, mirroring the left pane — numbers end up hugging
// both outside edges, with code meeting in the middle at the copy arrows.
::ng-deep .acediff__right .ace_gutter {
left: auto !important;
right: 0 !important;
border-left: 1px solid $agent-divider-light;
}
::ng-deep .acediff__right .ace_scroller {
left: 0 !important;
right: 44px !important;
}
::ng-deep .acediff__right .ace_scrollbar-v {
right: 44px !important;
}
// Hide the LEFT pane's vertical scrollbar — it overlaps the center gutter and
// covers ace-diff's copy-arrow circles. ace-diff keeps both editors scroll-
// synced internally, and the right pane still shows its own scrollbar, so
// vertical scrolling remains available via mouse wheel / right-side thumb.
::ng-deep .acediff__left .ace_scrollbar,
::ng-deep .acediff__left .ace_scrollbar-v {
display: none !important;
width: 0 !important;
}
// Pull the left pane's scroller flush to its right edge so no blank strip
// remains where the scrollbar used to sit.
::ng-deep .acediff__left .ace_scroller {
right: 0 !important;
}
// Raise the entire center gutter above the panes so nothing from either
// editor can occlude the copy-arrow SVGs.
::ng-deep .acediff__gutter {
z-index: 10;
}
::ng-deep .acediff__gutter svg,
::ng-deep .acediff__copy {
z-index: 11;
position: relative;
}
// The connector SVG paints over the copy arrows and swallows clicks.
// Make the whole gutter SVG click-through so the copy arrow <div>s stay hit-testable.
::ng-deep .acediff__gutter svg { pointer-events: none !important; }
::ng-deep .acediff__copy,
::ng-deep .acediff__copy--left,
::ng-deep .acediff__copy--right,
::ng-deep .acediff__copy--left div,
::ng-deep .acediff__copy--right div {
pointer-events: auto !important;
z-index: 12 !important;
}
}
.diff-hint {
font-size: 12px; color: $agent-text-secondary; margin: 6px 0 0;
}

601
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.html

@ -5,28 +5,33 @@
-->
@if (!embedded) {
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<mat-toolbar color="tb-primary" class="tb-bottom-border">
@if (showBack) {
<button mat-icon-button (click)="back.emit()" type="button" tabindex="-1">
<mat-icon>arrow_back</mat-icon>
<button mat-icon-button (click)="back.emit()" type="button">
<mat-icon class="material-icons">arrow_back</mat-icon>
</button>
}
<div class="tb-install-wizard-toolbar-content">
<h2>{{ 'agent.app-install-title' | translate }}@if (agent) {:}</h2>
@if (agent) {
<span class="flex-1">
{{ 'agent.app-install-on-agent' | translate: { name: agent?.name } }}
</span>
}
</div>
<h2>{{ 'agent.app-install-title' | translate }}@if (agent) {: {{ 'agent.app-install-on-agent' | translate: { name: agent?.name } }}}</h2>
<span class="flex-1"></span>
<div [tb-help]="helpLinkId"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
}
@if (embedded) {
<ng-container [ngTemplateOutlet]="body"></ng-container>
<ng-container [ngTemplateOutlet]="actions"></ng-container>
} @else {
<div mat-dialog-content>
<ng-container [ngTemplateOutlet]="body"></ng-container>
</div>
<div mat-dialog-actions>
<ng-container [ngTemplateOutlet]="actions"></ng-container>
</div>
}
<div mat-dialog-content class="tb-install-wizard-body" [class.tb-install-wizard-embedded]="embedded">
<ng-template #body>
@if (checkingManaged) {
<div class="loading-state">
@ -35,7 +40,7 @@
}
@if (!checkingManaged && managedApp) {
<div class="managed-block">
<div class="managed-block p-6">
<tb-agent-deploy-status
[agent]="managedAgent"
[application]="managedApp"
@ -43,17 +48,11 @@
(goToAgentApplication)="goToAgentApplication()"
(goToAgentEvents)="goToAgentEvents()">
</tb-agent-deploy-status>
<div class="step-footer">
<span class="flex-1"></span>
@if (!embedded) {
<button mat-button (click)="cancel()">{{ 'action.close' | translate }}</button>
}
</div>
</div>
}
@if (selectAgent && !embedded && !checkingManaged && !managedApp) {
<div class="tb-form-hint tb-primary-fill mb-4">
<div class="tb-form-hint tb-primary-fill mx-6 mt-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.deploy-via-agent-desc</span>
</div>
@ -62,302 +61,292 @@
@if (!checkingManaged && !managedApp) {
<mat-stepper linear #stepper
[class.tb-steps-locked]="!!installedApplication"
(selectionChange)="selectedIndex = $event.selectedIndex"
[orientation]="(stepperOrientation | async)"
[labelPosition]="(stepperLabelPosition | async)">
@if (selectAgent) {
<mat-step [label]="'agent.deploy-select-agent-step' | translate"
[completed]="canProceedFromAgent()"
[editable]="!installedApplication">
<p class="hint" translate>agent.deploy-intro</p>
<tb-agent-autocomplete
[ngModel]="agent"
(ngModelChange)="onSelectedAgentChange($event)">
</tb-agent-autocomplete>
<div class="step-footer">
<button mat-raised-button color="primary" matStepperNext [disabled]="!canProceedFromAgent()">
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
}
@if (!lockedType) {
<mat-step [label]="'agent.app-install-step1' | translate">
<p class="hint" translate>agent.app-install-pick-type</p>
<div class="type-cards">
@for (card of typeCards; track card.type) {
<button type="button" class="type-card"
[class.selected]="selectedType === card.type"
[disabled]="isTypeDisabled(card.type)"
[attr.aria-pressed]="selectedType === card.type"
(click)="selectType(card.type)">
<mat-icon>{{ card.icon }}</mat-icon>
<h4>{{ card.labelKey | translate }}</h4>
<p>{{ (unavailableTypes.has(card.type) ? 'agent.app-type-unavailable' : card.descKey) | translate }}</p>
</button>
}
</div>
@if (loadingTemplate) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-install-loading-template</span>
</div>
@for (step of steps; track step) {
@switch (step) {
@case ('agent') {
<mat-step [label]="stepLabels[step] | translate"
[completed]="canProceedFromAgent()"
[editable]="!installedApplication">
<p class="hint" translate>agent.deploy-intro</p>
<tb-agent-autocomplete
[ngModel]="agent"
(ngModelChange)="onSelectedAgentChange($event)">
</tb-agent-autocomplete>
</mat-step>
}
@if (loadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ loadError }}</span>
</div>
@case ('type') {
<mat-step [label]="stepLabels[step] | translate" [completed]="canProceedFromType()">
<p class="hint" translate>agent.app-install-pick-type</p>
<div class="type-cards">
@for (card of typeCards; track card.type) {
<button type="button" class="type-card"
[class.selected]="selectedType === card.type"
[disabled]="isTypeDisabled(card.type)"
[attr.aria-pressed]="selectedType === card.type"
(click)="selectType(card.type)">
<mat-icon>{{ card.icon }}</mat-icon>
<h4>{{ card.labelKey | translate }}</h4>
<p>{{ (unavailableTypes.has(card.type) ? 'agent.app-type-unavailable' : card.descKey) | translate }}</p>
</button>
}
</div>
@if (loadingTemplate) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-install-loading-template</span>
</div>
}
@if (loadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ loadError }}</span>
</div>
}
</mat-step>
}
<div class="step-footer">
@if (selectAgent) {
<button mat-button matStepperPrevious>
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
</button>
}
<button mat-raised-button color="primary" matStepperNext [disabled]="!canProceedFromType()">
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
}
<mat-step [label]="'agent.app-install-step3' | translate" [editable]="!installedApplication">
<div class="config-toggle">
<tb-toggle-select [(ngModel)]="useProfile" (ngModelChange)="toggleUseProfile($event)" appearance="fill" disablePagination>
<tb-toggle-option [value]="true">{{ 'agent.app-install-from-profile' | translate }}</tb-toggle-option>
<tb-toggle-option [value]="false">{{ 'agent.app-install-custom-config' | translate }}</tb-toggle-option>
</tb-toggle-select>
</div>
<mat-form-field class="mat-block" appearance="outline">
<mat-label translate>agent.app-install-name</mat-label>
<input matInput [(ngModel)]="appName" required>
</mat-form-field>
@if (canHaveRelatedEntity) {
<tb-agent-related-entity-autocomplete
[appType]="selectedType"
[disabled]="!!lockedRelatedEntity"
[required]="relatedEntityRequired"
allowCreate
[ngModel]="relatedEntityId"
(ngModelChange)="relatedEntityId = $event; onRelatedEntityChange($event)"
(relatedEntityNameChange)="onRelatedEntityName($event)">
</tb-agent-related-entity-autocomplete>
}
@if (useProfile && typesWithoutTemplates.has(selectedType)) {
<div class="tb-form-hint tb-primary-fill tb-form-hint-warning mb-4">
<mat-icon>warning_amber</mat-icon>
<span translate>agent.app-no-templates</span>
</div>
}
@if (useProfile) {
<mat-form-field class="mat-block" appearance="outline" [formGroup]="profileSelectFormGroup">
<mat-label translate>agent.app-install-select-profile</mat-label>
<input matInput type="text" required
#profileInput
formControlName="profile"
[matAutocomplete]="profileAutocomplete">
@if (profileSelectFormGroup.get('profile').value) {
<button type="button"
matSuffix mat-icon-button aria-label="Clear"
(click)="clearProfile()">
<mat-icon class="material-icons">close</mat-icon>
</button>
}
@if (!profileSelectFormGroup.get('profile').value && canCreateProfileForType) {
<button
mat-button color="primary" matSuffix type="button"
(mousedown)="$event.preventDefault()"
(click)="createProfile($event)">
<span style="white-space: nowrap">{{ 'agent.deploy-create-new' | translate }}</span>
</button>
}
<mat-autocomplete class="tb-autocomplete"
#profileAutocomplete="matAutocomplete"
[displayWith]="displayProfileFn">
@if (filteredProfiles | async; as profiles) {
@for (p of profiles; track trackKey(p)) {
<mat-option [value]="p" class="tb-profile-option"
[matTooltip]="isVirtualProfile(p) ? ('agent.app-install-virtual-profile-hint' | translate) : ''"
matTooltipPosition="right">
<span>{{ p.name }}</span>
@if (isVirtualProfile(p)) {
<span class="tb-virtual-profile-badge">{{ 'agent.app-install-virtual-profile-badge' | translate }}</span>
}
@if (!isVirtualProfile(p) && p.templateVersion) {
<span class="tb-profile-template-version">{{ profileTemplateLabel(p) }}</span>
@case ('config') {
<mat-step [label]="stepLabels[step] | translate" [completed]="canSubmit() || !!installedApplication"
[editable]="!installedApplication">
<div class="config-toggle">
<tb-toggle-select class="xs:w-full" [(ngModel)]="useProfile" (ngModelChange)="toggleUseProfile($event)" appearance="fill" disablePagination>
<tb-toggle-option [value]="true">{{ 'agent.app-install-from-profile' | translate }}</tb-toggle-option>
<tb-toggle-option [value]="false">{{ 'agent.app-install-custom-config' | translate }}</tb-toggle-option>
</tb-toggle-select>
</div>
<mat-form-field class="mat-block" appearance="outline">
<mat-label translate>agent.app-install-name</mat-label>
<input matInput [(ngModel)]="appName" required>
</mat-form-field>
@if (canHaveRelatedEntity) {
<tb-agent-related-entity-autocomplete
[appType]="selectedType"
[disabled]="!!lockedRelatedEntity"
[required]="relatedEntityRequired"
allowCreate
[ngModel]="relatedEntityId"
(ngModelChange)="relatedEntityId = $event; onRelatedEntityChange($event)"
(relatedEntityNameChange)="onRelatedEntityName($event)">
</tb-agent-related-entity-autocomplete>
}
@if (useProfile && typesWithoutTemplates.has(selectedType)) {
<div class="tb-form-hint tb-primary-fill tb-form-hint-warning mb-4">
<mat-icon>warning_amber</mat-icon>
<span translate>agent.app-no-templates</span>
</div>
}
@if (useProfile) {
<mat-form-field class="mat-block" appearance="outline" [formGroup]="profileSelectFormGroup">
<mat-label translate>agent.app-install-select-profile</mat-label>
<input matInput type="text" required
#profileInput
formControlName="profile"
[matAutocomplete]="profileAutocomplete">
@if (profileSelectFormGroup.get('profile').value) {
<button type="button"
matSuffix mat-icon-button aria-label="Clear"
(click)="clearProfile()">
<mat-icon class="material-icons">close</mat-icon>
</button>
}
@if (!profileSelectFormGroup.get('profile').value && canCreateProfileForType) {
<button
mat-button color="primary" matSuffix type="button"
(mousedown)="$event.preventDefault()"
(click)="createProfile($event)">
<span style="white-space: nowrap">{{ 'agent.deploy-create-new' | translate }}</span>
</button>
}
<mat-autocomplete class="tb-autocomplete"
#profileAutocomplete="matAutocomplete"
[displayWith]="displayProfileFn">
@if (filteredProfiles | async; as profiles) {
@for (p of profiles; track trackKey(p)) {
<mat-option [value]="p" class="tb-profile-option"
[matTooltip]="isVirtualProfile(p) ? ('agent.app-install-virtual-profile-hint' | translate) : ''"
matTooltipPosition="right">
<span>{{ p.name }}</span>
@if (isVirtualProfile(p)) {
<span class="tb-virtual-profile-badge">{{ 'agent.app-install-virtual-profile-badge' | translate }}</span>
}
@if (!isVirtualProfile(p) && p.templateVersion) {
<span class="tb-profile-template-version">{{ profileTemplateLabel(p) }}</span>
}
</mat-option>
}
@if (!profiles.length) {
<mat-option [value]="null" disabled class="tb-not-found">
<div class="tb-not-found-content">
<span translate>agent.app-install-no-profiles</span>
</div>
</mat-option>
}
}
</mat-option>
</mat-autocomplete>
</mat-form-field>
}
@if (loadingProfiles) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-install-loading-template</span>
</div>
}
<tb-agent-app-step-inputs [bindings]="bindings"></tb-agent-app-step-inputs>
@if (useProfile && selectedProfile && !isVirtualProfile(selectedProfile)) {
<div class="tb-compare-actions">
<button mat-stroked-button color="primary" type="button" (click)="openEditProfile()">
<mat-icon>edit</mat-icon>
<span>{{ 'agent.app-update-edit-profile' | translate }}</span>
</button>
</div>
}
@if (useProfile && selectedProfile) {
<mat-expansion-panel class="tb-compose-panel">
<mat-expansion-panel-header>
<mat-panel-title translate>agent.app-install-yaml</mat-panel-title>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<tb-agent-compose-editor [value]="composeYaml" [readOnly]="useProfile && !!selectedProfile"></tb-agent-compose-editor>
</ng-template>
</mat-expansion-panel>
}
@if (mergeError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ mergeError }}</span>
</div>
}
@if (!useProfile && !template && loadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ loadError }}</span>
</div>
} @else if (!useProfile) {
@if (composeTypeKeys.length > 1) {
<mat-form-field class="mat-block" appearance="outline">
<mat-label translate>agent.app-compose-template-select</mat-label>
<mat-select [value]="composeType" (selectionChange)="onComposeTypeChange($event.value)">
@for (key of composeTypeKeys; track key) {
<mat-option [value]="key">
{{ composeTypeLabel(key) }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
@if (!profiles.length) {
<mat-option [value]="null" disabled class="tb-not-found">
<div class="tb-not-found-content">
<span translate>agent.app-install-no-profiles</span>
</div>
</mat-option>
@if (relatedEntityId) {
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-compose-creds-overridden-hint</span>
</div>
}
<div class="diff-header-row">
<div class="diff-header added" translate>agent.app-install-diff-template</div>
<div class="diff-header removed" translate>agent.app-install-diff-editable</div>
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="proposedYaml" [right]="currentYaml" [syncScroll]="diffSyncScroll" (rightChange)="composeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-install-diff-hint</p>
}
</mat-autocomplete>
</mat-form-field>
}
@if (loadingProfiles) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-install-loading-template</span>
</div>
}
<tb-agent-app-step-inputs [bindings]="bindings"></tb-agent-app-step-inputs>
@if (useProfile && selectedProfile && !isVirtualProfile(selectedProfile)) {
<div class="tb-compare-actions">
<button mat-stroked-button color="primary" type="button" (click)="openEditProfile()">
<mat-icon>edit</mat-icon>
<span>{{ 'agent.app-update-edit-profile' | translate }}</span>
</button>
</div>
}
@if (useProfile && selectedProfile) {
<mat-expansion-panel class="tb-compose-panel">
<mat-expansion-panel-header>
<mat-panel-title translate>agent.app-install-yaml</mat-panel-title>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<tb-agent-compose-editor [value]="composeYaml" [readOnly]="useProfile && !!selectedProfile"></tb-agent-compose-editor>
</ng-template>
</mat-expansion-panel>
}
@if (mergeError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ mergeError }}</span>
</div>
}
@if (!useProfile && !template && loadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ loadError }}</span>
</div>
} @else if (!useProfile) {
@if (composeTypeKeys.length > 1) {
<mat-form-field class="mat-block" appearance="outline">
<mat-label translate>agent.app-compose-template-select</mat-label>
<mat-select [value]="composeType" (selectionChange)="onComposeTypeChange($event.value)">
@for (key of composeTypeKeys; track key) {
<mat-option [value]="key">
{{ composeTypeLabel(key) }}
</mat-option>
</mat-step>
}
@case ('summary') {
<mat-step [label]="stepLabels[step] | translate" [completed]="!!installedApplication"
[editable]="!installedApplication">
<div class="summary-card">
<div class="summary-row">
<span class="label" translate>agent.app-name</span>
<span class="value">{{ appName }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-type</span>
<span class="value"><span class="tb-type-badge"
[class.edge]="selectedType === 'EDGE'"
[class.gateway]="selectedType === 'GATEWAY'"
[class.generic]="selectedType === 'GENERIC'">{{ selectedType }}</span></span>
</div>
@if (template) {
<div class="summary-row">
<span class="label" translate>agent.app-template</span>
<span class="value">{{ template.appType }} {{ template.currentVersion }}</span>
</div>
}
</mat-select>
</mat-form-field>
@if (useProfile && selectedProfile) {
<div class="summary-row">
<span class="label" translate>agent.app-install-select-profile</span>
<span class="value">{{ selectedProfile.name }}</span>
</div>
}
@if (agent) {
<div class="summary-row">
<span class="label" translate>agent.agents</span>
<span class="value">{{ agent.name }}</span>
</div>
}
</div>
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-install-confirm-info</span>
</div>
</mat-step>
}
@if (relatedEntityId) {
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-compose-creds-overridden-hint</span>
</div>
@case ('deploy') {
<mat-step [label]="stepLabels[step] | translate">
<tb-agent-deploy-status
[agent]="agent"
[application]="installedApplication"
(goToAgent)="goToAgent()"
(goToAgentApplication)="goToAgentApplication()"
(goToAgentEvents)="goToAgentEvents()">
</tb-agent-deploy-status>
</mat-step>
}
<div class="diff-header-row">
<div class="diff-header added" translate>agent.app-install-diff-template</div>
<div class="diff-header removed" translate>agent.app-install-diff-editable</div>
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="proposedYaml" [right]="currentYaml" [syncScroll]="diffSyncScroll" (rightChange)="composeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-install-diff-hint</p>
}
<div class="step-footer">
@if (!installedApplication) {
<button mat-button matStepperPrevious [disabled]="submitting">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
</button>
}
<button mat-raised-button color="primary" matStepperNext [disabled]="!canSubmit()">
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
<mat-step [label]="'agent.app-install-step4' | translate" [completed]="!!installedApplication"
[editable]="!installedApplication">
<div class="summary-card">
<div class="summary-row">
<span class="label" translate>agent.app-name</span>
<span class="value">{{ appName }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-type</span>
<span class="value"><span class="tb-type-badge"
[class.edge]="selectedType === 'EDGE'"
[class.gateway]="selectedType === 'GATEWAY'"
[class.generic]="selectedType === 'GENERIC'">{{ selectedType }}</span></span>
</div>
@if (template) {
<div class="summary-row">
<span class="label" translate>agent.app-template</span>
<span class="value">{{ template.appType }} {{ template.currentVersion }}</span>
</div>
}
@if (useProfile && selectedProfile) {
<div class="summary-row">
<span class="label" translate>agent.app-install-select-profile</span>
<span class="value">{{ selectedProfile.name }}</span>
</div>
}
@if (agent) {
<div class="summary-row">
<span class="label" translate>agent.agents</span>
<span class="value">{{ agent.name }}</span>
</div>
}
</div>
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-install-confirm-info</span>
</div>
<div class="step-footer">
@if (!installedApplication) {
<button mat-button matStepperPrevious [disabled]="submitting">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
</button>
}
@if (!installedApplication) {
<button mat-raised-button color="primary"
(click)="submit()" [disabled]="!canSubmit()">
<mat-icon>save</mat-icon>
<span>{{ 'agent.app-install-cta' | translate }}</span>
</button>
}
@if (installedApplication) {
<button mat-raised-button color="primary" matStepperNext>
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
}
</div>
</mat-step>
@if (selectAgent) {
<mat-step [label]="'agent.deploy-install-step' | translate">
<tb-agent-deploy-status
[agent]="agent"
[application]="installedApplication"
(goToAgent)="goToAgent()"
(goToAgentApplication)="goToAgentApplication()"
(goToAgentEvents)="goToAgentEvents()">
</tb-agent-deploy-status>
<div class="step-footer">
<span class="flex-1"></span>
@if (!embedded) {
<button mat-button (click)="cancel()">{{ 'action.close' | translate }}</button>
}
</div>
</mat-step>
}
</mat-stepper>
}
</div>
</ng-template>
<ng-template #actions>
@if (!checkingManaged && !managedApp && (canGoBack() || showNext())) {
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end">
@if (canGoBack()) {
<button mat-stroked-button
[disabled]="submitting"
(click)="stepper.previous()">{{ 'action.back' | translate }}</button>
}
<span class="flex-1"></span>
@if (showNext()) {
<button mat-stroked-button
color="primary"
[disabled]="!canGoNext()"
(click)="stepper.next()">{{ 'action.next-with-label' | translate: { label: (nextStepLabel() | translate) } }}</button>
}
</div>
@if (!embedded || canInstall()) {
<mat-divider class="w-full"></mat-divider>
}
}
@if (!embedded || canInstall()) {
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end gap-2">
@if (!embedded) {
<button mat-button
[disabled]="submitting"
(click)="cancel()">{{ (managedApp || installedApplication ? 'action.close' : 'action.cancel') | translate }}</button>
}
@if (canInstall()) {
<button mat-raised-button
color="primary"
[disabled]="currentStep() !== 'summary' || !canSubmit()"
(click)="submit()">{{ 'agent.app-install-cta' | translate }}</button>
}
</div>
}
</ng-template>

10
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.scss

@ -2,10 +2,18 @@
// SPDX-License-Identifier: BUSL-1.1
@use 'agent-wizard' as *;
@include wizard-chrome;
@include wizard-stepper-dialog(1280px);
@include wizard-step-basics;
@include wizard-type-cards;
@include wizard-yaml-editor;
@include wizard-diff;
@include wizard-summary;
@include agent-virtual-profile-badge;
@include wizard-steps-locked;
:host(.tb-embedded) {
display: block;
width: auto;
height: auto;
max-height: none;
}

87
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-flow.component.ts

@ -38,22 +38,28 @@ import {
buildVirtualAppProfiles,
VIRTUAL_APP_TYPES
} from '@home/pages/agent/util/virtual-app-profiles';
import {
AgentAppProfileWizardComponent,
AgentAppProfileWizardData
} from '@home/pages/agent/wizard/agent-app-profile-wizard.component';
import { openAgentAppProfileWizard } from '@home/pages/agent/wizard/agent-app-profile-wizard-dialog';
import { UserPermissionsService } from '@core/http/user-permissions.service';
import { Operation, Resource } from '@shared/models/security.models';
import { AgentAppWizardLoaderService } from '@home/pages/agent/wizard/agent-app-wizard-loader.service';
import { AgentAppWizardSubmitService } from '@home/pages/agent/wizard/agent-app-wizard-submit.service';
import { AgentAppUpgradeResult, AgentAppWizardFinish, AgentTypeCard } from '@home/pages/agent/wizard/agent-app-wizard.models';
import {
AGENT_APP_INSTALL_STEP_LABELS,
AgentAppInstallStepKey,
AgentAppUpgradeResult,
AgentAppWizardFinish,
AgentTypeCard
} from '@home/pages/agent/wizard/agent-app-wizard.models';
import { EdgeTemplateCompatibilityService } from '@home/pages/agent/util/edge-template-compatibility.service';
@Component({
selector: 'tb-agent-app-install-flow',
templateUrl: './agent-app-install-flow.component.html',
styleUrls: ['./agent-app-install-flow.component.scss'],
standalone: false
standalone: false,
host: {
'[class.tb-embedded]': 'embedded'
}
})
export class AgentAppInstallFlowComponent extends PageComponent implements OnInit {
@ -82,6 +88,9 @@ export class AgentAppInstallFlowComponent extends PageComponent implements OnIni
@ViewChild('stepper', { static: false })
stepper: MatStepper;
readonly stepLabels = AGENT_APP_INSTALL_STEP_LABELS;
steps: AgentAppInstallStepKey[] = [];
selectedIndex = 0;
bindings: StepBinding[] = [];
@ -207,6 +216,7 @@ export class AgentAppInstallFlowComponent extends PageComponent implements OnIni
}
ngOnInit() {
this.steps = this.buildSteps();
this.relatedEntityId = this.lockedRelatedEntity || null;
if (this.selectAgent && this.lockedRelatedEntity?.id && this.lockedRelatedEntity?.entityType) {
this.checkingManaged = true;
@ -402,12 +412,7 @@ export class AgentAppInstallFlowComponent extends PageComponent implements OnIni
const appType = this.selectedType || this.lockedType;
if (!appType) { return; }
const presetName = this.relatedEntityName ? `${this.relatedEntityName} profile` : undefined;
this.dialog.open<AgentAppProfileWizardComponent, AgentAppProfileWizardData, AgentAppProfile>(
AgentAppProfileWizardComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: { lockedAppType: appType, presetName }
}).afterClosed().subscribe(saved => {
openAgentAppProfileWizard(this.dialog, { lockedAppType: appType, presetName }).subscribe(saved => {
if (saved) {
this.availableProfiles = [
...this.availableProfiles.filter(p => !(isVirtualAppProfile(p) && p.templateVersion === saved.templateVersion)),
@ -421,12 +426,7 @@ export class AgentAppInstallFlowComponent extends PageComponent implements OnIni
openEditProfile() {
if (!this.selectedProfile || isVirtualAppProfile(this.selectedProfile)) { return; }
this.dialog.open<AgentAppProfileWizardComponent, AgentAppProfileWizardData, AgentAppProfile>(
AgentAppProfileWizardComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: { profile: this.selectedProfile }
}).afterClosed().subscribe(saved => {
openAgentAppProfileWizard(this.dialog, { profile: this.selectedProfile }).subscribe(saved => {
if (saved) {
this.availableProfiles = this.availableProfiles.map(p => p.id?.id === saved.id?.id ? saved : p);
this.cacheRealProfiles(saved.appType);
@ -731,4 +731,55 @@ export class AgentAppInstallFlowComponent extends PageComponent implements OnIni
cancel() {
this.cancelled.emit(null);
}
currentStep(): AgentAppInstallStepKey | undefined {
return this.steps[this.selectedIndex];
}
canGoBack(): boolean {
return this.selectedIndex > 0 && !this.installedApplication;
}
canInstall(): boolean {
return !this.checkingManaged && !this.managedApp && !this.installedApplication;
}
showNext(): boolean {
const hasNext = this.selectedIndex < this.steps.length - 1;
return hasNext && (this.currentStep() !== 'summary' || !!this.installedApplication);
}
canGoNext(): boolean {
switch (this.currentStep()) {
case 'agent':
return this.canProceedFromAgent();
case 'type':
return this.canProceedFromType();
case 'config':
return this.canSubmit();
case 'summary':
return !!this.installedApplication;
default:
return false;
}
}
nextStepLabel(): string {
return this.stepLabels[this.steps[this.selectedIndex + 1]] ?? '';
}
private buildSteps(): AgentAppInstallStepKey[] {
const keys: AgentAppInstallStepKey[] = [];
if (this.selectAgent) {
keys.push('agent');
}
if (!this.lockedType) {
keys.push('type');
}
keys.push('config', 'summary');
if (this.selectAgent) {
keys.push('deploy');
}
return keys;
}
}

22
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard-dialog.ts

@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { MatDialog } from '@angular/material/dialog';
import { Observable } from 'rxjs';
import {
AgentAppInstallWizardComponent,
AgentAppInstallWizardData,
AgentAppInstallWizardResult
} from '@home/components/agent/wizard/agent-app-install-wizard.component';
export function openAgentAppInstallWizard(
dialog: MatDialog,
data: AgentAppInstallWizardData
): Observable<AgentAppInstallWizardResult> {
return dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data
}
).afterClosed();
}

5
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard.component.scss

@ -1,5 +0,0 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use 'agent-wizard' as *;
@include wizard-chrome;

1
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-install-wizard.component.ts

@ -47,7 +47,6 @@ export { isAgentAppUpgradeResult } from '@home/pages/agent/wizard/agent-app-wiza
@Component({
selector: 'tb-agent-app-install-wizard',
templateUrl: './agent-app-install-wizard.component.html',
styleUrls: ['./agent-app-install-wizard.component.scss'],
standalone: false,
providers: [AgentAppWizardLoaderService, AgentAppWizardSubmitService]
})

72
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.html

@ -5,36 +5,28 @@
-->
@if (!embedded) {
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<mat-toolbar color="tb-primary" class="tb-bottom-border">
@if (showBack) {
<button mat-icon-button (click)="back.emit()" type="button" tabindex="-1">
<mat-icon>arrow_back</mat-icon>
<button mat-icon-button (click)="back.emit()" type="button">
<mat-icon class="material-icons">arrow_back</mat-icon>
</button>
}
<div class="tb-install-wizard-toolbar-content">
<h2>{{ 'agent.app-update-wizard-title' | translate }}@if (existingApplication) {
:
}</h2>
@if (existingApplication) {
<span class="flex-1">
{{ 'agent.app-update-on-app' | translate: { name: existingApplication?.name } }}
</span>
}
</div>
<h2>{{ 'agent.app-update-wizard-title' | translate }}@if (existingApplication) {: {{ 'agent.app-update-on-app' | translate: { name: existingApplication?.name } }}}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppUpdate"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
}
<div mat-dialog-content class="tb-install-wizard-body" [class.tb-install-wizard-embedded]="embedded">
<div mat-dialog-content>
<mat-stepper linear #stepper
(selectionChange)="selectedIndex = $event.selectedIndex"
[orientation]="(stepperOrientation | async)"
[labelPosition]="(stepperLabelPosition | async)">
<mat-step [label]="'agent.app-install-step3' | translate">
<mat-step [label]="'agent.app-install-step3' | translate" [completed]="canSubmit()">
<mat-form-field class="mat-block" appearance="outline">
<mat-label translate>agent.app-install-name</mat-label>
@ -124,13 +116,6 @@
<tb-agent-compose-diff [left]="currentYaml" [right]="futureYaml" [readOnly]="readOnlyCompare" [syncScroll]="diffSyncScroll"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-update-compare-hint</p>
}
<div class="step-footer">
<button mat-raised-button color="primary" matStepperNext [disabled]="!canSubmit()">
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
<mat-step [label]="'agent.app-install-step4' | translate">
@ -171,18 +156,33 @@
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-install-confirm-info</span>
</div>
<div class="step-footer">
<button mat-button matStepperPrevious [disabled]="submitting">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
</button>
<button mat-raised-button color="primary" (click)="submit()" [disabled]="!canSubmit()">
<mat-icon>save</mat-icon>
<span>{{ 'agent.app-update-cta' | translate }}</span>
</button>
</div>
</mat-step>
</mat-stepper>
</div>
<div mat-dialog-actions>
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end">
@if (selectedIndex > 0) {
<button mat-stroked-button
[disabled]="submitting"
(click)="stepper.previous()">{{ 'action.back' | translate }}</button>
}
<span class="flex-1"></span>
@if (selectedIndex === 0) {
<button mat-stroked-button
color="primary"
[disabled]="!canSubmit()"
(click)="stepper.next()">{{ 'action.next-with-label' | translate: { label: ('agent.app-install-step4' | translate) } }}</button>
}
</div>
<mat-divider class="w-full"></mat-divider>
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end gap-2">
<button mat-button
[disabled]="submitting"
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button
color="primary"
[disabled]="selectedIndex !== 1 || !canSubmit()"
(click)="submit()">{{ 'agent.app-update-cta' | translate }}</button>
</div>
</div>

2
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.scss

@ -2,7 +2,7 @@
// SPDX-License-Identifier: BUSL-1.1
@use 'agent-wizard' as *;
@include wizard-chrome;
@include wizard-stepper-dialog(1280px);
@include wizard-step-basics;
@include wizard-config-section;
@include wizard-diff;

14
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-update-flow.component.ts

@ -23,10 +23,7 @@ import { buildStepInputs, createStepBinding, StepBinding } from '@home/pages/age
import { buildUpdateApplication } from '@home/pages/agent/util/agent-app-payloads';
import { buildUpdateMergeDraft } from '@home/pages/agent/util/agent-app-compose-preview';
import { composeTemplateKeys, composeTypeLabelKey, dumpCompose, pickComposeType } from '@home/pages/agent/util/agent-compose-yaml';
import {
AgentAppProfileWizardComponent,
AgentAppProfileWizardData
} from '@home/pages/agent/wizard/agent-app-profile-wizard.component';
import { openAgentAppProfileWizard } from '@home/pages/agent/wizard/agent-app-profile-wizard-dialog';
import { AgentAppWizardLoaderService } from '@home/pages/agent/wizard/agent-app-wizard-loader.service';
import { AgentAppWizardSubmitService } from '@home/pages/agent/wizard/agent-app-wizard-submit.service';
import { AgentAppUpgradeResult, AgentAppWizardFinish } from '@home/pages/agent/wizard/agent-app-wizard.models';
@ -52,6 +49,8 @@ export class AgentAppUpdateFlowComponent extends PageComponent implements OnInit
@Output() cancelled = new EventEmitter<AgentAppUpgradeResult | null>();
@Output() back = new EventEmitter<void>();
selectedIndex = 0;
bindings: StepBinding[] = [];
proposedYaml = '';
@ -237,12 +236,7 @@ export class AgentAppUpdateFlowComponent extends PageComponent implements OnInit
openEditProfile() {
if (!this.profileForCompare) { return; }
this.dialog.open<AgentAppProfileWizardComponent, AgentAppProfileWizardData, AgentAppProfile>(
AgentAppProfileWizardComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: { profile: this.profileForCompare }
}).afterClosed().subscribe(saved => {
openAgentAppProfileWizard(this.dialog, { profile: this.profileForCompare }).subscribe(saved => {
if (saved) {
this.profileForCompare = saved;
this.refreshFutureCompare();

294
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.html

@ -5,30 +5,21 @@
-->
@if (!embedded) {
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<mat-toolbar color="tb-primary" class="tb-bottom-border">
@if (showBack) {
<button mat-icon-button (click)="back.emit()" type="button" tabindex="-1">
<mat-icon>arrow_back</mat-icon>
<button mat-icon-button (click)="back.emit()" type="button">
<mat-icon class="material-icons">arrow_back</mat-icon>
</button>
}
<div class="tb-install-wizard-toolbar-content">
<h2>{{ 'agent.app-upgrade-title' | translate }}@if (existingApplication) {
:
}</h2>
@if (existingApplication) {
<span class="flex-1">
{{ 'agent.app-upgrade-heading' | translate: { name: existingApplication?.name, from: fromVersion || '—', to: toVersion || '—' } }}
</span>
}
</div>
<h2>{{ 'agent.app-upgrade-title' | translate }}@if (existingApplication) {: {{ 'agent.app-upgrade-heading' | translate: { name: existingApplication?.name, from: fromVersion || '—', to: toVersion || '—' } }}}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppUpgrade"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
}
<div mat-dialog-content class="tb-install-wizard-body" [class.tb-install-wizard-embedded]="embedded">
<div mat-dialog-content>
@if (loadingTemplate || loadingProfile) {
<div class="loading-state">
@ -45,143 +36,154 @@
@if (!(loadingTemplate || loadingProfile || loadError)) {
<mat-stepper linear #stepper
(selectionChange)="selectedIndex = $event.selectedIndex"
[orientation]="(stepperOrientation | async)"
[labelPosition]="(stepperLabelPosition | async)">
@if (showProfileUpgradeStep) {
<mat-step [label]="'agent.app-upgrade-profile-step' | translate"
[completed]="profileUpgraded">
@if (loadingProfile) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-upgrade-profile-loading</span>
</div>
@for (step of steps; track step) {
@switch (step) {
@case ('profile') {
<mat-step [label]="stepLabels[step] | translate"
[completed]="profileUpgraded">
@if (loadingProfile) {
<div class="loading-state">
<mat-spinner diameter="20"></mat-spinner>
<span translate>agent.app-upgrade-profile-loading</span>
</div>
}
@if (!loadingProfile && profileLoadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ profileLoadError }}</span>
</div>
}
@if (!loadingProfile && !profileLoadError && profile && template) {
<div class="summary-card" style="margin-bottom: 16px;">
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-profile-name</span>
<span class="value">{{ profile.name }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-versions</span>
<span class="value">{{ fromVersion || '—' }} → {{ toVersion || '—' }}</span>
</div>
</div>
<p class="hint" translate>agent.app-upgrade-profile-hint</p>
<div class="diff-header-row">
<div class="diff-header added">
{{ 'agent.app-upgrade-template-new' | translate: { version: toVersion || '—' } }}
</div>
<div class="diff-header removed" translate>agent.app-upgrade-profile-current</div>
@if (profileUpgraded) {
<div class="diff-readonly-chip">
<mat-icon>lock</mat-icon>
<span translate>agent.app-diff-read-only</span>
</div>
}
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="profileProposedYaml" [right]="profileCurrentYaml" [readOnly]="profileUpgraded" [syncScroll]="diffSyncScroll" (rightChange)="profileComposeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-upgrade-diff-hint</p>
}
</mat-step>
}
@if (!loadingProfile && profileLoadError) {
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ profileLoadError }}</span>
</div>
@case ('config') {
<mat-step [label]="stepLabels[step] | translate" [completed]="canSubmit()">
@if (canHaveRelatedEntity && isProfileBoundUpgrade) {
<tb-agent-related-entity-autocomplete
[appType]="selectedType || existingApplication?.appType"
[disabled]="!!lockedRelatedEntity"
[required]="relatedEntityRequired"
[ngModel]="relatedEntityId"
(ngModelChange)="relatedEntityId = $event">
</tb-agent-related-entity-autocomplete>
}
<tb-agent-app-step-inputs [bindings]="bindings"></tb-agent-app-step-inputs>
@if (!isProfileBoundUpgrade) {
<div class="diff-header-row">
<div class="diff-header added">
{{ 'agent.app-upgrade-template-new' | translate: { version: toVersion || '—' } }}
</div>
<div class="diff-header removed" translate>agent.app-upgrade-current</div>
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="proposedYaml" [right]="currentYaml" [syncScroll]="diffSyncScroll" (rightChange)="composeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-upgrade-diff-hint</p>
}
</mat-step>
}
@if (!loadingProfile && !profileLoadError && profile && template) {
<div class="summary-card" style="margin-bottom: 16px;">
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-profile-name</span>
<span class="value">{{ profile.name }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-versions</span>
<span class="value">{{ fromVersion || '—' }} → {{ toVersion || '—' }}</span>
@case ('summary') {
<mat-step [label]="stepLabels[step] | translate">
<div class="summary-card">
<div class="summary-row">
<span class="label" translate>agent.app-name</span>
<span class="value">{{ appName }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-versions</span>
<span class="value">{{ fromVersion || '—' }} → {{ toVersion || '—' }}</span>
</div>
@if (hasBackupVolumeInput) {
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-volumes-label</span>
<span class="value">
{{ 'agent.app-upgrade-summary-volumes' | translate: { count: selectedBackupVolumeCount } }}
</span>
</div>
}
</div>
</div>
<p class="hint" translate>agent.app-upgrade-profile-hint</p>
<div class="diff-header-row">
<div class="diff-header added">
{{ 'agent.app-upgrade-template-new' | translate: { version: toVersion || '—' } }}
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-upgrade-rollback-info</span>
</div>
<div class="diff-header removed" translate>agent.app-upgrade-profile-current</div>
@if (profileUpgraded) {
<div class="diff-readonly-chip">
<mat-icon>lock</mat-icon>
<span translate>agent.app-diff-read-only</span>
</div>
}
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="profileProposedYaml" [right]="profileCurrentYaml" [readOnly]="profileUpgraded" [syncScroll]="diffSyncScroll" (rightChange)="profileComposeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-upgrade-diff-hint</p>
</mat-step>
}
<div class="step-footer">
@if (!profileUpgraded) {
<button mat-raised-button color="primary"
(click)="submitProfileUpgrade()"
[disabled]="!canSubmitProfileUpgrade()"
>
<mat-icon>upgrade</mat-icon>
<span>{{ 'agent.app-upgrade-profile-cta' | translate }}</span>
</button>
}
@if (profileUpgraded) {
<button mat-raised-button color="primary" matStepperNext>
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
}
</div>
</mat-step>
}
<mat-step [label]="'agent.app-install-step3' | translate">
@if (canHaveRelatedEntity && isProfileBoundUpgrade) {
<tb-agent-related-entity-autocomplete
[appType]="selectedType || existingApplication?.appType"
[disabled]="!!lockedRelatedEntity"
[required]="relatedEntityRequired"
[ngModel]="relatedEntityId"
(ngModelChange)="relatedEntityId = $event">
</tb-agent-related-entity-autocomplete>
}
<tb-agent-app-step-inputs [bindings]="bindings"></tb-agent-app-step-inputs>
@if (!isProfileBoundUpgrade) {
<div class="diff-header-row">
<div class="diff-header added">
{{ 'agent.app-upgrade-template-new' | translate: { version: toVersion || '—' } }}
</div>
<div class="diff-header removed" translate>agent.app-upgrade-current</div>
<button type="button" class="diff-sync-toggle"
[class.active]="diffSyncScroll"
[matTooltip]="'agent.app-diff-sync-scroll' | translate"
(click)="diffSyncScroll = !diffSyncScroll">
<mat-icon>{{ diffSyncScroll ? 'link' : 'link_off' }}</mat-icon>
</button>
</div>
<tb-agent-compose-diff [left]="proposedYaml" [right]="currentYaml" [syncScroll]="diffSyncScroll" (rightChange)="composeYaml = $event"></tb-agent-compose-diff>
<p class="diff-hint" translate>agent.app-upgrade-diff-hint</p>
}
<div class="step-footer">
<button mat-raised-button color="primary" matStepperNext [disabled]="!canSubmit()">
{{ 'action.next' | translate }}
<mat-icon iconPositionEnd>chevron_right</mat-icon>
</button>
</div>
</mat-step>
<mat-step [label]="'agent.app-install-step4' | translate">
<div class="summary-card">
<div class="summary-row">
<span class="label" translate>agent.app-name</span>
<span class="value">{{ appName }}</span>
</div>
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-versions</span>
<span class="value">{{ fromVersion || '—' }} → {{ toVersion || '—' }}</span>
</div>
@if (hasBackupVolumeInput) {
<div class="summary-row">
<span class="label" translate>agent.app-upgrade-summary-volumes-label</span>
<span class="value">
{{ 'agent.app-upgrade-summary-volumes' | translate: { count: selectedBackupVolumeCount } }}
</span>
</div>
}
</div>
<div class="tb-form-hint tb-primary-fill mb-4">
<mat-icon>info_outline</mat-icon>
<span translate>agent.app-upgrade-rollback-info</span>
</div>
<div class="step-footer">
<button mat-button matStepperPrevious [disabled]="submitting">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
</button>
<button mat-raised-button color="primary" (click)="submit()" [disabled]="!canSubmit()">
<mat-icon>upgrade</mat-icon>
<span>{{ 'agent.app-upgrade-cta' | translate }}</span>
</button>
</div>
</mat-step>
}
</mat-stepper>
}
</div>
<div mat-dialog-actions>
@if (canGoBack() || showNext()) {
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end">
@if (canGoBack()) {
<button mat-stroked-button
[disabled]="submitting"
(click)="stepper.previous()">{{ 'action.back' | translate }}</button>
}
<span class="flex-1"></span>
@if (showNext()) {
<button mat-stroked-button
color="primary"
[disabled]="!canGoNext()"
(click)="stepper.next()">{{ 'action.next-with-label' | translate: { label: (nextStepLabel() | translate) } }}</button>
}
</div>
<mat-divider class="w-full"></mat-divider>
}
<div class="dialog-actions-row flex flex-1 flex-row items-center justify-end gap-2">
<button mat-button
[disabled]="submitting"
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
@if (currentStep() === 'profile' && !profileUpgraded) {
<button mat-raised-button
color="primary"
[disabled]="!canSubmitProfileUpgrade()"
(click)="submitProfileUpgrade()">{{ 'agent.app-upgrade-profile-cta' | translate }}</button>
} @else {
<button mat-raised-button
color="primary"
[disabled]="currentStep() !== 'summary' || !canSubmit()"
(click)="submit()">{{ 'agent.app-upgrade-cta' | translate }}</button>
}
</div>
</div>

2
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.scss

@ -2,7 +2,7 @@
// SPDX-License-Identifier: BUSL-1.1
@use 'agent-wizard' as *;
@include wizard-chrome;
@include wizard-stepper-dialog(1280px);
@include wizard-step-basics;
@include wizard-diff;
@include wizard-summary;

35
ui-ngx/src/app/modules/home/components/agent/wizard/agent-app-upgrade-flow.component.ts

@ -29,7 +29,12 @@ import { ActionNotificationShow } from '@core/notification/notification.actions'
import * as YAML from 'yaml';
import { AgentAppWizardLoaderService } from '@home/pages/agent/wizard/agent-app-wizard-loader.service';
import { AgentAppWizardSubmitService } from '@home/pages/agent/wizard/agent-app-wizard-submit.service';
import { AgentAppUpgradeResult, AgentAppWizardFinish } from '@home/pages/agent/wizard/agent-app-wizard.models';
import {
AGENT_APP_UPGRADE_STEP_LABELS,
AgentAppUpgradeResult,
AgentAppUpgradeStepKey,
AgentAppWizardFinish
} from '@home/pages/agent/wizard/agent-app-wizard.models';
@Component({
selector: 'tb-agent-app-upgrade-flow',
@ -65,10 +70,11 @@ export class AgentAppUpgradeFlowComponent extends PageComponent implements OnIni
profileLoadError = '';
profileUpgrading = false;
profileUpgraded = false;
showProfileUpgradeStep = false;
@ViewChild('stepper', { static: false })
stepper: MatStepper;
readonly stepLabels = AGENT_APP_UPGRADE_STEP_LABELS;
steps: AgentAppUpgradeStepKey[] = ['config', 'summary'];
selectedIndex = 0;
bindings: StepBinding[] = [];
@ -210,7 +216,7 @@ export class AgentAppUpgradeFlowComponent extends PageComponent implements OnIni
private maybeInitProfileDiff() {
if (!this.needsProfileUpgrade || !this.template || !this.profile || this.profileMergeRequested) { return; }
this.profileMergeRequested = true;
this.showProfileUpgradeStep = true;
this.steps = ['profile', 'config', 'summary'];
const profileComposeType = dockerComposeConfig(this.profile)?.composeType || undefined;
this.profileProposedYaml = dumpRawTemplateCompose(this.template, profileComposeType);
const draft = { ...this.profile, templateVersion: this.template.currentVersion } as AgentAppProfile;
@ -354,4 +360,25 @@ export class AgentAppUpgradeFlowComponent extends PageComponent implements OnIni
// the caller refresh even when the user backs out before the app upgrade.
this.cancelled.emit(this.profileUpgraded ? { profileOnly: true } : null);
}
currentStep(): AgentAppUpgradeStepKey | undefined {
return this.loadingTemplate || this.loadingProfile || this.loadError ? undefined : this.steps[this.selectedIndex];
}
canGoBack(): boolean {
return this.selectedIndex > 0 && this.steps[this.selectedIndex - 1] !== 'profile';
}
showNext(): boolean {
const step = this.currentStep();
return step === 'config' || (step === 'profile' && this.profileUpgraded);
}
canGoNext(): boolean {
return this.currentStep() === 'profile' ? this.profileUpgraded : this.canSubmit();
}
nextStepLabel(): string {
return this.stepLabels[this.steps[this.selectedIndex + 1]] ?? '';
}
}

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

@ -142,7 +142,7 @@
}
}
@if (plainRows(block.rows).length) {
<dl class="k-fields k-detail-facts">
<dl class="k-fields k-detail-facts" [class.capped]="!changeRows(block.rows).length">
@for (fact of plainRows(block.rows); track $index) {
<dt>{{ label(fact) }}</dt>
<dd [class.mono]="fact.mono">

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

@ -127,7 +127,7 @@ export interface AiStepView {
const ASKED_FOR: Record<string, string> = {
'search-named': 'named', 'search-typed': 'typed', 'search-text': 'text', 'search-related-from': 'related-from',
'search-related-to': 'related-to', 'search-alarms-of': 'alarms-of', 'read-attributes-scope': 'attributes-scope',
'search-related-to': 'related-to', 'read-attributes-scope': 'attributes-scope',
'search-alarms': 'alarms', 'search-alarms-on': 'alarms-on', 'search-alarms-filter-on': 'alarms-filter-on', 'search-alarms-window': 'alarms-window',
'search-alarms-filter-window': 'alarms-filter-window', 'search-alarms-on-window': 'alarms-on-window', 'search-alarms-filter-on-window': 'alarms-filter-on-window',
'read-history': 'history', 'read-history-keys': 'history-keys', 'read-latest-keys': 'latest-keys', 'iot-hub-query': 'query',
@ -1295,6 +1295,10 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
};
case 'create_dashboard':
return {hood: text('create-dashboard', {name: str(values.title) ?? '—'}), blocks: []};
case 'generate_device_dashboard': {
const keys = Array.isArray(values.keys) ? values.keys.map(String) : [];
return {hood: text('generate-device-dashboard', {entity: of(values.deviceId, 'DEVICE')}), blocks: keys.length ? [{type: 'keys', keys}] : []};
}
case 'update_dashboard':
return {hood: text('update-dashboard', {entity: dashboard}), blocks: changes(values, ['dashboardId'], names)};
case 'read_dashboard_overview':
@ -2360,6 +2364,9 @@ function namesOf(message: {from: string; data?: any; references?: Array<{id: str
case 'create_dashboard':
put(created, values.title, 'DASHBOARD');
break;
case 'generate_device_dashboard':
put(created, undefined, 'DASHBOARD');
break;
case 'save_device':
put(created ?? savedObject(values).id, savedObject(values).name, 'DEVICE');
break;

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

@ -40,6 +40,7 @@ const TOOL_WORDS: Record<string, string> = {
test_converter: 'test-converter',
read_converter_library: 'read-converter-library',
create_dashboard: 'create-dashboard',
generate_device_dashboard: 'generate-device-dashboard',
update_dashboard: 'update-dashboard',
add_dashboard_state: 'add-dashboard-state',
update_dashboard_state: 'update-dashboard-state',

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

@ -55,6 +55,8 @@ const MAX_FIELDS = 5;
const DETAIL_TOKENS = new Set(['server-attributes', 'shared-attributes']);
const ATTRIBUTE_TOOLS = new Set(['save_attributes', 'delete_attributes']);
const VALUE_TOKENS: Record<string, string[]> = {
undo: ['none'],
defaultDashboard: ['none'],
@ -72,7 +74,7 @@ const CODE_FIELDS = new Set(['arguments', 'expression', 'output']);
const HEAD_VERBS = new Set(['create', 'update', 'delete', 'install', 'acknowledge', 'clear', 'assign', 'unassign']);
const REVIEW_VERBS = new Set(['install', 'restart', 'update', 'upgrade', 'upgrade-agent', 'delete', 'cancel', 'sync', 'acknowledge', 'clear', 'assign', 'unassign']);
const IMAGE_FIELDS = new Set(['widget-image', 'scada-symbol']);
const IMAGE_FIELDS = new Set(['widget-image', 'scada-symbol', 'dashboard-image']);
const BLOCK_FIELDS = new Set(['script']);
@ -195,6 +197,11 @@ function aiChangeHead(translate: TranslateService, data: ToolExecutionRequested)
if (!HEAD_VERBS.has(verb)) {
return translate.instant(label);
}
if (DETAIL_TOKENS.has(review.detail) || ATTRIBUTE_TOOLS.has(data.tool)) {
const kind = DETAIL_TOKENS.has(review.detail) ? translate.instant('ai-assistant.review.detail.' + review.detail)
: translate.instant('ai-assistant.review.kind.attributes');
return translate.instant('ai-assistant.review.head-change.' + verb, {kind});
}
const type = review.detail === 'alarm-rule' ? 'ALARM_RULE' : review.entityType;
const key = 'ai-assistant.review.kind.' + type;
const phrase = translate.instant(key);

2
ui-ngx/src/app/modules/home/components/ai/ai-artifact-pane.component.html

@ -6,7 +6,7 @@
-->
<div class="art-pane-edge" role="separator" tabindex="0" aria-orientation="vertical"
[attr.aria-label]="'ai-assistant.artifact.resize' | translate"
[matTooltip]="'ai-assistant.artifact.resize-hint' | translate" matTooltipPosition="left" matTooltipShowDelay="600"
[matTooltip]="'ai-assistant.artifact.resize-hint' | translate" matTooltipPosition="left"
(pointerdown)="startResize($event)" (dblclick)="resetWidth()" (keydown)="onEdgeKey($event)"></div>
<div class="art-pane-head">
<button type="button" class="art-ib art-pane-close" (click)="closed.emit()"

30
ui-ngx/src/app/modules/home/components/ai/ai-artifact-pane.component.ts

@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { readStored, writeStored } from '@core/local-storage/stored';
import { AfterViewInit, Component, ElementRef, EventEmitter, inject, input, Output, signal, ViewChild } from '@angular/core';
import { AfterViewInit, Component, DestroyRef, ElementRef, EventEmitter, inject, input, Output, signal, ViewChild } from '@angular/core';
const PANE_MIN = 360;
const CHAT_MIN = 340;
const WIDTH_KEY = 'tbSolutionPaneWidth';
const ESCAPE_OWNERS = ['mat-mdc-dialog-container', 'mat-mdc-menu-panel', 'mat-mdc-select-panel', 'mat-mdc-autocomplete-panel']
.map(owner => '.cdk-overlay-container .' + owner).join(', ');
@Component({
selector: 'tb-ai-artifact-pane',
@ -16,7 +18,8 @@ const WIDTH_KEY = 'tbSolutionPaneWidth';
'[class.scrolled]': 'scrolled()',
'[class.more]': 'more()',
'[style.flex-basis]': 'width() ? width() + "px" : null',
'(keydown.escape)': 'onEscape($event)'
'(keydown.escape)': 'onEscape($event)',
'(document:keydown.escape)': 'onDocumentEscape($event)'
}
})
export class AiArtifactPaneComponent implements AfterViewInit {
@ -32,9 +35,13 @@ export class AiArtifactPaneComponent implements AfterViewInit {
more = signal(false);
private host = inject(ElementRef<HTMLElement>);
private destroyRef = inject(DestroyRef);
ngAfterViewInit(): void {
setTimeout(() => this.refreshEdges(), 50);
const columns = (this.host.nativeElement as HTMLElement).parentElement;
columns?.addEventListener('keydown', this.onColumnsEscape);
this.destroyRef.onDestroy(() => columns?.removeEventListener('keydown', this.onColumnsEscape));
}
refreshEdges(): void {
@ -53,6 +60,25 @@ export class AiArtifactPaneComponent implements AfterViewInit {
this.closed.emit();
}
onDocumentEscape(event: KeyboardEvent): void {
if (event.target === document.body || event.target === document.documentElement) {
this.closeOnEscape(event);
}
}
private onColumnsEscape = (event: KeyboardEvent): void => {
if (event.key === 'Escape' && !(this.host.nativeElement as HTMLElement).contains(event.target as Node)) {
this.closeOnEscape(event);
}
};
private closeOnEscape(event: KeyboardEvent): void {
if (event.defaultPrevented || document.querySelector(ESCAPE_OWNERS)) {
return;
}
this.closed.emit();
}
startResize(event: PointerEvent): void {
event.preventDefault();
const edge = event.target as HTMLElement;

5
ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.scss

@ -92,3 +92,8 @@
}
}
}
:host(.closing) > :not(.tb-ai-grip) {
opacity: .4;
transition: opacity .2s ease;
}

40
ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { AI_TOOLTIP_PROVIDERS } from '@home/components/ai/ai-tooltip';
import { Component, computed, effect, ElementRef, inject, NgZone, signal, untracked, ViewChild } from '@angular/core';
import { MatTooltip } from '@angular/material/tooltip';
import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service';
@ -23,7 +24,8 @@ import { AiAssistantContextService } from '@home/components/ai/ai-assistant-cont
'(window:resize)': 'fit()',
'(click)': 'onClick($event)',
'(keydown.escape)': '$event.stopPropagation()'
}
},
providers: AI_TOOLTIP_PROVIDERS
})
export class AiAssistantPanelComponent {
@ -37,6 +39,10 @@ export class AiAssistantPanelComponent {
private static readonly PAGE_REFLOW_MS = 50;
private static readonly COMPOSE_DELAY_MS = 60;
private static readonly CLOSE_PAST = 72;
resizing = signal(false);
get isOpen() { return this.panelService.open(); }
@ -96,6 +102,11 @@ export class AiAssistantPanelComponent {
private openEffect = effect(() => {
if (this.panelService.open()) {
untracked(() => {
if (this.panelService.composesFresh()) {
this.chatId.set(undefined);
this.chats.load().subscribe();
return;
}
const carried = this.panelService.hasCarriedChat();
if (!carried) {
this.dropChatFromOtherContext();
@ -114,6 +125,18 @@ export class AiAssistantPanelComponent {
}
});
private composeEffect = effect(() => {
if (this.panelService.composed() && this.panelService.open()) {
untracked(() => {
const composed = this.panelService.takeComposed();
if (composed.fresh) {
this.chatId.set(undefined);
}
setTimeout(() => this.chat?.composeText(composed.text), AiAssistantPanelComponent.COMPOSE_DELAY_MS);
});
}
});
private contextSwitchEffect = effect(() => {
const key = this.panelService.contextKey();
if (this.panelService.open() && this.lastContextKey !== null && key !== null && key !== this.lastContextKey) {
@ -211,6 +234,7 @@ export class AiAssistantPanelComponent {
this.room.set(host.parentElement?.clientWidth ?? window.innerWidth);
const widest = this.widest();
let current = startWidth;
let closing = false;
let frame = 0;
let pageTimer: ReturnType<typeof setTimeout> | undefined;
let pageAt = 0;
@ -230,7 +254,13 @@ export class AiAssistantPanelComponent {
document.body.classList.add('tb-ai-resizing');
this.zone.runOutsideAngular(() => {
const move = (e: PointerEvent) => {
current = Math.round(Math.min(widest, Math.max(this.minWidth, startWidth + (startX - e.clientX))));
const wanted = startWidth + (startX - e.clientX);
const past = wanted < this.minWidth - AiAssistantPanelComponent.CLOSE_PAST;
if (past !== closing) {
closing = past;
host.classList.toggle('closing', past);
}
current = Math.round(Math.min(widest, Math.max(this.minWidth, wanted)));
if (!frame) {
frame = requestAnimationFrame(paint);
}
@ -242,9 +272,15 @@ export class AiAssistantPanelComponent {
cancelAnimationFrame(frame);
clearTimeout(pageTimer);
document.body.classList.remove('tb-ai-resizing');
host.classList.remove('closing');
host.style.width = '';
this.zone.run(() => {
this.resizing.set(false);
if (closing) {
this.setWidth(startWidth);
this.close();
return;
}
this.setWidth(current, current !== startWidth);
});
};

4
ui-ngx/src/app/modules/home/components/ai/ai-attachments.component.html

@ -6,7 +6,7 @@
-->
<div class="k-files">
@for (item of shown; track item.resource.id) {
<button type="button" class="k-file" [class.pic]="item.image" [matTooltip]="item.resource.name" matTooltipPosition="above" (click)="open(item)">
<button type="button" class="k-file" [class.pic]="item.image" [matTooltip]="item.resource.name" aiTipIfCut matTooltipPosition="above" (click)="open(item)">
@if (item.image) {
<span class="k-file-pic" aria-hidden="true">
@if (item.url$ | async; as url) {
@ -17,7 +17,7 @@
<mat-icon class="tb-mat-18" aria-hidden="true">{{ item.icon }}</mat-icon>
}
<span class="k-file-text">
<b><span class="art-name">{{ fileName(item.resource.name).base }}<span class="art-ext">{{ fileName(item.resource.name).ext }}</span></span></b>
<b><span class="art-name tb-ai-cut">{{ fileName(item.resource.name).base }}<span class="art-ext">{{ fileName(item.resource.name).ext }}</span></span></b>
<small>@if (!item.image && item.extension) { {{ item.extension }} · }{{ factOf(item) ?? (item.resource.size | fileSize) }}</small>
</span>
</button>

2
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html

@ -93,7 +93,7 @@
} @else if (msg.from === 'ACTION' && plans[$index]; as plan) {
<div class="ai plan" [attr.data-dock]="$index">
<tb-ai-plan [steps]="plan.steps" [progress]="plan.progress" [gate]="plan.gate" [replacedAfter]="plan.replacedAfter" [autoApprove]="autoApprove"
(run)="runPlan.emit({run: $event, steps: plan.steps})" (change)="changePlan.emit()"></tb-ai-plan>
(run)="runPlan.emit({run: $event, steps: plan.steps})" (changeRequested)="changePlan.emit()"></tb-ai-plan>
</div>
} @else if (msg.from === 'ACTION' && handOvers[$index]; as card) {
<div class="ai hand" [attr.data-dock]="$index">

4
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.scss

@ -561,6 +561,10 @@
padding: 0;
background: none;
box-shadow: none;
font-weight: 400;
}
td:first-child code.k-ent {
font-weight: 500;
}

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

@ -508,6 +508,8 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
this.runningLead = running.length ? running[0] : -1;
this.runningCount = running.length;
this.findReadGroups();
const last = this.messages[this.messages.length - 1];
this.waitApproval = last?.from === 'APPROVAL' && !this.autoApprove && !this.isAnswered(last as ApprovalChatMessage);
if (changes.messages.firstChange) {
if (this.initialScroll === 'bottom') {
this.pinToBottom();
@ -521,10 +523,6 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
const prevLastMsg = prevMsgs?.[prevMsgs.length - 1];
const msgs = changes.messages.currentValue as ChatMessage[];
const lastMsg = msgs[msgs.length - 1];
// In auto-approve we are not blocked on the user, so the assistant keeps working: the
// thinking indicator stays visible (waitApproval false), and the view follows the stream of
// auto-generated cards only while the reader is near the bottom.
this.waitApproval = lastMsg?.from === 'APPROVAL' && !this.autoApprove && !this.isAnswered(lastMsg as ApprovalChatMessage);
if (this.autoApprove) {
if (wasNearBottom) {
setTimeout(() => this.scrollToBottom('auto'), 0);

5
ui-ngx/src/app/modules/home/components/ai/ai-chat-title.component.html

@ -24,10 +24,7 @@
} @else {
<span class="ai-chat-name-wrap" [class.static]="!renamable()">
<button #chatName type="button" class="ai-chat-name" [class.clipped]="nameClipped()" [class.compact]="compact()"
[matTooltip]="nameClipped() ? name : renamable() ? ('ai-assistant.double-click-to-rename' | translate) : ''"
[matTooltipDisabled]="!nameClipped() && !renamable()"
matTooltipPosition="after" matTooltipPositionAtOrigin matTooltipClass="tb-ai-cursor-tooltip" matTooltipShowDelay="500"
(mouseenter)="nameClipped.set(chatName.scrollWidth > chatName.clientWidth + 1)"
[matTooltip]="name" [matTooltipDisabled]="!nameClipped()" matTooltipPosition="below"
(keydown.enter)="startRename()" (keydown.f2)="startRename()" (dblclick)="startRename()">{{ name }}</button>
@if (renamable()) {
<button type="button" class="ai-chat-name-pen" [attr.aria-label]="'action.rename' | translate"

6
ui-ngx/src/app/modules/home/components/ai/ai-chat-title.component.scss

@ -142,3 +142,9 @@
.ai-ib {
@include ai-icon-button;
}
@container k-head (max-width: 399px) {
.ai-chat-status > span:last-child {
display: none;
}
}

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

@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Component, ElementRef, EventEmitter, inject, input, Output, signal } from '@angular/core';
import { afterNextRender, Component, DestroyRef, effect, ElementRef, EventEmitter, inject, input, Output, signal } from '@angular/core';
import { ChatLevel } from '@shared/models/ai-chat.models';
@Component({
@ -25,6 +25,28 @@ export class AiChatTitleComponent {
renaming = signal(false);
nameClipped = signal(false);
constructor() {
const head = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => this.measure()) : null;
afterNextRender(() => {
const parent = this.host.nativeElement.parentElement;
if (parent) {
head?.observe(parent);
}
this.measure();
});
effect(() => {
this.title();
this.renaming();
setTimeout(() => this.measure());
});
inject(DestroyRef).onDestroy(() => head?.disconnect());
}
measure(): void {
const name = this.host.nativeElement.querySelector<HTMLElement>('.ai-chat-name');
this.nameClipped.set(!!name && name.scrollWidth > name.clientWidth + 1);
}
startRename(): void {
if (!this.title() || !this.renamable()) {
return;

64
ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html

@ -12,7 +12,7 @@
@if (variant() === 'panel') {
<tb-ai-mark size="32"></tb-ai-mark>
}
<tb-ai-chat-title [title]="chat()?.title" [placeholder]="historyLoading() ? '' : ((showGetStarted() ? 'ai-assistant.get-started.title' : 'ai-assistant.new-chat') | translate)" [level]="level()"
<tb-ai-chat-title [title]="shownTitle()" [placeholder]="historyLoading() ? '' : ((showGetStarted() ? 'ai-assistant.get-started.title' : 'ai-assistant.new-chat') | translate)" [level]="level()"
[statusTip]="statusTip()" [compact]="variant() === 'panel'" (renamed)="rename($event)"></tb-ai-chat-title>
<div class="ai-chat-actions">
@if (chatFiles().length && !titleRef?.renaming()) {
@ -26,15 +26,23 @@
}
@if (variant() === 'panel') {
@if (!titleRef?.renaming()) {
@if (chat()) {
<button type="button" class="ai-ib ai-new-chat" (click)="newChat()"
[matTooltip]="'ai-assistant.new-chat' | translate" matTooltipPosition="above" [attr.aria-label]="'ai-assistant.new-chat' | translate">
<mat-icon fontSet="material-icons-round">add</mat-icon>
</button>
}
<button type="button" class="ai-ib more" [matMenuTriggerFor]="panelMenu"
[matTooltip]="'ai-assistant.chats-menu' | translate" matTooltipPosition="above" [attr.aria-label]="'ai-assistant.chats-menu' | translate">
[matTooltip]="'action.more' | translate" matTooltipPosition="above" [attr.aria-label]="'action.more' | translate">
<mat-icon>more_vert</mat-icon>
</button>
<button type="button" class="ai-ib" (click)="toggleFullscreen()"
[matTooltip]="(fullscreen() ? 'fullscreen.exit' : 'ai-assistant.open-full-screen') | translate" matTooltipPosition="above"
[attr.aria-label]="(fullscreen() ? 'fullscreen.exit' : 'ai-assistant.open-full-screen') | translate">
<mat-icon fontSet="material-icons-round">{{ fullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
</button>
@if (fullscreen() || !headNarrow()) {
<button type="button" class="ai-ib" (click)="toggleFullscreen()"
[matTooltip]="(fullscreen() ? 'fullscreen.exit' : 'ai-assistant.open-full-screen') | translate" matTooltipPosition="above"
[attr.aria-label]="(fullscreen() ? 'fullscreen.exit' : 'ai-assistant.open-full-screen') | translate">
<mat-icon fontSet="material-icons-round">{{ fullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
</button>
}
@if (!fullscreen()) {
<button type="button" class="ai-ib" (click)="closed.emit()"
[matTooltip]="'action.close' | translate" matTooltipPosition="above" [attr.aria-label]="'action.close' | translate">
@ -263,9 +271,9 @@
@if (shownFile(); as file) {
@if (fileOpen()) {
<tb-ai-artifact-pane [class.art-dark]="fileDark(file)" [dark]="fileCode(file)" (closed)="fileOpen.set(false)">
<h2 artHead class="art-title" [matTooltip]="file.name" matTooltipPosition="below" [matTooltipShowDelay]="600">
<h2 artHead class="art-title" [matTooltip]="file.name" aiTipIfCut matTooltipPosition="below">
<mat-icon class="tb-mat-20" aria-hidden="true">{{ fileMark(file) }}</mat-icon>
<span class="art-name">{{ fileName(file.name).base }}<span class="art-ext">{{ fileName(file.name).ext }}</span></span>
<span class="art-name tb-ai-cut">{{ fileName(file.name).base }}<span class="art-ext">{{ fileName(file.name).ext }}</span></span>
</h2>
<div artHead class="art-head-r">
@if (!file.previewed) {
@ -399,14 +407,10 @@
</div>
<mat-menu #panelMenu="matMenu" xPosition="before" class="tb-ai-chat-menu">
@if (chat()) {
<button mat-menu-item (click)="startRename()">
<mat-icon fontSet="material-icons-round">edit</mat-icon>
<span>{{ 'action.rename' | translate }}</span>
</button>
<button mat-menu-item (click)="newChat()">
<mat-icon fontSet="material-icons-round">add</mat-icon>
<span>{{ 'ai-assistant.new-chat' | translate }}</span>
@if (!fullscreen() && headNarrow()) {
<button mat-menu-item (click)="toggleFullscreen()">
<mat-icon fontSet="material-icons-round">fullscreen</mat-icon>
<span>{{ 'ai-assistant.open-full-screen' | translate }}</span>
</button>
}
@if (docked() && (split() || splitAvailable())) {
@ -415,9 +419,23 @@
<span>{{ (split() ? 'ai-assistant.back-to-panel' : 'ai-assistant.split-view') | translate }}</span>
</button>
}
@if (recentChats().length) {
<div class="tb-ai-menu-h">{{ 'ai-assistant.recent-chats' | translate }}</div>
@for (other of recentChats(); track other.id) {
@if (chat()) {
<button mat-menu-item (click)="startRename()">
<mat-icon fontSet="material-icons-round">edit</mat-icon>
<span>{{ 'action.rename' | translate }}</span>
</button>
<button mat-menu-item (click)="togglePinned()">
<mat-icon fontSet="material-icons-round">push_pin</mat-icon>
<span>{{ (chat()?.pinned ? 'ai-assistant.unpin' : 'ai-assistant.pin') | translate }}</span>
</button>
<button mat-menu-item class="danger" (click)="deleteChat()">
<mat-icon fontSet="material-icons-round">delete_outline</mat-icon>
<span>{{ 'action.delete' | translate }}</span>
</button>
}
@for (group of otherChats(); track group.label) {
<div class="tb-ai-menu-h">{{ group.label | translate }}</div>
@for (other of group.chats; track other.id) {
<button mat-menu-item class="chat" (click)="chatId.set(other.id)">
<mat-icon fontSet="material-icons-round">chat_bubble_outline</mat-icon>
<span class="tb-ai-menu-chat">
@ -433,12 +451,6 @@
<mat-icon fontSet="material-icons-round">forum</mat-icon>
<span>{{ 'ai-assistant.all-chats' | translate }}</span>
</button>
@if (chat()) {
<button mat-menu-item class="danger" (click)="deleteChat()">
<mat-icon fontSet="material-icons-round">delete_outline</mat-icon>
<span>{{ 'action.delete' | translate }}</span>
</button>
}
</mat-menu>
<mat-menu #chatMenu="matMenu" xPosition="before" class="tb-ai-chat-menu">

1
ui-ngx/src/app/modules/home/components/ai/ai-chat.component.scss

@ -23,6 +23,7 @@
.ai-chat-head {
position: relative;
container: k-head / inline-size;
flex: none;
display: flex;
align-items: center;

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

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { AI_TOOLTIP_PROVIDERS } from '@home/components/ai/ai-tooltip';
import { aiCreditsLimitOf, AiCreditsLimitType } from '@home/components/ai/ai-credits.models';
import { aiClientOs, aiPageView, isAiTitledView } from '@shared/models/ai-chat.models';
import { getDefaultTimezone } from '@shared/models/time/time.models';
@ -46,6 +47,7 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { environment as env } from '@env/environment';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { isNotEmptyStr, parseHttpErrorMessage } from '@core/utils';
import { aiChatNameOf } from '@home/components/ai/ai-text';
import { ActionChatMessage, AiStartedFrom, ApprovalChatMessage, ChatMessage, GeneralChatMessage } from '@shared/models/solution-creator.models';
import {
AiAssistantPromptExample,
@ -110,14 +112,19 @@ interface AiRefusal {
'[class.split]': 'split() && docked()',
'[class.v-page]': '!docked()',
'[class.v-panel]': 'docked()'
}
},
providers: AI_TOOLTIP_PROVIDERS
})
export class AiChatComponent implements OnInit, OnDestroy {
private static readonly RESUME_ATTEMPTS = 4;
private static readonly RESUME_DELAY_MS = 2000;
private static readonly NOTICE_MS = 6000;
private static readonly RECENT_CHATS = 5;
private static readonly MENU_CHATS = 4;
private static readonly NEW_CHAT_TITLE = 'New chat';
private static readonly NARROW_HEAD = 500;
@ViewChild(AiPromptInputComponent) promptInput: AiPromptInputComponent;
@ViewChild(AiChatTitleComponent) titleRef: AiChatTitleComponent;
@ -167,10 +174,29 @@ export class AiChatComponent implements OnInit, OnDestroy {
{key: 'datasheet', icon: 'attach_file', file: true}
];
recentChats = computed(() => this.chats.chats()
.filter(chat => chat.id !== this.chatId())
.sort((a, b) => b.createdTime - a.createdTime)
.slice(0, AiChatComponent.RECENT_CHATS));
otherChats = computed<{label: string; chats: ChatInfo[]}[]>(() => {
const others = this.chats.chats()
.filter(chat => chat.id !== this.chatId())
.sort((a, b) => (b.updatedTime ?? b.createdTime) - (a.updatedTime ?? a.createdTime));
const startedHere = new Set(this.panelService.chatsStartedHere());
const here = others.filter(chat => startedHere.has(chat.id)).slice(0, AiChatComponent.MENU_CHATS - 1);
const recent = others.filter(chat => !startedHere.has(chat.id)).slice(0, Math.max(1, AiChatComponent.MENU_CHATS - here.length));
return [
...(here.length ? [{label: 'ai-assistant.on-this-page', chats: here}] : []),
...(recent.length ? [{label: 'ai-assistant.recent-chats', chats: recent}] : [])
];
});
headNarrow = signal(false);
shownTitle = computed(() => {
const title = this.chat()?.title;
if (title && title !== AiChatComponent.NEW_CHAT_TITLE) {
return title;
}
const first = this.messages().find(message => message.from === 'USER') as GeneralChatMessage | undefined;
return typeof first?.content === 'string' && first.content.trim() ? aiChatNameOf(first.content) : title;
});
fullscreen = signal<boolean>(false);
@ -549,6 +575,14 @@ export class AiChatComponent implements OnInit, OnDestroy {
});
ngOnInit(): void {
if (typeof ResizeObserver !== 'undefined') {
const head = new ResizeObserver(() => {
const width = this.hostElement.querySelector('.ai-chat-head')?.clientWidth ?? 0;
this.headNarrow.set(width > 0 && width < AiChatComponent.NARROW_HEAD);
});
head.observe(this.hostElement);
this.destroyRef.onDestroy(() => head.disconnect());
}
this.loadChat$.pipe(
switchMap(id => this.aiChat.getChatMessages(id, {ignoreLoading: true, ignoreErrors: true}).pipe(
catchError(err => {
@ -1054,8 +1088,11 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.messageCancelled = false;
const startOrContinue$ = this.chatId()
? of(null)
: this.chats.create('New chat', this.newChatAutoApprove()).pipe(
: this.chats.create(AiChatComponent.NEW_CHAT_TITLE, this.newChatAutoApprove()).pipe(
tap(chat => {
if (this.variant() === 'panel') {
this.panelService.noteStartedHere(chat.id);
}
this.freshChatId = chat.id;
this.shownChatId = chat.id;
this.chatId.set(chat.id);

8
ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.html

@ -7,12 +7,12 @@
<div class="k-colours" role="radiogroup" [attr.aria-label]="question().question">
@for (option of question().options; track option.label) {
<button type="button" role="radio" class="k-colour" [attr.aria-checked]="value() === option.label"
[disabled]="disabled()" (click)="pick(option.label)">
(click)="pick(option.label)">
<span class="k-sw" [style.background]="colorOf(option.label)" aria-hidden="true"></span>
<span class="k-colour-t"><b>{{ option.hint || colorOf(option.label)?.toUpperCase() }}</b>@if (option.hint) {<small>{{ colorOf(option.label)?.toUpperCase() }}</small>}</span>
</button>
}
<button type="button" role="radio" class="k-colour" [attr.aria-checked]="other()" [disabled]="disabled()" (click)="openHex()">
<button type="button" role="radio" class="k-colour" [attr.aria-checked]="other()" (click)="openHex()">
@if (hex(); as color) {
<span class="k-sw" [style.background]="color" aria-hidden="true"></span>
<span class="k-colour-t"><b>{{ 'ai-assistant.question.other-color-short' | translate }}</b><small>{{ color }}</small></span>
@ -27,11 +27,11 @@
<span class="k-hexf-f">
<span class="k-hexf-hash" aria-hidden="true">#</span>
<input #hexInput class="k-hex-in" type="text" maxlength="7" placeholder="00897B" spellcheck="false" autocomplete="off"
[value]="digits()" [disabled]="disabled()" [attr.aria-invalid]="wrong() || null"
[value]="digits()" [attr.aria-invalid]="wrong() || null"
[attr.aria-label]="'ai-assistant.question.hex-label' | translate: {question: question().question, label: ('ai-assistant.question.other-color-short' | translate)}"
(input)="typeHex(hexInput)" (blur)="checkHex(hexInput)" (keydown.enter)="hexEnter($event, hexInput)">
<span class="k-hexf-pick">
<button mat-icon-button type="button" [disabled]="disabled()"
<button mat-icon-button type="button"
[matTooltip]="'ai-assistant.question.pick-color' | translate" matTooltipPosition="above"
[attr.aria-label]="'ai-assistant.question.pick-color' | translate"
(click)="openPicker(picker, hexInput)"><mat-icon>colorize</mat-icon></button>

7
ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.ts

@ -22,7 +22,6 @@ export class AiColorFieldComponent {
question = input.required<AiQuestion>();
value = model('');
disabled = input(false);
enter = output<Event>();
private elementRef: ElementRef<HTMLElement> = inject(ElementRef);
@ -40,9 +39,6 @@ export class AiColorFieldComponent {
}
openHex(): void {
if (this.disabled()) {
return;
}
if (!this.other()) {
this.value.set('#');
}
@ -76,9 +72,6 @@ export class AiColorFieldComponent {
}
openPicker(picker: HTMLInputElement, field: HTMLInputElement): void {
if (this.disabled()) {
return;
}
picker.value = aiHexOf(field.value) ?? '#000000';
try {
picker.showPicker();

12
ui-ngx/src/app/modules/home/components/ai/ai-core.module.ts

@ -10,8 +10,8 @@ import { AiTipDirective } from '@home/components/ai/ai-tip.directive';
import { AiFadeInImageDirective } from '@home/components/ai/ai-fade-in-image.directive';
import { AiSpinComponent } from '@home/components/ai/ai-spin.component';
import { AiSevMarkComponent } from '@home/components/ai/ai-sev-mark.component';
import { AiLoadingModalComponent } from '@home/components/ai/ai-loading-modal.component';
import { AiNoTelemetryModalComponent } from '@home/components/ai/ai-no-telemetry-modal.component';
import { AiTipIfCutDirective, AiTooltipChainDirective } from '@home/components/ai/ai-tooltip';
@NgModule({
declarations: [
@ -22,12 +22,13 @@ import { AiNoTelemetryModalComponent } from '@home/components/ai/ai-no-telemetry
AiFadeInImageDirective,
AiSpinComponent,
AiSevMarkComponent,
AiLoadingModalComponent,
AiNoTelemetryModalComponent
],
imports: [
CommonModule,
SharedModule
SharedModule,
AiTooltipChainDirective,
AiTipIfCutDirective
],
exports: [
AiAssistantButtonComponent,
@ -37,8 +38,9 @@ import { AiNoTelemetryModalComponent } from '@home/components/ai/ai-no-telemetry
AiFadeInImageDirective,
AiSpinComponent,
AiSevMarkComponent,
AiLoadingModalComponent,
AiNoTelemetryModalComponent
AiNoTelemetryModalComponent,
AiTooltipChainDirective,
AiTipIfCutDirective
]
})
export class AiCoreModule {}

13
ui-ngx/src/app/modules/home/components/ai/ai-credits.component.scss

@ -1,12 +1,25 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
:host {
display: inline-flex;
min-width: 0;
}
.cred {
display: inline-flex;
align-items: center;
gap: 8px;
min-width: 0;
> :not(.cred-line) {
flex-shrink: 0;
}
}
.cred-line {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
font: 400 var(--chat-meta)/var(--chat-meta-lh) var(--tb-font);
color: var(--tb-ink-76);
white-space: nowrap;

71
ui-ngx/src/app/modules/home/components/ai/ai-dashboard-generation.service.ts

@ -1,11 +1,9 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { DestroyRef, Injectable } from '@angular/core';
import { Injectable } from '@angular/core';
import { createDefaultEntityDataPageLink, singleEntityFilterFromDeviceId } from '@shared/models/query/query.models';
import { AiLoadingModalComponent, AiLoadingModalData } from '@home/components/ai/ai-loading-modal.component';
import { dashboardGenerateImage, generateDashboardSteps } from '@home/components/ai/ai.models';
import { finalize } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { map } from 'rxjs/operators';
import { forkJoin, of } from 'rxjs';
import {
AiNoTelemetryModalComponent,
AiNoTelemetryModalData
@ -13,21 +11,20 @@ import {
import { Operation } from '@shared/models/security.models';
import { EntityType } from '@shared/models/entity-type.models';
import { EntityService } from '@core/http/entity.service';
import { DeviceService } from '@core/http/device.service';
import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service';
import { MatDialog } from '@angular/material/dialog';
import { AiChatService } from '@core/http/ai-chat.service';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DomSanitizer } from '@angular/platform-browser';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { UserPermissionsService } from '@core/http/user-permissions.service';
import { EntityGroupInfo } from '@shared/models/entity-group.models';
interface GenerateDashboardOptions {
deviceId: string;
destroyRef?: DestroyRef;
noTelemetry: AiNoTelemetryModalData;
beforeOpen?: () => void;
deviceName?: string;
keys?: string[];
checkTelemetry?: boolean;
noTelemetry?: AiNoTelemetryModalData;
beforeCompose?: () => void;
}
interface AllowDashboardGenerateOptions {
@ -41,47 +38,29 @@ interface AllowDashboardGenerateOptions {
export class AiDashboardGenerationService {
constructor(private entityService: EntityService,
private deviceService: DeviceService,
private dialog: MatDialog,
private aiChatService: AiChatService,
private router: Router,
private panelService: AiAssistantPanelService,
private translate: TranslateService,
private sanitizer: DomSanitizer,
private store: Store<AppState>,
private userPermissionsService: UserPermissionsService) {
}
generateWithTelemetryCheck(opts: GenerateDashboardOptions): void {
this.entityService.findEntityKeysByQueryV2({
askInChat(opts: GenerateDashboardOptions): void {
const telemetry$ = opts.checkTelemetry === false ? of(true) : this.entityService.findEntityKeysByQueryV2({
entityFilter: singleEntityFilterFromDeviceId(opts.deviceId),
pageLink: createDefaultEntityDataPageLink(1),
}, true, false).subscribe((res) => {
opts.beforeOpen?.();
if (res.timeseries.length) {
this.generate(opts.deviceId, opts.destroyRef);
} else {
this.openNoTelemetryModal(opts.noTelemetry);
}, true, false).pipe(map(res => res.timeseries.length > 0));
const name$ = opts.deviceName ? of(opts.deviceName) : this.deviceService.getDevice(opts.deviceId, {ignoreLoading: true}).pipe(map(device => device.name));
forkJoin([telemetry$, name$]).subscribe(([hasTelemetry, name]) => {
if (!hasTelemetry) {
this.openNoTelemetryModal(opts.noTelemetry ?? {});
return;
}
});
}
generate(deviceId: string, destroyRef?: DestroyRef, timeseriesKeys: string[] = []): void {
const dialogRef = this.dialog.open(AiLoadingModalComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: {
messages: generateDashboardSteps,
estimateWaitTime: 60000,
image: dashboardGenerateImage
} as AiLoadingModalData
});
let request$ = this.aiChatService.generateDashboard(deviceId, timeseriesKeys).pipe(
finalize(() => dialogRef.close())
);
if (destroyRef) {
request$ = request$.pipe(takeUntilDestroyed(destroyRef));
}
request$.subscribe({
next: (response) => this.router.navigate(['/dashboards', response])
opts.beforeCompose?.();
const keys = (opts.keys ?? []).filter(Boolean);
this.panelService.compose(keys.length
? this.translate.instant('ai-assistant.ask.device-dashboard-keys', {name, keys: keys.join(', ')})
: this.translate.instant('ai-assistant.ask.device-dashboard', {name}));
});
}

15
ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.html

@ -1,15 +0,0 @@
<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
<div class="tb-generated flex flex-col items-center justify-center">
<div class="panel flex max-w-full flex-col items-center gap-6 rounded-lg p-10">
<img [src]="data?.image || generateImage" alt="Loading">
<div class="flex flex-col items-center gap-1">
<span class="msg text-xl font-semibold" [class.text-changed]="statusMessageChanged">{{ statusMessage | translate }}</span>
<span class="info">{{ 'solution-creator.estimate-wait-time' | translate: {time: (data.estimateWaitTime | milliSecondsToTimeString:true : true)} }}</span>
</div>
</div>
</div>

34
ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.scss

@ -1,34 +0,0 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
.tb-generated {
z-index: 3;
.panel {
box-shadow: 0 6px 12px 0 rgba(0, 0, 0, 0.04), 0 12px 32px 0 rgba(0, 0, 0, 0.08);
background-color: #fff;
width: 500px;
}
img {
width: 200px;
}
.info {
white-space: pre-line;
text-align: center;
line-height: 1.5;
letter-spacing: 0.15px;
}
.msg.text-changed {
animation: fadeInSlideUp 0.5s ease-out forwards;
}
@keyframes fadeInSlideUp {
0% {
opacity: 0;
transform: translateY(15px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
}

61
ui-ngx/src/app/modules/home/components/ai/ai-loading-modal.component.ts

@ -1,61 +0,0 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Component, DestroyRef, Inject, OnInit, ViewEncapsulation } from '@angular/core';
import { DialogComponent } from '@shared/components/dialog.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { from, of } from 'rxjs';
import { concatMap, delay } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { generatedStateImages } from '@home/components/ai/ai.models';
export interface AiLoadingModalData {
messages: Array<{text: string; delay: number}>;
estimateWaitTime: number;
image?: string;
}
@Component({
selector: 'tb-ai-loading-modal',
templateUrl: './ai-loading-modal.component.html',
styleUrl: './ai-loading-modal.component.scss',
encapsulation: ViewEncapsulation.None,
standalone: false,
host: {
style: 'width: 100%; height: 100%; min-height: 100%; display: flex; overflow: hidden;'
}
})
export class AiLoadingModalComponent extends DialogComponent<AiLoadingModalComponent> implements OnInit {
generateImage: string = generatedStateImages[Math.floor(Math.random() * generatedStateImages.length)];
statusMessage: string = '';
statusMessageChanged = false;
constructor(protected store: Store<AppState>,
protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: AiLoadingModalData,
public dialogRef: MatDialogRef<AiLoadingModalComponent>,
private destroyRef: DestroyRef) {
super(store, router, dialogRef);
}
ngOnInit() {
this.initGenerateState();
}
private initGenerateState(): void {
from(this.data.messages).pipe(
concatMap(message => of(message).pipe(delay(message.delay))),
takeUntilDestroyed(this.destroyRef)
).subscribe((msg) => {
this.statusMessageChanged = true;
this.statusMessage = msg.text;
setTimeout(() => {
this.statusMessageChanged = false;
}, 500);
});
}
}

6
ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.html

@ -5,16 +5,16 @@
-->
<div class="k-numf" [class.s]="size() === 's'" [class.m]="size() === 'm'" [class.l]="size() === 'l'">
<button mat-icon-button type="button" [disabled]="disabled()" [attr.aria-label]="'ai-assistant.question.lower' | translate: {step: step()}"
<button mat-icon-button type="button" [attr.aria-label]="'ai-assistant.question.lower' | translate: {step: step()}"
(click)="stepBy(numInput, -1)"><mat-icon>remove</mat-icon></button>
<input #numInput class="k-num-in" type="text" inputmode="decimal" spellcheck="false" [disabled]="disabled()"
<input #numInput class="k-num-in" type="text" inputmode="decimal" spellcheck="false"
[value]="value()" [attr.aria-invalid]="wrong() || null" [attr.aria-label]="question().question + (question().number?.unit ? ' · ' + question().number.unit : '')"
(input)="typed(numInput)" (blur)="settle()" (keydown.arrowup)="$event.preventDefault(); stepBy(numInput, 1)"
(keydown.arrowdown)="$event.preventDefault(); stepBy(numInput, -1)" (keydown.enter)="onEnter($event)">
@if (question().number?.unit) {
<span class="k-unit">{{ question().number.unit }}</span>
}
<button mat-icon-button type="button" [disabled]="disabled()" [attr.aria-label]="'ai-assistant.question.higher' | translate: {step: step()}"
<button mat-icon-button type="button" [attr.aria-label]="'ai-assistant.question.higher' | translate: {step: step()}"
(click)="stepBy(numInput, 1)"><mat-icon>add</mat-icon></button>
</div>
@if (wrong()) {

4
ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.ts

@ -15,7 +15,6 @@ export class AiNumberFieldComponent {
question = input.required<AiQuestion>();
value = model('');
disabled = input(false);
enter = output<Event>();
private translate = inject(TranslateService);
@ -31,9 +30,6 @@ export class AiNumberFieldComponent {
}
stepBy(field: HTMLInputElement, direction: number): void {
if (this.disabled()) {
return;
}
const current = aiReadNumber(field.value, this.locale());
const base = isNaN(current) ? (this.question().number?.suggested ?? 0) : current;
const decimals = Math.max(aiStepDecimals(this.step()), isNaN(current) ? 0 : aiStepDecimals(current));

4
ui-ngx/src/app/modules/home/components/ai/ai-plan.component.html

@ -22,7 +22,7 @@
<span class="k-plan-count">{{ gate() || !progress() ? ('ai-assistant.plan.steps' | translate: {count: counted()}) : ('ai-assistant.plan.done-of' | translate: {done: done(), count: counted()}) }}</span>
<span class="tb-spacer"></span>
@if (gate()) {
<button type="button" class="k-iconbtn" (click)="change.emit()" [matTooltip]="'ai-assistant.plan.change' | translate"
<button type="button" class="k-iconbtn" (click)="changeRequested.emit()" [matTooltip]="'ai-assistant.plan.change' | translate"
matTooltipPosition="above" [attr.aria-label]="'ai-assistant.plan.change' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">edit</mat-icon>
</button>
@ -47,7 +47,7 @@
<button mat-flat-button type="button" (click)="start(true)" [matTooltip]="'ai-assistant.plan.run-auto-tip' | translate" matTooltipPosition="above">
<mat-icon>bolt</mat-icon>{{ 'ai-assistant.plan.run-auto' | translate }}
</button>
<button mat-stroked-button type="button" (click)="start(false)" [matTooltip]="'ai-assistant.plan.run-tip' | translate" matTooltipPosition="above">
<button mat-stroked-button type="button" (click)="start(false)">
<mat-icon>play_arrow</mat-icon>{{ 'ai-assistant.plan.run-step-by-step' | translate }}
</button>
} @else {

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

@ -30,7 +30,7 @@ export class AiPlanComponent {
open = this.fold.open;
@Output() run = new EventEmitter<AiPlanRun>();
@Output() change = new EventEmitter<void>();
@Output() changeRequested = new EventEmitter<void>();
private cleared = signal<ReadonlySet<number>>(new Set());

2
ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.html

@ -53,7 +53,7 @@
<div class="composer-row">
<span class="composer-chevron" aria-hidden="true"></span>
@if (suggestion && !hasText()) {
<div class="composer-ghost" aria-hidden="true"><span>{{ suggestion }}</span><kbd>Tab</kbd></div>
<div class="composer-ghost" [class.tight]="ghostTight()" aria-hidden="true">@if (ghostTight()) {<span>{{ suggestion }}</span><kbd>Tab</kbd>} @else {<span>{{ ghostHead() }}<span class="composer-ghost-end">{{ ghostLast() }}<kbd>Tab</kbd></span></span>}</div>
<span id="composer-suggestion" class="tb-ai-sr-only">{{ 'ai-assistant.suggestion-sr' | translate: {text: suggestion} }}</span>
}
<textarea #textarea

62
ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.ts

@ -23,6 +23,7 @@ import {
import { FormControl } from '@angular/forms';
import { toSignal } from '@angular/core/rxjs-interop';
import { Subscription } from 'rxjs';
import { take } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';
import { MatDialog } from '@angular/material/dialog';
import { AiShortcutsDialogComponent } from '@home/components/ai/ai-shortcuts-dialog.component';
@ -80,6 +81,8 @@ export class AiPromptInputComponent implements OnChanges, AfterViewInit, OnDestr
@Input() suggestion: string | null = null;
ghostTight = signal(false);
@Input() quote: AiLinesQuote | null = null;
@Output() quoteRemoved = new EventEmitter<void>();
@ -176,6 +179,9 @@ export class AiPromptInputComponent implements OnChanges, AfterViewInit, OnDestr
if (changes.dropZone) {
this.listenForDrops(this.dropZone ?? this.host.nativeElement);
}
if (changes.suggestion) {
setTimeout(() => this.fitGhost());
}
}
ngAfterViewInit(): void {
@ -258,18 +264,39 @@ export class AiPromptInputComponent implements OnChanges, AfterViewInit, OnDestr
this.clearAttachments(true);
}
restoreAttachments(resources: AiResourceInfo[]): void {
const kept = untracked(() => this.attachments());
const missing = (resources ?? []).filter(resource => !kept.some(attachment => attachment.resource?.id === resource.id));
for (const resource of missing) {
const kind = aiAttachmentKind(resource.mediaType, resource.name);
const key = guid();
this.attachments.update(list => [...list, {
key, name: resource.name, size: resource.size, icon: kind.icon, kind: kind.label, status: 'ready', progress: 100, resource
}]);
if (resource.mediaType?.startsWith('image/')) {
this.aiResourceService.getUrl(resource.id).pipe(take(1)).subscribe({
next: previewUrl => this.patch(key, {previewUrl}),
error: () => {}
});
}
}
}
focus(): void {
this.textarea?.nativeElement.focus();
}
setValue(value: string): void {
setValue(value: string, showStart = false): void {
this.message.setValue(value);
this.hasText.set(!!value);
setTimeout(() => {
const field = this.textarea?.nativeElement;
field?.focus();
field?.focus({preventScroll: showStart});
field?.setSelectionRange(field.value.length, field.value.length);
this.resize();
if (field && showStart) {
field.scrollTop = 0;
}
});
}
@ -423,6 +450,37 @@ export class AiPromptInputComponent implements OnChanges, AfterViewInit, OnDestr
const cap = this.docked ? Math.min(160, Math.round(innerHeight * 0.3)) : Math.min(this.pinned ? 240 : 220, Math.round(innerHeight * 0.4));
field.style.height = 'auto';
field.style.height = Math.min(field.scrollHeight, cap) + 'px';
this.fitGhost();
}
ghostHead(): string {
const text = this.suggestion ?? '';
const space = text.lastIndexOf(' ');
return space < 0 ? '' : text.slice(0, space + 1);
}
ghostLast(): string {
const text = this.suggestion ?? '';
return text.slice(text.lastIndexOf(' ') + 1);
}
private fitGhost(): void {
const ghost = this.host.nativeElement.querySelector<HTMLElement>('.composer-ghost');
const words = ghost?.firstElementChild as HTMLElement | null;
const key = ghost?.querySelector<HTMLElement>('kbd');
if (!ghost || !words || !key) {
this.ghostTight.set(false);
return;
}
ghost.classList.remove('tight');
const wrap = ghost.style.whiteSpace;
ghost.style.whiteSpace = 'nowrap';
const keyWidth = key.getBoundingClientRect().width + parseFloat(getComputedStyle(key).marginLeft || '0');
const wordsWidth = words.getBoundingClientRect().width - (words.contains(key) ? keyWidth : 0);
ghost.style.whiteSpace = wrap;
const tight = wordsWidth <= ghost.clientWidth && wordsWidth + keyWidth > ghost.clientWidth;
ghost.classList.toggle('tight', tight);
this.ghostTight.set(tight);
}
private clearText(): void {

36
ui-ngx/src/app/modules/home/components/ai/ai-question.component.html

@ -30,11 +30,11 @@
</section>
}
<div class="k-actions">
<button mat-flat-button type="button" color="primary" [disabled]="disabled() || !allReady()" (click)="finish()">
<button mat-flat-button type="button" color="primary" [disabled]="!allReady()" (click)="finish()">
<mat-icon>check</mat-icon>{{ 'ai-assistant.question.done' | translate }}
</button>
<span class="tb-spacer"></span>
<button mat-button type="button" [disabled]="disabled()" (click)="skipAll()">{{ 'ai-assistant.question.skip' | translate }}</button>
<button mat-button type="button" (click)="skipAll()">{{ 'ai-assistant.question.skip' | translate }}</button>
</div>
</div>
} @else if (current(); as question) {
@ -56,11 +56,11 @@
<mat-icon>arrow_back</mat-icon>{{ 'action.back' | translate }}
</button>
}
<button mat-flat-button type="button" color="primary" [disabled]="disabled() || !ready(question)" (click)="next()">
<button mat-flat-button type="button" color="primary" [disabled]="!ready(question)" (click)="next()">
<mat-icon>{{ last() ? 'check' : 'arrow_forward' }}</mat-icon>{{ (last() ? 'ai-assistant.question.done' : 'ai-assistant.question.next') | translate }}
</button>
<span class="tb-spacer"></span>
<button mat-button type="button" [disabled]="disabled()" (click)="skipAll()">{{ 'ai-assistant.question.skip' | translate }}</button>
<button mat-button type="button" (click)="skipAll()">{{ 'ai-assistant.question.skip' | translate }}</button>
</div>
</div>
}
@ -78,15 +78,15 @@
<div class="k-ask-a">
@switch (kind(step)) {
@case ('color') {
<tb-ai-color-field [question]="step" [value]="colorValue(step)" [disabled]="disabled()"
<tb-ai-color-field [question]="step" [value]="colorValue(step)"
(valueChange)="setColor(step, $event)" (enter)="onEnter($event)"></tb-ai-color-field>
}
@case ('secret') {
<tb-ai-secret-field [question]="step" [value]="otherText(step)" [disabled]="disabled()"
<tb-ai-secret-field [question]="step" [value]="otherText(step)"
(valueChange)="setTyped(step, $event)" (enter)="onEnter($event)"></tb-ai-secret-field>
}
@case ('number') {
<tb-ai-number-field [question]="step" [value]="otherText(step)" [disabled]="disabled()"
<tb-ai-number-field [question]="step" [value]="otherText(step)"
(valueChange)="setTyped(step, $event)" (enter)="onEnter($event)"></tb-ai-number-field>
}
@case ('text') {
@ -94,7 +94,7 @@
<div class="k-optcard other free" (click)="$any($event.currentTarget).querySelector('.k-opt-input')?.focus()">
<span class="k-optbody">
<b>{{ otherLabel(step) }}</b>
<textarea #freeArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
<textarea #freeArea class="k-opt-input" rows="1" spellcheck="false"
[value]="otherText(step)" [placeholder]="step.other?.placeholder || ('ai-assistant.question.type-answer' | translate)"
[attr.aria-label]="step.question" (input)="type(step, freeArea)" (keydown.enter)="onEnter($event)"></textarea>
</span>
@ -106,7 +106,7 @@
[style.--n]="step.options.length">
@for (option of step.options; track option.label) {
<button type="button" role="checkbox" class="k-optcard multi" [attr.aria-checked]="isChosen(step, option.label)"
[disabled]="disabled()" (click)="toggle(step, option.label)">
(click)="toggle(step, option.label)">
<span class="k-optdot"><mat-icon aria-hidden="true">check</mat-icon></span>
<span class="k-optbody"><b>@if (colorOf(option.label); as color) {<span class="k-swatch" [style.background]="color" aria-hidden="true"></span>}{{ option.label }}</b>@if (option.hint) {<span>{{ option.hint }}</span>}</span>
</button>
@ -115,7 +115,7 @@
<span class="k-optdot"><mat-icon aria-hidden="true">check</mat-icon></span>
<span class="k-optbody">
<b>{{ otherLabel(step) }}</b>
<textarea #multiArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
<textarea #multiArea class="k-opt-input" rows="1" spellcheck="false"
[value]="otherText(step)" [placeholder]="step.other?.placeholder || ('ai-assistant.question.other-hint' | translate)"
[attr.aria-label]="step.question + ' · ' + otherLabel(step)"
(input)="type(step, multiArea)" (keydown.enter)="onEnter($event)"></textarea>
@ -128,11 +128,11 @@
@for (option of step.options; track option.label) {
<button type="button" role="radio" class="ob-chip" [attr.aria-checked]="!isOther(step) && valueOf(step) === option.label"
[attr.aria-pressed]="!isOther(step) && valueOf(step) === option.label"
[disabled]="disabled()" (click)="pick(step, option.label)">{{ option.label }}</button>
(click)="pick(step, option.label)">{{ option.label }}</button>
}
<button #dayChip type="button" role="radio" class="ob-chip" aria-haspopup="dialog" [attr.aria-expanded]="dayOpen() === step.id"
[attr.aria-checked]="isOther(step) && !!otherText(step)" [attr.aria-pressed]="isOther(step) && !!otherText(step)"
[disabled]="disabled()" (click)="openDay(step, dayChip)">
(click)="openDay(step, dayChip)">
<mat-icon aria-hidden="true">calendar_today</mat-icon>{{ isOther(step) && otherText(step) ? otherText(step) : otherLabel(step) + '…' }}
</button>
</div>
@ -142,16 +142,16 @@
@for (option of step.options; track option.label) {
<button type="button" role="radio" class="ob-chip" [attr.aria-checked]="!isOther(step) && valueOf(step) === option.label"
[attr.aria-pressed]="!isOther(step) && valueOf(step) === option.label"
[disabled]="disabled()" (click)="pick(step, option.label)">{{ option.label }}</button>
(click)="pick(step, option.label)">{{ option.label }}</button>
}
<button type="button" role="radio" class="ob-chip" [attr.aria-checked]="isOther(step)" [attr.aria-pressed]="isOther(step)"
[disabled]="disabled()" (click)="pickOther(step)">{{ step.other?.label ? step.other.label + '…' : ('ai-assistant.question.other-chip' | translate) }}</button>
(click)="pickOther(step)">{{ step.other?.label ? step.other.label + '…' : ('ai-assistant.question.other-chip' | translate) }}</button>
</div>
@if (isOther(step) && step.number) {
<tb-ai-number-field [question]="step" [value]="otherText(step)" [disabled]="disabled()"
<tb-ai-number-field [question]="step" [value]="otherText(step)"
(valueChange)="setTyped(step, $event)" (enter)="onEnter($event)"></tb-ai-number-field>
} @else if (isOther(step)) {
<textarea #rowArea class="k-opt-input k-other-area" rows="1" spellcheck="false" [disabled]="disabled()"
<textarea #rowArea class="k-opt-input k-other-area" rows="1" spellcheck="false"
[value]="otherText(step)" [placeholder]="step.other?.placeholder || ('ai-assistant.question.other-hint' | translate)"
[attr.aria-label]="step.question + ' · ' + otherLabel(step)"
(input)="type(step, rowArea)" (keydown.enter)="onEnter($event)"></textarea>
@ -164,7 +164,7 @@
[style.--n]="step.options.length">
@for (option of step.options; track option.label) {
<button type="button" role="radio" class="k-optcard" [attr.aria-checked]="!isOther(step) && valueOf(step) === option.label"
[disabled]="disabled()" (click)="pick(step, option.label)">
(click)="pick(step, option.label)">
<span class="k-optdot"></span>
<span class="k-optbody"><b>{{ option.label }}</b>@if (option.hint) {<span>{{ option.hint }}</span>}</span>
</button>
@ -173,7 +173,7 @@
<span class="k-optdot"></span>
<span class="k-optbody">
<b>{{ otherLabel(step) }}</b>
<textarea #otherArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
<textarea #otherArea class="k-opt-input" rows="1" spellcheck="false"
[value]="otherText(step)"
[placeholder]="step.other?.placeholder || ('ai-assistant.question.other-hint' | translate)"
[attr.aria-label]="step.question + ' · ' + otherLabel(step)"

16
ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts

@ -74,7 +74,6 @@ export class AiQuestionComponent {
questions = input.required<AiQuestion[]>();
answered = input<AiQuestionAnswer[] | null>(null);
disabled = input(false);
time = input<number | undefined>(undefined);
@Output() done = new EventEmitter<AiQuestionAnswer[]>();
@ -164,9 +163,6 @@ export class AiQuestionComponent {
}
openDay(question: AiQuestion, chip: HTMLElement): void {
if (this.disabled()) {
return;
}
if (this.popoverService.hasPopover(chip)) {
this.popoverService.hidePopover(chip);
return;
@ -227,7 +223,7 @@ export class AiQuestionComponent {
allReady = computed(() => this.questions().every(question => this.ready(question)));
finish(): void {
if (!this.disabled() && this.questions().every(question => this.ready(question))) {
if (this.questions().every(question => this.ready(question))) {
this.done.emit(this.answers());
}
}
@ -265,7 +261,7 @@ export class AiQuestionComponent {
next(): void {
const question = this.current();
if (!question || !this.ready(question) || this.disabled()) {
if (!question || !this.ready(question)) {
return;
}
if (this.last()) {
@ -282,11 +278,9 @@ export class AiQuestionComponent {
}
skipAll(): void {
if (!this.disabled()) {
this.skip.emit(this.questions().map(question => this.given(question)
? {question, answer: this.answerOf(question), secret: !!question.secret && !question.options?.length}
: {question, answer: this.defaultOf(question)}));
}
this.skip.emit(this.questions().map(question => this.given(question)
? {question, answer: this.answerOf(question), secret: !!question.secret && !question.options?.length}
: {question, answer: this.defaultOf(question)}));
}
onEnter(event: Event): void {

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

@ -81,7 +81,7 @@ export function aiWidgetThumb(): string {
</div>
<span class="tb-rec-side">
@if (rec.hub) {
<span class="tb-ai-state hub" [matTooltip]="'ai-assistant.detail.on-iot-hub' | translate" matTooltipPosition="above">
<span class="tb-ai-state hub">
<mat-icon class="tb-mat-16" aria-hidden="true">hub</mat-icon>IoT Hub
</span>
} @else if (rec.alarm; as current) {

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

@ -11,9 +11,9 @@ export { AiRecordState } from '@home/components/ai/ai-record.models';
template: `
<span class="tb-rec-tile"><tb-icon aria-hidden="true">{{ kind().icon }}</tb-icon></span>
@if (url()) {
<a class="tb-rec-name" [routerLink]="url()" [matTooltip]="name()" matTooltipPosition="above" [matTooltipShowDelay]="600">{{ name() }}</a>
<a class="tb-rec-name" [routerLink]="url()" [matTooltip]="name()" aiTipIfCut matTooltipPosition="above">{{ name() }}</a>
} @else {
<span class="tb-rec-name" [matTooltip]="name()" matTooltipPosition="above" [matTooltipShowDelay]="600">{{ name() }}</span>
<span class="tb-rec-name" [matTooltip]="name()" aiTipIfCut matTooltipPosition="above">{{ name() }}</span>
}
@if (badge(); as label) {
<span class="tb-rec-badge" [attr.data-badge]="label.toLowerCase()">{{ label }}</span>

4
ui-ngx/src/app/modules/home/components/ai/ai-secret-field.component.html

@ -7,9 +7,9 @@
<div class="k-secret">
<span class="k-secret-f">
<input #secretInput class="k-opt-input" [type]="shown() ? 'text' : 'password'" autocomplete="new-password" spellcheck="false"
[disabled]="disabled()" [value]="value()" [placeholder]="question().other?.placeholder || ('ai-assistant.question.type-secret' | translate)"
[value]="value()" [placeholder]="question().other?.placeholder || ('ai-assistant.question.type-secret' | translate)"
[attr.aria-label]="question().question" (input)="value.set(secretInput.value)" (keydown.enter)="enter.emit($event)">
<button mat-icon-button type="button" class="k-show" [disabled]="disabled()"
<button mat-icon-button type="button" class="k-show"
[attr.aria-label]="(shown() ? 'ai-assistant.question.hide' : 'ai-assistant.question.show') | translate"
[matTooltip]="(shown() ? 'ai-assistant.question.hide' : 'ai-assistant.question.show') | translate"
(click)="toggle(secretInput)">

1
ui-ngx/src/app/modules/home/components/ai/ai-secret-field.component.ts

@ -13,7 +13,6 @@ export class AiSecretFieldComponent {
question = input.required<AiQuestion>();
value = model('');
disabled = input(false);
enter = output<Event>();
readonly shown = signal(false);

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

@ -56,7 +56,7 @@ const LIST_PAGES: Record<string, {entityType: string; url: string}> = {
@if (page(); as current) {
<span>{{ 'ai-assistant.started-from' | translate }}</span>
@if (current.url) {
<a class="tb-chiplink" [routerLink]="current.url" [matTooltip]="'ai-assistant.open-page' | translate: {name: current.name}" matTooltipPosition="above">
<a class="tb-chiplink" [routerLink]="current.url">
<code class="k-ent" [attr.data-pal]="kind().palette"><tb-icon class="k-ent-ic" aria-hidden="true">{{ kind().icon }}</tb-icon>{{ current.name }}<mat-icon class="tb-chip-go" aria-hidden="true">chevron_right</mat-icon></code>
</a>
} @else {

12
ui-ngx/src/app/modules/home/components/ai/ai-text.ts

@ -16,3 +16,15 @@ export function aiLocale(lang: string | undefined): string | undefined {
export function aiClockText(time: number | undefined, lang: string | undefined): string {
return new Date(time ?? Date.now()).toLocaleTimeString(aiLocale(lang), {hour: '2-digit', minute: '2-digit', hourCycle: 'h23'});
}
const CHAT_NAME_MAX = 44;
const CHAT_NAME_MIN_CUT = 20;
export function aiChatNameOf(prompt: string): string {
const first = prompt.replace(/[*_`#>]/g, '').trim().split(/[.:\n]/)[0].trim();
if (first.length <= CHAT_NAME_MAX) {
return first;
}
const space = first.lastIndexOf(' ', CHAT_NAME_MAX);
return first.slice(0, space > CHAT_NAME_MIN_CUT ? space : CHAT_NAME_MAX).replace(/[,;·\s]+$/, '') + '…';
}

70
ui-ngx/src/app/modules/home/components/ai/ai-tooltip.ts

@ -0,0 +1,70 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Directive, ElementRef, HostListener, inject, Provider } from '@angular/core';
import { MAT_TOOLTIP_DEFAULT_OPTIONS, MatTooltip, MatTooltipDefaultOptions } from '@angular/material/tooltip';
export const AI_TOOLTIP_OPTIONS: MatTooltipDefaultOptions = {
showDelay: 500,
hideDelay: 0,
touchendHideDelay: 1500,
disableTooltipInteractivity: true,
tooltipClass: 'tb-ai-tip'
};
export const AI_TOOLTIP_PROVIDERS: Provider[] = [{provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: AI_TOOLTIP_OPTIONS}];
const NEXT_AT_ONCE_MS = 400;
let lastTipAt = 0;
@Directive({
selector: '[matTooltip]',
standalone: true
})
export class AiTooltipChainDirective {
private tooltip = inject(MatTooltip, {self: true});
private host = inject<ElementRef<HTMLElement>>(ElementRef);
@HostListener('mouseenter')
onEnter(): void {
if (this.inChat()) {
this.tooltip.showDelay = Date.now() - lastTipAt < NEXT_AT_ONCE_MS ? 0 : AI_TOOLTIP_OPTIONS.showDelay;
}
}
@HostListener('mouseleave')
onLeave(): void {
if (this.inChat() && this.tooltip._isTooltipVisible()) {
lastTipAt = Date.now();
}
}
@HostListener('focus')
onFocus(): void {
if (this.inChat()) {
this.tooltip.showDelay = this.host.nativeElement.matches(':focus-visible') ? 0 : AI_TOOLTIP_OPTIONS.showDelay;
}
}
private inChat(): boolean {
return (this.tooltip.tooltipClass as string | string[]) === AI_TOOLTIP_OPTIONS.tooltipClass;
}
}
@Directive({
selector: '[aiTipIfCut]',
standalone: true
})
export class AiTipIfCutDirective {
private tooltip = inject(MatTooltip, {self: true});
private host = inject<ElementRef<HTMLElement>>(ElementRef);
@HostListener('mouseenter')
@HostListener('focus')
check(): void {
const element = this.host.nativeElement.querySelector<HTMLElement>('.tb-ai-cut') ?? this.host.nativeElement;
this.tooltip.disabled = element.scrollWidth <= element.clientWidth + 1;
}
}

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

@ -1,22 +0,0 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
export const generatedStateImages: string[] = [
'/assets/solution-creator/building-animated.webp',
'/assets/solution-creator/catch-animated.webp',
'/assets/solution-creator/dashboard-animated.webp',
'/assets/solution-creator/forest-animated.webp',
'/assets/solution-creator/parachute-animated.webp',
'/assets/solution-creator/rocket-animated.webp'
];
export const dashboardGenerateImage = '/assets/solution-creator/dashboard-animated.webp';
export const generateDashboardSteps = [
{ text: 'solution-creator.step-reading-device-data', delay: 0 },
{ text: 'solution-creator.step-analyzing-telemetry-attributes', delay: 2000 },
{ text: 'solution-creator.step-selecting-widgets', delay: 10000 },
{ text: 'solution-creator.step-configuring-titles-units-ranges', delay: 15000 },
{ text: 'solution-creator.step-designing-layout', delay: 25000 },
{ text: 'solution-creator.step-arranging-widgets', delay: 35000 },
{ text: 'solution-creator.step-loading-adding-finishing-touches', delay: 45000 },
]

12
ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.html

@ -30,8 +30,7 @@
<div class="sol-sec-head">
<h3>
@if (section.link) {
<a class="sol-sec-link" [routerLink]="section.link" matTooltipPosition="above" matTooltipShowDelay="600"
[matTooltip]="'solution-creator.pane.open-list' | translate: {name: (section.title | translate)}">
<a class="sol-sec-link" [routerLink]="section.link">
{{ section.title | translate }}<mat-icon aria-hidden="true">open_in_new</mat-icon>
</a>
} @else {
@ -45,8 +44,7 @@
<tr [class.waiting]="row.progress === 'wait'">
<td class="wrap sol-installed-name">
@if (link(row.type, row); as url) {
<a class="sol-name sol-ent" [attr.data-pal]="row.palette" [routerLink]="url" matTooltipPosition="above" matTooltipShowDelay="600"
[matTooltip]="'solution-creator.pane.open-list' | translate: {name: row.primary.additionalData?.name}">
<a class="sol-name sol-ent" [attr.data-pal]="row.palette" [routerLink]="url">
<tb-icon aria-hidden="true">{{ row.icon }}</tb-icon><b>{{ row.primary.additionalData?.name }}</b>
</a>
} @else {
@ -61,14 +59,12 @@
<td class="act">
<span class="sol-acts">
@if (link(row.type, row); as url) {
<a mat-button class="sol-act" [routerLink]="url" matTooltipPosition="above" matTooltipShowDelay="600"
[matTooltip]="'solution-creator.pane.open-name' | translate: {name: row.primary.additionalData?.name}">
<a mat-button class="sol-act" [routerLink]="url">
<mat-icon>open_in_new</mat-icon>{{ 'solution-creator.pane.open' | translate }}
</a>
}
@if (canViewAs(row)) {
<button mat-button type="button" class="sol-act" (click)="viewAs(row)" matTooltipPosition="above" matTooltipShowDelay="600"
[matTooltip]="'solution-creator.pane.view-as-user' | translate: {name: dashboardUser(row)}">
<button mat-button type="button" class="sol-act" (click)="viewAs(row)">
<mat-icon>person</mat-icon>{{ 'solution-creator.pane.view-as' | translate }}
</button>
}

10
ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.html

@ -39,6 +39,10 @@
<p class="sol-lead">{{ 'solution-creator.what-it-becomes' | translate }}</p>
@if (creditsOut(); as limitType) {
<tb-ai-credits-out class="sol-hero-credits" [limitType]="limitType" (dismissed)="creditsOut.set(null)"></tb-ai-credits-out>
} @else if (notice(); as current) {
<div [class]="'k-notice sol-hero-notice ' + (current.kind === 'block' ? 'blocking' : current.kind)" [attr.role]="current.kind === 'block' ? 'alert' : 'status'">
<mat-icon aria-hidden="true">{{ current.icon }}</mat-icon><span>{{ current.text }}</span>
</div>
}
<tb-ai-prompt-input class="sol-hero-input"
[placeholder]="activePlaceholder() | translate"
@ -48,7 +52,7 @@
</tb-ai-prompt-input>
<div class="sol-examples">
@for (ex of solutionExamples; track ex.key) {
<button type="button" class="ob-chip" [matTooltip]="'solution-creator.example-tip' | translate" matTooltipPosition="below"
<button type="button" class="ob-chip"
(click)="fillExample(ex.key)">
<mat-icon aria-hidden="true">{{ ex.icon }}</mat-icon>{{ ex.labelKey | translate }}
</button>
@ -199,7 +203,6 @@
@for (view of views(); track view.id) {
<button type="button" [attr.aria-pressed]="currentView() === view.id" [class.working]="view.state === 'working' && currentView() !== view.id"
[disabled]="view.state === 'next'" (click)="pickView(view.id)"
[matTooltip]="('solution-creator.pane.view-' + view.id) | translate" matTooltipPosition="below"
[attr.aria-label]="('solution-creator.pane.view-' + view.id) | translate">
@if (view.state === 'working' && currentView() !== view.id) {
<tb-ai-spin [kind]="view.id === 'solution' ? 'install' : 'gen'"></tb-ai-spin>
@ -243,8 +246,7 @@
</div>
}
@if (jsonAvailable()) {
<button artHead type="button" class="sol-tool" [class.on]="json()" [attr.aria-pressed]="json()" (click)="toggleJson()"
[matTooltip]="'solution-creator.pane.json-tip' | translate" matTooltipPosition="below">
<button artHead type="button" class="sol-tool" [class.on]="json()" [attr.aria-pressed]="json()" (click)="toggleJson()">
<mat-icon aria-hidden="true">data_object</mat-icon><span>JSON</span>
</button>
}

10
ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.scss

@ -194,6 +194,16 @@ tb-ai-chat-title:has(.ai-chat-status) + .sol-head-actions {
}
}
.sol-hero-notice {
align-self: stretch;
margin: 24px 0 8px;
text-align: left;
+ .sol-hero-input {
margin-top: 0;
}
}
.sol-examples {
display: flex;
flex-wrap: wrap;

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

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { AI_TOOLTIP_PROVIDERS } from '@home/components/ai/ai-tooltip';
import { aiCreditsLimitOf, AiCreditsLimitType } from '@home/components/ai/ai-credits.models';
import { AiCardAction } from '@home/components/ai/ai-card-actions.component';
import { AiNotice } from '@shared/models/ai-chat.models';
@ -48,10 +49,11 @@ import {
SolutionStepStatus
} from '@shared/models/solution-creator.models';
import { AiPromptInputComponent } from '@home/components/ai/ai-prompt-input.component';
import { AiPromptMessage } from '@shared/models/ai-chat.models';
import { AiPromptMessage, AiResourceInfo } from '@shared/models/ai-chat.models';
import { SolutionsCreatorService } from '@core/http/solutions-creator.service';
import {
catchError,
defaultIfEmpty,
filter,
finalize,
map,
@ -94,12 +96,16 @@ function formatCredits(credits: number): string {
return String(credits);
}
const isVisibleMessage = (msg: ChatMessage): boolean =>
msg.from === 'AI' || (msg.from === 'USER' && !/^<[a-z-]+\/>$/.test(((msg as GeneralChatMessage).content ?? '').trim()));
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'tb-solution-chat',
templateUrl: './solution-chat.component.html',
styleUrls: ['./solution-chat.component.scss'],
standalone: false
standalone: false,
providers: AI_TOOLTIP_PROVIDERS
})
export class SolutionChatComponent extends PageComponent implements OnInit, OnDestroy {
@ -628,6 +634,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
);
activePlaceholder = computed(() => this.isInitialEmpty()
|| (this.creatorStep() === 'chat' && this.solutionStep() === SolutionStep.INITIAL_CONFIGURATION && !this.isReadyStep() && !this.pendingQuestions().length)
? 'solution-creator.describe-solution-you-want'
: this.pendingQuestions().length ? 'solution-creator.type-the-answer'
: this.creatorStep() === 'result' ? 'solution-creator.ask-about-solution' : 'solution-creator.say-what-to-change');
@ -758,7 +765,9 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
switchMap(data => {
if (data.solutionId && data.solutionId !== NEW_SOLUTION_ID) {
this.opening.set(true);
return this.solutionCreator.getSolutionById(data.solutionId, {ignoreLoading: true, ignoreErrors: true}).pipe(
const listed$ = this.aiSolutions.loaded() ? of(null) : this.aiSolutions.load().pipe(catchError(() => of(null)));
return forkJoin([this.solutionCreator.getSolutionById(data.solutionId, {ignoreLoading: true, ignoreErrors: true}), listed$]).pipe(
map(([solution]) => solution),
catchError(err => {
this.opening.set(false);
this.creatorStep.set('chat');
@ -867,11 +876,16 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
private restorePrompt(msg: string): void {
const messages = this.messages();
const last = messages.map(message => message.from).lastIndexOf('USER');
let resources: AiResourceInfo[] = [];
if (last >= 0 && (messages[last] as GeneralChatMessage).content === msg) {
resources = (messages[last] as GeneralChatMessage).resources ?? [];
this.messages.set([...messages.slice(0, last), ...messages.slice(last + 1)]);
this.messageSteps = this.messageSteps.slice(0, -1);
}
setTimeout(() => this.promptInput?.setValue(msg));
setTimeout(() => {
this.promptInput?.setValue(msg);
this.promptInput?.restoreAttachments(resources);
});
}
private discardFreshSolution(msg: string): boolean {
@ -956,87 +970,96 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
fillExample(key: string): void {
const example = this.solutionExamples.find(ex => ex.key === key);
if (example) {
this.promptInput?.setValue(example.message);
this.promptInput?.setValue(example.message, true);
}
}
nextStep() {
if(this.solutionInfo.states[this.solutionStep()]?.status === SolutionStepStatus.READY) {
if (this.solutionStep() === SolutionStep.INITIAL_CONFIGURATION) {
const dashboardState = this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION];
const notStarted = !dashboardState || (!dashboardState.messages?.length && dashboardState.status !== SolutionStepStatus.READY);
if (notStarted) {
this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION] = {
messages: [],
status: SolutionStepStatus.IN_PROGRESS,
chatId: dashboardState?.chatId ?? null
}
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
this.sendDashboardConfigurationMsg('<start/>');
} else if (dashboardState.pendingChanges?.length) {
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
this.sendDashboardConfigurationMsg('<sync/>');
} else {
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
const toDashboards = this.solutionStep() === SolutionStep.INITIAL_CONFIGURATION || this.currentView() === 'overview';
if (toDashboards && this.solutionInfo.states[SolutionStep.INITIAL_CONFIGURATION]?.status !== SolutionStepStatus.READY) {
return;
}
if (!toDashboards && this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION]?.status !== SolutionStepStatus.READY) {
if (this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION]?.pendingChanges?.length) {
this.sendDashboardConfigurationMsg('<sync/>');
}
return;
}
this.pickedView.set(null);
if (toDashboards) {
const dashboardState = this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION];
const notStarted = !dashboardState || (!dashboardState.messages?.length && dashboardState.status !== SolutionStepStatus.READY);
if (notStarted) {
this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION] = {
messages: [],
status: SolutionStepStatus.IN_PROGRESS,
chatId: dashboardState?.chatId ?? null
}
} else if (this.solutionStep() === SolutionStep.DASHBOARDS_CONFIGURATION) {
if (this.solutionInfo.metadata?.built) {
this.creatorStep.set('result');
} else {
this.installProgress.set(null);
this.makeStartedAt.set(Date.now());
this.installOnly.set(false);
SolutionChatComponent.markMaking(this.solutionId, true);
const dialogRef = this.initGenerateState('create');
const uninstallOrContinue$ = !this.solutionInfo.metadata?.installed
? of(null)
: this.solutionCreator.uninstallSolution(this.solutionId, {ignoreLoading: true, ignoreErrors: true});
uninstallOrContinue$.pipe(
switchMap(() => this.withProgress(this.solutionCreator.createSolution(this.solutionId, {
ignoreLoading: true,
ignoreErrors: true
}))),
tap(() => this.creatorStep.set('result')),
switchMap((solution) =>
this.installWithProgress()
.pipe(map((installData) => {
if (!solution.metadata) {
solution.metadata = {} as SolutionMetadata;
}
solution.metadata.installed = true;
if (!solution.metadata.installResult) {
solution.metadata.installResult = {} as SolutionInstallResult;
}
Object.assign(solution.metadata.installResult, installData);
return solution;
}))
),
takeUntil(this.cancelPending$),
finalize(() => {
this.isGenerating.set(false);
dialogRef.close();
})
)
.subscribe({
next: (value) => {
SolutionChatComponent.markMaking(value.id, false);
this.solutionInfo = value;
this.aiSolutions.upsert(value);
this.showInstalled();
},
error: (err) => {
if (err?.status !== 0 && !SolutionChatComponent.unloading) {
SolutionChatComponent.markMaking(this.solutionId, false);
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
this.sendDashboardConfigurationMsg('<start/>');
} else if (dashboardState.pendingChanges?.length) {
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
this.sendDashboardConfigurationMsg('<sync/>');
} else {
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
this.updatedCurrentMsg();
}
} else {
if (this.solutionInfo.metadata?.built) {
this.creatorStep.set('result');
} else {
this.installProgress.set(null);
this.makeStartedAt.set(Date.now());
this.installOnly.set(false);
SolutionChatComponent.markMaking(this.solutionId, true);
const dialogRef = this.initGenerateState('create');
const uninstallOrContinue$ = !this.solutionInfo.metadata?.installed
? of(null)
: this.solutionCreator.uninstallSolution(this.solutionId, {ignoreLoading: true, ignoreErrors: true});
uninstallOrContinue$.pipe(
switchMap(() => this.withProgress(this.solutionCreator.createSolution(this.solutionId, {
ignoreLoading: true,
ignoreErrors: true
}))),
tap(() => this.creatorStep.set('result')),
switchMap((solution) =>
this.installWithProgress()
.pipe(map((installData) => {
if (!solution.metadata) {
solution.metadata = {} as SolutionMetadata;
}
if (!this.wasStopped(err, () => this.nextStep(), 'build') && !this.noticeFor(err)) {
this.reportFailure(err);
solution.metadata.installed = true;
if (!solution.metadata.installResult) {
solution.metadata.installResult = {} as SolutionInstallResult;
}
Object.assign(solution.metadata.installResult, installData);
return solution;
}))
),
takeUntil(this.cancelPending$),
finalize(() => {
this.isGenerating.set(false);
dialogRef.close();
})
)
.subscribe({
next: (value) => {
SolutionChatComponent.markMaking(value.id, false);
this.solutionInfo = value;
this.aiSolutions.upsert(value);
this.showInstalled();
},
error: (err) => {
if (err?.status !== 0 && !SolutionChatComponent.unloading) {
SolutionChatComponent.markMaking(this.solutionId, false);
}
});
}
if (!this.wasStopped(err, () => this.nextStep(), 'build') && !this.noticeFor(err)) {
this.reportFailure(err);
}
}
});
}
}
}
@ -1193,7 +1216,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
this.aiSolutions.update(this.solutionId, {installed: false});
this.uninstalledAt.set(Date.now());
if (this.creatorStep() === 'result') {
this.back();
this.pickedView.set({view: 'solution', phase: this.phase()});
}
});
}
@ -1246,8 +1269,10 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
this.solutionCreator.updateSolutionData(this.solutionId, 'solutionDescriptor', descriptor, {ignoreLoading: true}).pipe(
takeUntil(this.cancelPending$)
).subscribe(value => {
this.solutionInfo = value;
});
this.solutionInfo = value;
this.aiSolutions.upsert(value);
this.updatedCurrentMsg();
});
}
updatedDashboardOverview(dashboards: DashboardsOverview[]) {
@ -1255,6 +1280,8 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
takeUntil(this.cancelPending$)
).subscribe(value => {
this.solutionInfo = value;
this.aiSolutions.upsert(value);
this.updatedCurrentMsg();
});
}
@ -1419,8 +1446,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
const steps = this.solutionStep() === SolutionStep.DASHBOARDS_CONFIGURATION
? [SolutionStep.INITIAL_CONFIGURATION, SolutionStep.DASHBOARDS_CONFIGURATION]
: [SolutionStep.INITIAL_CONFIGURATION];
const visible = (msg: ChatMessage) => msg.from === 'AI' || (msg.from === 'USER' && !/^<[a-z-]+\/>$/.test(((msg as GeneralChatMessage).content ?? '').trim()));
const tagged = steps.flatMap(step => (this.solutionInfo.states[step]?.messages ?? []).filter(visible).map(message => ({message, step})));
const tagged = steps.flatMap(step => (this.solutionInfo.states[step]?.messages ?? []).filter(isVisibleMessage).map(message => ({message, step})));
this.messageSteps = tagged.map(item => item.step);
this.messages.set(tagged.map(item => item.message));
const stepState = this.solutionInfo.states[this.solutionStep()];
@ -1663,14 +1689,17 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
this.aiSolutions.load()
]).pipe(catchError(() => EMPTY))),
take(1),
defaultIfEmpty(null),
takeUntil(this.cancelPending$),
takeUntilDestroyed(this.destroyRef)
).subscribe(([solution]) => {
).subscribe(result => {
if (this.solutionId !== solutionId) {
return;
}
this.notice.set(null);
const received = (solution.states?.[step]?.messages ?? []).filter(message => message.from === 'USER').length >= sent;
const solution = result?.[0];
const received = !!solution && (solution.states?.[step]?.messages ?? [])
.filter(message => message.from === 'USER' && isVisibleMessage(message)).length >= sent;
if (!received) {
this.restorePrompt(msg);
this.setNotice('warn', 'wifi_off', 'connection-failed');
@ -1689,6 +1718,9 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
private stepAwaitingReply(solution: SolutionCreatorInfo | undefined, step: SolutionStep): boolean {
const state = solution?.states?.[step];
const last = state?.messages?.at(-1) as GeneralChatMessage | undefined;
if (state && state.status !== SolutionStepStatus.READY && this.aiSolutions.find(solution.id)?.status === 'RUNNING') {
return true;
}
if (state && !last && state.status !== SolutionStepStatus.READY) {
return !this.aiSolutions.loaded() || this.aiSolutions.find(solution.id)?.status === 'RUNNING';
}

9
ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts

@ -6,7 +6,6 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
ElementRef,
Injector,
Input,
@ -216,7 +215,6 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
private elementRef: ElementRef,
private fb: FormBuilder,
private timeService: TimeService,
private destroyRef: DestroyRef,
private aiDashboardGenerationService: AiDashboardGenerationService) {
super(store);
this.isSysAdmin = getCurrentAuthUser(this.store).authority === Authority.SYS_ADMIN;
@ -677,8 +675,11 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
generateDashboard($event: Event) {
$event.stopPropagation();
const selectedTimeseries = this.dataSource.selection.selected.map(telemetry => telemetry.key);
this.aiDashboardGenerationService.generate(this.entityIdValue.id, this.destroyRef, selectedTimeseries);
this.aiDashboardGenerationService.askInChat({
deviceId: this.entityIdValue.id,
keys: this.dataSource.selection.selected.map(telemetry => telemetry.key),
checkTelemetry: false
});
}
isAllowedDashboardGenerate(): boolean {

1
ui-ngx/src/app/modules/home/components/group/entity-groups-table-config.resolver.ts

@ -114,6 +114,7 @@ export class EntityGroupsTableConfigResolver {
return this.edgeService.getEdge(config.edgeId).pipe(
map((info) => {
config.tableTitle = info.name + ': ' + this.translate.instant(entityGroupsTitle(config.groupType));
config.edgeOwnerId = info.ownerId;
return config;
})
);

10
ui-ngx/src/app/modules/home/components/group/entity-groups-table-config.ts

@ -30,10 +30,12 @@ import { EntityId } from '@shared/models/id/entity-id';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { AuthUser } from '@shared/models/user.model';
import { edgeCreationAllowed } from '@shared/models/edge.models';
import { Authority } from '@shared/models/authority.enum';
export class EntityGroupsTableConfig extends EntityTableConfig<EntityGroupInfo> {
edgeId: string;
edgeOwnerId: EntityId;
groupType: EntityType;
shared: boolean;
@ -288,7 +290,13 @@ export class EntityGroupsTableConfig extends EntityTableConfig<EntityGroupInfo>
$event.stopPropagation();
}
let ownerId = this.userPermissionsService.getUserOwnerId();
if (this.params.customerId) {
if (this.edgeOwnerId && this.authUser.authority === Authority.TENANT_ADMIN) {
// List groups of the edge owner and its parent owners, so the groups of the customer that owns the edge are
// available no matter which page the edge was opened from (Edge management or Customers).
// Tenant admin only: for a customer user the edge owner may be outside their owner chain (an edge shared
// from the tenant or a parent customer), and the hierarchy request is then denied
ownerId = this.edgeOwnerId;
} else if (this.params.customerId) {
ownerId = {
id: this.params.customerId,
entityType: EntityType.CUSTOMER

9
ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { ChangeDetectorRef, Component, DestroyRef, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ChangeDetectorRef, Component, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Store } from '@ngrx/store';
@ -429,7 +429,6 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
protected router: Router,
protected dialogRef: MatDialogRef<TbDeviceInstallDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: DeviceInstallDialogData,
private destroyRef: DestroyRef,
private cdr: ChangeDetectorRef,
private deviceProfileService: DeviceProfileService,
private deviceService: DeviceService,
@ -832,10 +831,10 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
if (!deviceId) {
return;
}
this.aiDashboardGenerationService.generateWithTelemetryCheck({
this.aiDashboardGenerationService.askInChat({
deviceId,
destroyRef: this.destroyRef,
noTelemetry: { hideSendTelemetry: true }
noTelemetry: { hideSendTelemetry: true },
beforeCompose: () => this.done()
});
}

2
ui-ngx/src/app/modules/home/home.component.html

@ -58,7 +58,7 @@
</mat-toolbar>
</mat-sidenav>
<mat-sidenav-content class="tb-site-content" [class.tb-force-fullscreen]="forceFullscreen">
<div class="tb-site-main flex flex-col" role="main" style="height: 100%;" [class.openAiAssistant]="aiPanelLoaded() && panelService.open()">
<div class="tb-site-main flex flex-col" role="main" style="height: 100%;" [class.openAiAssistant]="aiPanelLoaded() && panelService.open() && !panelService.suppressed()">
@if ((homeService.hideMainToolbar$ | async) === false) {
<mat-toolbar color="tb-primary" class="tb-primary-toolbar tb-bottom-border flex flex-row">
<button mat-icon-button id="main"

3
ui-ngx/src/app/modules/home/pages/agent/agent-app-profile.component.ts

@ -10,7 +10,6 @@ import {
AgentAppArgument,
AgentAppProfile,
AgentApplicationType,
AgentAppTemplate,
agentApplicationTypeTranslationMap,
AgentAppConfigType,
dockerComposeConfig
@ -175,7 +174,7 @@ export class AgentAppProfileComponent extends EntityComponent<AgentAppProfile>
this.dialog.open<AgentAppProfileUpgradeDialogComponent, AgentAppProfileUpgradeDialogData, AgentAppProfile | null>(
AgentAppProfileUpgradeDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: { profile: this.entity }
}
).afterClosed().subscribe(saved => {

13
ui-ngx/src/app/modules/home/pages/agent/agent-app-profiles-table-config.resolver.ts

@ -23,10 +23,7 @@ import { AgentService } from '@core/http/agent.service';
import { AgentAppProfileComponent } from '@home/pages/agent/agent-app-profile.component';
import { MatDialog } from '@angular/material/dialog';
import { DialogService } from '@core/services/dialog.service';
import {
AgentAppProfileWizardComponent,
AgentAppProfileWizardData
} from '@home/pages/agent/wizard/agent-app-profile-wizard.component';
import { openAgentAppProfileWizard } from '@home/pages/agent/wizard/agent-app-profile-wizard-dialog';
import { AiAssistantConfigService } from '@core/services/ai-assistant-config.service';
import { AiAssistantViewType } from '@shared/models/ai-chat.models';
@ -135,13 +132,7 @@ export class AgentAppProfilesTableConfigResolver {
}
private openProfileWizard(): Observable<AgentAppProfile | null> {
return this.dialog.open<AgentAppProfileWizardComponent, AgentAppProfileWizardData, AgentAppProfile>(
AgentAppProfileWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {}
}
).afterClosed().pipe(
return openAgentAppProfileWizard(this.dialog, {}, false).pipe(
tap(saved => {
if (saved) {
this.templateCache.clear();

46
ui-ngx/src/app/modules/home/pages/agent/agent-application.component.ts

@ -41,11 +41,7 @@ import {
AgentAppDeleteDialogComponent,
AgentAppDeleteDialogData
} from '@home/pages/agent/dialog/agent-app-delete-dialog.component';
import {
AgentAppInstallWizardComponent,
AgentAppInstallWizardData,
AgentAppInstallWizardResult
} from '@home/components/agent/wizard/agent-app-install-wizard.component';
import { openAgentAppInstallWizard } from '@home/components/agent/wizard/agent-app-install-wizard-dialog';
import { catchError, map, mergeMap, share, startWith } from 'rxjs/operators';
import { findComposeDownStep } from '@home/pages/agent/util/agent-app-steps';
import { confineWheelToAceEditor } from '@home/pages/agent/util/ace-wheel-confine';
@ -387,7 +383,7 @@ export class AgentApplicationComponent extends EntityComponent<AgentApplicationI
mergeMap(futureYaml => this.dialog.open<AgentAppAssignCompareDialogComponent, AgentAppAssignCompareDialogData, boolean>(
AgentAppAssignCompareDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: {
appName: this.entity?.name,
profileName: profile.name,
@ -608,18 +604,12 @@ export class AgentApplicationComponent extends EntityComponent<AgentApplicationI
takeUntilDestroyed(this.destroyRef)
).subscribe(({ full, confirmed }) => {
if (!confirmed) { return; }
this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {
agentId: full.agentId.id,
agent: null,
mode: 'update',
application: full
}
}
).afterClosed().subscribe(event => {
openAgentAppInstallWizard(this.dialog, {
agentId: full.agentId.id,
agent: null,
mode: 'update',
application: full
}).subscribe(event => {
if (event) {
this.reloadEntity();
}
@ -659,18 +649,12 @@ export class AgentApplicationComponent extends EntityComponent<AgentApplicationI
this.agentService.getAgentApplicationInfoById(this.entity.id.id).pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(full => {
this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {
agentId: full.agentId.id,
agent: null,
mode: 'upgrade',
application: full
}
}
).afterClosed().subscribe(event => {
openAgentAppInstallWizard(this.dialog, {
agentId: full.agentId.id,
agent: null,
mode: 'upgrade',
application: full
}).subscribe(event => {
if (event) {
this.reloadEntity();
}
@ -692,7 +676,7 @@ export class AgentApplicationComponent extends EntityComponent<AgentApplicationI
mergeMap(composeDownStep => this.dialog.open<AgentAppDeleteDialogComponent, AgentAppDeleteDialogData, AgentAppEvent | null>(
AgentAppDeleteDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: { application: full, composeDownStep }
}
).afterClosed().pipe(map(event => ({ full, event }))))

54
ui-ngx/src/app/modules/home/pages/agent/agent-applications-table-config.resolver.ts

@ -47,12 +47,8 @@ import {
AgentAppDeleteDialogComponent,
AgentAppDeleteDialogData
} from '@home/pages/agent/dialog/agent-app-delete-dialog.component';
import {
AgentAppInstallWizardComponent,
AgentAppInstallWizardData,
AgentAppInstallWizardResult,
isAgentAppUpgradeResult
} from '@home/components/agent/wizard/agent-app-install-wizard.component';
import { isAgentAppUpgradeResult } from '@home/components/agent/wizard/agent-app-install-wizard.component';
import { openAgentAppInstallWizard } from '@home/components/agent/wizard/agent-app-install-wizard-dialog';
import { AiAssistantConfigService } from '@core/services/ai-assistant-config.service';
import { AiAssistantViewType } from '@shared/models/ai-chat.models';
import { AgentId } from '@shared/models/id/agent-id';
@ -300,18 +296,12 @@ export class AgentApplicationsTableConfigResolver {
))
).subscribe(({ full, confirmed }) => {
if (!confirmed) { return; }
this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {
agentId: this.agentId,
agent: this.agent,
mode: 'update',
application: full
}
}
).afterClosed().subscribe(event => {
openAgentAppInstallWizard(this.dialog, {
agentId: this.agentId,
agent: this.agent,
mode: 'update',
application: full
}).subscribe(event => {
if (event) {
this.config.updateData();
}
@ -367,7 +357,7 @@ export class AgentApplicationsTableConfigResolver {
this.dialog.open<AgentAppDeleteDialogComponent, AgentAppDeleteDialogData, AgentAppEvent | null>(
AgentAppDeleteDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: {
application: app,
agentName: this.agent?.name,
@ -389,18 +379,12 @@ export class AgentApplicationsTableConfigResolver {
}
private showUpgradeWizard(application: AgentApplicationInfo) {
this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {
agentId: this.agentId,
agent: this.agent,
mode: 'upgrade',
application
}
}
).afterClosed().subscribe(event => {
openAgentAppInstallWizard(this.dialog, {
agentId: this.agentId,
agent: this.agent,
mode: 'upgrade',
application
}).subscribe(event => {
if (event) {
this.config.updateData();
}
@ -408,13 +392,7 @@ export class AgentApplicationsTableConfigResolver {
}
private openInstallWizard(): Observable<AgentApplicationInfo | null> {
return this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: { agentId: this.agentId, agent: this.agent }
}
).afterClosed().pipe(
return openAgentAppInstallWizard(this.dialog, { agentId: this.agentId, agent: this.agent }).pipe(
switchMap(result => !isAgentAppUpgradeResult(result) && result?.applicationId?.id
? this.agentService.getAgentApplicationInfoById(result.applicationId.id)
: of(null))

31
ui-ngx/src/app/modules/home/pages/agent/agent-deploy-dialog.service.ts

@ -5,13 +5,10 @@ import { MatDialog } from '@angular/material/dialog';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { EntityId } from '@shared/models/id/entity-id';
import { AgentApplication, AgentApplicationType, AgentAppEvent } from '@shared/models/agent.models';
import { AgentApplication, AgentApplicationType } from '@shared/models/agent.models';
import { AgentService } from '@core/http/agent.service';
import {
AgentAppInstallWizardComponent,
AgentAppInstallWizardData,
AgentAppInstallWizardResult
} from '@home/components/agent/wizard/agent-app-install-wizard.component';
import { AgentAppInstallWizardResult } from '@home/components/agent/wizard/agent-app-install-wizard.component';
import { openAgentAppInstallWizard } from '@home/components/agent/wizard/agent-app-install-wizard-dialog';
@Injectable({ providedIn: 'root' })
export class AgentDeployDialogService {
@ -29,19 +26,13 @@ export class AgentDeployDialogService {
open(appType: AgentApplicationType, relatedEntity: EntityId,
options?: { showBack?: boolean }): Observable<AgentAppInstallWizardResult> {
return this.dialog.open<AgentAppInstallWizardComponent, AgentAppInstallWizardData, AgentAppInstallWizardResult>(
AgentAppInstallWizardComponent, {
disableClose: false,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: {
mode: 'install',
selectAgent: true,
lockedType: appType,
lockedRelatedEntity: relatedEntity,
navigateToAgentOnFinish: true,
showBack: !!options?.showBack
}
}
).afterClosed();
return openAgentAppInstallWizard(this.dialog, {
mode: 'install',
selectAgent: true,
lockedType: appType,
lockedRelatedEntity: relatedEntity,
navigateToAgentOnFinish: true,
showBack: !!options?.showBack
});
}
}

13
ui-ngx/src/app/modules/home/pages/agent/agent-executions-side-panel.component.ts

@ -28,10 +28,7 @@ import {
AgentProfileInfo
} from '@shared/models/agent.models';
import { TranslateService } from '@ngx-translate/core';
import {
AgentAppEventProgressDialogComponent,
AgentAppEventProgressDialogData
} from '@home/pages/agent/dialog/agent-app-event-progress-dialog.component';
import { openAgentAppEventProgress } from '@home/pages/agent/util/agent-app-event-progress';
const NON_TERMINAL_BULK: ReadonlyArray<AgentBulkActionStatus> = [
AgentBulkActionStatus.QUEUED,
@ -173,13 +170,7 @@ export class AgentExecutionsSidePanelComponent implements OnChanges, OnDestroy {
}
private openProgressDialog(application: AgentApplication | null, event: AgentAppEventInfo): void {
this.dialog.open<AgentAppEventProgressDialogComponent, AgentAppEventProgressDialogData, boolean>(
AgentAppEventProgressDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog'],
data: { application, event }
}
).afterClosed().subscribe(() => this.refresh());
openAgentAppEventProgress(this.dialog, application, event).subscribe(() => this.refresh());
}
formatTime(ts: number): string {

11
ui-ngx/src/app/modules/home/pages/agent/agent-install-instructions-dialog.component.scss

@ -1,13 +1,8 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use '../../components/agent/agent-shared' as *;
@use '../../components/agent/wizard/agent-wizard' as *;
:host {
display: block;
width: min(720px, 95vw);
min-width: 0;
max-width: 95vw;
}
@include wizard-dialog(720px);
.tb-agent-install-dialog-header {
display: flex;
@ -24,8 +19,6 @@
.tb-agent-install-dialog-body {
padding: 16px 24px 24px;
max-height: 70vh;
overflow-y: auto;
}
.instructions-section {

2
ui-ngx/src/app/modules/home/pages/agent/agent-profile-create-dialog.service.ts

@ -18,7 +18,7 @@ export class AgentProfileCreateDialogService {
return this.dialog.open<AgentProfilePresetDialogComponent, AgentProfileWizardData, AgentProfile>(
AgentProfilePresetDialogComponent, {
disableClose: true,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data
}).afterClosed();
}

32
ui-ngx/src/app/modules/home/pages/agent/agent-profile-created-dialog.component.html

@ -4,18 +4,18 @@
SPDX-License-Identifier: BUSL-1.1
-->
<div mat-dialog-title class="tb-agent-profile-created-header">
<h2 class="flex-1">
<mat-icon class="success-icon">check_circle</mat-icon>
<span translate>agent.agent-profile-created</span>
</h2>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<mat-icon class="material-icons mr-2">check_circle</mat-icon>
<h2 translate>agent.agent-profile-created</h2>
<span class="flex-1"></span>
<div tb-help="agentProfileProvisionCommand"></div>
<button mat-icon-button (click)="close()" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button
(click)="close()"
type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</div>
<div mat-dialog-content class="tb-agent-profile-created-body">
</mat-toolbar>
<div mat-dialog-content>
<section class="instructions-section">
<h3>
@ -63,13 +63,13 @@
</div>
<div mat-dialog-actions align="end" class="tb-agent-profile-created-footer">
<button mat-button (click)="close()">
{{ 'action.close' | translate }}
</button>
<div mat-dialog-actions class="flex items-center justify-end">
<button mat-button
(click)="close()">{{ 'action.close' | translate }}</button>
@if (agentProfile?.id?.id) {
<button mat-raised-button color="primary"
(click)="goToProfile()">
<button mat-raised-button
color="primary"
(click)="goToProfile()">
<mat-icon>open_in_new</mat-icon>
<span translate>agent.go-to-profile</span>
</button>

49
ui-ngx/src/app/modules/home/pages/agent/agent-profile-created-dialog.component.scss

@ -1,42 +1,8 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use '../../components/agent/agent-shared' as *;
@use '../../components/agent/wizard/agent-wizard' as *;
:host {
display: block;
width: min(760px, 95vw);
min-width: 0;
max-width: 95vw;
}
.tb-agent-profile-created-header {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0;
h2 {
display: flex;
align-items: center;
gap: 10px;
font-size: 20px;
font-weight: 400;
margin: 0;
.success-icon {
color: #4caf50;
font-size: 24px;
width: 24px;
height: 24px;
}
}
}
.tb-agent-profile-created-body {
padding: 16px 24px 24px;
max-height: 72vh;
overflow-y: auto;
}
@include wizard-dialog(760px);
.instructions-section {
h3 {
@ -89,14 +55,3 @@
}
}
}
.tb-agent-profile-created-footer {
padding: 8px 16px;
button[mat-raised-button] mat-icon {
font-size: 18px;
width: 18px;
height: 18px;
margin-right: 4px;
}
}

5
ui-ngx/src/app/modules/home/pages/agent/agent-profile-merged-profiles.component.ts

@ -28,7 +28,6 @@ import {
AgentAppConfigType,
AgentAppEventActionType,
agentAppEventActionTypeTranslationMap,
AgentAppProfile,
AgentAppProfileRelationInfo,
AgentAppTemplate,
AgentApplicationType,
@ -321,7 +320,7 @@ export class AgentProfileMergedProfilesComponent implements OnInit, OnChanges, O
this.dialog.open<AgentProfileAssignProfileDialogComponent, AgentProfileAssignProfileDialogData, string[]>(
AgentProfileAssignProfileDialogComponent, {
disableClose: true,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: { selectedIds }
}
).afterClosed().pipe(takeUntil(this.destroy$)).subscribe(nextIds => {
@ -476,7 +475,7 @@ export class AgentProfileMergedProfilesComponent implements OnInit, OnChanges, O
switchMap(({ templates, preview }) => this.dialog.open<AgentProfileBulkActionDialogComponent, AgentProfileBulkActionDialogData>(
AgentProfileBulkActionDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: {
agentProfile: this.agentProfile,
profile,

2
ui-ngx/src/app/modules/home/pages/agent/agent-profiles-table-config.resolver.ts

@ -97,7 +97,7 @@ export class AgentProfilesTableConfigResolver {
this.dialog.open<AgentProfileCreatedDialogComponent, AgentProfileCreatedDialogData>(
AgentProfileCreatedDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: { agentProfile, dockerCommand: res?.instructions || '' }
});
});

2
ui-ngx/src/app/modules/home/pages/agent/agents-table-config.resolver.ts

@ -394,7 +394,7 @@ export class AgentsTableConfigResolver {
this.dialog.open<AgentInstallInstructionsDialogComponent, AgentInstallInstructionsDialogData>(
AgentInstallInstructionsDialogComponent, {
disableClose: false,
panelClass: ['tb-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-wide-dialog'],
data: {
agent,
afterAdd,

30
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-assign-compare-dialog.component.html

@ -4,18 +4,15 @@
SPDX-License-Identifier: BUSL-1.1
-->
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<div class="tb-install-wizard-toolbar-content">
<h2>{{ 'agent.app-assign-compare-title' | translate }}:</h2>
<span class="flex-1">{{ data.profileName }}</span>
</div>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<h2>{{ 'agent.app-assign-compare-title' | translate }}: {{ data.profileName }}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppProfileUse"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div mat-dialog-content class="tb-install-wizard-body">
<div mat-dialog-content>
<div class="diff-header-row">
<div class="diff-header compare">{{ 'agent.app-update-current-config' | translate }}</div>
<div class="diff-header compare">{{ 'agent.app-update-future-config' | translate }}</div>
@ -35,12 +32,11 @@
{{ 'agent.app-assign-compare-hint' | translate: { profileName: data.profileName, appName: data.appName } }}
</p>
<div class="step-footer">
<button mat-button (click)="cancel()">
{{ 'action.cancel' | translate }}
</button>
<button mat-raised-button color="primary" (click)="confirm()">
<span>{{ 'agent.app-assign-compare-cta' | translate }}</span>
</button>
</div>
</div>
<div mat-dialog-actions class="flex items-center justify-end">
<button mat-button
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button
color="primary"
(click)="confirm()">{{ 'agent.app-assign-compare-cta' | translate }}</button>
</div>

2
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-assign-compare-dialog.component.scss

@ -2,5 +2,5 @@
// SPDX-License-Identifier: BUSL-1.1
@use '../../../components/agent/wizard/agent-wizard' as *;
@include wizard-chrome;
@include wizard-dialog(1280px);
@include wizard-diff;

15
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-event-progress-dialog.component.html

@ -4,16 +4,15 @@
SPDX-License-Identifier: BUSL-1.1
-->
<mat-toolbar color="tb-primary" class="tb-progress-dialog-header">
<h2 mat-dialog-title translate>agent.app-event-progress-title</h2>
<span class="header-app-name">{{ subjectName }}</span>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<h2>{{ 'agent.app-event-progress-title' | translate }}: {{ subjectName }}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppEvents"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div mat-dialog-content class="tb-progress-body">
<div mat-dialog-content>
@if (loading) {
<div class="tb-progress-loading">
<mat-spinner diameter="20"></mat-spinner>
@ -112,7 +111,7 @@
}
</div>
<div mat-dialog-actions class="tb-progress-actions">
<div mat-dialog-actions class="flex flex-wrap items-center justify-end">
@if (canCancel) {
<button mat-button color="warn" (click)="cancelEvent($event)">
<mat-icon>cancel</mat-icon>

53
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-event-progress-dialog.component.scss

@ -1,44 +1,8 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use '../../../components/agent/agent-shared' as *;
@use '../../../components/agent/wizard/agent-wizard' as *;
:host { display: block; width: min(640px, 95vw); min-width: 0; max-width: 95vw; }
.tb-progress-dialog-header {
display: flex;
align-items: center;
gap: 8px;
padding: 0 16px 0 24px;
min-height: 56px;
h2 {
font-size: 20px;
font-weight: 400;
margin: 0;
padding: 0;
color: inherit;
&::before {
display: none;
}
}
.header-app-name {
flex: 1;
min-width: 0;
font-size: 14px;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.tb-progress-body {
padding: 16px 24px 24px;
max-height: 70vh;
overflow-y: auto;
}
@include wizard-dialog(640px);
.tb-progress-loading,
.tb-progress-error {
@ -51,12 +15,12 @@
display: flex; gap: 12px; margin-bottom: 20px;
padding: 12px 16px; border: 1px solid $agent-divider-light;
border-radius: 4px; background: $agent-surface-muted;
.info-col { flex: 1; }
.info-col { flex: 1; min-width: 0; }
.info-label {
font-size: 11px; font-weight: 500; color: $agent-text-secondary;
text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px;
}
.info-value { font-size: 13px; font-weight: 500; }
.info-value { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
}
.tb-status-badge {
@ -131,7 +95,8 @@
.step-content { flex: 1; padding-top: 4px; min-width: 0; }
.step-title {
font-size: 14px; font-weight: 500; color: $agent-text-primary;
margin-bottom: 2px; display: flex; align-items: center; gap: 8px;
margin-bottom: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
overflow-wrap: anywhere;
}
.step-type-label {
font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 3px;
@ -144,9 +109,3 @@
&.processing .step-meta { color: $agent-color-warning-light; font-weight: 500; }
&.error .step-meta { color: $agent-color-error; font-weight: 500; }
}
.tb-progress-actions {
display: flex; align-items: center;
padding: 8px 16px; border-top: 1px solid $agent-divider-light;
button mat-icon { font-size: 18px; width: 18px; height: 18px; margin-right: 4px; }
}

41
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-profile-upgrade-dialog.component.html

@ -4,18 +4,15 @@
SPDX-License-Identifier: BUSL-1.1
-->
<mat-toolbar color="tb-primary" class="tb-install-wizard-toolbar">
<div class="tb-install-wizard-toolbar-content">
<h2>{{ 'agent.app-upgrade-title' | translate }}:</h2>
<span class="flex-1">{{ profile.name }}</span>
</div>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<h2>{{ 'agent.app-upgrade-title' | translate }}: {{ profile.name }}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppProfileVersions"></div>
<button mat-icon-button (click)="cancel()" type="button" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button (click)="cancel()" type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div mat-dialog-content class="tb-install-wizard-body">
<div mat-dialog-content>
@if (loadingTemplate) {
<div class="loading-state">
@ -27,9 +24,6 @@
<div class="error-state">
<mat-icon>error_outline</mat-icon>
<span>{{ loadError }}</span>
<div class="step-footer">
<button mat-button (click)="cancel()">{{ 'action.close' | translate }}</button>
</div>
</div>
}
@ -61,14 +55,19 @@
<span translate>agent.app-compose-invalid-yaml</span>
</div>
}
<div class="step-footer">
<button mat-button (click)="cancel()" [disabled]="submitting">
{{ 'action.cancel' | translate }}
</button>
<button mat-raised-button color="primary" (click)="submit()" [disabled]="!canSubmit()">
<mat-icon>upgrade</mat-icon>
<span>{{ 'agent.app-upgrade-cta' | translate }}</span>
</button>
</div>
}
</div>
<div mat-dialog-actions class="flex items-center justify-end">
<button mat-button
[disabled]="submitting"
(click)="cancel()">{{ (loadError ? 'action.close' : 'action.cancel') | translate }}</button>
@if (!loadingTemplate && !loadError) {
<button mat-raised-button
color="primary"
[disabled]="!canSubmit()"
(click)="submit()">
<mat-icon>upgrade</mat-icon>
<span>{{ 'agent.app-upgrade-cta' | translate }}</span>
</button>
}
</div>

2
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-profile-upgrade-dialog.component.scss

@ -2,7 +2,7 @@
// SPDX-License-Identifier: BUSL-1.1
@use '../../../components/agent/wizard/agent-wizard' as *;
@include wizard-chrome;
@include wizard-dialog(1280px);
@include wizard-step-basics;
@include wizard-diff;
@include wizard-summary;

18
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-version-warning-dialog.component.html

@ -4,16 +4,18 @@
SPDX-License-Identifier: BUSL-1.1
-->
<div mat-dialog-title class="tb-app-version-warning-header" [class.destructive]="destructive">
<mat-icon class="warn-icon">warning</mat-icon>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<mat-icon class="material-icons mr-2 flex-none">warning</mat-icon>
<h2>{{ titleKey | translate }}</h2>
<span class="flex-1"></span>
<div tb-help="agentAppProfileVersions"></div>
<button mat-icon-button (click)="cancel()" tabindex="-1">
<mat-icon>close</mat-icon>
<button mat-icon-button
(click)="cancel()"
type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</div>
<div mat-dialog-content class="tb-app-version-warning-body">
</mat-toolbar>
<div mat-dialog-content>
<p class="warning-text">
{{ textKey | translate: {
@ -40,7 +42,7 @@
</div>
</div>
<div mat-dialog-actions align="end" class="tb-app-version-warning-footer">
<div mat-dialog-actions class="flex flex-wrap items-center justify-end">
<button mat-button (click)="cancel()">
{{ 'action.cancel' | translate }}
</button>

53
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-app-version-warning-dialog.component.scss

@ -1,55 +1,16 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use '../../../components/agent/agent-shared' as *;
@use '../../../components/agent/wizard/agent-wizard' as *;
:host {
display: block;
width: min(560px, 95vw);
min-width: 0;
max-width: 95vw;
}
.tb-app-version-warning-header {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
.warn-icon {
color: $agent-color-warning-strong;
font-size: 22px;
width: 22px;
height: 22px;
}
@include wizard-dialog(560px);
&.destructive .warn-icon {
color: $agent-color-error-accent;
}
h2 {
flex: 1;
font-size: 20px;
font-weight: 400;
margin: 0;
}
}
.tb-app-version-warning-body {
padding: 16px 24px 24px;
.warning-text {
font-size: 14px;
color: rgba(0, 0, 0, 0.74);
margin: 0 0 16px;
line-height: 1.5;
}
.warning-text {
font-size: 14px;
color: rgba(0, 0, 0, 0.74);
margin: 0 0 16px;
line-height: 1.5;
}
.app-summary {
@include agent-summary-card($agent-surface-muted, $agent-divider-light);
}
.tb-app-version-warning-footer {
padding: 8px 24px 16px;
gap: 8px;
}

9
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-profile-assign-profile-dialog.component.scss

@ -1,13 +1,8 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@use '../../../components/agent/agent-shared' as *;
@use '../../../components/agent/wizard/agent-wizard' as *;
:host {
display: block;
width: min(920px, 95vw);
min-width: 0;
max-width: 95vw;
}
@include wizard-dialog(920px);
.tb-create-new-link {
white-space: nowrap;

15
ui-ngx/src/app/modules/home/pages/agent/dialog/agent-profile-assign-profile-dialog.component.ts

@ -7,11 +7,8 @@ import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { DialogComponent } from '@shared/components/dialog.component';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { AgentAppProfile, AgentApplicationType } from '@shared/models/agent.models';
import {
AgentAppProfileWizardComponent,
AgentAppProfileWizardData
} from '@home/pages/agent/wizard/agent-app-profile-wizard.component';
import { AgentApplicationType } from '@shared/models/agent.models';
import { openAgentAppProfileWizard } from '@home/pages/agent/wizard/agent-app-profile-wizard-dialog';
export interface AgentProfileAssignProfileDialogData {
selectedIds?: string[];
@ -62,13 +59,7 @@ export class AgentProfileAssignProfileDialogComponent
}
private openAppProfileWizard() {
this.dialog.open<AgentAppProfileWizardComponent, AgentAppProfileWizardData, AgentAppProfile>(
AgentAppProfileWizardComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-agent-wizard-dialog'],
data: { lockedAppType: this.data?.lockedAppType }
}
).afterClosed().subscribe(saved => {
openAgentAppProfileWizard(this.dialog, { lockedAppType: this.data?.lockedAppType }).subscribe(saved => {
if (saved) {
const currentIds: string[] = this.formGroup.value?.appProfileIds ?? [];
if (!currentIds.includes(saved.id.id)) {

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save