Skip to content

Commit

Permalink
Outsource test device data to a separate file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektronikerDev committed Dec 26, 2023
1 parent 5af4c20 commit 3a3fd64
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

<ng-container ngbColumnDef="action">
<th *ngbHeaderCellDef ngb-header-cell></th>
<td *ngbCellDef="let event" ngb-cell >
<td *ngbCellDef="let event" ngb-cell routerLink="/devices/manage/{{event.id}}">
<i class="fas fa-angle-double-right opendevice-icon"></i>
</td>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {AfterViewInit, Component, EventEmitter, OnInit, Output, ViewChild} from
import {NgbPaginator, NgbSort, NgbTableDataSource} from 'dfx-bootstrap-table';
import {FormControl} from "@angular/forms";
import {Device, DeviceIcon, ProtectionStatus} from 'src/app/services/device.service';
import {dummyDevices} from "../../../../../test/data/devices";


@Component({
Expand All @@ -13,66 +14,7 @@ export class DeviceTableComponent implements AfterViewInit {
DeviceIcon = DeviceIcon;
ProtectionStatus = ProtectionStatus;

public devices: Device[] = [
{
id: 1,
name: "Test Server 1",
connection: true,
icon: DeviceIcon.SERVER,
selected: false,
lastBackup: "25.12.2023 13:55",
protection: ProtectionStatus.OK,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
{
id: 2,
name: "Test Server 2",
connection: true,
icon: DeviceIcon.SERVER,
selected: false,
lastBackup: "22.12.2023 09:33",
protection: ProtectionStatus.WARNING,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2", "182.322.33.134"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
comment: "Hello World, this is a description of this device. How are you? How long could this text can be?",
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
{
id: 3,
name: "Test Computer",
connection: false,
icon: DeviceIcon.COMPUTER,
selected: false,
lastBackup: "25.12.2023 11:15",
protection: ProtectionStatus.ERROR,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
]
public devices = dummyDevices;

// Filtering
public filter = new FormControl();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-body">

</div>
</div>
</div>
<div class="col-6">

</div>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DevicesManageComponent } from './devices-manage.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component } from '@angular/core';
import {Device} from "../../../services/device.service";
import {dummyDevices} from "../../../../../test/data/devices";

@Component({
selector: 'app-devices-manage',
standalone: true,
imports: [],
templateUrl: './devices-manage.component.html',
styleUrl: './devices-manage.component.scss'
})
export class DevicesManageComponent {
public device: Device | undefined;

constructor() {
this.device = dummyDevices[0];

}

}
5 changes: 5 additions & 0 deletions web/src/app/pages/devices/devices.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {RouterModule, Routes} from "@angular/router";
import {DefaultLayoutComponent} from "../../layouts/default-layout/default-layout.component";
import {FormsModule} from "@angular/forms";
import {NgbTooltipModule} from "@ng-bootstrap/ng-bootstrap";
import {DevicesManageComponent} from "./devices-manage/devices-manage.component";



Expand All @@ -17,6 +18,10 @@ const routes: Routes = [
{
path: 'delete',
component: DevicesDeleteComponent
},
{
path: 'manage/:id',
component: DevicesManageComponent
}

];
Expand Down
62 changes: 62 additions & 0 deletions web/test/data/devices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {Device, DeviceIcon, ProtectionStatus} from "../../src/app/services/device.service";

export const dummyDevices: Device[] = [
{
id: 1,
name: "Test Server 1",
connection: true,
icon: DeviceIcon.SERVER,
selected: false,
lastBackup: "25.12.2023 13:55",
protection: ProtectionStatus.OK,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
{
id: 2,
name: "Test Server 2",
connection: true,
icon: DeviceIcon.SERVER,
selected: false,
lastBackup: "22.12.2023 09:33",
protection: ProtectionStatus.WARNING,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2", "182.322.33.134"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
comment: "Hello World, this is a description of this device. How are you? How long could this text can be?",
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
{
id: 3,
name: "Test Computer",
connection: false,
icon: DeviceIcon.COMPUTER,
selected: false,
lastBackup: "25.12.2023 11:15",
protection: ProtectionStatus.ERROR,
agent: "OpenSSH_6.6.1p1",
ip_addresses: ["127.0.0.2"],
os: {
osName: "Ubuntu 22.04",
cpu: "AMD Epyc 7402P",
ram: "64 GB RAM",
totalHarddrive: "1 TB"
},
machineIdentifier: "33970533-952c-43e9-a999-27f5ba1c655c",
backupPlans: []
},
]

0 comments on commit 3a3fd64

Please sign in to comment.