From cee1ca5200f3dfebcf71ddaddec5dd71d4de15a7 Mon Sep 17 00:00:00 2001 From: Apollo3zehn Date: Thu, 4 Jul 2024 10:27:28 +0200 Subject: [PATCH] Intermediate commit --- .vscode/settings.json | 5 +- .../Components/CatalogAboutView.razor | 94 ++++++++++--------- src/Nexus.UI/Core/AppState.cs | 6 +- src/Nexus.UI/Core/NexusDemoClient.cs | 10 +- .../FakeResourceCatalogViewModel.cs | 6 +- .../DataSource/DataSourceController.cs | 39 +++++--- src/Nexus/Extensions/Sources/Sample.cs | 4 +- src/Nexus/wwwroot/css/app.css | 4 + tests/TestExtensionProject/TestDataSource.cs | 2 +- 9 files changed, 97 insertions(+), 73 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index cd510c2a..f4285776 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,8 @@ "src/clients/python-client" ], "dotnet.defaultSolution": "Nexus.sln", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "[aspnetcorerazor]": { + "editor.formatOnSave": false + } } \ No newline at end of file diff --git a/src/Nexus.UI/Components/CatalogAboutView.razor b/src/Nexus.UI/Components/CatalogAboutView.razor index c70fe6bd..32db5055 100644 --- a/src/Nexus.UI/Components/CatalogAboutView.razor +++ b/src/Nexus.UI/Components/CatalogAboutView.razor @@ -1,14 +1,10 @@ @inject ISnackbar Snackbar - + - + @@ -17,7 +13,7 @@ - @if (_extensionDescription is null) + @if (_extensionDescriptions is null || !_extensionDescriptions.Any()) {
@@ -26,42 +22,51 @@ } else { -

data source

-
+
+ @foreach(var description in _extensionDescriptions) + { +

@description.Type

-
- @Catalog.Info.DataSourceType -  @@  - @_extensionDescription.Version -
+
- @if (!string.IsNullOrWhiteSpace(_extensionDescription.Description)) - { - @_extensionDescription.Description - } +
@description.Version
- @if (!string.IsNullOrWhiteSpace(Catalog.Info.DataSourceInfoUrl)) - { - - - Info Website - - } + @if (!string.IsNullOrWhiteSpace(description.Description)) + { + @description.Description + } - @if (!string.IsNullOrWhiteSpace(_extensionDescription.ProjectUrl)) - { - - - Project Website - - } + @* @if (!string.IsNullOrWhiteSpace(description.DataSourceInfoUrl)) + { + + + Info Website + + } *@ - @if (!string.IsNullOrWhiteSpace(_extensionDescription.RepositoryUrl)) - { - - - Source Repository - +
+ + @if (!string.IsNullOrWhiteSpace(description.ProjectUrl)) + { + + + Project Website + + } + + @if (!string.IsNullOrWhiteSpace(description.RepositoryUrl)) + { + + + Source Repository + + } + +
+
}
} @@ -70,7 +75,6 @@ @code { private bool _isCatalogAboutDialogOpen; - private ExtensionDescription? _extensionDescription; private IReadOnlyList? _extensionDescriptions; [Parameter] @@ -90,14 +94,20 @@ { try { - _extensionDescriptions = await Client.Sources.GetDescriptionsAsync(); - _extensionDescription = _extensionDescriptions.FirstOrDefault(current => current.Type == Catalog.Info.DataSourceType); + var dataSourceTypes = Catalog.Info.PipelineInfo.Types; + var extensionDescriptions = await Client.Sources.GetDescriptionsAsync(); + + _extensionDescriptions = extensionDescriptions + .Where(current => dataSourceTypes.Contains(current.Type)) + .ToArray(); + + _extensionDescriptions = [_extensionDescriptions[0], _extensionDescriptions[0]]; } catch (Exception ex) { AppState.AddError(ex, Snackbar); } - + StateHasChanged(); }); } diff --git a/src/Nexus.UI/Core/AppState.cs b/src/Nexus.UI/Core/AppState.cs index 085faa32..7f734ea0 100644 --- a/src/Nexus.UI/Core/AppState.cs +++ b/src/Nexus.UI/Core/AppState.cs @@ -51,10 +51,8 @@ public AppState( IsReleased: true, IsVisible: true, IsOwner: false, - DataSourceInfoUrl: default, - DataSourceType: default!, - DataSourceRegistrationId: default, - PackageReferenceId: default); + PackageReferenceIds: default!, + PipelineInfo: default!); RootCatalog = new FakeResourceCatalogViewModel(rootInfo, "", client, this, childCatalogInfosTask); diff --git a/src/Nexus.UI/Core/NexusDemoClient.cs b/src/Nexus.UI/Core/NexusDemoClient.cs index e8eecd18..74a211ee 100644 --- a/src/Nexus.UI/Core/NexusDemoClient.cs +++ b/src/Nexus.UI/Core/NexusDemoClient.cs @@ -185,10 +185,12 @@ We hope you enjoy it! IsReleased: true, IsVisible: true, IsOwner: false, - DataSourceInfoUrl: default, - DataSourceType: "Nexus.FakeSource", - DataSourceRegistrationId: Guid.NewGuid(), - PackageReferenceId: Guid.NewGuid() + PackageReferenceIds: [Guid.NewGuid()], + PipelineInfo: new PipelineInfo( + Id: Guid.NewGuid(), + Types: ["Nexus.FakeSource"], + InfoUrls: [default] + ) ); return Task.FromResult((IReadOnlyList)[catalogInfo]); diff --git a/src/Nexus.UI/ViewModels/FakeResourceCatalogViewModel.cs b/src/Nexus.UI/ViewModels/FakeResourceCatalogViewModel.cs index 4fb3ffef..761de583 100644 --- a/src/Nexus.UI/ViewModels/FakeResourceCatalogViewModel.cs +++ b/src/Nexus.UI/ViewModels/FakeResourceCatalogViewModel.cs @@ -76,10 +76,8 @@ private static List PrepareChildCatalogs( IsReleased: true, IsVisible: true, IsOwner: false, - DataSourceInfoUrl: default, - DataSourceType: "Nexus.FakeSource", - DataSourceRegistrationId: default, - PackageReferenceId: default); + PackageReferenceIds: default!, + PipelineInfo: default!); var childCatalogInfosTask = Task.FromResult((IReadOnlyList)group.ToList()); result.Add(new FakeResourceCatalogViewModel(childInfo, id, client, appState, childCatalogInfosTask)); diff --git a/src/Nexus/Extensibility/DataSource/DataSourceController.cs b/src/Nexus/Extensibility/DataSource/DataSourceController.cs index fc09f89d..684ff69a 100644 --- a/src/Nexus/Extensibility/DataSource/DataSourceController.cs +++ b/src/Nexus/Extensibility/DataSource/DataSourceController.cs @@ -232,35 +232,46 @@ public async Task GetCatalogAsync( else { - var type = DataSources - .GetType(); - var nexusVersion = typeof(Program).Assembly .GetCustomAttribute()! .InformationalVersion; - var dataSourceVersion = type.Assembly - .GetCustomAttribute()! - .InformationalVersion; + var jsonPipeline = new JsonArray(); + + foreach (var dataSource in DataSources) + { + var type = dataSource.GetType(); - var repositoryUrl = type - .GetCustomAttribute(inherit: false)! - .RepositoryUrl; + var dataSourceVersion = type.Assembly + .GetCustomAttribute()! + .InformationalVersion; - var newResourceProperties = catalogProperties is null - ? [] - : catalogProperties.ToDictionary(entry => entry.Key, entry => entry.Value); + var repositoryUrl = type + .GetCustomAttribute(inherit: false)! + .RepositoryUrl; + + var jsonPipelineElement = new JsonObject() + { + ["data-source-repository-url"] = repositoryUrl, + ["data-source-version"] = dataSourceVersion + }; + + jsonPipeline.Add(jsonPipelineElement); + } var originJsonObject = new JsonObject() { ["origin"] = new JsonObject() { ["nexus-version"] = nexusVersion, - ["data-source-repository-url"] = repositoryUrl, - ["data-source-version"] = dataSourceVersion, + ["pipeline"] = jsonPipeline } }; + var newResourceProperties = catalogProperties is null + ? [] + : catalogProperties.ToDictionary(entry => entry.Key, entry => entry.Value); + newResourceProperties[DATA_SOURCE_KEY] = JsonSerializer.SerializeToElement(originJsonObject); catalog = catalog with diff --git a/src/Nexus/Extensions/Sources/Sample.cs b/src/Nexus/Extensions/Sources/Sample.cs index fe0fa9ff..ac47a32c 100644 --- a/src/Nexus/Extensions/Sources/Sample.cs +++ b/src/Nexus/Extensions/Sources/Sample.cs @@ -117,9 +117,7 @@ public Task EnrichCatalogAsync( ResourceCatalog catalog, CancellationToken cancellationToken) { - throw new Exception(); - - // return Task.FromResult(LoadCatalog(catalogId)); + return Task.FromResult(LoadCatalog(catalog.Id)); } public Task<(DateTime Begin, DateTime End)> GetTimeRangeAsync( diff --git a/src/Nexus/wwwroot/css/app.css b/src/Nexus/wwwroot/css/app.css index bedf785f..69ea3cf3 100644 --- a/src/Nexus/wwwroot/css/app.css +++ b/src/Nexus/wwwroot/css/app.css @@ -941,6 +941,10 @@ video { gap: 1.25rem; } +.gap-4 { + gap: 1rem; +} + .overflow-auto { overflow: auto; } diff --git a/tests/TestExtensionProject/TestDataSource.cs b/tests/TestExtensionProject/TestDataSource.cs index e9e71b9b..14e210b2 100644 --- a/tests/TestExtensionProject/TestDataSource.cs +++ b/tests/TestExtensionProject/TestDataSource.cs @@ -20,7 +20,7 @@ public Task GetCatalogRegistrationsAsync(string path, Can throw new NotImplementedException(nameof(EnrichCatalogAsync)); } - public Task EnrichCatalogAsync(string catalogId, CancellationToken cancellationToken) + public Task EnrichCatalogAsync(ResourceCatalog catalog, CancellationToken cancellationToken) { throw new NotImplementedException(nameof(EnrichCatalogAsync)); }