-
-
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 #247 from cobbler/feature/cobbler-status
Feature: Add UI for ` cobbler status`
- Loading branch information
Showing
9 changed files
with
247 additions
and
9 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
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
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
70 changes: 70 additions & 0 deletions
70
projects/cobbler-frontend/src/app/actions/status/status.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<h1 class="title">Installation Status</h1> | ||
|
||
<mat-form-field> | ||
<mat-label>Filter</mat-label> | ||
<input matInput (keyup)="applyFilter($event)" placeholder="Ex. 10.0.0.1" #input> | ||
</mat-form-field> | ||
|
||
<div class="mat-elevation-z8"> | ||
<table mat-table [dataSource]="dataSource" matSort> | ||
|
||
<!-- IP Column --> | ||
<ng-container matColumnDef="ip"> | ||
<th mat-header-cell *matHeaderCellDef> IP</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.ip }}</td> | ||
</ng-container> | ||
|
||
<!-- Object Type Column --> | ||
<ng-container matColumnDef="objType"> | ||
<th mat-header-cell *matHeaderCellDef> Object Type</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.mostRecentTarget.split(":")[0] }}</td> | ||
</ng-container> | ||
|
||
<!-- Name Column --> | ||
<ng-container matColumnDef="name"> | ||
<th mat-header-cell *matHeaderCellDef> Name</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.mostRecentTarget.split(":")[1] }}</td> | ||
</ng-container> | ||
|
||
<!-- Most Recent Start Column --> | ||
<ng-container matColumnDef="mostRecentStart"> | ||
<th mat-header-cell *matHeaderCellDef> Most Recent Start</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.mostRecentStart * 1000 | date:'short' }}</td> | ||
</ng-container> | ||
|
||
<!-- Most Recent Stop Column --> | ||
<ng-container matColumnDef="mostRecentStop"> | ||
<th mat-header-cell *matHeaderCellDef> Most Recent Stop</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.mostRecentStop * 1000 | date:'short' }}</td> | ||
</ng-container> | ||
|
||
<!-- Seen Start Column --> | ||
<ng-container matColumnDef="seenStart"> | ||
<th mat-header-cell *matHeaderCellDef> Seen Start Counter</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.seenStop }}</td> | ||
</ng-container> | ||
|
||
<!-- Seen Stop Column --> | ||
<ng-container matColumnDef="seenStop"> | ||
<th mat-header-cell *matHeaderCellDef> Seen Stop Counter</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.seenStop }}</td> | ||
</ng-container> | ||
|
||
<!-- State Column --> | ||
<ng-container matColumnDef="state"> | ||
<th mat-header-cell *matHeaderCellDef> State</th> | ||
<td mat-cell *matCellDef="let element"> {{ element.state }}</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
|
||
<!-- Row shown when there is no matching data. --> | ||
<tr class="mat-row" *matNoDataRow> | ||
<td class="mat-cell" colspan="4">No data matching the filter "{{ input.value }}"</td> | ||
</tr> | ||
</table> | ||
|
||
<!-- Paginator --> | ||
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select number of installations"></mat-paginator> | ||
</div> |
Empty file.
46 changes: 46 additions & 0 deletions
46
projects/cobbler-frontend/src/app/actions/status/status.component.spec.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {provideHttpClient} from '@angular/common/http'; | ||
import {provideHttpClientTesting} from '@angular/common/http/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatPaginatorModule} from '@angular/material/paginator'; | ||
import {MatTableModule} from '@angular/material/table'; | ||
import {NoopAnimationsModule} from '@angular/platform-browser/animations'; | ||
import {COBBLER_URL} from 'cobbler-api'; | ||
|
||
import { StatusComponent } from './status.component'; | ||
|
||
describe('StatusComponent', () => { | ||
let component: StatusComponent; | ||
let fixture: ComponentFixture<StatusComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
StatusComponent, | ||
MatFormFieldModule, | ||
MatInputModule, | ||
MatTableModule, | ||
MatPaginatorModule, | ||
NoopAnimationsModule, | ||
], | ||
providers: [ | ||
{ | ||
provide: COBBLER_URL, | ||
useValue: new URL('http://localhost/cobbler_api') | ||
}, | ||
provideHttpClient(), | ||
provideHttpClientTesting(), | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(StatusComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
projects/cobbler-frontend/src/app/actions/status/status.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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import {DatePipe} from '@angular/common'; | ||
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; | ||
import {MatSort} from '@angular/material/sort'; | ||
import {MatTableDataSource, MatTableModule} from '@angular/material/table'; | ||
import {CobblerApiService, InstallationStatus} from 'cobbler-api'; | ||
import {UserService} from '../../services/user.service'; | ||
|
||
|
||
@Component({ | ||
selector: 'cobbler-status', | ||
standalone: true, | ||
imports: [ | ||
MatFormFieldModule, | ||
MatInputModule, | ||
MatTableModule, | ||
MatPaginatorModule, | ||
MatSort, | ||
DatePipe, | ||
], | ||
templateUrl: './status.component.html', | ||
styleUrl: './status.component.scss' | ||
}) | ||
export class StatusComponent implements OnInit, AfterViewInit { | ||
displayedColumns: string[] = [ | ||
'ip', | ||
'objType', | ||
'name', | ||
'mostRecentStart', | ||
'mostRecentStop', | ||
'seenStart', | ||
'seenStop', | ||
'state' | ||
]; | ||
dataSource: MatTableDataSource<InstallationStatus> = new MatTableDataSource([]); | ||
|
||
@ViewChild(MatPaginator) paginator: MatPaginator; | ||
@ViewChild(MatSort) sort: MatSort; | ||
|
||
constructor( | ||
public userService: UserService, | ||
private cobblerApiService: CobblerApiService, | ||
) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.cobblerApiService.get_status("normal", this.userService.token).subscribe((value) => { | ||
console.log(value) | ||
this.dataSource.data = value | ||
}) | ||
} | ||
|
||
ngAfterViewInit() { | ||
this.dataSource.paginator = this.paginator; | ||
this.dataSource.sort = this.sort; | ||
} | ||
|
||
applyFilter(event: Event) { | ||
const filterValue = (event.target as HTMLInputElement).value; | ||
this.dataSource.filter = filterValue.trim().toLowerCase(); | ||
|
||
if (this.dataSource.paginator) { | ||
this.dataSource.paginator.firstPage(); | ||
} | ||
} | ||
} |
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
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