projects/cobbler-frontend/src/app/actions/hardlink/hardlink.component.ts

Implements

OnDestroy

Metadata

Relationships

Used by

No results matching.

Depends on

Index

Properties
Methods

Methods

ngOnDestroy
ngOnDestroy()
Returns : void
runHardlink
runHardlink()
Returns : void

Properties

Private _snackBar
Type : unknown
Default value : inject(MatSnackBar)
Private cobblerApiService
Type : unknown
Default value : inject(CobblerApiService)
Private ngUnsubscribe
Type : unknown
Default value : new Subject<void>()
userService
Type : unknown
Default value : inject(UserService)
import { Component, OnDestroy, inject } from '@angular/core';
import { MatButton } from '@angular/material/button';
import { MatSnackBar } from '@angular/material/snack-bar';
import { CobblerApiService } from 'cobbler-api';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { UserService } from '../../services/user.service';
import Utils from '../../utils';

@Component({
  selector: 'cobbler-hardlink',
  imports: [MatButton],
  templateUrl: './hardlink.component.html',
  styleUrl: './hardlink.component.scss',
})
export class HardlinkComponent implements OnDestroy {
  userService = inject(UserService);
  private cobblerApiService = inject(CobblerApiService);
  private _snackBar = inject(MatSnackBar);

  // Unsubscribe
  private ngUnsubscribe = new Subject<void>();

  ngOnDestroy(): void {
    this.ngUnsubscribe.next();
    this.ngUnsubscribe.complete();
  }

  runHardlink(): void {
    this.cobblerApiService
      .background_hardlink(this.userService.token)
      .pipe(takeUntil(this.ngUnsubscribe))
      .subscribe(
        (value) => {
          // TODO
        },
        (error) => {
          // HTML encode the error message since it originates from XML
          this._snackBar.open(
            Utils.toHTML(error.message),
            $localize`:@@snackbar.action.close:Close`,
          );
        },
      );
  }
}
<h1 i18n="@@action.hardlink.title">HARDLINK</h1>

<button mat-button (click)="runHardlink()" i18n="@@action.hardlink.run">
  Hardlink
</button>

./hardlink.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""