Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit 6ebceca

Browse files
author
Leonardo Chaia
committed
feat: show current attached container info below terminal
1 parent 460ca3e commit 6ebceca

6 files changed

+124
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<div fxLayout="column"
2+
fxLayoutGap="16px"
23
style="padding:16px;">
34
<div>
45
<tim-container-attacher [containerId]="containerId"
56
[stream]="stream$">
67
</tim-container-attacher>
78
</div>
9+
10+
<div>
11+
<tim-container-inspect-cards [containerId]="containerId"></tim-container-inspect-cards>
12+
</div>
813
</div>

src/app/daemon-tools/container-exec-container/container-exec-container.component.html

+4
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
<div *ngIf="execId">
1111
Exec {{execId}}
1212
</div>
13+
14+
<div>
15+
<tim-container-inspect-cards [containerId]="containerId"></tim-container-inspect-cards>
16+
</div>
1317
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<div *ngIf="containerInfo"
2+
fxLayout="column"
3+
fxLayoutGap="16px">
4+
<mat-card>
5+
<h3>
6+
<mat-icon class="tim-text-primary">computer</mat-icon>
7+
{{containerInfo.Name}} ({{containerInfo.Id | slice:0:12}})
8+
</h3>
9+
<p>
10+
<b>{{containerInfo.Config.Image}}</b>
11+
</p>
12+
13+
</mat-card>
14+
15+
<mat-card *ngIf="portMappings && portMappings.length">
16+
<h3>
17+
<mat-icon class="tim-text-primary">network_wifi</mat-icon>
18+
Port bindings:
19+
</h3>
20+
<ul>
21+
<li *ngFor="let mapping of portMappings">
22+
<span title="Container Port">{{mapping.containerPort}}</span>
23+
<mat-icon>arrow_right_alt</mat-icon>
24+
<b title="HostPort">{{mapping.hostPort}}</b>
25+
</li>
26+
</ul>
27+
</mat-card>
28+
29+
<mat-card *ngIf="containerInfo.Mounts && containerInfo.Mounts.length">
30+
<h3>
31+
<mat-icon class="tim-text-primary">storage</mat-icon>
32+
Volumes
33+
</h3>
34+
<ul>
35+
<li *ngFor="let mapping of containerInfo.Mounts">
36+
<span title="Container Path">{{mapping.Destination}}</span>
37+
<mat-icon>arrow_right_alt</mat-icon>
38+
<b title="Volume">{{mapping['Name']}}</b> ({{mapping['Type']}})
39+
</li>
40+
</ul>
41+
</mat-card>
42+
43+
<mat-card>
44+
<h3>
45+
<mat-icon class="tim-text-primary">confirmation_number</mat-icon>
46+
Environment Variables
47+
</h3>
48+
<pre><ng-container *ngFor="let env of containerInfo.Config.Env">{{env+"\n"}}</ng-container></pre>
49+
</mat-card>
50+
51+
<mat-card *ngIf="labels && labels.length">
52+
<h3>
53+
<mat-icon class="tim-text-primary">label</mat-icon>
54+
Labels
55+
</h3>
56+
<ul>
57+
<li *ngFor="let label of labels">
58+
{{label.key}}: <b>{{label.value}}</b>
59+
</li>
60+
</ul>
61+
</mat-card>
62+
</div>

src/app/daemon-tools/container-inspect-cards/container-inspect-cards.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Component, OnInit, Input } from '@angular/core';
2+
import { DockerContainerService } from '../docker-container.service';
3+
import { ContainerInspectInfo } from 'dockerode';
4+
5+
@Component({
6+
selector: 'tim-container-inspect-cards',
7+
templateUrl: './container-inspect-cards.component.html',
8+
styleUrls: ['./container-inspect-cards.component.scss']
9+
})
10+
export class ContainerInspectCardsComponent implements OnInit {
11+
12+
@Input()
13+
public containerId: string;
14+
15+
public containerInfo: ContainerInspectInfo;
16+
public portMappings: { containerPort: string, hostPort: string }[] = [];
17+
public labels: { key: string, value: string }[] = [];
18+
19+
constructor(private containerService: DockerContainerService) { }
20+
21+
public ngOnInit() {
22+
23+
this.containerService.inspect(this.containerId)
24+
.subscribe(info => {
25+
this.containerInfo = info;
26+
for (const containerPort in info.HostConfig.PortBindings) {
27+
if (info.HostConfig.PortBindings.hasOwnProperty(containerPort)) {
28+
const portBindings = info.HostConfig.PortBindings[containerPort];
29+
for (const iterator of portBindings) {
30+
const port = {
31+
containerPort: containerPort.slice(0, containerPort.indexOf('/')),
32+
hostPort: iterator.HostPort
33+
};
34+
this.portMappings.push(port);
35+
}
36+
37+
for (const key in info.Config.Labels) {
38+
if (info.Config.Labels.hasOwnProperty(key)) {
39+
const label = info.Config.Labels[key];
40+
this.labels.push({
41+
key: key,
42+
value: label
43+
});
44+
}
45+
}
46+
}
47+
}
48+
});
49+
}
50+
51+
}

src/app/daemon-tools/daemon-tools.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { ContainerLauncherComponent } from './container-launcher/container-launc
4848
import { PullImageJobLogsComponent } from './pull-image-job-logs/pull-image-job-logs.component';
4949
import { JobsModule } from '../jobs/jobs.module';
5050
import { TimDialogModule } from '../tim-dialog/tim-dialog.module';
51+
import { ContainerInspectCardsComponent } from './container-inspect-cards/container-inspect-cards.component';
5152

5253
@NgModule({
5354
imports: [
@@ -101,6 +102,7 @@ import { TimDialogModule } from '../tim-dialog/tim-dialog.module';
101102
ContainerListContainerComponent,
102103
PullImageJobLogsComponent,
103104
ContainerLauncherComponent,
105+
ContainerInspectCardsComponent,
104106
],
105107
exports: [
106108
ContainerListComponent,

0 commit comments

Comments
 (0)