mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Implements library management update library
This commit is contained in:
1 parent
d0d53fd471
commit
291d1fa329
68 files changed
+1003
-110
No files matched your search
@@ -14,10 +14,15 @@ namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
||||
public class LibraryModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the library.
|
||||
/// Gets or sets the unique identifier of the media library.
|
||||
/// </summary>
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the user owning the media library.
|
||||
/// </summary>
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the library.
|
||||
/// </summary>
|
||||
@@ -26,7 +31,7 @@ public class LibraryModel
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the library.
|
||||
/// </summary>
|
||||
public LibraryType? LibraryType { get; set; }
|
||||
public string? LibraryType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of directories that contain the library files.
|
||||
|
||||
+3
-4
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -40,7 +39,7 @@ public class DirectoriesController : Controller
|
||||
public async Task<IActionResult> GetDirectories([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<DirectoryModel> response = await _apiHttpClient.GetAsync<DirectoryModel[]>(
|
||||
$"directories/get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
$"directories/get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public class DirectoriesController : Controller
|
||||
public async Task<IActionResult> GetTreeDirectories([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<FileSystemTreeNodeModel> response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>(
|
||||
$"directories/get-tree-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
$"directories/get-tree-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public class DirectoriesController : Controller
|
||||
[HttpGet("get-directory-tree")]
|
||||
public async Task<IActionResult> GetDirectoryTree([FromQuery] string path, [FromQuery] bool includeFiles, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>($"directories/get-directory-tree?path={Uri.EscapeDataString(path)}&includeFiles={includeFiles}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>($"directories/get-directory-tree?path={Uri.EscapeDataString(path)}&includeFiles={includeFiles}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class DrivesController : Controller
|
||||
[HttpGet("get-drives")]
|
||||
public async Task<IActionResult> GetDrives(CancellationToken cancellationToken)
|
||||
{
|
||||
FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>($"drives/get-drives", cancellationToken: cancellationToken);
|
||||
FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>($"drives/get-drives", cancellationToken);
|
||||
return Json(new { success = true, data = new { drives = response } });
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class FileSystemController : Controller
|
||||
[HttpGet("get-type")]
|
||||
public async Task<IActionResult> GetType(CancellationToken cancellationToken)
|
||||
{
|
||||
FileSystemTypeModel response = await _apiHttpClient.GetAsync<FileSystemTypeModel>($"file-system/get-type", cancellationToken: cancellationToken);
|
||||
FileSystemTypeModel response = await _apiHttpClient.GetAsync<FileSystemTypeModel>($"file-system/get-type", cancellationToken);
|
||||
return Json(new { success = true, data = new { platformType = response.PlatformType.ToString() } });
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -40,7 +39,7 @@ public class FilesController : Controller
|
||||
public async Task<IActionResult> GetTreeFiles([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<FileSystemTreeNodeModel> response = await _apiHttpClient.GetAsync<FileSystemTreeNodeModel[]>(
|
||||
$"files/get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
$"files/get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public class FilesController : Controller
|
||||
public async Task<IActionResult> GetFiles([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<FileModel> response = await _apiHttpClient.GetAsync<FileModel[]>(
|
||||
$"files/get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
$"files/get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class PathController : Controller
|
||||
[HttpGet("get-path-root")]
|
||||
public async Task<IActionResult> GetPathRoot([FromQuery] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentModel response = await _apiHttpClient.GetAsync<PathSegmentModel>($"path/get-path-root?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken);
|
||||
PathSegmentModel response = await _apiHttpClient.GetAsync<PathSegmentModel>($"path/get-path-root?path={Uri.EscapeDataString(path)}", cancellationToken);
|
||||
return Json(new { success = true, data = new { root = response } });
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PathController : Controller
|
||||
[HttpGet("get-path-separator")]
|
||||
public async Task<IActionResult> GetPathSeparator(CancellationToken cancellationToken)
|
||||
{
|
||||
PathSeparatorModel response = await _apiHttpClient.GetAsync<PathSeparatorModel>($"path/get-path-separator", cancellationToken: cancellationToken);
|
||||
PathSeparatorModel response = await _apiHttpClient.GetAsync<PathSeparatorModel>($"path/get-path-separator", cancellationToken);
|
||||
return Json(new { success = true, data = new { pathSeparator = response.Separator } });
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PathController : Controller
|
||||
[HttpGet("get-path-parent")]
|
||||
public async Task<IActionResult> GetPathParent([FromQuery] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentModel[] response = await _apiHttpClient.GetAsync<PathSegmentModel[]>($"path/get-path-parent?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken);
|
||||
PathSegmentModel[] response = await _apiHttpClient.GetAsync<PathSegmentModel[]>($"path/get-path-parent?path={Uri.EscapeDataString(path)}", cancellationToken);
|
||||
return Json(new { success = true, data = new { pathSegments = response } });
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PathController : Controller
|
||||
[HttpGet("split")]
|
||||
public async Task<IActionResult> SplitPath([FromQuery] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentModel[] response = await _apiHttpClient.GetAsync<PathSegmentModel[]>($"path/split?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken);
|
||||
PathSegmentModel[] response = await _apiHttpClient.GetAsync<PathSegmentModel[]>($"path/split?path={Uri.EscapeDataString(path)}", cancellationToken);
|
||||
return Json(new { success = true, data = new { pathSegments = response } });
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PathController : Controller
|
||||
[HttpGet("validate")]
|
||||
public async Task<IActionResult> ValidatePath([FromQuery] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
PathValidModel response = await _apiHttpClient.GetAsync<PathValidModel>($"path/validate?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken);
|
||||
PathValidModel response = await _apiHttpClient.GetAsync<PathValidModel>($"path/validate?path={Uri.EscapeDataString(path)}", cancellationToken);
|
||||
return Json(new { success = true, data = new { isValid = response.IsValid } });
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PathController : Controller
|
||||
[HttpGet("check-path-exists")]
|
||||
public async Task<IActionResult> CheckPathExists([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken)
|
||||
{
|
||||
PathExistsModel response = await _apiHttpClient.GetAsync<PathExistsModel>($"path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken);
|
||||
PathExistsModel response = await _apiHttpClient.GetAsync<PathExistsModel>($"path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken);
|
||||
return Json(new { success = true, data = new { exists = response.Exists } });
|
||||
}
|
||||
}
|
||||
+17
-13
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
@@ -30,24 +31,27 @@ public class LibraryManagementController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("item/{id?}")]
|
||||
public IActionResult EditLibrary(Guid? id = null)
|
||||
public async Task<IActionResult> EditLibrary(Guid? id = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
LibraryModel libraryModel = new()
|
||||
{
|
||||
Id = id,
|
||||
LibraryType = LibraryType.Book,
|
||||
ContentLocations = ["a", "b", "c"],
|
||||
Title = ""
|
||||
};
|
||||
LibraryModel libraryModel = new();
|
||||
if (id is not null)
|
||||
libraryModel = await _apiHttpClient.GetAsync<LibraryModel>($"libraries/{id}", cancellationToken);
|
||||
return View("/Views/Library/Management/Item.cshtml", libraryModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new media library, or updates an existing one.
|
||||
/// </summary>
|
||||
/// <param name="data">The model containing the new library data.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[ValidateAntiForgeryToken]
|
||||
[HttpPost("item")]
|
||||
public async Task<IActionResult> SaveLibraryAsync([FromBody] LibraryModel model)
|
||||
public async Task<IActionResult> SaveLibrary([FromBody] LibraryModel data, CancellationToken cancellationToken)
|
||||
{
|
||||
LibraryModel response = model.Id.HasValue
|
||||
? await _apiHttpClient.PutAsync<LibraryModel, LibraryModel>($"libraries/{model.Id}", model)
|
||||
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", model);
|
||||
return Json(new { success = true });
|
||||
// call different API endpoints based on whether this is a new library or an existing one
|
||||
LibraryModel response = data.Id.HasValue
|
||||
? await _apiHttpClient.PutAsync<LibraryModel, LibraryModel>($"libraries/{data.Id}", data, cancellationToken)
|
||||
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", data, cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
@@ -113,15 +114,16 @@ public class AuthController : Controller
|
||||
/// Registers a new account.
|
||||
/// </summary>
|
||||
/// <param name="data">User credentials used for registration.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
[HttpPost("register")]
|
||||
public async Task<IActionResult> Register([FromBody] RegisterRequestModel data)
|
||||
public async Task<IActionResult> Register([FromBody] RegisterRequestModel data, CancellationToken cancellationToken)
|
||||
{
|
||||
// call different endpoints based on the view hidden field - registration for normal users, or initial application admin account setup
|
||||
string endpoint = data.RegistrationType == "Admin" ? "initialization" : "auth/register";
|
||||
// attempt API registration
|
||||
RegisterResponseModel response = await _apiHttpClient.PostAsync<RegisterResponseModel, RegisterRequestModel>(endpoint, data);
|
||||
RegisterResponseModel response = await _apiHttpClient.PostAsync<RegisterResponseModel, RegisterRequestModel>(endpoint, data, cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
@@ -129,15 +131,16 @@ public class AuthController : Controller
|
||||
/// Logs in an account.
|
||||
/// </summary>
|
||||
/// <param name="data">User credentials used for login.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
[HttpPost("login")]
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequestModel data)
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequestModel data, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
// attempt API registration
|
||||
LoginResponseModel response = await _apiHttpClient.PostAsync<LoginResponseModel, LoginRequestModel>("auth/login", data);
|
||||
LoginResponseModel response = await _apiHttpClient.PostAsync<LoginResponseModel, LoginRequestModel>("auth/login", data, cancellationToken);
|
||||
// store the received token in a secure cookie
|
||||
Response.Cookies.Delete("Token");
|
||||
Response.Cookies.Append("Token", _cryptographyService.Encrypt(response.Token!), new CookieOptions
|
||||
@@ -193,12 +196,13 @@ public class AuthController : Controller
|
||||
/// Recovers the password of an account.
|
||||
/// </summary>
|
||||
/// <param name="data">User credentials used for password recovery.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
[HttpPost("recover-password")]
|
||||
public async Task<IActionResult> RecoverPassword([FromBody] RecoverPasswordRequestModel data)
|
||||
public async Task<IActionResult> RecoverPassword([FromBody] RecoverPasswordRequestModel data, CancellationToken cancellationToken)
|
||||
{
|
||||
RecoverPasswordResponseModel response = await _apiHttpClient.PostAsync<RecoverPasswordResponseModel, RecoverPasswordRequestModel>("auth/recover-password", data);
|
||||
RecoverPasswordResponseModel response = await _apiHttpClient.PostAsync<RecoverPasswordResponseModel, RecoverPasswordRequestModel>("auth/recover-password", data, cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
@@ -206,12 +210,13 @@ public class AuthController : Controller
|
||||
/// Changes the password of an account.
|
||||
/// </summary>
|
||||
/// <param name="data">User credentials used for password change.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[ValidateAntiForgeryToken]
|
||||
[HttpPost("change-password")]
|
||||
public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordRequestModel data)
|
||||
public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordRequestModel data, CancellationToken cancellationToken)
|
||||
{
|
||||
data = data with { Username = User?.Identity?.Name }; // assign the currently logged in user as the user for which to change the password
|
||||
ChangePasswordResponseModel response = await _apiHttpClient.PostAsync<ChangePasswordResponseModel, ChangePasswordRequestModel>("auth/change-password", data);
|
||||
ChangePasswordResponseModel response = await _apiHttpClient.PostAsync<ChangePasswordResponseModel, ChangePasswordRequestModel>("auth/change-password", data, cancellationToken);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button id="btn-recover-password" type="button" class="abort-button h-22px w-150px" data-link="@_urlService.GetAbsoluteUrl("RecoverPassword", "Auth")">Recover Password</button>
|
||||
<button id="btn-recover-password" type="button" class="abort-button h-22px w-150px">Recover Password</button>
|
||||
<button id="btn-login" type="submit" class="confirm-button h-22px w-100px">Login</button>
|
||||
</div>
|
||||
<!-- 2FA -->
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<!-- section registration success -->
|
||||
<div class="text-center w-100">
|
||||
<p id="recover-password-success" class="text-light-one w-100 hidden">Password Temporarily Reset</p>
|
||||
<button id="btn-redirect-login" type="submit" class="confirm-button h-22px w-80px hidden" data-link="@_urlService.GetAbsoluteUrl("Login", "Auth")">Login</button>
|
||||
<button id="btn-redirect-login" type="submit" class="confirm-button h-22px w-80px hidden">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
|
||||
@@ -11,15 +11,18 @@
|
||||
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
|
||||
}
|
||||
|
||||
@inject IUrlService _urlService
|
||||
|
||||
@model LibraryModel
|
||||
|
||||
@await Component.InvokeAsync("FileSystemBrowser")
|
||||
|
||||
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-50 mb-10" style="min-width: 320px; margin-top: 1rem;">
|
||||
<div class="shine-effect"></div>
|
||||
<form asp-controller="LibraryManagement" asp-action="EditLibrary" method="post" id="add-media-library-form">
|
||||
<form asp-controller="LibraryManagement" asp-action="EditLibrary" method="post" id="add-media-library-form" class="inline">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" asp-for="Id" value="@id" />
|
||||
<input type="hidden" asp-for="UserId" value="@Model.UserId"/>
|
||||
<div class="form-row">
|
||||
<h1 class="text-light-two w-100 text-center pt-0 pb-0 engraved-title">@(id is not null ? "Edit" : "Add New") Library</h1>
|
||||
</div>
|
||||
@@ -52,9 +55,44 @@
|
||||
<div class="enlightenment-dropdown">
|
||||
<div class="shine-effect" style="top: -4px;"></div>
|
||||
<!-- Dropdown options remain the same -->
|
||||
<div class="enlightenment-option first-option disabled">Book</div>
|
||||
<div class="enlightenment-option first-option disabled">Written Content</div>
|
||||
<div class="enlightenment-option" data-value="Book">Book</div>
|
||||
<!-- ... rest of the options ... -->
|
||||
<div class="enlightenment-option" data-value="EBook">E Book</div>
|
||||
<div class="enlightenment-option" data-value="BookSeries">Book Series</div>
|
||||
<div class="enlightenment-option" data-value="ComicBook">Comic Book</div>
|
||||
<div class="enlightenment-option" data-value="ComicSeries">Comic Series</div>
|
||||
<div class="enlightenment-option" data-value="Magazine">Magazine</div>
|
||||
<div class="enlightenment-option" data-value="Manga">Manga</div>
|
||||
<div class="enlightenment-option" data-value="GraphicNovel">Graphic Novel</div>
|
||||
<div class="enlightenment-option" data-value="AcademicPaper">Academic Paper</div>
|
||||
<div class="enlightenment-option" data-value="SheetMusic">Sheet Music</div>
|
||||
<div class="enlightenment-option" data-value="Screenplay">Screenplay</div>
|
||||
<div class="enlightenment-option disabled">Video Content</div>
|
||||
<div class="enlightenment-option" data-value="TvShow">Tv Show</div>
|
||||
<div class="enlightenment-option" data-value="Movie">Movie</div>
|
||||
<div class="enlightenment-option" data-value="FilmSeries">Film Series</div>
|
||||
<div class="enlightenment-option" data-value="FilmFranchise">Film Franchise</div>
|
||||
<div class="enlightenment-option" data-value="Concert">Concert</div>
|
||||
<div class="enlightenment-option" data-value="Documentary">Documentary</div>
|
||||
<div class="enlightenment-option" data-value="Tutorial">Tutorial</div>
|
||||
<div class="enlightenment-option" data-value="Personal">Personal</div>
|
||||
<div class="enlightenment-option" data-value="Anime">Anime</div>
|
||||
<div class="enlightenment-option" data-value="Youtube">Youtube</div>
|
||||
<div class="enlightenment-option" data-value="Videoclip">Videoclip</div>
|
||||
<div class="enlightenment-option disabled">Audio Content</div>
|
||||
<div class="enlightenment-option" data-value="Music">Music</div>
|
||||
<div class="enlightenment-option" data-value="AudioBook">Audio Book</div>
|
||||
<div class="enlightenment-option" data-value="LivePerformance">Live Performance</div>
|
||||
<div class="enlightenment-option" data-value="Interview">Interview</div>
|
||||
<div class="enlightenment-option" data-value="Cover">Cover</div>
|
||||
<div class="enlightenment-option" data-value="Remix">Remix</div>
|
||||
<div class="enlightenment-option" data-value="Soundeffect">Soundeffect</div>
|
||||
<div class="enlightenment-option" data-value="Podcast">Podcast</div>
|
||||
<div class="enlightenment-option" data-value="RadioShow">Radio Show</div>
|
||||
<div class="enlightenment-option disabled">Visual Content</div>
|
||||
<div class="enlightenment-option" data-value="PhotoAlbum">Photo Album</div>
|
||||
<div class="enlightenment-option disabled">Miscellaneous Content</div>
|
||||
<div class="enlightenment-option last-option" data-value="Other">Other</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,9 +123,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!-- section success -->
|
||||
<div class="text-center w-100">
|
||||
<p id="save-success" class="text-light-one w-100 hidden">Library Saved</p>
|
||||
<button id="btn-back-to-libraries" type="button" class="abort-button h-22px w-150px mx-auto mt-10 hidden">Back To Libraries</button>
|
||||
<button id="btn-add-new-library" type="button" class="confirm-button h-22px w-150px mx-auto mt-10 hidden">Add New Library</button>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
<script type="text/javascript" data-form="@scriptId" defer>
|
||||
const saveSuccess = document.getElementById('save-success');
|
||||
const btnBackToLibraries = document.getElementById('btn-back-to-libraries');
|
||||
const btnAddNewLibrary = document.getElementById('btn-add-new-library');
|
||||
|
||||
document.getElementById('add-media-library-form').addEventListener('keypress', async (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
@@ -105,19 +152,29 @@
|
||||
async function handleAddMediaLibrary(form) {
|
||||
const formData = {
|
||||
Id: form.querySelector('[name="Id"]').value || null,
|
||||
UserId: form.querySelector('[name="UserId"]').value || null,
|
||||
Title: form.querySelector('[name="Title"]').value,
|
||||
LibraryType: form.querySelector('.enlightenment-selected-text').textContent,
|
||||
ContentLocations: Array.from(form.querySelectorAll('.form-table-row span'))
|
||||
.map(span => span.textContent)
|
||||
};
|
||||
const result = await callApiPostAsync('/library/manage/item', formData);
|
||||
if (result) {
|
||||
// Optional: Handle successful response
|
||||
// For example, redirect after success
|
||||
// window.location.href = '/library/manage';
|
||||
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl("SaveLibrary", "LibraryManagement")', formData);
|
||||
if (data) {
|
||||
form.classList.replace('inline', 'hidden');
|
||||
saveSuccess.classList.replace('hidden', 'inline');
|
||||
btnAddNewLibrary.classList.replace('hidden', 'block');
|
||||
btnBackToLibraries.classList.replace('hidden', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
btnBackToLibraries.addEventListener('click', () => {
|
||||
window.location.href = '@_urlService.GetAbsoluteUrl("Index", "LibraryManagement")';
|
||||
});
|
||||
|
||||
btnAddNewLibrary.addEventListener('click', () => {
|
||||
window.location.href = '@_urlService.GetAbsoluteUrl("EditLibrary", "LibraryManagement")';
|
||||
});
|
||||
|
||||
document.getElementById('add-media-directory').addEventListener('click', function () {
|
||||
showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addNewPaths); // TODO: take path and include hidden elements from settings
|
||||
});
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
}
|
||||
@if (User?.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Login", "Auth")"><span>Register</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Login", "Auth")"><span>Change Password</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Login", "Auth")"><span>Profile</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Register", "Auth")" class="nav-link"><span>Register</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("ChangePassword", "Auth")" class="nav-link"><span>Change Password</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Profile", "Auth")" class="nav-link"><span>Profile</span></a></li>
|
||||
}
|
||||
</ul>
|
||||
@if (User?.Identity?.IsAuthenticated == true)
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="library/manage"><span>Manage libraries</span></a></li>
|
||||
<li><a href="library/manage/item"><span>Add media library</span></a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("EditLibrary", "LibraryManagement")" class="nav-link"><span>Add new library</span></a></li>
|
||||
</ul>
|
||||
<div class="mobile-menu-heading">
|
||||
Written Content
|
||||
@@ -93,9 +93,9 @@
|
||||
}
|
||||
@if (User?.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Register", "Auth")">Register</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("ChangePassword", "Auth")">Change Password</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Profile", "Auth")">Profile</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Register", "Auth")" class="nav-link">Register</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("ChangePassword", "Auth")" class="nav-link">Change Password</a></li>
|
||||
<li><a href="@_urlService.GetAbsoluteUrl("Profile", "Auth")" class="nav-link">Profile</a></li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
@@ -113,7 +113,7 @@
|
||||
<label for="library-menu">Library</label>
|
||||
<ul>
|
||||
<li tabindex="0"><a href="library/manage">Manage libraries</a></li>
|
||||
<li tabindex="0"><a href="library/manage/item">Add new library</a></li>
|
||||
<li tabindex="0"><a href="@_urlService.GetAbsoluteUrl("EditLibrary", "LibraryManagement")" class="nav-link">Add new library</a></li>
|
||||
<li class="has-submenu" tabindex="0">
|
||||
<label>Written Content</label>
|
||||
<ul>
|
||||
|
||||
Reference in new issue
Block a user