From 3abe8b277fa9b1c3fc29a5c22bfe72bd485c8025 Mon Sep 17 00:00:00 2001 From: Enno Gotthold Date: Sat, 20 Jul 2024 18:23:38 +0200 Subject: [PATCH] Cobbler-Frontend: Add UI for distro overview and detail view --- ...component.css => check-sys.component.scss} | 0 .../actions/check-sys/check-sys.component.ts | 2 +- .../src/app/app-routing.module.ts | 6 +- .../distro/edit/distro-edit.component.html | 63 +++++++ .../distro/edit/distro-edit.component.scss | 30 ++++ .../distro/edit/distro-edit.component.spec.ts | 23 +++ .../distro/edit/distro-edit.component.ts | 109 +++++++++++ .../overview/distros-overview.component.css} | 0 .../overview/distros-overview.component.html | 46 +++++ .../distros-overview.component.spec.ts} | 10 +- .../overview/distros-overview.component.ts | 93 ++++++++++ .../app/items/distros/distros.component.html | 170 ------------------ .../items/distros/distros.component.spec.js | 66 ------- .../distros/distros.component.spec.js.map | 1 - .../app/items/distros/distros.component.ts | 95 ---------- .../manage-menu/manage-menu.component.html | 2 +- .../app/services/data-distro.service.spec.js | 15 -- .../services/data-distro.service.spec.js.map | 1 - .../app/services/data-distro.service.spec.ts | 16 -- .../src/app/services/data-distro.service.ts | 63 ------- 20 files changed, 375 insertions(+), 436 deletions(-) rename projects/cobbler-frontend/src/app/actions/check-sys/{check-sys.component.css => check-sys.component.scss} (100%) create mode 100644 projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.html create mode 100644 projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.scss create mode 100644 projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.spec.ts create mode 100644 projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.ts rename projects/cobbler-frontend/src/app/items/{distros/distros.component.css => distro/overview/distros-overview.component.css} (100%) create mode 100644 projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.html rename projects/cobbler-frontend/src/app/items/{distros/distros.component.spec.ts => distro/overview/distros-overview.component.spec.ts} (79%) create mode 100644 projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.ts delete mode 100644 projects/cobbler-frontend/src/app/items/distros/distros.component.html delete mode 100644 projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js delete mode 100644 projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js.map delete mode 100644 projects/cobbler-frontend/src/app/items/distros/distros.component.ts delete mode 100644 projects/cobbler-frontend/src/app/services/data-distro.service.spec.js delete mode 100644 projects/cobbler-frontend/src/app/services/data-distro.service.spec.js.map delete mode 100644 projects/cobbler-frontend/src/app/services/data-distro.service.spec.ts delete mode 100644 projects/cobbler-frontend/src/app/services/data-distro.service.ts diff --git a/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.css b/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.scss similarity index 100% rename from projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.css rename to projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.scss diff --git a/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.ts b/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.ts index 64f365c3..7bafa129 100644 --- a/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.ts +++ b/projects/cobbler-frontend/src/app/actions/check-sys/check-sys.component.ts @@ -14,7 +14,7 @@ import {UserService} from '../../services/user.service'; @Component({ selector: 'cobbler-check-sys', templateUrl: './check-sys.component.html', - styleUrls: ['./check-sys.component.css'], + styleUrls: ['./check-sys.component.scss'], standalone: true, imports: [ RouterOutlet, diff --git a/projects/cobbler-frontend/src/app/app-routing.module.ts b/projects/cobbler-frontend/src/app/app-routing.module.ts index f2f4aff7..fcb73213 100644 --- a/projects/cobbler-frontend/src/app/app-routing.module.ts +++ b/projects/cobbler-frontend/src/app/app-routing.module.ts @@ -11,7 +11,8 @@ import { SyncComponent } from './actions/sync/sync.component'; import {ValidateAutoinstallsComponent} from './actions/validate-autoinstalls/validate-autoinstalls.component'; import { AppEventsComponent } from './app-events/app-events.component'; import { AppManageComponent } from './appManage'; -import { DistrosComponent } from './items/distros/distros.component'; +import {DistroEditComponent} from './items/distro/edit/distro-edit.component'; +import { DistrosOverviewComponent } from './items/distro/overview/distros-overview.component'; import { FilesComponent } from './items/files/files.component'; import { ImagesComponent } from './items/images/images.component'; import { ManagementClassesComponent } from './items/management-classes/management-classes.component'; @@ -36,7 +37,8 @@ export const routes: Routes = [ {path: '', pathMatch: 'full', redirectTo: '/login' }, {path: 'unauthorized', component: UnauthorizedComponent}, {path: 'manage', component: AppManageComponent, canActivate: [AuthGuardService]}, - {path: 'distros', component: DistrosComponent, canActivate: [AuthGuardService]}, + {path: 'distro', component: DistrosOverviewComponent, canActivate: [AuthGuardService]}, + {path: 'distro/:name', component: DistroEditComponent, canActivate: [AuthGuardService]}, {path: 'profiles', component: ProfilesComponent, canActivate: [AuthGuardService]}, {path: 'systems', component: SystemsComponent, canActivate: [AuthGuardService]}, {path: 'repos', component: ReposComponent, canActivate: [AuthGuardService]}, diff --git a/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.html b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.html new file mode 100644 index 00000000..5c4d530f --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.html @@ -0,0 +1,63 @@ +
+
+

Name: {{ name }}

+ + + + + + + + + + + + +
+
+ +
+ + Name + + + + UID + + + + Last modified time + + + + Creation time + + + + Depth + + + + Architecture + + + @if (isEditMode) { + + } +
diff --git a/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.scss b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.scss new file mode 100644 index 00000000..2a9efa5d --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.scss @@ -0,0 +1,30 @@ +.title-table { + display: table; + width: 100%; +} + +.title-row { + display: table-cell; + width: 100%; +} + +.title-cell-text { + display: table-cell; + width: 100%; + vertical-align: middle; +} + +.title-cell-button { + display: table-cell; +} + +.form-replicate { + min-width: 150px; + max-width: 600px; + width: 100%; +} + +.form-field-full-width { + width: 100%; +} + diff --git a/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.spec.ts b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.spec.ts new file mode 100644 index 00000000..a4253872 --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DistroEditComponent } from './distro-edit.component'; + +describe('EditComponent', () => { + let component: DistroEditComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [DistroEditComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(DistroEditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.ts b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.ts new file mode 100644 index 00000000..4a245b60 --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/edit/distro-edit.component.ts @@ -0,0 +1,109 @@ +import {Component, inject, OnInit} from '@angular/core'; +import {FormBuilder, FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {MatButton, MatIconButton} from '@angular/material/button'; +import {MatFormField, MatLabel} from '@angular/material/form-field'; +import {MatIcon} from '@angular/material/icon'; +import {MatInput} from '@angular/material/input'; +import {MatSnackBar} from '@angular/material/snack-bar'; +import {MatTooltip} from '@angular/material/tooltip'; +import {ActivatedRoute, Router} from '@angular/router'; +import {CobblerApiService, Distro} from 'cobbler-api'; +import {UserService} from '../../../services/user.service'; + +@Component({ + selector: 'cobbler-edit', + standalone: true, + imports: [ + MatIcon, + MatIconButton, + ReactiveFormsModule, + MatFormField, + MatInput, + MatLabel, + FormsModule, + MatTooltip, + MatButton, + ], + templateUrl: './distro-edit.component.html', + styleUrl: './distro-edit.component.scss' +}) +export class DistroEditComponent implements OnInit{ + name: string; + distro: Distro; + private readonly _formBuilder = inject(FormBuilder); + distroFormGroup = this._formBuilder.group({ + name: new FormControl({value: "", disabled: true}), + uid: new FormControl({value: "", disabled: true}), + mtime: new FormControl({value: "", disabled: true}), + ctime: new FormControl({value: "", disabled: true}), + depth: new FormControl({value: 0, disabled: true}), + arch: new FormControl({value: "", disabled: true}), + }); + isEditMode: boolean = false; + + constructor( + private route: ActivatedRoute, + private userService: UserService, + private cobblerApiService: CobblerApiService, + private _snackBar: MatSnackBar, + private router: Router, + ) { + this.name = this.route.snapshot.paramMap.get("name"); + } + + ngOnInit(): void { + this.refreshData() + } + + refreshData(): void { + this.cobblerApiService.get_distro(this.name, false, false, this.userService.token).subscribe(value => { + this.distro = value + this.distroFormGroup.controls.name.setValue(this.distro.name) + this.distroFormGroup.controls.uid.setValue(this.distro.uid) + this.distroFormGroup.controls.mtime.setValue(new Date(this.distro.mtime * 1000).toString()) + this.distroFormGroup.controls.ctime.setValue(new Date(this.distro.ctime * 1000).toString()) + this.distroFormGroup.controls.depth.setValue(this.distro.depth) + this.distroFormGroup.controls.arch.setValue(this.distro.arch) + }, error => { + // HTML encode the error message since it originates from XML + this._snackBar.open(this.toHTML(error.message), 'Close'); + }) + } + + removeDistro(): void { + this.cobblerApiService.remove_distro(this.name, this.userService.token, false).subscribe(value => { + if (value) { + this.router.navigate(["/distro"]) + } + // HTML encode the error message since it originates from XML + this._snackBar.open("Delete failed! Check server logs for more information.", 'Close'); + }, error => { + // HTML encode the error message since it originates from XML + this._snackBar.open(this.toHTML(error.message), 'Close'); + }) + } + + editDistro(): void { + // TODO + this._snackBar.open("Not implemented at the moment!", "Close") + } + + copyDistro(): void { + this.cobblerApiService.copy_distro("", "", 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'); + }) + } + + saveDistro(): void { + // TODO + } + + toHTML(input: string): any { + // FIXME: Deduplicate method + return new DOMParser().parseFromString(input, 'text/html').documentElement.textContent; + } +} diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.css b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.css similarity index 100% rename from projects/cobbler-frontend/src/app/items/distros/distros.component.css rename to projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.css diff --git a/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.html b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.html new file mode 100644 index 00000000..dfa12d74 --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.html @@ -0,0 +1,46 @@ +

DISTROS

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name{{element.name}}Breed{{element.breed}}Operating System Version{{element.os_version}} + + + + + + +
+ diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.ts b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.spec.ts similarity index 79% rename from projects/cobbler-frontend/src/app/items/distros/distros.component.spec.ts rename to projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.spec.ts index 50f29164..44e3e374 100644 --- a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.ts +++ b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.spec.ts @@ -7,12 +7,12 @@ import { MatTabsModule } from '@angular/material/tabs'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import {provideRouter} from '@angular/router'; -import { DistrosComponent } from './distros.component'; +import { DistrosOverviewComponent } from './distros-overview.component'; describe('DistrosComponent', () => { - let component: DistrosComponent; - let fixture: ComponentFixture; + let component: DistrosOverviewComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ @@ -23,7 +23,7 @@ describe('DistrosComponent', () => { MatTabsModule, MatTableModule, NoopAnimationsModule, - DistrosComponent, + DistrosOverviewComponent, ], providers: [ provideRouter([]), @@ -32,7 +32,7 @@ describe('DistrosComponent', () => { }); beforeEach(() => { - fixture = TestBed.createComponent(DistrosComponent); + fixture = TestBed.createComponent(DistrosOverviewComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.ts b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.ts new file mode 100644 index 00000000..3c4f19b6 --- /dev/null +++ b/projects/cobbler-frontend/src/app/items/distro/overview/distros-overview.component.ts @@ -0,0 +1,93 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {MatButton, MatIconButton} from '@angular/material/button'; +import {MatIcon} from '@angular/material/icon'; +import {MatMenu, MatMenuItem, MatMenuTrigger} from '@angular/material/menu'; +import {MatSnackBar} from '@angular/material/snack-bar'; +import { + MatCell, + MatCellDef, + MatColumnDef, + MatHeaderCell, + MatHeaderCellDef, + MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, + MatTable +} from '@angular/material/table'; +import {Router} from '@angular/router'; +import {CobblerApiService, Distro} from 'cobbler-api'; +import {UserService} from '../../../services/user.service'; + +@Component({ + selector: 'cobbler-distros', + templateUrl: './distros-overview.component.html', + styleUrls: ['./distros-overview.component.css'], + + standalone: true, + imports: [ + MatButton, + MatTable, + MatHeaderCell, + MatCell, + MatColumnDef, + MatHeaderCellDef, + MatCellDef, + MatHeaderRow, + MatRow, + MatRowDef, + MatHeaderRowDef, + MatIcon, + MatIconButton, + MatMenu, + MatMenuItem, + MatMenuTrigger + ], +}) +export class DistrosOverviewComponent implements OnInit{ + displayedColumns: string[] = ['name', "breed", "os_version", "actions"]; + dataSource: Array = []; + + @ViewChild(MatTable) table: MatTable; + + constructor( + public userService: UserService, + private cobblerApiService: CobblerApiService, + private _snackBar: MatSnackBar, + private router: Router, + ) { + } + + ngOnInit(): void { + this.retrieveDistros() + } + + private retrieveDistros(): void { + this.cobblerApiService.get_distros().subscribe(value => { + this.dataSource = value + }, error => { + // HTML encode the error message since it originates from XML + this._snackBar.open(this.toHTML(error.message), 'Close'); + }) + } + + showDistro(uid: string, name: string): void { + this.router.navigate(["/distro", name]) + } + + editDistro(uid: string, name: string): void { + // TODO + } + + deleteDistro(uid: string, name: string): void { + this.cobblerApiService.remove_distro(name, this.userService.token, false).subscribe(value => { + this.retrieveDistros() + }, 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; + } + +} diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.html b/projects/cobbler-frontend/src/app/items/distros/distros.component.html deleted file mode 100644 index 92106f9b..00000000 --- a/projects/cobbler-frontend/src/app/items/distros/distros.component.html +++ /dev/null @@ -1,170 +0,0 @@ - - -
-

DISTROS

- - - -

Editing a Distro

-

Name: {{datatable[14][5]}}

-
- - -
-
-
- - Owners - - -
-
- - Kernel - - -
-
- - Initrd - - -
-
- - Kernel Options - - -
-
- - Kernel Options post-install - - -
-
- - Auto-install template metadata - - -
-
- - Architecture - - -
-
- - Breed - - -
-
- - OS Version - - -
-
- - Boot Loader - - -
-
- - Comment - - -
-
-
CAUTION: Tab navigation will EXIT edit mode
-
- - - - - - - - - - - - - - - - - - - - - - - - -
No. {{i + 1}}Item{{datatable[i][0]}}Description{{datatable[i][5]}}
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
No. {{i + 1}}Type{{datatable[0][1]}}Version{{datatable[15][1]}} Update - - - - -
-
-
- -
diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js b/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js deleted file mode 100644 index ac8d14dd..00000000 --- a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var testing_1 = require("@angular/core/testing"); -var distros_component_1 = require("./distros.component"); -describe('DistrosComponent', function () { - var component; - var fixture; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.TestBed.configureTestingModule({ - declarations: [distros_component_1.DistrosComponent] - }) - .compileComponents()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - beforeEach(function () { - fixture = testing_1.TestBed.createComponent(distros_component_1.DistrosComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - it('should create', function () { - expect(component).toBeTruthy(); - }); -}); -//# sourceMappingURL=distros.component.spec.js.map \ No newline at end of file diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js.map b/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js.map deleted file mode 100644 index f2e6edf2..00000000 --- a/projects/cobbler-frontend/src/app/items/distros/distros.component.spec.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"distros.component.spec.js","sourceRoot":"","sources":["distros.component.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkE;AAElE,yDAAuD;AAEvD,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,IAAI,SAA2B,CAAC;IAChC,IAAI,OAA2C,CAAC;IAEhD,UAAU,CAAC;;;wBACT,qBAAM,iBAAO,CAAC,sBAAsB,CAAC;wBACnC,YAAY,EAAE,CAAE,oCAAgB,CAAE;qBACnC,CAAC;yBACD,iBAAiB,EAAE,EAAA;;oBAHpB,SAGoB,CAAC;;;;SACtB,CAAC,CAAC;IAEH,UAAU,CAAC;QACT,OAAO,GAAG,iBAAO,CAAC,eAAe,CAAC,oCAAgB,CAAC,CAAC;QACpD,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACtC,OAAO,CAAC,aAAa,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,EAAE;QAClB,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/projects/cobbler-frontend/src/app/items/distros/distros.component.ts b/projects/cobbler-frontend/src/app/items/distros/distros.component.ts deleted file mode 100644 index 51eb6885..00000000 --- a/projects/cobbler-frontend/src/app/items/distros/distros.component.ts +++ /dev/null @@ -1,95 +0,0 @@ -import {Component} from '@angular/core'; -import {DataDistroService} from '../../services/data-distro.service'; -import { RouterOutlet } from '@angular/router'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatTabsModule } from '@angular/material/tabs'; -import {MatInputModule} from "@angular/material/input"; -import {MatTableModule} from "@angular/material/table"; -import {MatButtonModule} from "@angular/material/button"; - -@Component({ - selector: 'cobbler-distros', - templateUrl: './distros.component.html', - styleUrls: ['./distros.component.css'], - - standalone: true, - imports: [RouterOutlet, MatFormFieldModule, MatTabsModule, MatInputModule, MatTableModule, MatButtonModule], -}) -export class DistrosComponent { - // Distro object contains [0-5] not editable - // [6-24] items below - // There can be more than one distro object - arch = []; - autoinstall = []; - bFiles = []; - bLoader = []; - breed = []; - comment = []; - fFiles = []; - initrd = []; - kernel = []; - reboInitrd = []; - reboKernel = []; - kernelOptions = []; - kOptPost = []; - mngClass = []; - name = []; - osVersion = []; - owners = []; - rhMngKey = []; - tmpltFiles = []; - // persistant use items: - datatable = []; - ActiveElement = 'description'; - displayedColumns = ['position', 'type', 'version','update'] - displayedColumns2 = ['position', 'item', 'description'] - - constructor(service: DataDistroService) { - /*USE - -------- - for items of tabledata[i]: - [0] = python variable name - [1] = data about this item - [2] = number = 0 - [3] = description - [4] = boolean | True - [5] = use case - [6] = function call | 0 - [7] = data type - -------- - Example: - to get and display arch type: - {{datatable[0][7]}} - */ - // Linter throws errors on these variable names. - // These variable names are set in the data, but can be changed for linter purposes - this.arch = service.get_item('arch'); // 0 - this.autoinstall = service.get_item('autoinstall'); // 1 - this.bFiles = service.get_item('b_files'); // 2 - this.bLoader = service.get_item('b_loader'); // 3 - this.breed = service.get_item('breed'); // 4 - this.comment = service.get_item('comment'); // 5 - this.fFiles = service.get_item('f_files'); // 6 - this.initrd = service.get_item('initrd'); // 7 - this.kernel = service.get_item('kernel'); // 8 - this.reboInitrd = service.get_item('rebo_initrd'); // 9 - this.reboKernel = service.get_item('rebo_kernel'); // 10 - this.kernelOptions = service.get_item('kernel_options'); // 11 - this.kOptPost = service.get_item('k_opt_post'); // 12 - this.mngClass = service.get_item('mng_class'); // 13 - this.name = service.get_item('name'); // 14 - this.osVersion = service.get_item('os_version'); // 15 - this.owners = service.get_item('owners'); // 16 - this.rhMngKey = service.get_item('rh_mng_key'); // 17 - this.tmpltFiles = service.get_item('tmplt_files'); // 18 - - this.datatable = [this.arch, this.autoinstall, this.bFiles, this.bLoader, this.breed, this.comment, this.fFiles, - this.initrd, this.kernel, this.reboInitrd, this.reboKernel, this.kernelOptions, this.kOptPost, - this.mngClass, this.name, this.osVersion, this.owners, this.rhMngKey, this.tmpltFiles]; - } - - show(name: string): void { - this.ActiveElement = name; - // console.log(this.ActiveElement) - } -} diff --git a/projects/cobbler-frontend/src/app/manage-menu/manage-menu.component.html b/projects/cobbler-frontend/src/app/manage-menu/manage-menu.component.html index 5f809ce8..e0eacbac 100644 --- a/projects/cobbler-frontend/src/app/manage-menu/manage-menu.component.html +++ b/projects/cobbler-frontend/src/app/manage-menu/manage-menu.component.html @@ -12,7 +12,7 @@

Configuration

mat-list-item class="nav-link" aria-current="page" - [routerLink]="['/distros']" + [routerLink]="['/distro']" [routerLinkActive]="'is-active'" > » diff --git a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js b/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js deleted file mode 100644 index e5296cab..00000000 --- a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var testing_1 = require("@angular/core/testing"); -var data_distro_service_1 = require("./data-distro.service"); -describe('DataDistroService', function () { - var service; - beforeEach(function () { - testing_1.TestBed.configureTestingModule({}); - service = testing_1.TestBed.inject(data_distro_service_1.DataDistroService); - }); - it('should be created', function () { - expect(service).toBeTruthy(); - }); -}); -//# sourceMappingURL=data-distro.service.spec.js.map \ No newline at end of file diff --git a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js.map b/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js.map deleted file mode 100644 index f1c3e316..00000000 --- a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"data-distro.service.spec.js","sourceRoot":"","sources":["data-distro.service.spec.ts"],"names":[],"mappings":";;AAAA,iDAAgD;AAEhD,6DAA0D;AAE1D,QAAQ,CAAC,mBAAmB,EAAE;IAC5B,IAAI,OAA0B,CAAC;IAE/B,UAAU,CAAC;QACT,iBAAO,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,GAAG,iBAAO,CAAC,MAAM,CAAC,uCAAiB,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE;QACtB,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.ts b/projects/cobbler-frontend/src/app/services/data-distro.service.spec.ts deleted file mode 100644 index 7e3a25aa..00000000 --- a/projects/cobbler-frontend/src/app/services/data-distro.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { DataDistroService } from './data-distro.service'; - -describe('DataDistroService', () => { - let service: DataDistroService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(DataDistroService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/projects/cobbler-frontend/src/app/services/data-distro.service.ts b/projects/cobbler-frontend/src/app/services/data-distro.service.ts deleted file mode 100644 index f8a3a23e..00000000 --- a/projects/cobbler-frontend/src/app/services/data-distro.service.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class DataDistroService { - // boolean True/False in python - // boolean true/false in typescript - // Changed function calls to strings for mockdata - // python 'None' => typescript 'null' - // shout names be shortened as keys, or kept descriptive? - // mockdata to be replace by the xmlrpc fetched data - canAccess: boolean; - mockdata = { - arch: ['arch', 'x86_64', 0, 'Architecture', true, 'Architecture', 'utils.get_valid_archs()', 'str'], - autoinstall: ['autoinstall_meta', {}, 0, 'Automatic Installation Template Metadata', true, 'Ex: dog=fang agent=86', - 0, 'dict'], - b_files: ['boot_files', {}, 0, 'TFTP Boot Files', true, 'Files copied into tftpboot beyond the kernel/initrd', 0, - 'list'], - b_loader: ['boot_loader', '<>', 0, 'Boot loader', true, 'Network installation boot loader', - 'utils.get_supported_system_boot_loaders()', 'str'], - breed: ['breed', 'redhat', 0, 'Breed', true, 'What is the type of distribution?', 'utils.get_valid_breeds()', 'str'], - comment: ['comment', '', 0, 'Comment', true, 'Free form text description', 0, 'str'], - f_files: ['fetchable_files', {}, 0, 'Fetchable Files', true, 'Templates for tftp or wget/curl', 0, 'list'], - initrd: ['initrd', null, 0, 'Initrd', true, 'Absolute path to kernel on filesystem', 0, 'str'], - kernel: ['kernel', null, 0, 'Kernel', true, 'Absolute path to kernel on filesystem', 0, 'str'], - rebo_initrd: ['remote_boot_initrd', null, 0, 'Remote Boot Initrd', true, - 'URL the bootloader directly retrieves and boots from', 0, 'str'], - rebo_kernel: ['remote_boot_kernel', null, 0, 'Remote Boot Kernel', true, - 'URL the bootloader directly retrieves and boots from', 0, 'str'], - kernel_options: ['kernel_options', {}, 0, 'Kernel Options', true, 'Ex: selinux=permissive', 0, 'dict'], - k_opt_post: ['kernel_options_post', {}, 0, 'Kernel Options (Post Install)', true, 'Ex: clocksource=pit noapic', 0, - 'dict'], - mng_class: ['mgmt_classes', [], 0, 'Management Classes', true, 'Management classes for external config management', - 0, 'list'], - name: ['name', '', 0, 'Name', true, 'Ex: Fedora-11-i386', 0, 'str'], - os_version: ['os_version', 'virtio26', 0, 'OS Version', true, 'Needed for some virtualization optimizations', - 'utils.get_valid_os_versions()', 'str'], - owners: ['owners', 'DEFAULT', 0, 'Owners', true, 'Owners list for authz_ownership (space delimited)', 0, 'list'], - rh_mng_key: ['redhat_management_key', '', '', 'Redhat Management Key', true, - 'Registration key for RHN, Spacewalk, or Satellite', 0, 'str'], - tmplt_files: ['template_files', {}, 0, 'Template Files', true, 'File mappings for built-in config management', 0, - 'dict'] - -}; - - constructor() { - // possibly add authentication subscription as seen in navbar.component.ts? - } - - // TODO: Specify return type properly - get_item(key: any): any { - // return list of data from mockdata - const data = this.mockdata[key]; - const faildata = ['none=name', 'none=extra data', 'none=num', 'none=Title', 'none=boolean', 'none=description', - 'none=num', 'none=type']; - // add type check for array ? - if (data !== null) { - return data; - } - return faildata; - } -}