Open-source IoT Platform - Device management, data collection, processing and visualization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

424 lines
24 KiB

<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
<header class="sol-head" [class.scrolled]="logScrolled() && !(showPane() && paneOpen())" tb-fullscreen [fullscreenElement]="hostElement" [fullscreen]="fullscreen()"
(fullscreenChanged)="fullscreen.set($event)">
<mat-icon class="sol-head-mark" fontSet="material-icons-round" aria-hidden="true">layers</mat-icon>
<tb-ai-chat-title [title]="shownTitle()" [placeholder]="opening() ? '' : ('solution-creator.new-solution' | translate)" [level]="level()"
[statusTip]="statusTip()" [renamable]="!!info()?.id" (renamed)="renameTo($event)"></tb-ai-chat-title>
<div class="sol-head-actions">
@if (title() || built()) {
<button type="button" class="sol-ib" [matMenuTriggerFor]="solutionMenu"
[matTooltip]="'action.more' | translate" matTooltipPosition="above" [attr.aria-label]="'action.more' | translate">
<mat-icon>more_vert</mat-icon>
</button>
}
<button type="button" class="sol-ib" (click)="toggleFullscreen()"
[matTooltip]="(fullscreen() ? 'fullscreen.exit' : 'fullscreen.expand') | translate" matTooltipPosition="above"
[attr.aria-label]="(fullscreen() ? 'fullscreen.exit' : 'fullscreen.expand') | translate">
<mat-icon fontSet="material-icons-round">{{ fullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
</button>
</div>
</header>
<div class="sol-toast" tb-toast toastTarget="solution-creator"></div>
@if (opening()) {
<div class="ai-chat-loading sol-opening" role="status">
<tb-ai-spin kind="think"></tb-ai-spin>
<span>{{ 'solution-creator.opening' | translate }}</span>
</div>
} @else if (isInitialEmpty()) {
<div class="sol-hero">
<div class="sol-hero-scroll">
<div class="sol-hero-in">
<tb-ai-mark class="sol-mark" size="64" icon="layers"></tb-ai-mark>
<h1 class="sol-title">{{ 'solution-creator.what-should-it-do' | translate }}</h1>
<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"
[loading]="loading()"
[blocked]="!!creditsOut()"
(messageSent)="sendMsgFromUser($event)">
</tb-ai-prompt-input>
<div class="sol-examples">
@for (ex of solutionExamples; track ex.key) {
<button type="button" class="ob-chip"
(click)="fillExample(ex.key)">
<mat-icon aria-hidden="true">{{ ex.icon }}</mat-icon>{{ ex.labelKey | translate }}
</button>
}
</div>
<p class="sol-hero-foot">{{ 'solution-creator.limits' | translate }}</p>
<button type="button" class="sol-learn" [attr.aria-expanded]="aboutOpen()" (click)="aboutOpen.set(true)">
<mat-icon fontSet="material-icons-round" aria-hidden="true">info_outline</mat-icon>{{ 'solution-creator.what-is-solution' | translate }}
</button>
</div>
</div>
<div class="sol-about" [class.open]="aboutOpen()" role="region" [attr.aria-hidden]="!aboutOpen()"
[attr.aria-label]="'solution-creator.what-is-solution' | translate">
<div class="sol-about-in">
<div class="sol-about-head">
<b><mat-icon fontSet="material-icons-round" aria-hidden="true">layers</mat-icon>{{ 'solution-creator.about-title' | translate }}</b>
<button type="button" class="sol-ib" (click)="aboutOpen.set(false)" [attr.tabindex]="aboutOpen() ? 0 : -1"
[matTooltip]="'action.close' | translate" matTooltipPosition="above" [attr.aria-label]="'action.close' | translate">
<mat-icon>close</mat-icon>
</button>
</div>
<div class="sol-feats" role="list">
@for (feature of aboutFeatures; track feature.icon) {
<div class="sol-feat" role="listitem">
<mat-icon aria-hidden="true">{{ feature.icon }}</mat-icon>
<div><b>{{ feature.title | translate }}</b><span>{{ feature.line | translate }}</span></div>
</div>
}
</div>
</div>
</div>
</div>
} @else if (creatorStep()) {
<div class="sol-cols art-cols" [class.with-pane]="showPane() && paneOpen()">
<div class="sol-chat" [class.scrolled]="logScrolled()">
<div #chatArea class="sol-log" (scroll)="onLogScroll(chatArea)">
<div class="sol-log-in">
<tb-ai-chat-messages
[messages]="viewMessages()"
[loading]="false"
[scrollContainer]="chatArea"
[feedback]="!!info()?.id"
initialScroll="bottom"
(rate)="onRate($event)"
(report)="onReport($event)"
(chip)="onChip($event)"
(resume)="resume()"
(resourceError)="showErrorMessage($event)">
</tb-ai-chat-messages>
@if (pendingQuestions(); as questions) {
@if (questions.length) {
<tb-ai-question class="sol-ask" [questions]="questions" (done)="answerQuestions($event)" (skip)="skipQuestions($event)"></tb-ai-question>
}
}
@if (skipInterviewAllowed() && !loading() && !isGenerating() && !pendingQuestions().length) {
<tb-ai-card-actions class="sol-chips" [actions]="skipActions()" (act)="skipInterview()"></tb-ai-card-actions>
}
@if (creatorStep() === 'chat' && uninstalledAt(); as at) {
<div class="k-hint note sol-hint">
<mat-icon aria-hidden="true">info_outline</mat-icon>
<span><b>{{ 'solution-creator.uninstalled-at' | translate: {time: (at | date:'HH:mm')} }}</b>
{{ 'solution-creator.uninstalled-note' | translate }}</span>
</div>
} @else if (creatorStep() === 'chat' && installed()) {
<div class="k-hint heads-up sol-hint">
<mat-icon aria-hidden="true">outlined_flag</mat-icon>
<span><b>{{ 'solution-creator.installed-already' | translate }}</b>
{{ 'solution-creator.installed-already-note' | translate }}</span>
</div>
}
@if (creatorStep() === 'result' && issues().length) {
<div class="sol-closing sol-issues">
<p>{{ 'solution-creator.issues-lead' | translate: {count: issues().length} }}</p>
<ul>
@for (issue of issues().slice(0, 6); track $index) {
<li><b>{{ issue.name }}</b> · {{ issue.status === 'WARN' && issue.message ? issue.message : ((issue.status === 'ERROR' ? 'solution-creator.pane.status-error' : 'solution-creator.pane.status-warn') | translate) }}</li>
}
</ul>
<div class="k-hint tip sol-hint">
<mat-icon aria-hidden="true">lightbulb_outline</mat-icon>
<span><b>{{ 'solution-creator.issues-tip-lead' | translate }}</b> {{ 'solution-creator.issues-tip' | translate }}</span>
</div>
</div>
}
@if (failure(); as message) {
<div class="sol-failure" role="status">
<mat-icon fontSet="material-icons-round" aria-hidden="true">error_outline</mat-icon>
<span>{{ message }}</span>
</div>
}
@if (work(); as current) {
<tb-ai-work-line class="sol-work" [words]="paneTalks() ? (current.lines?.[0] ?? current.words) : current.words" [kind]="current.kind" [since]="current.since"></tb-ai-work-line>
}
</div>
</div>
<div #composer class="sol-composer">
<div class="sol-toast-chat" tb-toast toastTarget="solution-creator-chat"></div>
@if (pill(); as current) {
<button type="button" class="k-pill" [class.new]="current.mode === 'new'"
[matTooltip]="current.label" matTooltipPosition="above" [attr.aria-label]="'ai-assistant.go-to-end' | translate"
(click)="goToEnd(chatArea)">
@if (current.mode === 'new') {
<mat-icon class="tb-mat-18">arrow_downward</mat-icon>{{ current.count }}
} @else {
<tb-ai-spin [kind]="current.kind"></tb-ai-spin>
}
</button>
}
@if (showPane() && !paneOpen()) {
<button type="button" class="art-tray" (click)="openPane()" [attr.aria-label]="'solution-creator.pane.open' | translate">
<mat-icon aria-hidden="true">layers</mat-icon>
<b>{{ 'solution-creator.pane.solution' | translate }}</b>
<span class="art-tray-note" [class.working]="!!making()" [class.failed]="!making() && !!failure()">
@if (making()) {
<tb-ai-spin [kind]="making() === 'solution' ? 'install' : 'gen'"></tb-ai-spin>
}
{{ trayNote() }}
</span>
@if (level() === 'needs') {
<span class="art-tray-dot" aria-hidden="true"></span>
}
<mat-icon class="art-tray-chev" aria-hidden="true">chevron_right</mat-icon>
</button>
}
@if (creditsOut(); as limitType) {
<tb-ai-credits-out [limitType]="limitType" (dismissed)="creditsOut.set(null)"></tb-ai-credits-out>
} @else if (notice(); as current) {
<div class="k-notice k-notice-edge" [class]="'k-notice k-notice-edge ' + (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
[placeholder]="activePlaceholder() | translate"
[loading]="loading() || isGenerating() || making() === 'solution'"
[stoppable]="!!info()?.id"
[blocked]="notice()?.kind === 'block' || !!creditsOut()"
[stopping]="stopping()"
(stopped)="stop()"
[pinned]="true"
[dropZone]="chatArea"
(messageSent)="sendMsgFromUser($event)">
</tb-ai-prompt-input>
</div>
</div>
@if (showPane() && paneOpen()) {
<tb-ai-artifact-pane #pane [dark]="json() && jsonDark()" [class.art-dark]="json() && jsonDark()" [class.sol-json-on]="json()" (closed)="closePane()">
<div artHead class="sol-views" role="group" [attr.aria-label]="'solution-creator.pane.view' | translate">
@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)"
[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>
} @else {
<mat-icon aria-hidden="true">{{ view.icon }}</mat-icon>
}
<span class="sol-views-l">{{ ('solution-creator.pane.view-' + view.id) | translate }}</span>
</button>
}
</div>
@if (json() && jsonView) {
<div artHead class="art-head-r sol-json-tools">
<div class="art-tools">
@if (!jsonView.body().editing()) {
<button type="button" class="art-tool icon-only" (click)="jsonView.body().openFind()"
[matTooltip]="'ai-assistant.file.find' | translate" matTooltipPosition="below" [attr.aria-label]="'ai-assistant.file.find' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">search</mat-icon>
</button>
}
<button type="button" class="art-tool icon-only" [class.on]="jsonWrap()" [attr.aria-pressed]="jsonWrap()" (click)="toggleJsonWrap()"
[matTooltip]="'ai-assistant.file.wrap' | translate" matTooltipPosition="below" [attr.aria-label]="'ai-assistant.file.wrap' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">wrap_text</mat-icon>
</button>
<button type="button" class="art-tool icon-only" [matMenuTriggerFor]="jsonOptions"
[matTooltip]="'ai-assistant.file.more' | translate" matTooltipPosition="below" [attr.aria-label]="'ai-assistant.file.more' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">more_vert</mat-icon>
</button>
</div>
<div class="art-tools">
<button type="button" class="art-tool icon-only art-copy" [class.copied]="jsonCopied()" (click)="copyJson()"
[matTooltip]="(jsonCopied() ? 'ai-assistant.copied' : 'ai-assistant.file.copy') | translate" matTooltipPosition="below"
[attr.aria-label]="'ai-assistant.file.copy' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">{{ jsonCopied() ? 'check' : 'content_copy' }}</mat-icon>
</button>
<span class="tb-ai-sr-only" aria-live="polite">{{ jsonCopied() ? ('ai-assistant.copied' | translate) : '' }}</span>
<button type="button" class="art-tool icon-only" (click)="downloadJson()"
[matTooltip]="'ai-assistant.file.download' | translate" matTooltipPosition="below" [attr.aria-label]="'ai-assistant.file.download' | translate">
<mat-icon class="tb-mat-18" aria-hidden="true">download</mat-icon>
</button>
</div>
</div>
}
@if (jsonAvailable()) {
<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>
}
@if (making() === 'solution' && currentView() === 'solution' && progressInfo(); as progress) {
<tb-solution-installed [solution]="progress" [creating]="true" [items]="installProgress()?.items ?? null"
[stage]="installProgress()?.stage ?? null" [createShare]="createShare()"
[seconds]="makeSeconds()" [startedAt]="makeStartedAt()"></tb-solution-installed>
} @else if (making() && currentView() === making()) {
<div class="art-loading k-mark sol-loading" role="status">
<span class="art-load-markwrap">
<span class="art-load-glow" aria-hidden="true"></span>
<tb-ai-mark size="64"></tb-ai-mark>
</span>
<tb-ai-load-lines [line]="work()?.words" [lines]="work()?.lines ?? []"></tb-ai-load-lines>
<p class="art-load-note">{{ estimateOf(making()) }}</p>
</div>
} @else if (json()) {
<tb-solution-json #jsonView class="sol-json" [value]="jsonValue()"
[fileName]="currentView() === 'dashboards' ? 'dashboards.json' : 'solution.json'"
[wrap]="jsonWrap()" [whitespace]="jsonWhitespace()"
(applied)="applyJson($event)" (discarded)="onJsonDiscarded()"></tb-solution-json>
} @else {
@switch (currentView()) {
@case ('overview') {
<tb-solution-overview [descriptor]="info()?.data?.solutionDescriptor"
(descriptorChange)="updatedSolutionDescriptor($event)"></tb-solution-overview>
}
@case ('dashboards') {
<tb-solution-dashboards [dashboards]="info()?.data?.dashboardsOverview ?? []"></tb-solution-dashboards>
}
@case ('solution') {
<tb-solution-installed [solution]="info()" (openMain)="gotoMainDashboard()"></tb-solution-installed>
}
}
}
@if (!making()) {
<footer artFoot class="art-pane-foot" [class.file-bar]="json()">
@if (json() && jsonView; as view) {
<span class="file-bar-info">
@if (view.body().editing()) {
@if (view.error(); as message) {
<span class="file-bar-state sol-json-err" role="alert"><i class="file-bar-dot" aria-hidden="true"></i>{{ 'solution-creator.pane.json-invalid' | translate: {message} }}</span>
} @else if (view.body().dirty()) {
<span class="file-bar-state"><i class="file-bar-dot" aria-hidden="true"></i>{{ 'ai-assistant.file.unsaved' | translate }}</span>
} @else {
<span class="file-bar-state">{{ 'ai-assistant.file.editing' | translate }}</span>
}
@if (view.body().caret(); as caret) {
<i class="file-bar-sep" aria-hidden="true">·</i>
<span class="file-bar-pos">{{ 'ai-assistant.file.position' | translate: {line: caret.line, col: caret.col} }}</span>
}
} @else if (view.body().saved()) {
<span class="file-bar-saved"><mat-icon aria-hidden="true">check</mat-icon>{{ 'solution-creator.pane.json-applied' | translate }}</span>
} @else {
<span class="file-bar-name">{{ view.fileName() }}</span>
<i class="file-bar-sep" aria-hidden="true">·</i>
<span>{{ 'ai-assistant.file.lines' | translate: {count: view.file().lines} }}</span>
<i class="file-bar-sep" aria-hidden="true">·</i>
<span>{{ view.file().size }}</span>
}
</span>
<span class="file-bar-acts">
@if (view.body().editing()) {
@if (view.body().dirty()) {
<button mat-stroked-button type="button" class="file-bar-b" (click)="view.body().discard()">{{ 'ai-assistant.file.discard' | translate }}</button>
<button mat-flat-button type="button" class="file-bar-b file-bar-save" [disabled]="!!view.error()" (click)="view.body().save()"
[matTooltip]="'solution-creator.pane.json-note' | translate" matTooltipPosition="above">
{{ 'action.apply' | translate }}
</button>
} @else {
<button mat-stroked-button type="button" class="file-bar-b" (click)="view.body().done()">{{ 'ai-assistant.file.done' | translate }}</button>
}
} @else {
<button mat-stroked-button type="button" class="file-bar-b" (click)="view.body().startEdit()">
<mat-icon>edit</mat-icon>{{ 'ai-assistant.file.edit' | translate }}
</button>
}
</span>
} @else if (currentView() === 'solution' || creatorStep() === 'result') {
@if (installed()) {
<button mat-button type="button" class="warn" (click)="uninstallSolution()">
<mat-icon>delete_outline</mat-icon>{{ 'solution-creator.uninstall-solution' | translate }}
</button>
}
<span class="sol-spacer"></span>
<button mat-button type="button" (click)="back()">
<mat-icon>edit</mat-icon>{{ 'action.edit' | translate }}
</button>
@if (installed()) {
@if (mainUser()) {
<button mat-stroked-button type="button" class="sol-foot-stroked" (click)="viewAsMainUser()">
<mat-icon>person</mat-icon>{{ 'solution-creator.pane.view-as-main' | translate }}
</button>
} @else if (solutionMetadata.installResult?.mainDashboardId) {
<button mat-stroked-button type="button" class="sol-foot-stroked" (click)="gotoMainDashboard()">
<mat-icon>dashboard</mat-icon>{{ 'solution-creator.main-dashboard' | translate }}
</button>
}
} @else {
<button mat-flat-button type="button" (click)="installSolution()">
<mat-icon>rocket_launch</mat-icon>{{ 'solution-creator.install-solution' | translate }}
</button>
}
} @else if (currentView() === 'overview') {
<span class="sol-foot-note">{{ estimateOf('dashboards') }}</span>
<button mat-flat-button type="button" [disabled]="loading()" (click)="nextStep()">
{{ 'solution-creator.next-dashboards' | translate }}
</button>
} @else {
<span class="sol-foot-note">{{ estimateOf('solution') }}</span>
<button mat-button type="button" [disabled]="loading()" (click)="back()">{{ 'action.back' | translate }}</button>
<button mat-stroked-button type="button" class="sol-foot-stroked" [disabled]="loading() || !messages().length" (click)="startOver()">
<mat-icon>refresh</mat-icon>{{ 'solution-creator.regenerate' | translate }}
</button>
<button mat-flat-button type="button" [disabled]="loading()" (click)="nextStep()">
{{ nextButtonLabel | translate }}
</button>
}
</footer>
}
</tb-ai-artifact-pane>
}
</div>
}
<mat-menu #solutionMenu="matMenu" xPosition="before" class="tb-ai-chat-menu">
<button mat-menu-item (click)="titleRef?.startRename()">
<mat-icon fontSet="material-icons-round">edit</mat-icon>
<span>{{ 'action.rename' | translate }}</span>
</button>
@if (built() && creatorStep() === 'result') {
<button mat-menu-item (click)="editDesign()">
<mat-icon fontSet="material-icons-round">design_services</mat-icon>
<span>{{ 'ai-assistant.edit-design' | translate }}</span>
</button>
}
@if (creatorStep() === 'result') {
<button mat-menu-item (click)="openInfo()">
<mat-icon fontSet="material-icons-round">info_outline</mat-icon>
<span>{{ 'solution-creator.info' | translate }}</span>
</button>
}
@if (installed()) {
<button mat-menu-item (click)="uninstallSolution()">
<mat-icon fontSet="material-icons-round">delete_sweep</mat-icon>
<span>{{ 'solution-creator.uninstall-solution' | translate }}</span>
</button>
}
<button mat-menu-item class="danger" (click)="deleteSolution()">
<mat-icon fontSet="material-icons-round">delete_outline</mat-icon>
<span>{{ 'action.delete' | translate }}</span>
</button>
</mat-menu>
<mat-menu #jsonOptions="matMenu" xPosition="before" class="tb-ai-chat-menu art-opts">
@if (!jsonView?.body()?.editing()) {
<button mat-menu-item role="menuitemcheckbox" [attr.aria-checked]="jsonWhitespace()" (click)="$event.stopPropagation(); toggleJsonWhitespace()">
<mat-icon fontSet="material-icons-round">space_bar</mat-icon>
<span class="art-opt-l">{{ 'ai-assistant.file.show-whitespace' | translate }}</span>
<span class="art-switch" [class.on]="jsonWhitespace()" aria-hidden="true"><i></i></span>
</button>
}
<div class="art-opt-row" role="group" [attr.aria-label]="'ai-assistant.file.theme' | translate" (click)="$event.stopPropagation()">
<mat-icon fontSet="material-icons-round" aria-hidden="true">contrast</mat-icon>
<span>{{ 'ai-assistant.file.theme' | translate }}</span>
<div class="art-modes art-opt-modes" role="radiogroup">
<button type="button" role="radio" [attr.aria-checked]="jsonDark()" (click)="setJsonTheme('dark')">
<mat-icon class="tb-mat-16" aria-hidden="true">dark_mode</mat-icon><span>{{ 'ai-assistant.file.dark' | translate }}</span>
</button>
<button type="button" role="radio" [attr.aria-checked]="!jsonDark()" (click)="setJsonTheme('light')">
<mat-icon class="tb-mat-16" aria-hidden="true">light_mode</mat-icon><span>{{ 'ai-assistant.file.light' | translate }}</span>
</button>
</div>
</div>
</mat-menu>