Skip to content

Commit

Permalink
add mkloaders view
Browse files Browse the repository at this point in the history
  • Loading branch information
00Kadie00 committed Jul 19, 2024
1 parent 055eaed commit d12086c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 0 deletions.
15 changes: 15 additions & 0 deletions projects/cobbler-api/src/lib/cobbler-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ export class CobblerApiService {
})
);
}
backgroundMkloaders(token: string): Observable<string> {
const mkloadersOptions: XmlRpcStruct = {members: []}
return this.client
.methodCall('background_mkloaders', [mkloadersOptions, token])
.pipe(
map<MethodResponse | MethodFault, string>((data: MethodResponse | MethodFault) => {
if (AngularXmlrpcService.instanceOfMethodResponse(data)) {
return data.value as string;
} else if (AngularXmlrpcService.instanceOfMethodFault(data)) {
throw new Error('Mkloading files on the server in the background failed with code "' + data.faultCode
+ '" and error message "' + data.faultString + '"');
}
})
);
}

background_validate_autoinstall_files(token: string): Observable<string> {
const validateAutoinstallOptions: XmlRpcStruct = {members: []}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>MKLOADERS</h1>

<button mat-button (click)="runMkloaders()">Mkloaders</button>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MkloadersComponent } from './mkloaders.component';

describe('MkloadersComponent', () => {
let component: MkloadersComponent;
let fixture: ComponentFixture<MkloadersComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MkloadersComponent]
})
.compileComponents();

fixture = TestBed.createComponent(MkloadersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Component, inject, OnDestroy } from '@angular/core';
import { UserService } from '../../services/user.service';
import { CobblerApiService } from 'cobbler-api';
import { Subscription } from 'rxjs';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatButton } from '@angular/material/button';

@Component({
selector: 'cobbler-mkloaders',
standalone: true,
imports: [MatButton],
templateUrl: './mkloaders.component.html',
styleUrl: './mkloaders.component.scss',
})
export class MkloadersComponent implements OnDestroy {
private userSvc = inject(UserService);
private cobblerApiSvc = inject(CobblerApiService);

private subs: Subscription = new Subscription();

constructor(private _snackBar: MatSnackBar) {}

ngOnDestroy(): void {
this.subs.unsubscribe();
}
runMkloaders(): void {
this.subs.add(
this.cobblerApiSvc.background_hardlink(this.userSvc.token).subscribe({
next:(value) => {
// TODO
},
error:(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;
}
}
2 changes: 2 additions & 0 deletions projects/cobbler-frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { AuthGuardService } from './services/auth-guard.service';
import { SettingsViewComponent } from './settings/view/settings-view.component';
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
import {SignaturesComponent} from "./signatures/signatures.component";
import { MkloadersComponent } from './actions/mkloaders/mkloaders.component';


export const routes: Routes = [
Expand All @@ -52,6 +53,7 @@ export const routes: Routes = [
{path: 'check', component: CheckSysComponent, canActivate: [AuthGuardService]},
{path: 'status', component: StatusComponent, canActivate: [AuthGuardService]},
{path: 'hardlink', component: HardlinkComponent, canActivate: [AuthGuardService]},
{path: 'mkloaders', component: MkloadersComponent, canActivate: [AuthGuardService]},
{path: 'events', component: AppEventsComponent, canActivate: [AuthGuardService]},
{path: 'signatures', component: SignaturesComponent, canActivate: [AuthGuardService]},
{path: 'validate-autoinstalls', component: ValidateAutoinstallsComponent, canActivate: [AuthGuardService]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h2 matSubheader>Actions</h2>
<a mat-list-item class="nav-link" [routerLink]="['/hardlink']">
<b class="symbol">&#9881;</b>Hardlink</a
>
<a mat-list-item class="nav-link" [routerLink]="['/mkloaders']">
<b class="symbol">&#9881;</b>Mkloaders</a
>
<a mat-list-item class="nav-link" [routerLink]="['/validate-autoinstalls']">
<b class="symbol">&#9881;</b>Validate Autoinstalls</a
>
Expand Down

0 comments on commit d12086c

Please sign in to comment.