Skip to content

Commit

Permalink
Add image interface, some bottom margin on dashboard cards
Browse files Browse the repository at this point in the history
  • Loading branch information
AbduazizZiyodov committed May 3, 2024
1 parent caa6cbf commit fae6274
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 48 deletions.
4 changes: 3 additions & 1 deletion src/client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { TieredMenuModule } from 'primeng/tieredmenu';
import { InputGroupModule } from 'primeng/inputgroup';
import { InputNumberModule } from 'primeng/inputnumber';
import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
import { ProgressSpinnerModule } from 'primeng/progressspinner';
// Components
import { ContainersComponent } from '@containers/containers.component';
import { DashboardComponent } from './dashboard/dashboard.component';
Expand Down Expand Up @@ -77,7 +78,8 @@ import { CreateContainersComponent } from './create-containers/create-containers
InputNumberModule,
InputGroupModule,
InputGroupAddonModule,
StyleClassModule
StyleClassModule,
ProgressSpinnerModule
],
providers: [MessageService],
bootstrap: [AppComponent]
Expand Down
3 changes: 3 additions & 0 deletions src/client/src/app/containers/containers.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h2>Containers?</h2>
icon="fa-solid fa-plus"
size="small"
severity="success"
[routerLink]="['new']"
></p-button>
</div>
</div>
Expand All @@ -30,9 +31,11 @@ <h2>
icon="fa-solid fa-plus"
size="small"
severity="success"
[routerLink]="['new']"
></p-button>
</h2>
<p-table
class="shadow-1"
[rows]="5"
[value]="containers"
[paginator]="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="container-create-form">
<p-card>
<h2 class="text-center">Run new container</h2>

<input pInputText id="container_name" placeholder="Container name" />
<br />
<p-dropdown
[options]="imageOptions"
[lazy]="true"
[(ngModel)]="selectedImage"
optionLabel="name"
[showClear]="true"
placeholder="Select a Docker Image"
></p-dropdown>

<p-divider></p-divider>

<p-button size="large" [raised]="true" label="Bake"></p-button>
</p-card>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.container-create-form {
margin: auto;
width: 50% !important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CreateContainersComponent } from './create-containers.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { ImageService } from '@services/image.service'
import { Image } from '@models/image'
import { IMAGE_CONFIG } from '@angular/common';

@Component({
selector: 'app-create-containers',
templateUrl: './create-containers.component.html',
styleUrl: './create-containers.component.scss'
})
export class CreateContainersComponent implements OnInit {
selectedImage: Image = {} as Image;
images: Image[] = [] as Image[];
imageOptions: any;
constructor(private imageService: ImageService) { }


ngOnInit(): void {
this.imageService.all().subscribe((data: Image[]) => {
this.images = data;
for (let image of data) {
this.imageOptions[image.name + ":" + image.tag] = image.short_id
}
})
}
}
61 changes: 25 additions & 36 deletions src/client/src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-3 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<span class="block text-500 font-medium mb-3">Total</span>
<div class="text-900 font-medium text-xl">
<h1 class="font-bold p-0 m-0">
{{ dashboardInfo.system_wide_info.containers.total }}
</div>
</h1>
</div>
<div
class="flex align-items-center justify-content-center bg-blue-100 border-round"
Expand All @@ -18,14 +18,14 @@
</div>
</div>
</div>
<div class="col-md-3">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-3 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<span class="block text-500 font-medium mb-3">Running</span>
<div class="text-900 font-medium text-xl">
<h1 class="font-bold p-0 m-0">
{{ dashboardInfo.system_wide_info.containers.running }}
</div>
</h1>
</div>
<div
class="flex align-items-center justify-content-center bg-green-100 border-round"
Expand All @@ -36,14 +36,14 @@
</div>
</div>
</div>
<div class="col-md-3">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-3 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<span class="block text-500 font-medium mb-3">Paused</span>
<div class="text-900 font-medium text-xl">
<span class="block text-500 font-bold mb-3">Paused</span>
<h1 class="font-bold p-0 m-0">
{{ dashboardInfo.system_wide_info.containers.paused }}
</div>
</h1>
</div>
<div
class="flex align-items-center justify-content-center bg-yellow-100 border-round"
Expand All @@ -54,14 +54,14 @@
</div>
</div>
</div>
<div class="col-md-3">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-3 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<span class="block text-500 font-medium mb-3">Stopped</span>
<div class="text-900 font-medium text-xl">
<span class="block text-500 font-bold mb-3">Stopped</span>
<h1 class="font-bold p-0 m-0">
{{ dashboardInfo.system_wide_info.containers.stopped }}
</div>
</h1>
</div>
<div
class="flex align-items-center justify-content-center bg-red-100 border-round"
Expand All @@ -75,8 +75,8 @@
</div>

<div class="row mt-3">
<div class="col-md-6">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-6 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<h3>
Expand Down Expand Up @@ -124,17 +124,11 @@ <h3>
</span>
</h3>
</div>
<div
class="flex align-items-center justify-content-center bg-teal-100 border-round"
style="width: 2.5rem; height: 2.5rem"
>
<i class="fa-solid fa-circle-info text-teal-900 text-xl p-2"></i>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="surface-card shadow-2 p-5 border-round">
<div class="col-md-6 mb-2">
<div class="surface-card shadow-1 p-5 border-round">
<div class="flex justify-content-between mb-1">
<div>
<h3>
Expand Down Expand Up @@ -168,18 +162,13 @@ <h3>
</span>
</h3>
</div>
<div
class="flex align-items-center justify-content-center bg-indigo-100 border-round"
style="width: 2.5rem; height: 2.5rem"
>
<i class="fa-solid fa-server text-indigo-500 text-xl p-2"></i>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="text-center mt-2">
<small>Running on {{ dashboardInfo.docker_info.platform_name }}</small>
<div class="text-center mt-4">
<small>Running on {{ dashboardInfo.docker_info.platform_name }}
</small>
</div>
30 changes: 19 additions & 11 deletions src/client/src/app/models/image.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
export interface Image {
id: string;
name: string;
short_id: string;
labels: object;
star_count?: number;
is_official?: boolean;
description?: string;
is_pulled?: boolean;
is_pulling?: boolean;
tag: string;
}
id: string;
name: string;
short_id: string;
labels: object;
star_count?: number;
is_official?: boolean;
description?: string;
is_pulled?: boolean;
is_pulling?: boolean;
tag: string;
}

export interface ImageSearchResult {
name: string
star_count: number
description: string
is_official: boolean
is_automated: boolean
}
16 changes: 16 additions & 0 deletions src/client/src/app/services/image.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { ImageService } from './image.service';

describe('ImageService', () => {
let service: ImageService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ImageService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
41 changes: 41 additions & 0 deletions src/client/src/app/services/image.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Image, ImageSearchResult } from '@models/image';
import { Container } from '@models/container'

@Injectable({
providedIn: 'root'
})
export class ImageService {

api: string = 'http://127.0.0.1:2120/api';

constructor(private http: HttpClient) { }

all() {
return this.http.get<Image[]>(`${this.api}/images`);
}

get(image_id: string) {
return this.http.get<Image>(`${this.api}/images/${image_id}`);
}

delete(image_id: string) {
return this.http.delete(`${this.api}/images/${image_id}/remove/`);
}
search(term: string, limit: number) {
return this.http.get<ImageSearchResult[]>(`${this.api}/images/search`, {
params: {
term, limit
}
});
}

containers(image_id: string) {
return this.http.get<Container[]>(`${this.api}/images/${image_id}/containers`);
}

}


0 comments on commit fae6274

Please sign in to comment.