WIP reg page

This commit is contained in:
2022-09-23 20:34:51 +01:00
parent 14206ac477
commit fececb327e
36 changed files with 264 additions and 211 deletions

View File

@ -1,15 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using isn.abst;
using isnd.Data;
using isnd.Data.Catalog;
using isnd.Entities;
namespace isnd.Helpers
{
public static class PackageVersionHelpers
{
public static bool IsOwner(this ClaimsPrincipal user, PackageVersion v)
{
var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
return v.Package.OwnerId == userId;
}
public static RegistrationPage[] CreateRegistrationPages(this IEnumerable<RegistrationLeaf> leaves,
string bid)
{
List<RegistrationPage> pages = new List<RegistrationPage>();
var ids = leaves.Select(l => l.Entry.Id).Distinct().ToArray();
foreach (var id in ids)
{
var lbi = leaves.Where(l=>l.Entry.Id == id).OrderBy(l=>
new Version(l.Entry.version));
var latest = new Version(lbi.Last().Entry.version);
pages.Add(new RegistrationPage
{
Id = bid + id + "/" + latest.Major + "."
+ latest.Minor + "."
+ latest.Build,
Count = lbi.Count(),
Lower = new Version(lbi.First().Entry.version),
Upper = latest,
Items = lbi.ToArray(),
Parent = bid + id + "/" + ApiConfig.IndexDotJson,
});
}
return pages.ToArray();
}
}
}

View File

@ -10,7 +10,7 @@ namespace isnd.Helpers
{
public static class UnleashHelpers
{
public static IUnleash CreateUnleahClient(this IHostingEnvironment env,
UnleashClientSettings unleashClientSettings)
{