fixes the catalog page

main
Paul Schneider 6 months ago
parent d6180aa154
commit 8656bce151
9 changed files with 30 additions and 24 deletions

@ -54,6 +54,7 @@ namespace isnd.Data.Catalog
long commitMax = 0;
foreach (var p in vitems)
{
if (p.LatestCommit==null) continue;
var pkg = p.ToPackage(apiBase);
if (items.Contains(pkg)) continue;
@ -69,8 +70,8 @@ namespace isnd.Data.Catalog
}
items.Add(pkg);
}
Upper = upper.ToFullString();
Lower = lower.ToFullString();
Upper = upper?.ToFullString() ?? lower?.ToFullString();
Lower = lower?.ToFullString() ?? upper?.ToFullString();
}
/// <summary>

@ -10,6 +10,7 @@ using isnd.Entities;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using NuGet.Versioning;
using System;
namespace isnd.Data
{
@ -72,6 +73,6 @@ namespace isnd.Data
return new Catalog.Package(apiBase, this.PackageId , FullString,
new Catalog.PackageDetails(this, apiBase, apiBase + ApiConfig.Registration + "/" + this.PackageId + "/" + FullString + ".json"));
}
public bool IsDeleted => LatestCommit.Action == PackageAction.DeletePackage;
public bool IsDeleted => LatestCommit?.Action == PackageAction.DeletePackage;
}
}

@ -211,9 +211,14 @@ namespace isnd.Services
(string pkgId, string semver = null, string pkgType = null)
{
return (await dbContext.PackageVersions
.Include(v => v.Package).Include(v => v.Package.Owner)
.Include(v => v.Package)
.Include(v => v.Package.LatestCommit)
.Include(v => v.Package.Owner)
.Include(v => v.LatestCommit)
.Where(v => v.PackageId == pkgId
&& v.FullString == semver).SingleOrDefaultAsync()).ToPackage(
&& v.FullString == semver
&& v.LatestCommit !=null
).SingleOrDefaultAsync()).ToPackage(
apiBase);
}
@ -237,6 +242,7 @@ namespace isnd.Services
return dbContext.PackageVersions
.Include(v => v.Package)
.Include(v => v.Package.Owner)
.Include(v => v.Package.LatestCommit)
.Include(v => v.LatestCommit)
.Where(v => v.PackageId == pkgId && semver == v.FullString
&& (pkgType == null || pkgType == v.Type)
@ -264,6 +270,7 @@ namespace isnd.Services
.Include(p => p.Versions)
.Include(p => p.Owner)
.Include(p => p.LatestCommit)
.Include(p => p.Versions[0].LatestCommit)
.SingleOrDefaultAsync(p => p.Id.ToLower() == query.Query);
if (scope==null) return null;
if (scope.Versions.Count==0) return null;
@ -283,8 +290,11 @@ namespace isnd.Services
.Include(p => p.Owner)
.Include(p => p.Versions)
.Include(p => p.LatestCommit)
.Include(p => p.LatestCommit.Versions)
.Where(p => p.Id.StartsWith(query.Query)
&& (query.Prerelease || p.Versions.Any(p => !p.IsPrerelease)))
&& p.LatestCommit != null
&& (query.Prerelease || p.Versions.Any(p => !p.IsPrerelease))
&& p.Versions.Count()>0)
.OrderBy(p => p.CommitNId);
return new PackageSearchResult(await scope.Skip(query.Skip).Take(query.Take)

@ -32,6 +32,5 @@
</dl>
</div>
<div>
@Html.ActionLink("Edit", "Edit", new { pkgid = Model.PackageId, version = Model.FullString }) |
<a asp-action="Index">Back to List</a>
</div>

@ -37,9 +37,8 @@
<button class="far fa-copy" style="float:right" onclick="navigator.clipboard.writeText($('#code').text());this.innerText='copied'" >copy</button>
<pre><code id="code" >&lt;PackageReference Include="@Model.pkgid" Version="@Model.latest.FullString" /&gt;</code></pre>
</div>
<div>
@Html.ActionLink("Edit", "Edit", new { pkgid = Model.pkgid, version = Model.latest.FullString }) |
@Html.ActionLink("Delete", "Delete", new { pkgid = Model.pkgid, version= Model.latest.FullString }) |
<div class="controls">
@Html.ActionLink("Delete", "Delete", new { pkgid = Model.pkgid, version= Model.latest.FullString }) |
<a asp-action="Index">Back to List</a>
</div>
</div>

@ -46,7 +46,7 @@
</div>
<footer class="border-top footer text-muted" style="position:bottom">
isn @SiteHelpers.SemVer &copy; 2021-2022 Paul Schneider - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
isn @SiteHelpers.SemVer &copy; 2021-2024 Paul Schneider - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</footer>
<!-- <script src="/lib/jquery/dist/jquery.slim.min.js" ></script>
<script src="/lib/popper/popper.min.js"></script>

@ -114,7 +114,7 @@ namespace isnd.host.tests
}
public string SPIIndexURI
{
get => server.Addresses.First(a => a.StartsWith("https:")) + "/v3/index.json";
get => server.Addresses.First(a => a.StartsWith("http:")) + "/v3/index.json";
}
[Fact]

@ -5,6 +5,7 @@ using isn;
using isnd.Data;
using isnd.Entities;
using isnd.Interfaces;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
@ -46,32 +47,27 @@ namespace isnd.tests
public void SetupHost()
{
var webhostBuilder = new WebHostBuilder()
.UseKestrel()
.UseIISIntegration()
var builder = WebHost.CreateDefaultBuilder(new string[0]);
// .UseContentRoot("../../../../../src/isnd")
.UseStartup(typeof(Startup))
builder.UseStartup(typeof(Startup))
.ConfigureAppConfiguration((builderContext, config) =>
{
config.AddJsonFile("appsettings.json", false);
config.AddJsonFile("appsettings.json", true);
config.AddJsonFile("appsettings.Development.json", false);
});
Host = webhostBuilder.Build();
Host = builder.Build();
var logFactory = Host.Services.GetRequiredService<ILoggerFactory>();
Logger = logFactory.CreateLogger<WebServerFixture>();
Host.Start(); //Starts listening on the configured addresses.
var server = Host.Services.GetRequiredService<IServer>();
var addressFeature = server.Features.Get<IServerAddressesFeature>();
var addressFeatures = server.Features.Get<IServerAddressesFeature>();
foreach (var address in addressFeature.Addresses)
foreach (var address in addressFeatures.Addresses)
{
Addresses.Add(address);
}

Loading…