From 36470f8264e363574dba1770e146e156c9d73943 Mon Sep 17 00:00:00 2001 From: Gary Murphy Date: Mon, 1 May 2023 00:48:37 +0100 Subject: [PATCH] module config page added --- src/PanoptesFrontend/Data/ModuleConfig.cs | 5 + src/PanoptesFrontend/Data/Post.cs | 15 --- src/PanoptesFrontend/Pages/ModConfig.razor | 134 +++++++++++++++++++++ 3 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 src/PanoptesFrontend/Data/ModuleConfig.cs delete mode 100644 src/PanoptesFrontend/Data/Post.cs create mode 100644 src/PanoptesFrontend/Pages/ModConfig.razor diff --git a/src/PanoptesFrontend/Data/ModuleConfig.cs b/src/PanoptesFrontend/Data/ModuleConfig.cs new file mode 100644 index 0000000..72ddd2d --- /dev/null +++ b/src/PanoptesFrontend/Data/ModuleConfig.cs @@ -0,0 +1,5 @@ +public class ModuleConfig { + public string ImageName {get; set;} + public Dictionary Environment {get; set;} = new Dictionary(); + public Dictionary Volumes {get; set;} = new Dictionary(); +} \ No newline at end of file diff --git a/src/PanoptesFrontend/Data/Post.cs b/src/PanoptesFrontend/Data/Post.cs deleted file mode 100644 index 2250a72..0000000 --- a/src/PanoptesFrontend/Data/Post.cs +++ /dev/null @@ -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; - } - -} diff --git a/src/PanoptesFrontend/Pages/ModConfig.razor b/src/PanoptesFrontend/Pages/ModConfig.razor new file mode 100644 index 0000000..38d5028 --- /dev/null +++ b/src/PanoptesFrontend/Pages/ModConfig.razor @@ -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 + +

Module Configuration

+ +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+

Environment

+
+
+
+ + +
+
+ + +
+ + + + + + + + + + @foreach (var kvp in ModuleConfig.Environment) + { + + + + + } + +
KeyValue
@kvp.Key@kvp.Value
+
+
+
+
+
+
+

Volumes

+
+
+
+ + +
+
+ + +
+ + + + + + + + + + @foreach (var kvp in ModuleConfig.Volumes) + { + + + + + } + +
KeyValue
@kvp.Key@kvp.Value
+
+
+
+
+ +
+
+ +
+
+ +@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); + } +} +} \ No newline at end of file