-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image interface, some bottom margin on dashboard cards
- Loading branch information
1 parent
caa6cbf
commit fae6274
Showing
10 changed files
with
180 additions
and
48 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
20 changes: 20 additions & 0 deletions
20
src/client/src/app/create-containers/create-containers.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,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> |
4 changes: 4 additions & 0 deletions
4
src/client/src/app/create-containers/create-containers.component.scss
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,4 @@ | ||
.container-create-form { | ||
margin: auto; | ||
width: 50% !important; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/client/src/app/create-containers/create-containers.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,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(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/client/src/app/create-containers/create-containers.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,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 | ||
} | ||
}) | ||
} | ||
} |
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
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 | ||
} |
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,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(); | ||
}); | ||
}); |
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,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`); | ||
} | ||
|
||
} | ||
|
||
|