-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from cobbler/feature/add-buildiso
Feature: Implement UI for "cobbler buildiso"
- Loading branch information
Showing
6 changed files
with
157 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
49 changes: 36 additions & 13 deletions
49
projects/cobbler-frontend/src/app/actions/build-iso/build-iso.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
<div class="right-column" id="dataScreen"> | ||
<router-outlet></router-outlet> | ||
<div class="BuildISO-div"> | ||
<h1 class="title"> BUILD </h1> | ||
<div class="list-group"> | ||
<mat-list> | ||
<mat-list-item>data 01</mat-list-item> | ||
<mat-list-item>data 02</mat-list-item> | ||
<mat-list-item>data 03</mat-list-item> | ||
</mat-list> | ||
</div> | ||
</div> | ||
</div> | ||
<h1 class="title"> BUILD ISO IMAGES </h1> | ||
|
||
<form class="form-replicate" [formGroup]="buildisoFormGroup"> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Distro</mat-label> | ||
<input matInput required type="text" formControlName="distro" placeholder="leap-x86_64" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>ISO</mat-label> | ||
<input matInput type="text" formControlName="iso" placeholder="/var/lib/cobbler/isos/autoinstall.iso" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Profiles</mat-label> | ||
<input matInput type="text" formControlName="profiles" placeholder="" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Systems</mat-label> | ||
<input matInput type="text" formControlName="systems" placeholder="" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Buildiso directory</mat-label> | ||
<input matInput type="text" formControlName="buildisodir" placeholder="/var/cache/cobbler/buildiso" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Source</mat-label> | ||
<input matInput type="text" formControlName="source" placeholder="/var/lib/cobbler/iso-source/leap-x86_64" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>xorrisofs Options</mat-label> | ||
<input matInput type="text" formControlName="xorrisofsOpts" placeholder="-v" /> | ||
</mat-form-field> | ||
<mat-checkbox class="form-field-full-width" formControlName="standalone">Standalone</mat-checkbox> | ||
<mat-checkbox class="form-field-full-width" formControlName="airgapped">Airgapped</mat-checkbox> | ||
<mat-checkbox class="form-field-full-width" formControlName="excludeDNS">Exclude DNS</mat-checkbox> | ||
<button mat-button (click)="runBuildiso()">Run</button> | ||
</form> |
9 changes: 9 additions & 0 deletions
9
projects/cobbler-frontend/src/app/actions/build-iso/build-iso.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.form-replicate { | ||
min-width: 150px; | ||
max-width: 600px; | ||
width: 100%; | ||
} | ||
|
||
.form-field-full-width { | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 73 additions & 6 deletions
79
projects/cobbler-frontend/src/app/actions/build-iso/build-iso.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,81 @@ | ||
import { Component } from '@angular/core'; | ||
import { MatListModule } from '@angular/material/list'; | ||
import { RouterOutlet } from '@angular/router'; | ||
import {Component, inject} from '@angular/core'; | ||
import {FormBuilder, FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
import {MatButton} from '@angular/material/button'; | ||
import {MatCheckbox} from '@angular/material/checkbox'; | ||
import {MatFormField, MatLabel} from '@angular/material/form-field'; | ||
import {MatInput} from '@angular/material/input'; | ||
import {MatListModule} from '@angular/material/list'; | ||
import {MatSnackBar} from '@angular/material/snack-bar'; | ||
import {BackgroundBuildisoOptions, CobblerApiService} from 'cobbler-api'; | ||
import {UserService} from '../../services/user.service'; | ||
|
||
@Component({ | ||
selector: 'cobbler-build-iso', | ||
templateUrl: './build-iso.component.html', | ||
styleUrls: ['./build-iso.component.css'], | ||
styleUrls: ['./build-iso.component.scss'], | ||
standalone: true, | ||
imports: [RouterOutlet, MatListModule], | ||
imports: [ | ||
MatListModule, | ||
FormsModule, | ||
MatButton, | ||
MatFormField, | ||
MatInput, | ||
MatLabel, | ||
ReactiveFormsModule, | ||
MatCheckbox | ||
], | ||
}) | ||
export class BuildISOComponent { | ||
constructor() {} | ||
private readonly _formBuilder = inject(FormBuilder); | ||
buildisoFormGroup = this._formBuilder.group({ | ||
iso: '', | ||
profiles: '', | ||
systems: '', | ||
buildisodir: '', | ||
distro: '', | ||
standalone: false, | ||
airgapped: false, | ||
source: '', | ||
excludeDNS: false, | ||
xorrisofsOpts: '', | ||
}) | ||
|
||
constructor( | ||
public userService: UserService, | ||
private cobblerApiService: CobblerApiService, | ||
private _snackBar: MatSnackBar | ||
) { | ||
} | ||
|
||
runBuildiso(): void { | ||
const buildisoOptions: BackgroundBuildisoOptions = { | ||
iso: this.buildisoFormGroup.controls.iso.value, | ||
profiles: this.buildisoFormGroup.controls.profiles.value, | ||
systems: this.buildisoFormGroup.controls.systems.value, | ||
buildisodir: this.buildisoFormGroup.controls.buildisodir.value, | ||
distro: this.buildisoFormGroup.controls.distro.value, | ||
standalone: this.buildisoFormGroup.controls.standalone.value, | ||
airgapped: this.buildisoFormGroup.controls.airgapped.value, | ||
source: this.buildisoFormGroup.controls.source.value, | ||
excludeDNS: this.buildisoFormGroup.controls.excludeDNS.value, | ||
xorrisofsOpts: this.buildisoFormGroup.controls.xorrisofsOpts.value, | ||
}; | ||
if (this.buildisoFormGroup.invalid) { | ||
this._snackBar.open('Please fill out all required inputs!', 'Close', {duration: 2000}); | ||
return; | ||
} | ||
this.cobblerApiService.background_buildiso(buildisoOptions, this.userService.token).subscribe( | ||
value => { | ||
// TODO | ||
}, | ||
error => { | ||
// HTML encode the error message since it originates from XML | ||
this._snackBar.open(this.toHTML(error.message), 'Close'); | ||
}); | ||
} | ||
|
||
toHTML(input: string): any { | ||
// FIXME: Deduplicate method | ||
return new DOMParser().parseFromString(input, 'text/html').documentElement.textContent; | ||
} | ||
} |