src/app/core/setup/assistant-dialog/assistant-dialog.component.ts
The Assistant Panel shown by the AssistantButton, which dynamically displays different assistant views depending on the current system state.
| changeDetection | ChangeDetectionStrategy.OnPush |
| selector | app-assistant-dialog |
| standalone | true |
| imports |
MatTabGroup
MatTab
MatIconButton
MatMenuTrigger
Angulartics2OnModule
MatMenu
MatTooltip
MatDialogClose
|
| styleUrls | ./assistant-dialog.component.scss |
| templateUrl | ./assistant-dialog.component.html |
| styleUrl | ./assistant-dialog.component.scss |
No results matching.
ContextAwareAssistantComponent
MatTabGroup
MatTab
SystemInitAssistantComponent
SetupWizardComponent
FaIconComponent
MatIconButton
MatMenuTrigger
Angulartics2OnModule
MatMenu
MatMenuItem
RouterLink
MatTooltip
MatDialogClose
OnInit
Properties |
Methods |
| onTabChange | ||||||
onTabChange(event: MatTabChangeEvent)
|
||||||
|
Parameters :
Returns :
void
|
| updateSetupWizardVisible | ||||||
updateSetupWizardVisible(newState: boolean)
|
||||||
|
Parameters :
Returns :
void
|
| assistants |
Type : object
|
Default value : {
initDemo: false,
contextAwareGuide: false,
setupWizard: false,
}
|
|
Lists all available assistants and whether they are enabled. |
import {
Component,
inject,
OnInit,
ChangeDetectionStrategy,
} from "@angular/core";
import { ContextAwareAssistantComponent } from "../context-aware-assistant/context-aware-assistant.component";
import { MatTab, MatTabChangeEvent, MatTabGroup } from "@angular/material/tabs";
import { SystemInitAssistantComponent } from "../system-init-assistant/system-init-assistant.component";
import { ConfigService } from "../../config/config.service";
import { Config } from "../../config/config";
import {
CONFIG_SETUP_WIZARD_ID,
SetupWizardConfig,
} from "../../admin/setup-wizard/setup-wizard-config";
import { Logging } from "../../logging/logging.service";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { filter } from "rxjs/operators";
import { EntityMapperService } from "../../entity/entity-mapper/entity-mapper.service";
import { SetupWizardComponent } from "../../admin/setup-wizard/setup-wizard.component";
import { MatDialogClose, MatDialogRef } from "@angular/material/dialog";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
import { MatIconButton } from "@angular/material/button";
import { MatMenu, MatMenuItem, MatMenuTrigger } from "@angular/material/menu";
import { Angulartics2OnModule } from "angulartics2";
import { AssistantService } from "#src/app/core/setup/assistant.service";
import { RouterLink } from "@angular/router";
import { MatTooltip } from "@angular/material/tooltip";
/**
* The Assistant Panel shown by the AssistantButton,
* which dynamically displays different assistant views
* depending on the current system state.
*/
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: "app-assistant-dialog",
imports: [
ContextAwareAssistantComponent,
MatTabGroup,
MatTab,
SystemInitAssistantComponent,
SetupWizardComponent,
FaIconComponent,
MatIconButton,
MatMenuTrigger,
Angulartics2OnModule,
MatMenu,
MatMenuItem,
RouterLink,
MatTooltip,
MatDialogClose,
],
templateUrl: "./assistant-dialog.component.html",
styleUrl: "./assistant-dialog.component.scss",
})
@UntilDestroy()
export class AssistantDialogComponent implements OnInit {
private readonly dialogRef = inject(MatDialogRef<AssistantDialogComponent>);
private readonly configService = inject(ConfigService);
private readonly entityMapper = inject(EntityMapperService);
/**
* Lists all available assistants and whether they are enabled.
*/
assistants = {
initDemo: false,
contextAwareGuide: false,
setupWizard: false,
};
ngOnInit(): void {
this.detectAssistantModes();
}
private detectAssistantModes() {
if (!this.configService.hasConfig()) {
this.assistants.initDemo = true;
} else {
this.assistants.initDemo = false;
this.assistants.contextAwareGuide = true;
this.checkIfSetupWizardEnabled();
}
}
private checkIfSetupWizardEnabled() {
this.entityMapper
.load(Config, CONFIG_SETUP_WIZARD_ID)
.then((r: Config<SetupWizardConfig>) => {
this.assistants.setupWizard = !r.data.finished;
})
.catch((e) => Logging.debug("No Setup Wizard Config found"));
this.entityMapper
.receiveUpdates<Config<SetupWizardConfig>>(Config)
.pipe(
untilDestroyed(this),
filter(({ entity }) => entity.getId() === CONFIG_SETUP_WIZARD_ID),
)
.subscribe(
(update) =>
(this.assistants.setupWizard = !update.entity.data.finished),
);
}
onTabChange(event: MatTabChangeEvent) {
if (event.tab.id === "setupWizard") {
this.setDialogFullscreen();
}
if (event.tab.id === "initDemo") {
this.setDialogFullscreen();
}
}
private setDialogFullscreen() {
this.dialogRef.updateSize(
"calc(100% - 100px)",
AssistantService.ASSISTANT_DIALOG_HEIGHT,
);
}
updateSetupWizardVisible(newState: boolean) {
this.assistants.setupWizard = newState;
// TODO: save this to SetupWizard Config
}
}
<mat-tab-group
(selectedTabChange)="onTabChange($event)"
class="assistant-panel-container dialog-header-bar"
>
@if (assistants.initDemo) {
<mat-tab id="initDemo" label="Create System" i18n-label>
<app-system-init-assistant></app-system-init-assistant>
</mat-tab>
}
@if (assistants.contextAwareGuide) {
<mat-tab id="contextAwareGuide" label="Guide" i18n-label>
<app-context-aware-assistant></app-context-aware-assistant>
</mat-tab>
}
@if (assistants.setupWizard) {
<mat-tab id="setupWizard" label="Setup Wizard" i18n-label>
<app-setup-wizard></app-setup-wizard>
</mat-tab>
}
<!-- ... more modes to be added -->
</mat-tab-group>
<button
class="context-menu-button"
mat-icon-button
color="primary"
[matMenuTriggerFor]="contextMenu"
>
<fa-icon icon="ellipsis-v"></fa-icon>
</button>
<mat-menu #contextMenu>
<button
mat-menu-item
(click)="updateSetupWizardVisible(!assistants.setupWizard)"
>
<fa-icon
[icon]="assistants.setupWizard ? 'eye' : 'eye-slash'"
class="standard-icon-with-text"
></fa-icon>
<span i18n>Setup Wizard</span>
</button>
<button
mat-menu-item
routerLink="/support"
matDialogClose
matTooltip="View detailed technical information for troubleshooting"
i18n-matTooltip
i18n
>
Technical Information
</button>
</mat-menu>
./assistant-dialog.component.scss
@use "variables/colors";
@use "variables/sizes";
:host {
--dialog-header-border: 18px;
}
.assistant-panel-container {
height: 100%;
box-sizing: border-box;
}
.dialog-header-bar {
border-top: var(--dialog-header-border) solid colors.$accent;
}
::ng-deep mat-tab-header {
// gap to add context menu button in right corner
margin-right: 48px;
}
.context-menu-button {
position: absolute;
right: 0;
top: var(--dialog-header-border);
::ng-deep {
--mat-icon-button-container-shape: 0;
}
}
::ng-deep .mat-mdc-tab-body-wrapper {
height: 100%;
padding: sizes.$regular;
}
// disable shadow of Assistant Button in toolbar while opened dialog
::ng-deep .mdc-dialog--open .mat-mdc-dialog-surface,
.mdc-dialog--closing .mat-mdc-dialog-surface {
border-radius: 0px !important;
box-shadow:
0px 0px 0px 0px rgba(0, 0, 0, 0),
0px 24px 38px 3px rgba(0, 0, 0, 0.14),
0px 9px 0px 0px rgba(0, 0, 0, 0.12);
}