-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
843 additions
and
638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Fedora.Abstractions; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Preservation; | ||
|
||
namespace Dashboard.Controllers; | ||
|
||
public class BrowseController : Controller | ||
{ | ||
private readonly ILogger<BrowseController> logger; | ||
private readonly IPreservation preservation; | ||
|
||
public BrowseController( | ||
IPreservation preservation, | ||
ILogger<BrowseController> logger) | ||
{ | ||
this.preservation = preservation; | ||
this.logger = logger; | ||
} | ||
|
||
[Route("browse/{*path}")] | ||
public async Task<IActionResult> IndexAsync(string? path = null) | ||
{ | ||
var resource = await preservation.GetResource(path); | ||
if (resource == null) | ||
{ | ||
return NotFound(); | ||
} | ||
if(resource.PreservationApiPartOf != null) | ||
{ | ||
ViewBag.ArchivalGroupPath = preservation.GetInternalPath(resource.PreservationApiPartOf); | ||
} | ||
switch(resource.Type) | ||
{ | ||
case "Container": | ||
case "RepositoryRoot": | ||
return View("Container", resource as Container); | ||
case "Binary": | ||
return View("Binary", resource as Binary); | ||
case "ArchivalGroup": | ||
return View("ArchivalGroup", resource as ArchivalGroup); | ||
default: | ||
return Problem("Unknown Preservation type"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
using Dashboard.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Preservation.API; | ||
using Preservation; | ||
using System.Diagnostics; | ||
|
||
namespace Dashboard.Controllers | ||
namespace Dashboard.Controllers; | ||
|
||
public class HomeController : Controller | ||
{ | ||
public class HomeController : Controller | ||
private readonly ILogger<HomeController> logger; | ||
private readonly IPreservation preservation; | ||
|
||
public HomeController( | ||
IPreservation preservation, | ||
ILogger<HomeController> logger) | ||
{ | ||
this.preservation = preservation; | ||
this.logger = logger; | ||
} | ||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
|
||
//public async Task<IActionResult> ForecastAsync() | ||
//{ | ||
// var forecasts = await preservation.Test(); | ||
// return View(forecasts[0]); | ||
//} | ||
|
||
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
public IActionResult Error() | ||
{ | ||
private readonly ILogger<HomeController> logger; | ||
private readonly IPreservation preservation; | ||
|
||
public HomeController( | ||
IPreservation preservation, | ||
ILogger<HomeController> logger) | ||
{ | ||
this.preservation = preservation; | ||
this.logger = logger; | ||
} | ||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
|
||
public async Task<IActionResult> ForecastAsync() | ||
{ | ||
var forecasts = await preservation.Test(); | ||
return View(forecasts[0]); | ||
} | ||
|
||
public IActionResult Privacy() | ||
{ | ||
return View(); | ||
} | ||
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
public IActionResult Error() | ||
{ | ||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
} | ||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Fedora.Abstractions; | ||
|
||
namespace Dashboard.Helpers; | ||
|
||
public static class ResourceX | ||
{ | ||
public static string GetDisplayName(this Resource resource) | ||
{ | ||
if(!string.IsNullOrWhiteSpace(resource.Name)) return resource.Name; | ||
|
||
if (resource.Type == "RepositoryRoot") return "(Root of repository)"; | ||
|
||
var slug = resource.GetSlug(); | ||
if(!string.IsNullOrWhiteSpace(slug)) return slug; | ||
|
||
return $"[{resource.GetType().Name}]"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
LeedsExperiment/Dashboard/Views/Browse/ArchivalGroup.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@using Dashboard.Helpers | ||
@model Fedora.Abstractions.ArchivalGroup | ||
|
||
<div> | ||
<div class="alert alert-primary" role="alert"> | ||
<h1 class="display-4">📦 @Model.GetDisplayName()</h1> | ||
</div> | ||
|
||
<partial name="_CommonMetadata" model="Model" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@using Dashboard.Helpers | ||
@model Fedora.Abstractions.Binary | ||
|
||
<div> | ||
@if (ViewBag.ArchivalGroupPath != null) | ||
{ | ||
<div class="alert alert-primary" role="alert"> | ||
Part of an <i>Archival Group</i>: <a href="/browse/@ViewBag.ArchivalGroupPath">@ViewBag.ArchivalGroupPath</a> | ||
</div> | ||
} | ||
|
||
<h1 class="display-4">📄 @Model.GetDisplayName()</h1> | ||
|
||
<partial name="_CommonMetadata" model="Model" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@using Dashboard.Helpers | ||
@model Fedora.Abstractions.Container | ||
|
||
<div> | ||
@if (ViewBag.ArchivalGroupPath != null) | ||
{ | ||
<div class="alert alert-primary" role="alert"> | ||
Part of an <i>Archival Group</i>: <a href="/browse/@ViewBag.ArchivalGroupPath">@ViewBag.ArchivalGroupPath</a> | ||
</div> | ||
} | ||
|
||
<h1 class="display-4">@(Model.Type == "RepositoryRoot") ? "🏠" : "📁") @Model.GetDisplayName()</h1> | ||
|
||
<partial name="_CommonMetadata" model="Model" /> | ||
|
||
@foreach(var container in Model.Containers) | ||
{ | ||
<partial name="_SimpleContainer" model="container" /> | ||
} | ||
|
||
@foreach (var binary in Model.Binaries) | ||
{ | ||
<partial name="_SimpleBinary" model="binary" /> | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@{ | ||
ViewData["Title"] = "Home Page"; | ||
} | ||
|
||
<div class="text-center"> | ||
<h1 class="display-4">@ViewBag.Path</h1> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
LeedsExperiment/Dashboard/Views/Shared/_CommonMetadata.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@model Fedora.Abstractions.Resource | ||
<table class="table"> | ||
<tr> | ||
<th scope="row">Created</th> | ||
<td>@Model.Created</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Created by</th> | ||
<td>@Model.CreatedBy</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Last modified</th> | ||
<td>@Model.LastModified</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Last modified by</th> | ||
<td>@Model.LastModifiedBy</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Fedora.ApiModel; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Fedora.Abstractions; | ||
|
||
public class Binary : Resource | ||
{ | ||
public Binary() { } | ||
|
||
public Binary(FedoraJsonLdResponse jsonLdResponse) : base(jsonLdResponse) | ||
{ | ||
Type = "Binary"; | ||
var binaryresp = jsonLdResponse as BinaryMetadataResponse; | ||
if (binaryresp != null) | ||
{ | ||
FileName = binaryresp.FileName; | ||
ContentType = binaryresp.ContentType; | ||
Size = Convert.ToInt64(binaryresp.Size); | ||
Digest = binaryresp.Digest?.Split(':')[^1]; | ||
} | ||
} | ||
|
||
[JsonPropertyName("filename")] | ||
[JsonPropertyOrder(21)] | ||
public string? FileName { get; set; } | ||
|
||
[JsonPropertyName("contentType")] | ||
[JsonPropertyOrder(22)] | ||
public string? ContentType { get; set; } | ||
|
||
[JsonPropertyName("size")] | ||
[JsonPropertyOrder(23)] | ||
public long Size { get; set; } | ||
|
||
[JsonPropertyName("digest")] | ||
[JsonPropertyOrder(24)] | ||
public string? Digest { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return $"🗎 {Name ?? GetType().Name}"; | ||
} | ||
} |
Oops, something went wrong.