module config page added
This commit is contained in:
parent
ed399bfbde
commit
36470f8264
5
src/PanoptesFrontend/Data/ModuleConfig.cs
Normal file
5
src/PanoptesFrontend/Data/ModuleConfig.cs
Normal file
@ -0,0 +1,5 @@
|
||||
public class ModuleConfig {
|
||||
public string ImageName {get; set;}
|
||||
public Dictionary<string, string> Environment {get; set;} = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> Volumes {get; set;} = new Dictionary<string, string>();
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
public class Post {
|
||||
|
||||
public int userId {get; set;}
|
||||
public int id {get; set;}
|
||||
public string title {get; set;}
|
||||
public string body {get; set;}
|
||||
|
||||
public Post(int userId, int id, string title, string body){
|
||||
userId = userId;
|
||||
id = id;
|
||||
title = title;
|
||||
body = body;
|
||||
}
|
||||
|
||||
}
|
||||
134
src/PanoptesFrontend/Pages/ModConfig.razor
Normal file
134
src/PanoptesFrontend/Pages/ModConfig.razor
Normal file
@ -0,0 +1,134 @@
|
||||
@page "/module-config"
|
||||
@using System.Text.Json
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.JSInterop
|
||||
@using System.Net;
|
||||
@using PanoptesFrontend.Data
|
||||
@using PanoptesFrontend.Services
|
||||
@inject IHttpService httpService
|
||||
|
||||
<h1>Module Configuration</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label for="imageName">Image Name</label>
|
||||
<input type="text" class="form-control" id="imageName" @bind="ModuleConfig.ImageName" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Environment</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="key1">Key</label>
|
||||
<input type="text" class="form-control" id="key1" @bind="Key1" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="value1">Value</label>
|
||||
<input type="text" class="form-control" id="value1" @bind="Value1" />
|
||||
</div>
|
||||
<button class="btn btn-primary" @onclick="AddKeyValuePair1">Add</button>
|
||||
<table class="table mt-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var kvp in ModuleConfig.Environment)
|
||||
{
|
||||
<tr>
|
||||
<td>@kvp.Key</td>
|
||||
<td>@kvp.Value</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Volumes</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="key2">Key</label>
|
||||
<input type="text" class="form-control" id="key2" @bind="Key2" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="value2">Value</label>
|
||||
<input type="text" class="form-control" id="value2" @bind="Value2" />
|
||||
</div>
|
||||
<button class="btn btn-primary" @onclick="AddKeyValuePair2">Add</button>
|
||||
<table class="table mt-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var kvp in ModuleConfig.Volumes)
|
||||
{
|
||||
<tr>
|
||||
<td>@kvp.Key</td>
|
||||
<td>@kvp.Value</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mt-3">
|
||||
<button class="btn btn-success" @onclick="SubmitForm">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
@code {
|
||||
private string Key1 { get; set; }
|
||||
private string Value1 { get; set; }
|
||||
private string Key2 { get; set; }
|
||||
private string Value2 { get; set; }
|
||||
private ModuleConfig ModuleConfig { get; set; } = new ModuleConfig();
|
||||
|
||||
|
||||
|
||||
private void AddKeyValuePair1()
|
||||
{
|
||||
ModuleConfig.Environment.Add(Key1, Value1);
|
||||
Key1 = "";
|
||||
Value1 = "";
|
||||
}
|
||||
|
||||
private void AddKeyValuePair2()
|
||||
{
|
||||
ModuleConfig.Volumes.Add(Key2, Value2);
|
||||
Key2 = "";
|
||||
Value2 = "";
|
||||
}
|
||||
|
||||
private async void SubmitForm()
|
||||
{
|
||||
// Log ModuleConfig object to console and send to backend
|
||||
var config = JsonSerializer.Serialize(ModuleConfig);
|
||||
await httpService.PostAsync("http://localhost:8080/config_module", config);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user