Skip to content

Commit

Permalink
Cobbler-Frontend: Add basic overview and detail pages
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Jul 21, 2024
1 parent 89dbd41 commit c66b55b
Show file tree
Hide file tree
Showing 120 changed files with 3,977 additions and 1,333 deletions.
58 changes: 38 additions & 20 deletions projects/cobbler-frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ import { AppEventsComponent } from './app-events/app-events.component';
import { AppManageComponent } from './appManage';
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';
import { PackagesComponent } from './items/packages/packages.component';
import { ProfilesComponent } from './items/profiles/profiles.component';
import { ReposComponent } from './items/repos/repos.component';
import { SnippetsComponent } from './items/snippets/snippets.component';
import { SystemsComponent } from './items/systems/systems.component';
import { TemplatesComponent } from './items/templates/templates.component';
import {FileEditComponent} from './items/file/edit/file-edit.component';
import { FileOverviewComponent } from './items/file/overview/file-overview.component';
import {ImageEditComponent} from './items/image/edit/image-edit.component';
import { ImageOverviewComponent } from './items/image/overview/image-overview.component';
import {ManagementClassEditComponent} from './items/management-class/edit/management-class-edit.component';
import {ManagementClassOverviewComponent} from './items/management-class/overview/management-class-overview.component';
import {PackageEditComponent} from './items/package/edit/package-edit.component';
import { PackageOverviewComponent } from './items/package/overview/package-overview.component';
import {ProfileEditComponent} from './items/profile/edit/profile-edit.component';
import { ProfileOverviewComponent } from './items/profile/overview/profile-overview.component';
import {RepositoryEditComponent} from './items/repository/edit/repository-edit.component';
import { RepositoryOverviewComponent } from './items/repository/overview/repository-overview.component';
import {SnippetEditComponent} from './items/snippet/edit/snippet-edit.component';
import { SnippetOverviewComponent } from './items/snippet/overview/snippet-overview.component';
import {SystemEditComponent} from './items/system/edit/system-edit.component';
import { SystemOverviewComponent } from './items/system/overview/system-overview.component';
import {TemplateEditComponent} from './items/template/edit/template-edit.component';
import { TemplateOverviewComponent } from './items/template/overview/template-overview.component';
import { LogInFormComponent } from './login/login.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { AuthGuardService } from './services/auth-guard.service';
Expand All @@ -37,18 +46,27 @@ export const routes: Routes = [
{path: '', pathMatch: 'full', redirectTo: '/login' },
{path: 'unauthorized', component: UnauthorizedComponent},
{path: 'manage', component: AppManageComponent, 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]},
{path: 'images', component: ImagesComponent, canActivate: [AuthGuardService]},
{path: 'templates', component: TemplatesComponent, canActivate: [AuthGuardService]},
{path: 'snippets', component: SnippetsComponent, canActivate: [AuthGuardService]},
{path: 'management-classes', component: ManagementClassesComponent, canActivate: [AuthGuardService]},
{path: 'items/distro', component: DistrosOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/distro/:name', component: DistroEditComponent, canActivate: [AuthGuardService]},
{path: 'items/profile', component: ProfileOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/profile/:name', component: ProfileEditComponent, canActivate: [AuthGuardService]},
{path: 'items/system', component: SystemOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/system/:name', component: SystemEditComponent, canActivate: [AuthGuardService]},
{path: 'items/repository', component: RepositoryOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/repository/:name', component: RepositoryEditComponent, canActivate: [AuthGuardService]},
{path: 'items/image', component: ImageOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/image/:name', component: ImageEditComponent, canActivate: [AuthGuardService]},
{path: 'items/template', component: TemplateOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/template/:name', component: TemplateEditComponent, canActivate: [AuthGuardService]},
{path: 'items/snippet', component: SnippetOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/snippet/:name', component: SnippetEditComponent, canActivate: [AuthGuardService]},
{path: 'items/management-class', component: ManagementClassOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/management-class/:name', component: ManagementClassEditComponent, canActivate: [AuthGuardService]},
{path: 'items/package', component: PackageOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/package/:name', component: PackageEditComponent, canActivate: [AuthGuardService]},
{path: 'items/file', component: FileOverviewComponent, canActivate: [AuthGuardService]},
{path: 'items/file/:name', component: FileEditComponent, canActivate: [AuthGuardService]},
{path: 'settings', component: SettingsViewComponent, canActivate: [AuthGuardService]},
{path: 'packages', component: PackagesComponent, canActivate: [AuthGuardService]},
{path: 'app-files', component: FilesComponent, canActivate: [AuthGuardService]},
{path: 'import', component: ImportDVDComponent, canActivate: [AuthGuardService]},
{path: 'sync', component: SyncComponent, canActivate: [AuthGuardService]},
{path: 'reposync', component: RepoSyncComponent, canActivate: [AuthGuardService]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClientTesting} from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {ActivatedRoute, provideRouter} from '@angular/router';
import {COBBLER_URL} from 'cobbler-api';

import { DistroEditComponent } from './distro-edit.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DistroEditComponent]
imports: [
DistroEditComponent,
NoopAnimationsModule,
],
providers: [
provideRouter([]),
provideHttpClient(),
provideHttpClientTesting(),
{
provide: COBBLER_URL,
useValue: new URL('http://localhost/cobbler_api')
},
{
provide: ActivatedRoute,
useValue: {
snapshot: {
paramMap: {
get: () => "testdistro"
},
},
},
},
]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DistroEditComponent implements OnInit{
removeDistro(): void {
this.cobblerApiService.remove_distro(this.name, this.userService.token, false).subscribe(value => {
if (value) {
this.router.navigate(["/distro"])
this.router.navigate(["/items", "distro"])
}
// HTML encode the error message since it originates from XML
this._snackBar.open("Delete failed! Check server logs for more information.", 'Close');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClientTesting} from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
Expand All @@ -6,11 +8,12 @@ import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import {provideRouter} from '@angular/router';
import {COBBLER_URL} from 'cobbler-api';

import { DistrosOverviewComponent } from './distros-overview.component';


describe('DistrosComponent', () => {
describe('DistroOverviewComponent', () => {
let component: DistrosOverviewComponent;
let fixture: ComponentFixture<DistrosOverviewComponent>;

Expand All @@ -27,6 +30,12 @@ describe('DistrosComponent', () => {
],
providers: [
provideRouter([]),
provideHttpClient(),
provideHttpClientTesting(),
{
provide: COBBLER_URL,
useValue: new URL('http://localhost/cobbler_api')
},
]
}).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DistrosOverviewComponent implements OnInit{
}

showDistro(uid: string, name: string): void {
this.router.navigate(["/distro", name])
this.router.navigate(["/items", "distro", name])
}

editDistro(uid: string, name: string): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<div class="title-table">
<div class="title-row">
<h1 class="title title-cell-text">Name: {{ name }}</h1>
<span class="title-cell-button">
<button
mat-icon-button
(click)="this.refreshData()"
matTooltip="Refresh data"
><mat-icon>refresh</mat-icon></button>
</span>
<span class="title-cell-button">
<button
mat-icon-button
(click)="this.copyFile()"
matTooltip="Copy"
><mat-icon>content_copy</mat-icon></button>
</span>
<span class="title-cell-button">
<button
mat-icon-button
(click)="this.editFile()"
matTooltip="Edit"
><mat-icon>edit</mat-icon></button>
</span>
<span class="title-cell-button">
<button
mat-icon-button
(click)="this.removeFile()"
matTooltip="Delete"
><mat-icon>delete</mat-icon></button>
</span>
</div>
</div>

<form class="form-replicate" [formGroup]="fileFormGroup">
<mat-form-field class="form-field-full-width">
<mat-label>Name</mat-label>
<input matInput type="text" formControlName="name"/>
</mat-form-field>
<mat-form-field class="form-field-full-width">
<mat-label>UID</mat-label>
<input matInput type="text" formControlName="uid"/>
</mat-form-field>
<mat-form-field class="form-field-full-width">
<mat-label>Last modified time</mat-label>
<input matInput type="text" formControlName="mtime"/>
</mat-form-field>
<mat-form-field class="form-field-full-width">
<mat-label>Creation time</mat-label>
<input matInput type="text" formControlName="ctime"/>
</mat-form-field>
<mat-form-field class="form-field-full-width">
<mat-label>Depth</mat-label>
<input matInput type="number" formControlName="depth"/>
</mat-form-field>
<mat-checkbox class="form-field-full-width" formControlName="is_subobject">Is Subobject?</mat-checkbox>
<mat-form-field class="form-field-full-width">
<mat-label>Comment</mat-label>
<input matInput type="text" formControlName="comment"/>
</mat-form-field>
@if (isEditMode) {
<button mat-button (click)="saveFile()">Save Distro</button>
}
</form>

Original file line number Diff line number Diff line change
@@ -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%;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {provideHttpClient} from '@angular/common/http';
import {provideHttpClientTesting} from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {ActivatedRoute, provideRouter} from '@angular/router';
import {COBBLER_URL} from 'cobbler-api';

import { FileEditComponent } from './file-edit.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
FileEditComponent,
NoopAnimationsModule,
],
providers: [
provideRouter([]),
provideHttpClient(),
provideHttpClientTesting(),
{
provide: COBBLER_URL,
useValue: new URL('http://localhost/cobbler_api')
},
{
provide: ActivatedRoute,
useValue: {
snapshot: {
paramMap: {
get: () => "testfile"
},
},
},
},
]
})
.compileComponents();

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit c66b55b

Please sign in to comment.