WIP reg page
This commit is contained in:
parent
14206ac477
commit
fececb327e
36 changed files with 264 additions and 211 deletions
|
|
@ -27,7 +27,10 @@ namespace isnd
|
|||
// GET: PackageVersion
|
||||
public async Task<IActionResult> Index(PackageVersionIndexViewModel model)
|
||||
{
|
||||
var applicationDbContext = _context.PackageVersions.Include(p => p.Package).Where(
|
||||
var applicationDbContext = _context.PackageVersions.Include(p => p.Package)
|
||||
.Include(p => p.Package.Owner)
|
||||
.Include(p => p.Package.Versions)
|
||||
.Where(
|
||||
p => (model.Prerelease || !p.IsPrerelease)
|
||||
&& ((model.PackageId == null) || p.PackageId.StartsWith(model.PackageId)));
|
||||
model.Versions = await applicationDbContext.ToArrayAsync();
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@ using isnd.ViewModels;
|
|||
using System.Threading.Tasks;
|
||||
using isnd.Interfaces;
|
||||
using isn.Abstract;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController : Controller
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.IndexDotJson)]
|
||||
public IActionResult ApiIndex()
|
||||
{
|
||||
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Catalog)]
|
||||
public IActionResult CatalogIndex()
|
||||
|
|
@ -27,40 +24,46 @@ namespace isnd.Controllers
|
|||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration
|
||||
+ "/{id}/index.json")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id, string lower)
|
||||
{
|
||||
bool askForindex = lower != null && lower.EndsWith(ApiConfig.Base);
|
||||
bool askForindex = lower == null;
|
||||
if (askForindex)
|
||||
{
|
||||
lower = lower.Substring(0, lower.Length - ApiConfig.Base.Length);
|
||||
string sublower = lower.Substring(0, lower.Length - ApiConfig.IndexDotJson.Length);
|
||||
|
||||
var pkgFromname = packageManager.SearchByName(id, 0, 1);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
foreach (var item in pkgFromname.Items)
|
||||
{
|
||||
item.Id = this.Url.Action();
|
||||
}
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!NuGetVersion.TryParse(lower, out NuGetVersion version))
|
||||
return BadRequest(lower);
|
||||
|
||||
var pkgFromname = packageManager.GetVersions(id, version, true);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgFromname = packageManager.SearchByName(id, 0, 1);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{*lower}")]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
|
||||
{
|
||||
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower)
|
||||
.ToArray();
|
||||
|
||||
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower).ToArray();
|
||||
if (pkgvs.Count() == 0) return NotFound();
|
||||
|
||||
List<string> types = pkgvs
|
||||
.Select(
|
||||
List<string> types = pkgvs.Select(
|
||||
v => v.Type ?? "Dependency"
|
||||
)
|
||||
.Distinct().ToList();
|
||||
).Distinct().ToList();
|
||||
if (!types.Contains("PackageDelete"))
|
||||
types.Add("PackageDetails");
|
||||
|
||||
var last = pkgvs.Last();
|
||||
var pub = last.LatestCommit.CommitTimeStamp;
|
||||
|
||||
return Ok(new Data.Packages.Catalog.CatalogLeaf
|
||||
{
|
||||
CommitId = last.CommitId,
|
||||
|
|
@ -68,10 +71,8 @@ namespace isnd.Controllers
|
|||
CommitTimeStamp = pub,
|
||||
Version = last.FullString,
|
||||
Published = pub,
|
||||
RefType = types.ToArray(),
|
||||
|
||||
RefType = types.ToArray()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -4,17 +4,20 @@ using isnd.Helpers;
|
|||
using isnd.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using isnd.Attributes;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpDelete(_pkgRootPrefix + ApiConfig.Delete + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> Delete(
|
||||
[HttpDelete(_pkgRootPrefix + ApiConfig.Delete + "/{id}/{lower?}/{type?}")]
|
||||
public async Task<IActionResult> ApiDelete(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower)
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute] string type)
|
||||
{
|
||||
string pkgtype = ParamHelpers.Optional(ref lower);
|
||||
var report = await packageManager.DeletePackageAsync(id, lower, pkgtype);
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var report = await packageManager.UserAskForPackageDeletionAsync(uid, id, lower, type);
|
||||
return Ok(report);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.Base)]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.IndexDotJson)]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
|
|
|
|||
|
|
@ -15,15 +15,9 @@ namespace isnd.Controllers
|
|||
public partial class PackagesController
|
||||
{
|
||||
// Web search
|
||||
public async Task<IActionResult> Index(PackageRegistrationIndexViewModel model)
|
||||
public async Task<IActionResult> Index(PackageRegistrationIndexQuery model)
|
||||
{
|
||||
var applicationDbContext = dbContext.Packages.Include(p => p.Versions)
|
||||
.Include(p => p.Owner)
|
||||
.Where(
|
||||
p => (model.Prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
||||
&& ((model.Query == null) || p.Id.StartsWith(model.Query)));
|
||||
model.Data = await applicationDbContext.Select(p => p.ToLeave()).ToArrayAsync();
|
||||
return View(model);
|
||||
return View(packageManager.GetCatalogIndex());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(string pkgid)
|
||||
|
|
@ -64,6 +58,7 @@ namespace isnd.Controllers
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
// var report = await packageManager.DeletePackageAsync(id, lower, type);
|
||||
|
||||
var packageVersion = await dbContext.PackageVersions.Include(p => p.Package)
|
||||
.FirstOrDefaultAsync(m => m.PackageId == pkgid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue