File

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

Implements

OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(userService: UserService, cobblerApiService: CobblerApiService, _snackBar: MatSnackBar)
Parameters :
Name Type Optional
userService UserService No
cobblerApiService CobblerApiService No
_snackBar MatSnackBar No

Methods

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

Properties

Private ngUnsubscribe
Default value : new Subject<void>()
Public userService
Type : UserService
import { Component, OnDestroy } 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',
  standalone: true,
  imports: [MatButton],
  templateUrl: './hardlink.component.html',
  styleUrl: './hardlink.component.scss',
})
export class HardlinkComponent implements OnDestroy {
  // Unsubscribe
  private ngUnsubscribe = new Subject<void>();

  constructor(
    public userService: UserService,
    private cobblerApiService: CobblerApiService,
    private _snackBar: MatSnackBar,
  ) {}

  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), 'Close');
        },
      );
  }
}
<h1>HARDLINK</h1>

<button mat-button (click)="runHardlink()">Hardlink</button>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""