Skip to content

Commit

Permalink
Implement basic dashboard page, add ports field on container api
Browse files Browse the repository at this point in the history
  • Loading branch information
AbduazizZiyodov committed Jan 19, 2024
1 parent 5a77590 commit 9db4c8d
Show file tree
Hide file tree
Showing 16 changed files with 496 additions and 10 deletions.
17 changes: 17 additions & 0 deletions src/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular/router": "^17.0.0",
"@fortawesome/fontawesome-free": "^6.5.1",
"chart.js": "^4.4.1",
"primeicons": "^6.0.1",
"primeng": "^17.3.1",
"rxjs": "~7.8.0",
Expand Down
16 changes: 11 additions & 5 deletions src/client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { ContainersComponent } from '@containers/containers.component'
import { ContainersComponent } from './containers/containers.component'
import { DashboardComponent } from './dashboard/dashboard.component';

const routes: Routes = [{
path: 'containers',
component: ContainersComponent
}];
const routes: Routes = [
{
path: '',
component: DashboardComponent
},
{
path: 'containers',
component: ContainersComponent
}];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
2 changes: 1 addition & 1 deletion src/client/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2>Admiral</h2>
size="small"
[rounded]="true"
(onClick)="changeTheme()"
[icon]="isDark ? 'fa-regular fa-moon' : 'fa-regular fa-lightbulb'"
[icon]="!isDark ? 'fa-regular fa-moon' : 'fa-regular fa-lightbulb'"
[outlined]="true"
></p-button>
<p-divider></p-divider>
Expand Down
6 changes: 5 additions & 1 deletion src/client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component } from '@angular/core';

import { MenuItem, PrimeNGConfig } from 'primeng/api';
import { ThemeService } from '@services/theme.service';
import { TreeNode } from 'primeng/api';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -31,6 +30,11 @@ export class AppComponent {

this.primengConfig.ripple = true;
this.items = [
{
label: 'Home',
icon: 'fa-solid fa-house-chimney',
routerLink: '/'
},
{
label: 'Containers',
icon: 'fa-solid fa-box-open',
Expand Down
14 changes: 11 additions & 3 deletions src/client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ import { MessageService } from 'primeng/api';
import { TableModule } from 'primeng/table';
import { AvatarModule } from 'primeng/avatar'
import { ButtonModule } from 'primeng/button';
import { PanelModule } from 'primeng/panel';
import { ToolbarModule } from 'primeng/toolbar'
import { TooltipModule } from 'primeng/tooltip';
import { DividerModule } from 'primeng/divider';
import { ListboxModule } from 'primeng/listbox';
import { SidebarModule } from 'primeng/sidebar';
import { DropdownModule } from 'primeng/dropdown';
import { FieldsetModule } from 'primeng/fieldset'
import { PanelMenuModule } from 'primeng/panelmenu';
import { TieredMenuModule } from 'primeng/tieredmenu';
import { ToolbarModule } from 'primeng/toolbar'
// Components
import { ContainersComponent } from '@containers/containers.component';
import { DashboardComponent } from './dashboard/dashboard.component';

@NgModule({
declarations: [
AppComponent,
ContainersComponent
ContainersComponent,
DashboardComponent
],
imports: [
BrowserModule,
Expand All @@ -49,10 +54,13 @@ import { ContainersComponent } from '@containers/containers.component';
MenuModule,
BadgeModule,
TieredMenuModule,
PanelModule,
DividerModule,
PanelMenuModule,
DropdownModule,
ToolbarModule
ToolbarModule,
FieldsetModule,
TooltipModule,
],
providers: [MessageService],
bootstrap: [AppComponent]
Expand Down
182 changes: 182 additions & 0 deletions src/client/src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<div class="text-center mb-2">
<h1
pTooltip="I'm not frontend developer, I'm trying my best."
tooltipPosition="top"
>
Dashboard
</h1>
</div>

<div class="grid">
<div class="col-6">
<p-fieldset legend="Docker">
<div class="grid">
<div class="col-6">
<p-divider align="center" type="solid">
<b><i class="fa-brands fa-docker"></i> Docker Related</b>
</p-divider>
<h3>
Docker API Version&nbsp;
<p-badge
[value]="dashboardInfo.docker_info.api_version"
severity="success"
size="large"
pTooltip="The default (and highest) API version that is supported by the daemon"
tooltipPosition="top"
></p-badge>
</h3>

<h3>
Platform Version&nbsp;
<p-badge
[value]="dashboardInfo.docker_info.platform_version"
severity="success"
size="large"
pTooltip="The version of the daemon"
tooltipPosition="top"
></p-badge>
</h3>

<h3>
Go Version&nbsp;
<p-badge
[value]="dashboardInfo.docker_info.go_version"
severity="warning"
size="large"
pTooltip="The version Go used to compile the daemon, and the version of the Go runtime in use."
tooltipPosition="top"
></p-badge>
</h3>

<h3>
Root Dir&nbsp;
<p-badge
[value]="dashboardInfo.system_wide_info.root_dir"
size="large"
pTooltip="Root directory of persistent Docker state."
tooltipPosition="top"
></p-badge>
</h3>
</div>

<div class="col-6 mx-5">
<p-divider align="left" type="solid">
<b><i class="fa-solid fa-box-open"></i> Containers</b>
</p-divider>

<h3>
<i class="fa-solid fa-box-open" style="color: var(--blue-500)"></i>
Total&nbsp;
<p-badge
[value]="
dashboardInfo.system_wide_info.containers.total.toString()
"
size="large"
></p-badge>
</h3>

<h3>
<i class="fa-solid fa-rocket" style="color: var(--green-400)"></i>
Running&nbsp;
<p-badge
[value]="
dashboardInfo.system_wide_info.containers.running.toString()
"
severity="success"
size="large"
></p-badge>
</h3>

<h3>
<i
class="fa-solid fa-circle-pause"
style="color: var(--orange-400)"
></i>
Paused&nbsp;
<p-badge
[value]="
dashboardInfo.system_wide_info.containers.paused.toString()
"
severity="warning"
size="large"
></p-badge>
</h3>

<h3>
<i class="fa-solid fa-hand" style="color: var(--red-400)"></i>
Stopped&nbsp;
<p-badge
[value]="
dashboardInfo.system_wide_info.containers.stopped.toString()
"
severity="danger"
size="large"
></p-badge>
</h3>
</div>
</div>
</p-fieldset>
</div>

<div class="col-6">
<p-fieldset legend="System">
<p-divider align="center" type="solid">
<b><i class="fa-solid fa-desktop"></i> Operating System Info</b>
</p-divider>
<h3>
Name
<p-badge
[value]="dashboardInfo.system_wide_info.os.name"
size="large"
></p-badge>
</h3>

<h3>
OS Type
<p-badge
[value]="dashboardInfo.system_wide_info.os.type"
severity="warning"
size="large"
></p-badge>
&nbsp;Version
<p-badge
[value]="dashboardInfo.system_wide_info.os.version"
severity="success"
size="large"
></p-badge>
</h3>

<p-divider align="center" type="solid">
<b>Others</b>
</p-divider>

<h3>
<i class="fa-solid fa-memory"></i> Total Memory
<p-badge
[value]="dashboardInfo.system_wide_info.total_memory"
severity="success"
size="large"
></p-badge>
&nbsp; <i class="fa-solid fa-microchip"></i> CPU count
<p-badge
pTooltip="The number of logical CPUs usable by the daemon."
[value]="dashboardInfo.system_wide_info.cpu_count.toString()"
severity="danger"
size="large"
></p-badge>
</h3>

<h3>
Kernel Version
<p-badge
[value]="dashboardInfo.system_wide_info.kernel_version"
size="large"
></p-badge>
</h3>
</p-fieldset>
</div>
</div>

<div class="text-center">
<small>Running on {{ dashboardInfo.docker_info.platform_name }}</small>
</div>
Empty file.
23 changes: 23 additions & 0 deletions src/client/src/app/dashboard/dashboard.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DashboardComponent } from './dashboard.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
21 changes: 21 additions & 0 deletions src/client/src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, OnInit } from '@angular/core';

import { DashboardService } from '@services/dashboard.service'
import { DashboardInfo } from '@models/dashboard'

@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrl: './dashboard.component.scss'
})
export class DashboardComponent implements OnInit {
dashboardInfo!: DashboardInfo;

constructor(private dashboardService: DashboardService) { }

ngOnInit(): void {
this.dashboardService.getDashboardInfo().subscribe((data: DashboardInfo) => {
this.dashboardInfo = data;
})
}
}
Loading

0 comments on commit 9db4c8d

Please sign in to comment.