Skip to content

Commit 3dd559e

Browse files
authored
Merge pull request #401 from serverlessworkflow/fix-dashboard-misc
Misc. dashboard improvements
2 parents bbc82e9 + 9b82f60 commit 3dd559e

File tree

31 files changed

+278
-126
lines changed

31 files changed

+278
-126
lines changed

src/api/Synapse.Api.Http/Synapse.Api.Http.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
</ItemGroup>
4444

4545
<ItemGroup>
46-
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.15.4" />
47-
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.15.4" />
46+
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.15.6" />
47+
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.15.6" />
4848
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.3" />
4949
</ItemGroup>
5050

src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
<ItemGroup>
4646
<PackageReference Include="IdentityModel" Version="7.0.0" />
4747
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
48-
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.15.4" />
49-
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.15.4" />
50-
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.15.4" />
51-
<PackageReference Include="Neuroglia.Mediation" Version="4.15.4" />
52-
<PackageReference Include="Neuroglia.Plugins" Version="4.15.4" />
48+
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.15.6" />
49+
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.15.6" />
50+
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.15.6" />
51+
<PackageReference Include="Neuroglia.Mediation" Version="4.15.6" />
52+
<PackageReference Include="Neuroglia.Plugins" Version="4.15.6" />
5353
<PackageReference Include="ServerlessWorkflow.Sdk.IO" Version="1.0.0-alpha2.15" />
5454
</ItemGroup>
5555

src/core/Synapse.Core/Synapse.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
<ItemGroup>
6565
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
6666
<PackageReference Include="KubernetesClient" Version="14.0.12" />
67-
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented" Version="4.15.4" />
68-
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.15.4" />
67+
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented" Version="4.15.6" />
68+
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.15.6" />
6969
<PackageReference Include="Semver" Version="2.3.0" />
7070
<PackageReference Include="ServerlessWorkflow.Sdk" Version="1.0.0-alpha2.15" />
7171
</ItemGroup>

src/correlator/Synapse.Correlator/Synapse.Correlator.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
<PackageReference Include="Microsoft.Extensions.Configuration.KeyPerFile" Version="8.0.8" />
3636
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
3737
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
38-
<PackageReference Include="Neuroglia.Data.Expressions.JavaScript" Version="4.15.4" />
39-
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.15.4" />
40-
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.15.4" />
41-
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.15.4" />
42-
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.15.4" />
43-
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.15.4" />
38+
<PackageReference Include="Neuroglia.Data.Expressions.JavaScript" Version="4.15.6" />
39+
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.15.6" />
40+
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.15.6" />
41+
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.15.6" />
42+
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.15.6" />
43+
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.15.6" />
4444
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.3" />
4545
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.3" />
4646
</ItemGroup>

src/dashboard/Synapse.Dashboard/Components/DocumentDetails/Store.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ namespace Synapse.Dashboard.Components.DocumentDetailsStateManagement;
1919
/// <summary>
2020
/// Represents the <see cref="ComponentStore{TState}" /> of a <see cref="DocumentDetails"/>
2121
/// </summary>
22+
/// <param name="logger">The service used to perform logging</param>
2223
/// <param name="apiClient">The service used interact with Synapse API</param>
2324
/// <param name="jsRuntime">The service used from JS interop</param>
2425
/// <param name="monacoEditorHelper">The service used ease Monaco Editor interactions</param>
2526
/// <param name="jsonSerializer">The service used to serialize and deserialize JSON</param>
2627
/// <param name="yamlSerializer">The service used to serialize and deserialize YAML</param>
2728
public class DocumentDetailsStore(
29+
ILogger<DocumentDetailsStore> logger,
2830
ISynapseApiClient apiClient,
2931
IJSRuntime jsRuntime,
3032
IMonacoEditorHelper monacoEditorHelper,
@@ -37,10 +39,16 @@ IYamlSerializer yamlSerializer
3739
private TextModel? _textModel = null;
3840
private readonly string _textModelUri = monacoEditorHelper.GetResourceUri();
3941

42+
/// <summary>
43+
/// Gets the service used to perform logging
44+
/// </summary>
45+
protected ILogger<DocumentDetailsStore> Logger { get; } = logger;
46+
4047
/// <summary>
4148
/// Gets the service used to interact with the Synapse API
4249
/// </summary>
4350
protected ISynapseApiClient ApiClient { get; } = apiClient;
51+
4452
/// <summary>
4553
/// Gets the service used for JS interop
4654
/// </summary>
@@ -192,8 +200,7 @@ public void SetDocument(object? document)
192200
}
193201
catch (Exception ex)
194202
{
195-
// todo: handle ex
196-
Console.WriteLine(ex.ToString());
203+
this.Logger.LogError("Unable to set document, exception: {exception}", ex.ToString());
197204
}
198205
}
199206
#endregion
@@ -273,8 +280,7 @@ public async Task LoadReferencedDocumentAsync()
273280
}
274281
catch (Exception ex)
275282
{
276-
Console.WriteLine(ex.ToString());
277-
// todo: handle exception
283+
this.Logger.LogError("Unabled to load referenced document: {exception}", ex.ToString());
278284
}
279285
}
280286

@@ -317,8 +323,7 @@ public async Task SetTextBasedEditorLanguageAsync()
317323
}
318324
catch (Exception ex)
319325
{
320-
Console.WriteLine(ex.ToString());
321-
// todo: handle exception
326+
this.Logger.LogError("Unabled to set text editor language: {exception}", ex.ToString());
322327
}
323328
}
324329

@@ -342,7 +347,7 @@ async Task SetTextEditorValueAsync()
342347
}
343348
catch (Exception ex)
344349
{
345-
Console.WriteLine(ex.ToString());
350+
this.Logger.LogError("Unabled to set text editor value: {exception}", ex.ToString());
346351
await this.MonacoEditorHelper.ChangePreferredLanguageAsync(language == PreferredLanguage.YAML ? PreferredLanguage.JSON : PreferredLanguage.YAML);
347352
}
348353
}

src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,31 @@
1212
// limitations under the License.
1313

1414
using Synapse.Api.Client.Services;
15+
using Synapse.Dashboard.Components.DocumentDetailsStateManagement;
1516

1617
namespace Synapse.Dashboard.Components.MonacoEditorStateManagement;
1718

1819
/// <summary>
1920
/// Represents the <see cref="ComponentStore{TState}" /> of a <see cref="MonacoEditor"/>
2021
/// </summary>
22+
/// <param name="logger">The service used to perform logging</param>
2123
/// <param name="apiClient">The service used interact with Synapse API</param>
2224
/// <param name="jsRuntime">The service used from JS interop</param>
2325
/// <param name="monacoEditorHelper">The service used ease Monaco Editor interactions</param>
2426
/// <param name="jsonSerializer">The service used to serialize and deserialize JSON</param>
2527
/// <param name="yamlSerializer">The service used to serialize and deserialize YAML</param>
26-
public class MonacoEditorStore(ISynapseApiClient apiClient, IJSRuntime jsRuntime, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
28+
public class MonacoEditorStore(ILogger<MonacoEditorStore> logger, ISynapseApiClient apiClient, IJSRuntime jsRuntime, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
2729
: ComponentStore<MonacoEditorState>(new())
2830
{
2931

3032
TextModel? _textModel;
3133
string _textModelUri = monacoEditorHelper.GetResourceUri();
3234

35+
/// <summary>
36+
/// Gets the service used to perform logging
37+
/// </summary>
38+
protected ILogger<MonacoEditorStore> Logger { get; } = logger;
39+
3340
/// <summary>
3441
/// Gets the service used to interact with the Synapse API
3542
/// </summary>
@@ -214,7 +221,7 @@ public async Task ToggleTextBasedEditorLanguageAsync(string _)
214221
}
215222
catch (Exception ex)
216223
{
217-
Console.WriteLine(ex.ToString());
224+
this.Logger.LogError("Unabled to set text editor value: {exception}", ex.ToString());
218225
await this.MonacoEditorHelper.ChangePreferredLanguageAsync(language == PreferredLanguage.YAML ? PreferredLanguage.JSON : PreferredLanguage.YAML);
219226
}
220227
}
@@ -248,8 +255,7 @@ public async Task SetTextBasedEditorLanguageAsync()
248255
}
249256
catch (Exception ex)
250257
{
251-
Console.WriteLine(ex.ToString());
252-
// todo: handle exception
258+
this.Logger.LogError("Unabled to set text editor language: {exception}", ex.ToString());
253259
}
254260
}
255261

src/dashboard/Synapse.Dashboard/Components/ResourceEditor/Store.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Neuroglia.Data;
1616
using Neuroglia.Serialization.Yaml;
1717
using Synapse.Api.Client.Services;
18+
using Synapse.Dashboard.Components.DocumentDetailsStateManagement;
1819

1920
namespace Synapse.Dashboard.Components.ResourceEditorStateManagement;
2021

@@ -24,15 +25,21 @@ namespace Synapse.Dashboard.Components.ResourceEditorStateManagement;
2425
/// <remarks>
2526
/// Initializes a new <see cref="ResourceEditorStore{TResource}"/>
2627
/// </remarks>
28+
/// <param name="logger">The service used to perform logging</param>
2729
/// <param name="apiClient">The service used to interact with a Synapse API</param>
2830
/// <param name="monacoEditorHelper">The service used to facilitate the Monaco editor interactions</param>
2931
/// <param name="jsonSerializer">The The service used to serialize/deserialize objects to/from JSON</param>
3032
/// <param name="yamlSerializer">The service used to serialize/deserialize objects to/from YAML</param>
31-
public class ResourceEditorStore<TResource>(ISynapseApiClient apiClient, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
33+
public class ResourceEditorStore<TResource>(ILogger<ResourceEditorStore<TResource>> logger, ISynapseApiClient apiClient, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
3234
: ComponentStore<ResourceEditorState<TResource>>(new())
3335
where TResource : Resource, new()
3436
{
3537

38+
/// <summary>
39+
/// Gets the service used to perform logging
40+
/// </summary>
41+
protected ILogger<ResourceEditorStore<TResource>> Logger { get; } = logger;
42+
3643
/// <summary>
3744
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="ResourceEditorState{TResource}.Resource"/> changes
3845
/// </summary>
@@ -238,7 +245,7 @@ public async Task ChangeTextEditorLanguageAsync(string language)
238245
}
239246
catch (Exception ex)
240247
{
241-
Console.WriteLine(ex.ToString());
248+
this.Logger.LogError("Unabled to change text editor language: {exception}", ex.ToString());
242249
await monacoEditorHelper.ChangePreferredLanguageAsync(language == PreferredLanguage.YAML ? PreferredLanguage.JSON : PreferredLanguage.YAML);
243250
}
244251
}
@@ -287,7 +294,7 @@ public async Task CreateResourceAsync()
287294
}
288295
catch (Exception ex)
289296
{
290-
Console.WriteLine(ex.ToString()); // todo: improve logging
297+
this.Logger.LogError("Unable to create resource: {exception}", ex.ToString());
291298
}
292299
this.SetSaving(false);
293300
}
@@ -327,7 +334,7 @@ public async Task UpdateResourceAsync()
327334
}
328335
catch (Exception ex)
329336
{
330-
Console.WriteLine(ex.ToString()); // todo: improve logging
337+
this.Logger.LogError("Unable to update resource: {exception}", ex.ToString());
331338
}
332339
}
333340
this.SetSaving(false);

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/ClusterResourceManagementComponentStore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313

1414
using Synapse.Api.Client.Services;
15-
using System.Reactive.Linq;
15+
using Synapse.Dashboard.Components.DocumentDetailsStateManagement;
1616

1717
namespace Synapse.Dashboard.Components.ResourceManagement;
1818

@@ -23,10 +23,11 @@ namespace Synapse.Dashboard.Components.ResourceManagement;
2323
/// <remarks>
2424
/// Initializes a new <see cref="ClusterResourceManagementComponentStore{TResource}"/>
2525
/// </remarks>
26+
/// <param name="logger">The service used to perform logging</param>
2627
/// <param name="apiClient">The service used to interact with the Synapse API</param>
2728
/// <param name="resourceEventHub">The <see cref="IResourceEventWatchHub"/> websocket service client</param>
28-
public class ClusterResourceManagementComponentStore<TResource>(ISynapseApiClient apiClient, ResourceWatchEventHubClient resourceEventHub)
29-
: ResourceManagementComponentStoreBase<TResource>(apiClient, resourceEventHub)
29+
public class ClusterResourceManagementComponentStore<TResource>(ILogger<ClusterResourceManagementComponentStore<TResource>> logger, ISynapseApiClient apiClient, ResourceWatchEventHubClient resourceEventHub)
30+
: ResourceManagementComponentStoreBase<TResource>(logger, apiClient, resourceEventHub)
3031
where TResource : Resource, new()
3132
{
3233

@@ -64,8 +65,7 @@ public override async Task ListResourcesAsync(ResourcesFilter? filter = null)
6465
}
6566
catch (Exception ex)
6667
{
67-
Console.WriteLine(ex.ToString());
68-
// todo: implement proper error handling
68+
this.Logger.LogError("Unable to list resources, {exception}", ex.ToString());
6969
}
7070
}
7171

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/NamespacedResourceManagementComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public abstract class NamespacedResourceManagementComponent<TComponent, TStore,
4545
/// <inheritdoc/>
4646
protected override async Task OnInitializedAsync()
4747
{
48-
await base.OnInitializedAsync();
4948
this.Store.Namespace.Subscribe(value => this.OnStateChanged(_ =>
5049
{
5150
this.@namespace = value;
52-
if (Namespace != value) this.Namespace = value;
51+
//if (Namespace != value) this.Namespace = value;
5352
}), token: this.CancellationTokenSource.Token);
5453
this.Store.Namespaces.Subscribe(value => this.OnStateChanged(_ => Namespaces = value), token: this.CancellationTokenSource.Token);
54+
await base.OnInitializedAsync();
5555
}
5656

5757
/// <inheritdoc/>

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/NamespacedResourceManagementComponentStore.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313

1414
using Synapse.Api.Client.Services;
15-
using System.Reactive.Linq;
1615

1716
namespace Synapse.Dashboard.Components.ResourceManagement;
1817

@@ -21,10 +20,11 @@ namespace Synapse.Dashboard.Components.ResourceManagement;
2120
/// </summary>
2221
/// <typeparam name="TState">The type of the component's state</typeparam>
2322
/// <typeparam name="TResource">The type of <see cref="IResource"/>s to manage</typeparam>
23+
/// <param name="logger">The service used to perform logging</param>
2424
/// <param name="apiClient">The service used to interact with the Synapse API</param>
2525
/// <param name="resourceEventHub">The <see cref="IResourceEventWatchHub"/> websocket service client</param>
26-
public class NamespacedResourceManagementComponentStore<TState, TResource>(ISynapseApiClient apiClient, ResourceWatchEventHubClient resourceEventHub)
27-
: ResourceManagementComponentStoreBase<TState, TResource>(apiClient, resourceEventHub)
26+
public class NamespacedResourceManagementComponentStore<TState, TResource>(ILogger<NamespacedResourceManagementComponentStore<TState, TResource>> logger, ISynapseApiClient apiClient, ResourceWatchEventHubClient resourceEventHub)
27+
: ResourceManagementComponentStoreBase<TState, TResource>(logger, apiClient, resourceEventHub)
2828
where TResource : Resource, new()
2929
where TState : NamespacedResourceManagementComponentState<TResource>, new()
3030
{
@@ -85,8 +85,8 @@ public override async Task DeleteResourceAsync(TResource resource)
8585
/// <inheritdoc/>
8686
public override async Task InitializeAsync()
8787
{
88-
await base.InitializeAsync();
8988
await this.ListNamespaceAsync().ConfigureAwait(false);
89+
await base.InitializeAsync();
9090
}
9191

9292
}

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/ResourceManagementComponent.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public abstract class ResourceManagementComponent<TComponent, TStore, TState, TR
9393
/// </summary>
9494
protected ElementReference? CheckboxAll { get; set; } = null;
9595

96-
string activeResourcesName = null!;
96+
string activeResourceName = null!;
9797
/// <summary>
9898
/// Gets/sets the name of the active resource
9999
/// </summary>
@@ -102,7 +102,6 @@ public abstract class ResourceManagementComponent<TComponent, TStore, TState, TR
102102
/// <inheritdoc/>
103103
protected override async Task OnInitializedAsync()
104104
{
105-
await base.OnInitializedAsync().ConfigureAwait(false);
106105
Observable.CombineLatest(
107106
this.Store.Resources,
108107
this.Store.SelectedResourceNames,
@@ -131,7 +130,7 @@ protected override async Task OnInitializedAsync()
131130
}
132131
}
133132
}, cancellationToken: this.CancellationTokenSource.Token);
134-
this.Store.ActiveResourceName.Subscribe(value => this.OnStateChanged(_ => this.activeResourcesName = value), token: this.CancellationTokenSource.Token);
133+
this.Store.ActiveResourceName.Subscribe(value => this.OnStateChanged(_ => this.activeResourceName = value), token: this.CancellationTokenSource.Token);
135134
this.Store.SearchTerm.Subscribe(value => this.OnStateChanged(_ => this.SearchTerm = value), token: this.CancellationTokenSource.Token);
136135
this.Store.Loading.Subscribe(value => this.OnStateChanged(_ => this.Loading = value), token: this.CancellationTokenSource.Token);
137136
this.Store.Definition.SubscribeAsync(async definition =>
@@ -152,13 +151,14 @@ protected override async Task OnInitializedAsync()
152151
await this.OnShowResourceDetailsAsync(resource);
153152
}
154153
}, cancellationToken: CancellationTokenSource.Token);
154+
await base.OnInitializedAsync().ConfigureAwait(false);
155155
}
156156

157157

158158
/// <inheritdoc/>
159159
protected override async Task OnParametersSetAsync()
160160
{
161-
if (!string.IsNullOrEmpty(Name) && Name != activeResourcesName)
161+
if (!string.IsNullOrEmpty(Name) && Name != activeResourceName)
162162
{
163163
Store.SetActiveResourceName(Name);
164164
}

0 commit comments

Comments
 (0)