Skip to content

Commit

Permalink
🔥 implementation of getting containers in real-time, edit image name …
Browse files Browse the repository at this point in the history
…to id
  • Loading branch information
AbduazizZiyodov committed Jul 14, 2022
1 parent a7bf251 commit 99c3c18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RunContainerModalComponent implements OnInit {
containerData['ports'] = {};
containerData['environment'] = {};

containerData['image'] = this.data.resource?.name;
containerData['image'] = this.data.resource?.short_id;

if (firstPort && secondPort) {
containerData['ports'][firstPort] = secondPort;
Expand Down
9 changes: 3 additions & 6 deletions src/client/src/app/core/containers/containers.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ <h2 class="h2-responsive text-center fw-bold navbar-text">
<i class="fas fa-cubes"></i> Containers
</h2>

<div class="card">
<div class="card" data-aos="zoom-in" data-aos-duration="500">
<div class="card-body">
<p
data-aos="zoom-in"
data-aos-duration="500"
data-aos-once="true"
*ngIf="containers.length == 0"
class="note border note-primary text-center"
>
Expand All @@ -27,11 +28,7 @@ <h2 class="h2-responsive text-center fw-bold navbar-text">
<th><i class="fas fa-compact-disc"></i> Actions</th>
</tr>
</thead>
<tbody
*ngFor="for; let container; of: containers; index as i"
data-aos="zoom-in"
data-aos-duration="500"
>
<tbody *ngFor="for; let container; of: containers; index as i">
<tr>
<td>{{ i + 1 }}.</td>
<td>
Expand Down
18 changes: 14 additions & 4 deletions src/client/src/app/core/containers/containers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import { Component, OnInit } from '@angular/core';
import { MdbModalRef, MdbModalService } from 'mdb-angular-ui-kit/modal';

import { Status } from '@models/status';
import { ModalData } from '@models/modal';
import { Container } from '@models/container';
import { ContainerService } from '@services/container.service';
import { ModalComponent } from '@components/modal/modal.component';

import { Subscription, timer } from 'rxjs';
import { switchMap } from 'rxjs/operators';

@Component({
selector: 'app-containers',
templateUrl: './containers.component.html',
styleUrls: ['./containers.component.scss'],
})
export class ContainersComponent implements OnInit {
containers!: Container[];
timerSubscription!: Subscription;
subscription!: Subscription;
modalRef: MdbModalRef<ModalComponent> | null = null;

status: Status = {
Expand All @@ -36,9 +40,15 @@ export class ContainersComponent implements OnInit {
) {}

ngOnInit(): void {
this.containerService.getContainers().subscribe((data: Container[]) => {
this.containers = data.reverse();
});
this.subscription = timer(0, 1000)
.pipe(switchMap(() => this.containerService.getContainers()))
.subscribe((data: Container[]) => {
this.containers = data.reverse();
});
}

ngOnDestroy() {
this.subscription.unsubscribe();
}

startContainer(container_id: string) {
Expand Down

0 comments on commit 99c3c18

Please sign in to comment.