mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
feat: adds FastEndpoints endpoints, views and resources to the web project
This commit is contained in:
1 parent
733e174cac
commit
d3b1c681dc
341 files changed
+44018
-113
No files matched your search
@@ -0,0 +1,94 @@
|
||||
@*
|
||||
/
|
||||
*@
|
||||
|
||||
@using Lumina.Presentation.Web.Common.DTO.Libraries
|
||||
@using Lumina.Presentation.Web.Common.Services
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
|
||||
@{
|
||||
// generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler
|
||||
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
|
||||
}
|
||||
|
||||
@inject IViewLocalizer _localizer
|
||||
@inject IUrlService _urlService
|
||||
|
||||
<div class="cotton-candy">
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;">
|
||||
<!--container with two rows, one fixed, one filling remaining space-->
|
||||
<div style="min-height: 1rem;"></div><!--the first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position-->
|
||||
<div id="libraries-container" class="cards-container justify-start pl-10 pr-10 w-100 h-100">
|
||||
<p id="no-libraries" class="hidden">@_localizer["NoLibraries"]</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
<script type="text/javascript" data-form="@scriptId" defer>
|
||||
// create cleanup registry for this view
|
||||
const cleanupFunctions = [];
|
||||
let isInitialized = false;
|
||||
|
||||
const librariesContainer = document.getElementById('libraries-container');
|
||||
const noLibrariesMessage = document.getElementById('no-libraries');
|
||||
|
||||
async function InitializeAsync() {
|
||||
if (isInitialized)
|
||||
return;
|
||||
isInitialized = true;
|
||||
// get the media libraries
|
||||
// TODO: add setting check whether the user desires this feature or not
|
||||
const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_ENABLED_LIBRARIES)');
|
||||
if (data && data.length > 0) {
|
||||
noLibrariesMessage.classList.replace('block', 'hidden');
|
||||
librariesContainer.classList.replace('justify-center', 'justify-start');
|
||||
// populate media library items
|
||||
data.forEach((library) => {
|
||||
// book libraries are browsable, so their panel is rendered as a link to their browse page
|
||||
const isBrowsable = library.libraryType === 'Book';
|
||||
const browseUrl = isBrowsable
|
||||
? '@_urlService.GetAbsoluteUrl(WebRoutes.Books.INDEX)' + '?libraryId=' + library.id
|
||||
: null;
|
||||
|
||||
const libraryElement = isBrowsable ? document.createElement('a') : document.createElement('div');
|
||||
libraryElement.className = isBrowsable ? 'media-panel nav-link no-underline' : 'media-panel';
|
||||
if (browseUrl)
|
||||
libraryElement.href = browseUrl;
|
||||
|
||||
// the cover image is optional, so it is only rendered when the library has one
|
||||
const coverImageHtml = library.coverImage
|
||||
? `<img src="${globalConfiguration.serverBasePath}/media/libraries/${library.id}/${library.coverImage.substring(library.coverImage.lastIndexOf('cover.'))}" />`
|
||||
: '';
|
||||
|
||||
libraryElement.innerHTML = `
|
||||
${coverImageHtml}
|
||||
<span class="text-light-two"><strong>${library.title}</strong></span>
|
||||
`;
|
||||
|
||||
librariesContainer.appendChild(libraryElement);
|
||||
});
|
||||
// bind the AJAX navigation behavior to the library links, which were created after the initial navigation binding
|
||||
bindNavigationLinks();
|
||||
} else {
|
||||
noLibrariesMessage.classList.replace('hidden', 'block');
|
||||
librariesContainer.classList.replace('justify-start', 'justify-center');
|
||||
}
|
||||
}
|
||||
|
||||
// add listeners
|
||||
document.addEventListener('DOMContentLoaded', InitializeAsync);
|
||||
|
||||
// register cleanup for these listeners
|
||||
cleanupFunctions.push(() => {
|
||||
document.removeEventListener('DOMContentLoaded', InitializeAsync);
|
||||
});
|
||||
|
||||
// store all cleanups for this view on window object using the scriptId
|
||||
window.viewCleanups = window.viewCleanups || {};
|
||||
window.viewCleanups['@scriptId'] = () => {
|
||||
cleanupFunctions.forEach(cleanup => cleanup());
|
||||
console.log(`Unloaded @scriptId`);
|
||||
};
|
||||
console.log(`Loaded @scriptId`);
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
Reference in new issue
Block a user