Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #28 from tfenster/alpha7
Browse files Browse the repository at this point in the history
alpha7
  • Loading branch information
Tobias Fenster authored Feb 4, 2019
2 parents 579b17e + a7f034b commit 538ab37
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 11 deletions.
23 changes: 23 additions & 0 deletions api/Controllers/ContainerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ public async Task<ActionResult<string>> Post(BCContainer container)
hostConf.Binds.Add($"{basePath}:{basePath}");
}

if (!string.IsNullOrEmpty(container.SecurityOpt))
{
IList<string> securityOpts = new List<string>();
securityOpts.Add(container.SecurityOpt);
hostConf.SecurityOpt = securityOpts;
}

if (!string.IsNullOrEmpty(container.License))
{
if (hostConf.Binds == null)
hostConf.Binds = new List<string>();
hostConf.Binds.Add(@"c:\programdata\bcinab\licenses:c:\licenses");
Env.Add(@"licensefile=c:\licenses\" + container.License);
}

var Labels = new Dictionary<string, string>();
Labels.Add("bcinab.guidef", $"{container.GuiDef}");

Expand All @@ -191,9 +206,17 @@ public async Task<ActionResult<string>> Post(BCContainer container)
new ContainerStartParameters() { }
);
if (started)
{
if (container.TestToolkit)
{

}
return Ok(createResp.ID);
}
else
{
return BadRequest($"could not start {createResp.ID}");
}
}
catch (Exception ex)
{
Expand Down
58 changes: 58 additions & 0 deletions api/Controllers/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,64 @@ public ActionResult<bool> Navcontainerhelper()
return Ok(Directory.Exists("C:\\programdata\\navcontainerhelper"));
}

// GET api/system
[HttpGet("[action]/")]
public async Task<ActionResult<IList<NetworkResponse>>> Networks()
{
try
{
var resp = await GetClient().Networks.ListNetworksAsync();
return Ok(resp);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}

}

// GET api/system
[HttpGet("[action]/")]
public ActionResult<IList<string>> Licenses()
{
try
{
var resp = new List<string>();
string[] files = Directory.GetFiles(@"c:\programdata\bcinab\licenses\", "*.flf");
foreach (var file in files)
{
resp.Add(file.Substring(file.LastIndexOf(@"\") + 1));
}
return Ok(resp);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}

}

// GET api/system
[HttpGet("[action]/")]
public ActionResult<IList<string>> CredentialSpecs()
{
try
{
var resp = new List<string>();
string[] files = Directory.GetFiles(@"c:\programdata\dockercredspecs\", "*.json");
foreach (var file in files)
{
resp.Add(file.Substring(file.LastIndexOf(@"\") + 1));
}
return Ok(resp);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}

}

private DockerClient GetClient()
{
if (_client == null)
Expand Down
4 changes: 4 additions & 0 deletions api/Models/BCContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class BCContainer
public string Name { get; set; }
public IList<string> Env { get; set; }
public bool Navcontainerhelper { get; set; }
public string Network { get; set; }
public string SecurityOpt { get; set; }
public string License { get; set; }
public bool TestToolkit { get; set; }
public string GuiDef { get; set; }
}
}
30 changes: 29 additions & 1 deletion gui/ClientApp/src/app/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ import {
import { throwError } from "rxjs";
import { BaseData } from "./model/baseData";
import { RegistryCredentials } from "./model/registryCredentials";
import { AdvancedData } from "./model/advancedData";
import { Network } from "./model/network";

const API_URL = environment.apiUrl;

export interface GuiDef {
image: Image;
tag: Tag;
base: BaseData;
adv: AdvancedData;
}

@Injectable()
export class ApiService {
constructor(private http: HttpClient) {}

// API: GET /system/navcontainerhepler
// API: GET /system/navcontainerhelper
public getNavcontainerhelper(): Observable<string> {
const headers = new HttpHeaders({
"Content-Type": "application/json; charset=UTF-8"
Expand All @@ -41,6 +44,13 @@ export class ApiService {
return ret;
}

// API: GET /system/networks
public getNetworks(): Observable<Network[]> {
return this.http
.get<Network[]>(API_URL + "/system/networks")
.pipe(catchError(this.handleError));
}

// API: GET /container
public getAllContainers(): Observable<Container[]> {
return this.http
Expand All @@ -55,6 +65,20 @@ export class ApiService {
.pipe(catchError(this.handleError));
}

// API: GET /container/credentialspecs
public getCredspecs(): Observable<string[]> {
return this.http
.get<string[]>(API_URL + "/system/credentialspecs")
.pipe(catchError(this.handleError));
}

// API: GET /container/licenses
public getLicenses(): Observable<string[]> {
return this.http
.get<string[]>(API_URL + "/system/licenses")
.pipe(catchError(this.handleError));
}

// API: POST /container
public createContainer(guiDef: GuiDef): Observable<any> {
let env: string[] = [];
Expand Down Expand Up @@ -84,6 +108,10 @@ export class ApiService {
Name: guiDef.base.name,
Env: env,
Navcontainerhelper: guiDef.base.navcontainerhelper,
TestToolkit: guiDef.adv.testToolkit,
Network: guiDef.adv.network,
License: guiDef.adv.license,
SecurityOpt: "credentialspec=file://" + guiDef.adv.credspec,
GuiDef: JSON.stringify(guiDef)
};
const headers = new HttpHeaders({
Expand Down
5 changes: 4 additions & 1 deletion gui/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
PullProgressDialog,
DeleteConfirmDialog,
BaseEntryDialog,
RegCredDialog
RegCredDialog,
AdvEntryDialog
} from "./fetch-data/fetch-data.component";
import { MaterialModule } from "./material-module";

Expand All @@ -36,6 +37,7 @@ import { ShowLogComponent } from "./show-log/show-log.component";
PullProgressDialog,
DeleteConfirmDialog,
BaseEntryDialog,
AdvEntryDialog,
ShowLogComponent,
RegCredDialog
],
Expand All @@ -46,6 +48,7 @@ import { ShowLogComponent } from "./show-log/show-log.component";
PullProgressDialog,
DeleteConfirmDialog,
BaseEntryDialog,
AdvEntryDialog,
RegCredDialog
],
imports: [
Expand Down
17 changes: 17 additions & 0 deletions gui/ClientApp/src/app/fetch-data/dialogs/adv-entry.dialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.flexcolumn {
display: flex;
flex-direction: column;
}

p {
margin-bottom: 0;
}

.mat-form-field {
padding-top: 1em;
}

.mat-radio-group {
flex-direction: column;
display: flex;
}
50 changes: 50 additions & 0 deletions gui/ClientApp/src/app/fetch-data/dialogs/adv-entry.dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<h1 mat-dialog-title>Create a new container</h1>
<div mat-dialog-content>
<p>
What config do you want to use for the container?
</p>
<div class="flexcolumn">
<mat-checkbox cdkFocusInitial
[(ngModel)]="data.adv.testToolkit">Include test toolkit</mat-checkbox>
</div>
<div class="flexcolumn">Which license to use?
<mat-radio-group class="example-radio-group"
[(ngModel)]="data.adv.license"
required cdkFocusInitial>
<mat-radio-button
class="image-radio-button"
*ngFor="let license of data.licenses"
[value]="license">
{{ license }}
</mat-radio-button>
</mat-radio-group>
</div>
<div class="flexcolumn">Which network to use?
<mat-radio-group class="example-radio-group"
[(ngModel)]="data.adv.network"
required cdkFocusInitial>
<mat-radio-button
class="image-radio-button"
*ngFor="let network of data.networks"
[value]="network.Name">
{{ network.Name }} ({{ network.Id}})
</mat-radio-button>
</mat-radio-group>
</div>
<div class="flexcolumn">Which credentialspec to use?
<mat-radio-group class="example-radio-group"
[(ngModel)]="data.adv.credspec"
required cdkFocusInitial>
<mat-radio-button
class="image-radio-button"
*ngFor="let credspec of data.credspecs"
[value]="credspec">
{{ credspec }}
</mat-radio-button>
</mat-radio-group>
</div>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onCancelClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data.adv">Create</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ <h1 mat-dialog-title>Create a new container</h1>
<input
matInput
[(ngModel)]="data.base.name"
placeholder="Container name non req (hostname will be the same)"
placeholder="Container name (hostname will be the same)"
/>
</mat-form-field>
<mat-form-field *ngIf="data.base.navcontainerhelper">
<input
matInput
[(ngModel)]="data.base.name"
placeholder="Container name req (hostname will be the same)"
placeholder="Container name (hostname will be the same)"
required
/>
</mat-form-field>
Expand Down Expand Up @@ -58,5 +58,5 @@ <h1 mat-dialog-title>Create a new container</h1>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onCancelClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data.base">Create</button>
<button mat-button [mat-dialog-close]="data.base">Next</button>
</div>
4 changes: 2 additions & 2 deletions gui/ClientApp/src/app/fetch-data/fetch-data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
</a>
<button mat-icon-button color="primary" *ngIf="row.State === 'exited'"
(click)="startContainer(row.Id, $event)" matTooltip="start">
<mat-icon>play_circle_outline</mat-icon>
<mat-icon>play_arrow</mat-icon>
</button>
<button mat-icon-button color="primary" *ngIf="row.State === 'running'"
(click)="stopContainer(row.Id, $event)" matTooltip="stop">
<mat-icon>pause_circle_outline</mat-icon>
<mat-icon>stop</mat-icon>
</button>
<button mat-icon-button color="primary" *ngIf="row.State === 'running'"
(click)="restartContainer(row.Id, $event)" matTooltip="restart">
Expand Down
Loading

0 comments on commit 538ab37

Please sign in to comment.