-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds docker container list + start, stop, delete
- Loading branch information
Showing
7 changed files
with
148 additions
and
3 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
45 changes: 45 additions & 0 deletions
45
frontend/lethean/src/app/settings/docker/settings-docker.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,45 @@ | ||
<main class=" pb-8"> | ||
<div class="mx-auto max-w-3xl px-4 sm:px-6 lg:max-w-7xl lg:px-8"> | ||
<h1 class="sr-only">Docker Setup Page</h1> | ||
<p class="sr-only">This page will communicate with your local docker service, download and bootstrap Lethean.</p> | ||
<!-- Main 3 column grid --> | ||
|
||
<section aria-labelledby="section-1-title"> | ||
<h2 class="sr-only" id="section-1-title">Section title</h2> | ||
<div class="overflow-hidden rounded-lg bg-white shadow"> | ||
<div class="p-6"> | ||
<!-- Your content --> | ||
|
||
<table class="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>State</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody class="bg-white divide-y divide-gray-300"> | ||
<tr *ngFor="let cont of containers"> | ||
<td class="px-6 py-4 whitespace-nowrap">{{ cont.Names[0] }}</td> | ||
<td class="px-6 py-4 whitespace-nowrap">{{ cont.State }}</td> | ||
<td class="px-6 py-4 whitespace-nowrap"> | ||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 rounded" (click)="startContainer(cont.Id)"> | ||
Start | ||
</button> | ||
<button class="bg-orange-500 hover:bg-orange-700 text-white font-bold py-1 px-2 rounded" (click)="stopContainer(cont.Id)"> | ||
Stop | ||
</button> | ||
<button class="bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-2 rounded" (click)="deleteContainer(cont.Id)"> | ||
Delete | ||
</button> | ||
</td> | ||
</table> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
</main> |
Empty file.
23 changes: 23 additions & 0 deletions
23
frontend/lethean/src/app/settings/docker/settings-docker.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 { SettingsDockerComponent } from './settings-docker.component'; | ||
|
||
describe('SettingsDockerComponent', () => { | ||
let component: SettingsDockerComponent; | ||
let fixture: ComponentFixture<SettingsDockerComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SettingsDockerComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SettingsDockerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
61 changes: 61 additions & 0 deletions
61
frontend/lethean/src/app/settings/docker/settings-docker.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,61 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {NgForOf, NgIf} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'app-docker', | ||
standalone: true, | ||
imports: [ | ||
NgIf, | ||
NgForOf | ||
], | ||
templateUrl: './settings-docker.component.html', | ||
styleUrl: './settings-docker.component.scss' | ||
}) | ||
export class SettingsDockerComponent implements OnInit { | ||
containers: any; | ||
|
||
ngOnInit(): void { | ||
|
||
this.getContainers() | ||
} | ||
|
||
getContainers() { | ||
fetch('http://localhost:36911/docker/container/list') | ||
.then(response => response.json()).then(data => { | ||
this.containers = data; | ||
}); | ||
} | ||
|
||
deleteContainer(Id: string) { | ||
fetch(`http://localhost:36911/docker/container/remove/${Id}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then(response => response.json()).then(data => { | ||
this.getContainers() | ||
}) | ||
} | ||
|
||
stopContainer(Id: string) { | ||
fetch(`http://localhost:36911/docker/container/stop/${Id}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then(response => response.json()).then(data => { | ||
this.getContainers() | ||
}) | ||
} | ||
|
||
startContainer(Id: string) { | ||
fetch(`http://localhost:36911/docker/container/start/${Id}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then(response => response.json()).then(data => { | ||
this.getContainers() | ||
}) | ||
} | ||
} |
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