Skip to content

Commit

Permalink
Intermediate commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Jul 4, 2024
1 parent a887b05 commit cee1ca5
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 73 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"src/clients/python-client"
],
"dotnet.defaultSolution": "Nexus.sln",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[aspnetcorerazor]": {
"editor.formatOnSave": false
}
}
94 changes: 52 additions & 42 deletions src/Nexus.UI/Components/CatalogAboutView.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
@inject ISnackbar Snackbar

<MudTooltip Text="About">
<MudIconButton
OnClick="OpenCatalogAboutModal"
Icon="@Icons.Material.Outlined.Info" />
<MudIconButton OnClick="OpenCatalogAboutModal" Icon="@Icons.Material.Outlined.Info" />
</MudTooltip>

<UIDialog
@bind-IsVisible="_isCatalogAboutDialogOpen"
MaxWidth="MaxWidth.ExtraSmall">
<UIDialog @bind-IsVisible="_isCatalogAboutDialogOpen" MaxWidth="MaxWidth.ExtraSmall">

<TitleContent>
<MudText Typo="Typo.h6">
Expand All @@ -17,7 +13,7 @@
</TitleContent>

<DialogContent>
@if (_extensionDescription is null)
@if (_extensionDescriptions is null || !_extensionDescriptions.Any())
{
<div class="h-full flex justify-center items-center text-gray-300">
<span class="mr-3 text-4xl mdi mdi-pac-man"></span>
Expand All @@ -26,42 +22,51 @@
}
else
{
<h1 class="uppercase tracking-widest p-1 my-2 border-b border-gray-200 text-cyan-700">data source</h1>
<div class="flex flex-col">
<div class="flex flex-col gap-3">
@foreach(var description in _extensionDescriptions)
{
<h1 class="uppercase tracking-widest p-1 mt-2 border-b border-gray-200 text-cyan-700">@description.Type</h1>

<div class="p-1">
<span>@Catalog.Info.DataSourceType</span>
&nbsp;<span class="text-cyan-700">@@</span>&nbsp;
<span>@_extensionDescription.Version</span>
</div>
<div class="flex flex-col p-1 gap-2">

@if (!string.IsNullOrWhiteSpace(_extensionDescription.Description))
{
<span class="p-1 text-sm">@_extensionDescription.Description</span>
}
<div>@description.Version</div>

@if (!string.IsNullOrWhiteSpace(Catalog.Info.DataSourceInfoUrl))
{
<a class="text-gray-700 text-sm hover:text-orange-500 p-1" href="@Catalog.Info.DataSourceInfoUrl" target="_blank">
<span class="mdi mdi-information-outline text-lg mr-1"></span>
<span>Info Website</span>
</a>
}
@if (!string.IsNullOrWhiteSpace(description.Description))
{
<span class="text-sm">@description.Description</span>
}

@if (!string.IsNullOrWhiteSpace(_extensionDescription.ProjectUrl))
{
<a class="text-cyan-700 text-sm hover:text-orange-500 p-1" href="@_extensionDescription.ProjectUrl" target="_blank">
<span class="mdi mdi-web text-lg mr-1"></span>
<span>Project Website</span>
</a>
}
@* @if (!string.IsNullOrWhiteSpace(description.DataSourceInfoUrl))
{
<a class="text-gray-700 text-sm hover:text-orange-500 p-1" href="@description.DataSourceInfoUrl"
target="_blank">
<span class="mdi mdi-information-outline text-lg mr-1"></span>
<span>Info Website</span>
</a>
} *@

@if (!string.IsNullOrWhiteSpace(_extensionDescription.RepositoryUrl))
{
<a class="text-cyan-700 text-sm hover:text-orange-500 p-1" href="@_extensionDescription.RepositoryUrl" target="_blank">
<span class="mdi mdi-source-branch text-lg mr-1"></span>
<span>Source Repository</span>
</a>
<div class="flex justify-between">

@if (!string.IsNullOrWhiteSpace(description.ProjectUrl))
{
<a class="text-cyan-700 text-sm hover:text-orange-500" href="@description.ProjectUrl"
target="_blank">
<span class="mdi mdi-web text-lg mr-1"></span>
<span>Project Website</span>
</a>
}

@if (!string.IsNullOrWhiteSpace(description.RepositoryUrl))
{
<a class="text-cyan-700 text-sm hover:text-orange-500" href="@description.RepositoryUrl"
target="_blank">
<span class="mdi mdi-source-branch text-lg mr-1"></span>
<span>Source Repository</span>
</a>
}

</div>
</div>
}
</div>
}
Expand All @@ -70,7 +75,6 @@

@code {
private bool _isCatalogAboutDialogOpen;
private ExtensionDescription? _extensionDescription;
private IReadOnlyList<ExtensionDescription>? _extensionDescriptions;

[Parameter]
Expand All @@ -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();
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/Nexus.UI/Core/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 6 additions & 4 deletions src/Nexus.UI/Core/NexusDemoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>)[catalogInfo]);
Expand Down
6 changes: 2 additions & 4 deletions src/Nexus.UI/ViewModels/FakeResourceCatalogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ private static List<ResourceCatalogViewModel> 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<CatalogInfo>)group.ToList());
result.Add(new FakeResourceCatalogViewModel(childInfo, id, client, appState, childCatalogInfosTask));
Expand Down
39 changes: 25 additions & 14 deletions src/Nexus/Extensibility/DataSource/DataSourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,46 @@ public async Task<ResourceCatalog> GetCatalogAsync(

else
{
var type = DataSources
.GetType();

var nexusVersion = typeof(Program).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
.InformationalVersion;

var dataSourceVersion = type.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
.InformationalVersion;
var jsonPipeline = new JsonArray();

foreach (var dataSource in DataSources)
{
var type = dataSource.GetType();

var repositoryUrl = type
.GetCustomAttribute<ExtensionDescriptionAttribute>(inherit: false)!
.RepositoryUrl;
var dataSourceVersion = type.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
.InformationalVersion;

var newResourceProperties = catalogProperties is null
? []
: catalogProperties.ToDictionary(entry => entry.Key, entry => entry.Value);
var repositoryUrl = type
.GetCustomAttribute<ExtensionDescriptionAttribute>(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
Expand Down
4 changes: 1 addition & 3 deletions src/Nexus/Extensions/Sources/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ public Task<ResourceCatalog> 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(
Expand Down
4 changes: 4 additions & 0 deletions src/Nexus/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,10 @@ video {
gap: 1.25rem;
}

.gap-4 {
gap: 1rem;
}

.overflow-auto {
overflow: auto;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestExtensionProject/TestDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Task<CatalogRegistration[]> GetCatalogRegistrationsAsync(string path, Can
throw new NotImplementedException(nameof(EnrichCatalogAsync));
}

public Task<ResourceCatalog> EnrichCatalogAsync(string catalogId, CancellationToken cancellationToken)
public Task<ResourceCatalog> EnrichCatalogAsync(ResourceCatalog catalog, CancellationToken cancellationToken)
{
throw new NotImplementedException(nameof(EnrichCatalogAsync));
}
Expand Down

0 comments on commit cee1ca5

Please sign in to comment.