src/app/core/admin/setup-wizard/setup-wizard-button/setup-wizard-button.component.ts

Deprecated

Will be replaced by AssistantDialog panel

Implements

OnInit

Example

Metadata

Relationships

Index

Properties
Methods

Methods

navigateToWizard
navigateToWizard()
Returns : void

Properties

showSetupWizard
Type : boolean
import {
  Component,
  OnInit,
  inject,
  ChangeDetectionStrategy,
} from "@angular/core";
import { Router } from "@angular/router";
import { EntityMapperService } from "../../../entity/entity-mapper/entity-mapper.service";
import { Config } from "../../../config/config";
import {
  CONFIG_SETUP_WIZARD_ID,
  SetupWizardConfig,
} from "../setup-wizard-config";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { filter } from "rxjs/operators";
import { Logging } from "../../../logging/logging.service";
import { environment } from "../../../../../environments/environment";
import { IconButtonComponent } from "#src/app/core/common-components/icon-button/icon-button.component";

/**
 * @deprecated Will be replaced by AssistantDialog panel
 */
@UntilDestroy()
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: "app-setup-wizard-button",
  imports: [IconButtonComponent],
  templateUrl: "./setup-wizard-button.component.html",
  styleUrls: ["./setup-wizard-button.component.scss"],
})
export class SetupWizardButtonComponent implements OnInit {
  private entityMapper = inject(EntityMapperService);
  private router = inject(Router);

  showSetupWizard: boolean;

  ngOnInit() {
    this.entityMapper
      .load(Config, CONFIG_SETUP_WIZARD_ID)
      .then((r: Config<SetupWizardConfig>) => {
        this.updateStatus(r.data);
        if (!r.data.finished && r.data.openOnStart) {
          this.navigateToWizard();
        }
      })
      .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.updateStatus(update.entity.data));
  }

  private updateStatus(config: SetupWizardConfig) {
    this.showSetupWizard = !config.finished && !environment.demo_mode;
    // demo_mode is showing the wizard in the assistant dialog
  }

  navigateToWizard() {
    this.router.navigate(["/admin/setup-wizard"]);
  }
}
@if (showSetupWizard) {
  <app-icon-button
    icon="person-digging"
    buttonType="mat-flat-button"
    color="accent"
    (buttonClick)="navigateToWizard()"
    i18n
  >
    Setup Wizard
  </app-icon-button>
}

./setup-wizard-button.component.scss

.button {
  border-top: solid 1px rgba(0, 0, 0, 0.12);
  border-radius: 0;
  overflow: hidden;
  width: 100%;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""