-
-
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 #267 from cobbler/feature/add-import
Feature: Implement page for "cobbler import"
- Loading branch information
Showing
7 changed files
with
151 additions
and
27 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.
50 changes: 37 additions & 13 deletions
50
projects/cobbler-frontend/src/app/actions/import-dvd/import-dvd.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,37 @@ | ||
<div class="right-column" id="dataScreen"> | ||
<router-outlet></router-outlet> | ||
<div class="ImportDVD-div"> | ||
<h1 class="title">IMPORT DVD</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">IMPORT DVD</h1> | ||
|
||
<form class="form-replicate" [formGroup]="importFormGroup"> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Path</mat-label> | ||
<input matInput type="text" required formControlName="path" placeholder="/mnt/cobbler-mounted/leap-15-4/" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Name</mat-label> | ||
<input matInput type="text" required formControlName="name" placeholder="my-distro" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Available as</mat-label> | ||
<input matInput type="text" formControlName="available_as" placeholder="my-distro" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Autoinstallation file</mat-label> | ||
<input matInput type="text" formControlName="autoinstall_file" placeholder="autoyast.xml" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>rsync flags</mat-label> | ||
<input matInput type="text" formControlName="rsync_flags" placeholder="-v" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Architecture</mat-label> | ||
<input matInput type="text" formControlName="arch" placeholder="x86_64" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Operating System Breed</mat-label> | ||
<input matInput type="text" formControlName="breed" placeholder="suse" /> | ||
</mat-form-field> | ||
<mat-form-field class="form-field-full-width"> | ||
<mat-label>Operating System Version</mat-label> | ||
<input matInput type="text" formControlName="os_version" placeholder="15.4" /> | ||
</mat-form-field> | ||
<button mat-button (click)="runImport()">Run</button> | ||
</form> |
9 changes: 9 additions & 0 deletions
9
projects/cobbler-frontend/src/app/actions/import-dvd/import-dvd.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
69 changes: 63 additions & 6 deletions
69
projects/cobbler-frontend/src/app/actions/import-dvd/import-dvd.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,16 +1,73 @@ | ||
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 {MatFormField, MatLabel} from '@angular/material/form-field'; | ||
import {MatInput} from '@angular/material/input'; | ||
import {MatSnackBar} from '@angular/material/snack-bar'; | ||
import {CobblerApiService, BackgroundImportOptions} from 'cobbler-api'; | ||
import {UserService} from '../../services/user.service'; | ||
|
||
@Component({ | ||
selector: 'cobbler-import-dvd', | ||
templateUrl: './import-dvd.component.html', | ||
styleUrls: ['./import-dvd.component.css'], standalone: true, | ||
imports: [RouterOutlet, MatListModule], | ||
styleUrls: ['./import-dvd.component.scss'], standalone: true, | ||
imports: [ | ||
FormsModule, | ||
MatFormField, | ||
MatInput, | ||
MatLabel, | ||
ReactiveFormsModule, | ||
MatButton | ||
], | ||
}) | ||
export class ImportDVDComponent { | ||
private readonly _formBuilder = inject(FormBuilder); | ||
importFormGroup = this._formBuilder.group({ | ||
path: '', | ||
name: '', | ||
available_as: '', | ||
autoinstall_file: '', | ||
rsync_flags: '', | ||
arch: '', | ||
breed: '', | ||
os_version: '', | ||
}) | ||
|
||
constructor() { | ||
constructor( | ||
public userService: UserService, | ||
private cobblerApiService: CobblerApiService, | ||
private _snackBar: MatSnackBar | ||
) { | ||
} | ||
|
||
runImport(): void { | ||
const importOptions: BackgroundImportOptions = { | ||
path: this.importFormGroup.controls.path.value, | ||
name: this.importFormGroup.controls.name.value, | ||
available_as: this.importFormGroup.controls.available_as.value, | ||
autoinstall_file: this.importFormGroup.controls.autoinstall_file.value, | ||
rsync_flags: this.importFormGroup.controls.rsync_flags.value, | ||
arch: this.importFormGroup.controls.arch.value, | ||
breed: this.importFormGroup.controls.breed.value, | ||
os_version: this.importFormGroup.controls.os_version.value, | ||
}; | ||
if (this.importFormGroup.invalid) { | ||
this._snackBar.open("Please give all inputs a system name!", "Close", {duration: 2000}) | ||
return; | ||
} | ||
this.cobblerApiService.background_import(importOptions, 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; | ||
} | ||
|
||
} |
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