Skip to content

Commit

Permalink
new container and AG creation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcrane committed Jan 26, 2024
1 parent af51502 commit e25fb07
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 2 additions & 0 deletions LeedsExperiment/Dashboard/Controllers/BrowseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public async Task<IActionResult> IndexAsync(
}

Container newContainer = await preservation.CreateContainer(path);
ViewBag.Parent = "/browse/" + parentPath;


ViewBag.Result = $"Container created at path {path}";
return View("Container", newContainer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,23 @@ public async Task<IActionResult> ImportStartAsync(
var existingAg = await preservation.GetArchivalGroup(path, null);
model.ArchivalGroup = existingAg;
}
else
else if(resourceInfo.StatusCode == 404)
{
model.NewName = name;
}
else
{
ViewBag.Problem = "Invalid Status code: " + resourceInfo.StatusCode;
return View("ImportStart", model);
}
if (!string.IsNullOrWhiteSpace(source))
{
// we already know where the update file are
// This is only for synchronising with S3; There'll need to be a different route
// for ad hoc construction of an ImportJob (e.g., it's just one deletion).
var importJob = await preservation.GetUpdateJob(path, source);
model.ImportJob = importJob;
importJob.ArchivalGroupName = name;
return View("ImportJob", model);
}
// else render a view that asks for the S3 source then resubmits
Expand Down
24 changes: 24 additions & 0 deletions LeedsExperiment/Dashboard/Views/Browse/Container.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,28 @@
</form>
}

@if (ViewBag.ArchivalGroupPath == null && Model.Type != "RepositoryRoot")
{
<form id="newAgForm" action="/import/@ViewBag.Path/NEW-AG" method="get">
<div class="mb-3">
<label for="agName" class="form-label">Create an Archival Group:</label>
<input type="text" class="form-control" id="agName" name="name" placeholder="(📦 path-safe name of archival group)">
</div>
<button type="submit" id="btnAgSubmit" class="btn btn-primary">Submit</button>
</form>

<script type="text/javascript">
const prefix = "/import/@(ViewBag.Path)/";
const agForm = document.getElementById("newAgForm");
agForm.addEventListener("submit", function (ev) {
ev.preventDefault();
const name = document.getElementById("agName").value;
agForm.action = prefix + name;
agForm.submit();
});
</script>
}

</div>
8 changes: 8 additions & 0 deletions LeedsExperiment/Dashboard/Views/ImportExport/ImportJob.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
@model Dashboard.Models.ImportModel

<div>

@if (ViewBag.Problem != null)
{
<div class="alert alert-danger" role="alert">
<p>@ViewBag.Problem</p>
</div>
}

<h1 class="display-4">Import 📦 - @Model.DisplayName</h1>
<p>Path: @Model.Path</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Preservation.API.Controllers
{
[Route("api/[controller]")]
[Route("api/repository/{*path}")]
[ApiController]
public class RepositoryController : Controller
{
Expand All @@ -16,8 +16,7 @@ public RepositoryController(IFedora fedora)
this.fedora = fedora;
}

[HttpGet(Name = "Browse")]
[Route("{*path}", Order = 2)]
[HttpGet]
public async Task<ActionResult<Resource?>> Index(
[FromRoute] string? path = null)
{
Expand All @@ -38,8 +37,7 @@ public RepositoryController(IFedora fedora)
return resource;
}

[HttpPut(Name = "CreateContainer")]
[Route("{*path}", Order = 3)]
[HttpPut]
public async Task<ActionResult<Container?>> CreateContainer(
[FromRoute] string path)
{
Expand Down

0 comments on commit e25fb07

Please sign in to comment.