File

core/setup/setup.component.ts

Description

This component is the parent of each setup and can be injected into setup steps to control them.

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(options: OptionsService, stepperService: StepperService, appState: AppStateService, alert: AlertService, permissions: Permissions, setupService: SetupService)
Parameters :
Name Type Optional
options OptionsService No
stepperService StepperService No
appState AppStateService No
alert AlertService No
permissions Permissions No
setupService SetupService No

Methods

cancel
cancel()

Cancels the wizards and goes back to the start view.

Returns : void
Async finalize
finalize()
Returns : any
finish
finish()

Finish the wizard and will start the application.

Returns : void
getByIndex
getByIndex(stepIndex: unknown)

Returns a step by it index position in the wizard.

Parameters :
Name Type Optional Description
stepIndex unknown No

The step index that you want to receive.

Returns : any

An indexed step definition.

skip
skip()

Skips the current setup wizard

Returns : void
start
start()

Starts the wizards (or finish the setup if no steps are found)

Returns : void
stepCompleted
stepCompleted(stepIndex: unknown, isCompleted: unknown)

Mark a step as completed. If the step is required, this is needed to fulfill the setup.

Parameters :
Name Type Optional Default value Description
stepIndex unknown No

The index of the step you want to mark as completed

isCompleted unknown No true

Defaults to true to mark it as completed but can be set to false to invalidate the step.

Returns : void
verify
verify()

Verifies every step and checks if all required are completed. Updates the icons to reflect the state of the steps (error, warning, done).

Returns : boolean

Returns true if no error was found.

Properties

completed$
Type : unknown
Default value : new Observable<boolean>().pipe(startWith(true))

Emits when the setup is done. You can add certain operations before completing the setup that needed to be awaited. Return true if everything is fine, otherwise false.

Example :
const asyncOperation = delay(2000);
this.setup.completed$ = this.setup.completed$.pipe(asyncOperation, map(() => true));

Note: Remember that a step can be viewed multiple times. The step needs to ensure, to only add a completed operation ones.

currentSetupState
Type : unknown
Default value : SetupState.START

The current state. SetupState.START shows an application overview while SetupState.WIZARD shows the steps.

data$
Type : unknown
Default value : new BehaviorSubject<Record<string, unknown>>({})

A subject which can be used to exchange data between steps.

Public options
Type : OptionsService
steps
Type : SetupStep[]

All current shown setup steps.

<c8y-title>
  {{ options.name | humanizeAppName | async }}
</c8y-title>

@if (currentSetupState !== setupState.START) {
  <div class="card content-fullpage fadeInRightBig animated">
    <c8y-stepper-outlet
      class="d-contents"
      [showDefaultButtons]="false"
      [steps]="steps"
    ></c8y-stepper-outlet>
  </div>
}

@if (currentSetupState === setupState.START) {
  <div class="card content-fullpage d-flex d-col zoomIn animated">
    <div class="inner-scroll flex-grow">
      <div class="card-block">
        <div class="row">
          <div class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3 p-t-24">
            <c8y-setup-illustration></c8y-setup-illustration>
            <h1
              class="p-t-16 p-b-16 text-center text-medium"
              ngNonBindable
              translate
              [translateParams]="{ appName: options.name | humanizeAppName | async }"
              data-cy="c8y-setup--setup-header-title"
            >
              Welcome to {{ appName }}
            </h1>
            @if (hasRole) {
              <p
                class="lead text-normal"
                translate
              >
                This application (or any plugin that you added recently) has pre-requirements that
                needs to be configured first. This wizard will guide you through the steps that are
                necessary to get your customized application up and running.
              </p>
            }
            @if (properties.length > 0) {
              <div class="flex-grow">
                <c8y-properties-list
                  icon="info"
                  [title]="'Application properties' | translate"
                  [properties]="properties"
                  [data]="options"
                ></c8y-properties-list>
              </div>
            }
            @if (!hasRole) {
              <div class="alert alert-danger m-32">
                <strong translate>No permission</strong>
                <div translate>
                  You don't have sufficient rights to setup this application. Contact an application
                  administrator to setup the required steps.
                </div>
              </div>
            }
            @if (!isOwner) {
              <div class="alert alert-danger m-32">
                <strong translate>Not the owner</strong>
                <div translate>
                  The current application is not owned by this tenant. Clone the application before
                  running the setup.
                </div>
              </div>
            }
          </div>
        </div>
      </div>
    </div>
    <div class="card-footer separator gap-8 d-flex j-c-center">
      @if (canSkip) {
        <button
          class="btn btn-default"
          [title]="
            'You can skip the setup now. It will be shown again as soon as you restart the application.'
              | translate
          "
          (click)="skip()"
          translate
          data-cy="c8y-setup--skip-setup-button"
        >
          Skip
        </button>
      }

      <button
        class="btn btn-primary"
        [title]="'Start the setup wizard.' | translate"
        (click)="start()"
        translate
        [disabled]="!hasRole || !isOwner"
        data-cy="c8y-setup--start-setup-button"
      >
        Start
      </button>
    </div>
  </div>
}

results matching ""

    No results matching ""