diff --git a/Components/Pages/Home.razor b/Components/Pages/Home.razor
index 930dcf8..afc1f46 100644
--- a/Components/Pages/Home.razor
+++ b/Components/Pages/Home.razor
@@ -21,15 +21,17 @@
@group.GroupName
-
- @foreach (var preset in group.Presets)
- {
- LoadPresetPublish(preset)">@preset.Name
- }
-
+ @foreach (var preset in group.Presets)
+ {
+ LoadPresetPublish(preset)">@preset.Name
+ }
}
+ @foreach (var preset in ungroupedPresets)
+ {
+ LoadPresetPublish(preset)">@preset.Name
+ }
@@ -79,15 +81,17 @@
@group.GroupName
-
- @foreach (var preset in group.Presets)
- {
- LoadPresetSubscribe(preset)">@preset.Name
- }
-
+ @foreach (var preset in group.Presets)
+ {
+ LoadPresetSubscribe(preset)">@preset.Name
+ }
}
+ @foreach (var preset in ungroupedPresets)
+ {
+ LoadPresetSubscribe(preset)">@preset.Name
+ }
@@ -153,12 +157,14 @@
Dropdown pubPresetDropdown;
Dropdown subPresetDropdown;
private List presetGroups = new List();
+ private List ungroupedPresets = new List();
private List messages = new List();
protected override async Task OnInitializedAsync()
{
presetGroups = await PresetService.GetPresetGroupsAsync();
+ ungroupedPresets = await PresetService.GetUngroupedPresetsAsync();
}
private async Task LoadPresetPublish(PresetModel preset)
diff --git a/Components/Pages/QueueBrowser.razor b/Components/Pages/QueueBrowser.razor
index 8fe39b5..275beac 100644
--- a/Components/Pages/QueueBrowser.razor
+++ b/Components/Pages/QueueBrowser.razor
@@ -15,20 +15,22 @@
@selectedPreset
- @foreach (var group in presetGroups)
- {
+ @foreach (var group in presetGroups)
+ {
@group.GroupName
-
- @foreach (var preset in group.Presets)
- {
- LoadPreset(preset)">@preset.Name
- }
-
+ @foreach (var preset in group.Presets)
+ {
+ LoadPreset(preset)">@preset.Name
+ }
- }
+ }
+ @foreach (var preset in ungroupedPresets)
+ {
+ LoadPreset(preset)">@preset.Name
+ }
@@ -161,6 +163,7 @@
private string selectedPreset = "Select Preset";
private List presetGroups = new List();
+ private List ungroupedPresets = new List();
Dropdown presetDropdown;
private bool isBrowsing = false;
@@ -215,6 +218,7 @@
protected override async Task OnInitializedAsync()
{
presetGroups = await PresetService.GetPresetGroupsAsync();
+ ungroupedPresets = await PresetService.GetUngroupedPresetsAsync();
}
protected override void OnInitialized()
diff --git a/Components/Pages/SEMP.razor b/Components/Pages/SEMP.razor
index 74679fa..531b971 100644
--- a/Components/Pages/SEMP.razor
+++ b/Components/Pages/SEMP.razor
@@ -22,15 +22,17 @@
@group.GroupName
-
- @foreach (var preset in group.Presets)
- {
- LoadPreset(preset)">@preset.Name
- }
-
+ @foreach (var preset in group.Presets)
+ {
+ LoadPreset(preset)">@preset.Name
+ }
}
+ @foreach (var preset in ungroupedPresets)
+ {
+ LoadPreset(preset)">@preset.Name
+ }
@@ -105,6 +107,7 @@
private string selectedPreset = "Select Preset";
private List presetGroups = new List();
+ private List ungroupedPresets = new List();
Dropdown presetDropdown;
private async Task GetQueues()
@@ -137,6 +140,7 @@
protected override async Task OnInitializedAsync()
{
presetGroups = await PresetService.GetPresetGroupsAsync();
+ ungroupedPresets = await PresetService.GetUngroupedPresetsAsync();
}
private void LoadPreset(PresetModel preset)
diff --git a/README.md b/README.md
index e96d41b..1874504 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@ The Solace Web Client is a .NET (C#) application that offers comprehensive funct
## Presets
The Solace Web Client allows you to manage connection presets, making it easy to switch between different configurations.
+You can either create presets directly (i.e. Exampele 5) or group them (i.e. "test" & "prod").
Create a presets.json and mount it in `/app/presets/presets.json`.
@@ -77,6 +78,16 @@ Example:
"sempUsername": "admin"
}
]
+ },
+ {
+ "Name": "Example 5",
+ "Host": "tcps://broker.domain:55443",
+ "VpnName": "default",
+ "Username": "demo",
+ "Topic": "a/b/c",
+ "QueueName": "myqueue",
+ "SempUrl": "https://broker.domain:1943",
+ "sempUsername": "admin"
}
]
diff --git a/Services/PresetService.cs b/Services/PresetService.cs
index 2e763bf..ce26616 100644
--- a/Services/PresetService.cs
+++ b/Services/PresetService.cs
@@ -10,8 +10,9 @@ namespace SolaceWebClient.Services
public class PresetGroupModel
{
public string GroupName { get; set; }
- public List Presets { get; set; }
+ public List Presets { get; set; } = new List(); // Initialisiere die Liste
}
+
public class PresetModel
{
public string Name { get; set; }
@@ -24,6 +25,12 @@ public class PresetModel
public string sempUsername { get; set; }
}
+ public class UngroupedPresetModel : PresetModel
+ {
+
+ }
+
+
public class PresetService
{
private readonly string presetsFilePath = Path.Combine("presets", "presets.json");
@@ -36,9 +43,54 @@ public async Task> GetPresetGroupsAsync()
}
var json = await File.ReadAllTextAsync(presetsFilePath);
- var presetGroups = JsonSerializer.Deserialize>(json);
+ var allPresets = JsonSerializer.Deserialize>(json);
+
+ var groupedPresets = new List();
+ var ungroupedPresets = new List();
+
+ foreach (var item in allPresets)
+ {
+ if (item.TryGetProperty("Presets", out _))
+ {
+ var group = JsonSerializer.Deserialize(item.GetRawText());
+ groupedPresets.Add(group);
+ }
+ else if (item.TryGetProperty("Name", out _))
+ {
+ var preset = JsonSerializer.Deserialize(item.GetRawText());
+ ungroupedPresets.Add(preset);
+ }
+ }
+ return groupedPresets;
+ }
+
+ public async Task> GetUngroupedPresetsAsync()
+ {
+ if (!File.Exists(presetsFilePath))
+ {
+ return new List();
+ }
+
+ var json = await File.ReadAllTextAsync(presetsFilePath);
+ var allPresets = JsonSerializer.Deserialize>(json);
+
+ var ungroupedPresets = new List();
+
+ foreach (var item in allPresets)
+ {
+ if (item.TryGetProperty("Presets", out _))
+ {
+ continue;
+ }
+
+ if (item.TryGetProperty("Name", out _))
+ {
+ var preset = JsonSerializer.Deserialize(item.GetRawText());
+ ungroupedPresets.Add(preset);
+ }
+ }
- return presetGroups ?? new List();
+ return ungroupedPresets;
}
}
diff --git a/presets/example.json b/presets/example.json
index 1f9316d..e31d4d4 100644
--- a/presets/example.json
+++ b/presets/example.json
@@ -46,5 +46,15 @@
"sempUsername": "admin"
}
]
+ },
+ {
+ "Name": "Example 5",
+ "Host": "tcps://broker.domain:55443",
+ "VpnName": "default",
+ "Username": "demo",
+ "Topic": "a/b/c",
+ "QueueName": "myqueue",
+ "SempUrl": "https://broker.domain:1943",
+ "sempUsername": "admin"
}
-]
+]
\ No newline at end of file