File
Implements
Methods
ngOnDestroy
|
ngOnDestroy()
|
|
|
runValidateAutoinstalls
|
runValidateAutoinstalls()
|
|
|
Private
ngUnsubscribe
|
Default value : new Subject<void>()
|
|
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-validate-autoinstalls',
standalone: true,
imports: [MatButton],
templateUrl: './validate-autoinstalls.component.html',
styleUrl: './validate-autoinstalls.component.scss',
})
export class ValidateAutoinstallsComponent 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();
}
runValidateAutoinstalls(): void {
this.cobblerApiService
.background_validate_autoinstall_files(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>VALIDATE AUTOINSTALLS</h1>
<button mat-button (click)="runValidateAutoinstalls()">Run</button>
Legend
Html element with directive