summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pages/Component/AboutDialog.razor26
-rw-r--r--Pages/Component/MediaTagTable.razor39
-rw-r--r--Pages/Component/NsfwSwitch.razor8
-rw-r--r--Pages/Component/Switch.razor4
-rw-r--r--Pages/Component/TagEditDialog.razor10
-rw-r--r--Pages/Component/TagSelectDialog.razor103
-rw-r--r--Pages/Component/Titlebar.razor93
-rw-r--r--Pages/Gallery.razor95
-rw-r--r--Pages/Login.razor12
-rw-r--r--Pages/TagDefinitions.razor128
-rw-r--r--Pages/Upload.razor1
-rw-r--r--Pages/ViewMedia.razor143
12 files changed, 354 insertions, 308 deletions
diff --git a/Pages/Component/AboutDialog.razor b/Pages/Component/AboutDialog.razor
index 1229dc7..fa7b1ca 100644
--- a/Pages/Component/AboutDialog.razor
+++ b/Pages/Component/AboutDialog.razor
@@ -1,7 +1,9 @@
@using System.Reflection
-@using Microsoft.AspNetCore.Hosting
-@inject IDbContextFactory<HBContext> dbFactory
-@inject IHostingEnvironment hostingEnvironment
+@*
+ * @using Microsoft.AspNetCore.Hosting
+ * @inject IDbContextFactory<HBContext> dbFactory
+ * @inject IHostingEnvironment hostingEnvironment
+ *@
@implements IDialog
<Dialog @ref=dialog>
@@ -699,15 +701,15 @@
set {
dialog.Visible = value;
if(value) {
- using var db = dbFactory.CreateDbContext();
- progress = (
- Untagged: db.Media
- .Where(m => m.Tags.Any(t => t.TagDefinition.ObjectId == (int) HBObjectId.IngestTag))
- .Count(),
- Total: db.Media.Count()
- );
- progressBar.Progress = (float) progress.Value!.Untagged / (float) progress.Value!.Total;
- InvokeAsync(() => StateHasChanged());
+ // using var db = dbFactory.CreateDbContext();
+ // progress = (
+ // Untagged: db.Media
+ // .Where(m => m.Tags.Any(t => t.TagDefinition.ObjectId == (int) HBObjectId.IngestTag))
+ // .Count(),
+ // Total: db.Media.Count()
+ // );
+ // progressBar.Progress = (float) progress.Value!.Untagged / (float) progress.Value!.Total;
+ // InvokeAsync(() => StateHasChanged());
}
}
}
diff --git a/Pages/Component/MediaTagTable.razor b/Pages/Component/MediaTagTable.razor
index 1b62832..0524739 100644
--- a/Pages/Component/MediaTagTable.razor
+++ b/Pages/Component/MediaTagTable.razor
@@ -1,7 +1,4 @@
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
+@inject HBSession hb
<table class="data-table">
<tr>
@@ -19,7 +16,7 @@
}
</td>
<td>
- <a href="/Gallery?t=@(e.tagDef.Guid)" class="nondecorated">
+ <a href="/Gallery?t=@(e.tagDef.TagDefinitionId)" class="nondecorated">
@if(e.isImplicit) {
<i>@e.tagDef.Name</i>
} else {
@@ -40,33 +37,39 @@
@code {
[Parameter]
- public Media Media { get; set; }
+ public Guid MediaId { get; set; }
- private (TagDefinition tagDef, bool isImplicit)[] tagDefs;
+ private (TagDefinition tagDef, bool isImplicit)[] tagDefs = [];
protected override void OnInitialized() => LoadTagDefs();
public void Refresh() {
LoadTagDefs();
- StateHasChanged();
+ // StateHasChanged();
}
private void Delete(TagDefinition tagDef) {
- tagService.RemoveTag(Media.Guid, tagDef.Guid);
- Refresh();
+ // tagService.RemoveTag(Media.Guid, tagDef.Guid);
+ // Refresh();
}
- private void LoadTagDefs() {
- using var db = dbFactory.CreateDbContext();
- var media = db.Media.First(m => m.ObjectId == Media.ObjectId);
+ private async void LoadTagDefs() {
+ var tags = await hb.Media.GetTagsAsync(MediaId);
+
+ tagDefs = tags.Select(td => (tagDef: td, isImplicit: false)).ToArray();
+
+ await InvokeAsync(() => StateHasChanged());
+
+ // using var db = dbFactory.CreateDbContext();
+ // var media = db.Media.First(m => m.ObjectId == Media.ObjectId);
- tagDefs = tagService.GetAllTags(Media)
- .Where(e => e.tagDefinition.Source == ApiModels.TagSource.UserTag)
- .ToArray();
+ // tagDefs = tagService.GetAllTags(Media)
+ // .Where(e => e.tagDefinition.Source == TagSource.UserTag)
+ // .ToArray();
}
private void MakeExplicit(TagDefinition tagDef) {
- tagService.AddTag(Media, tagDef);
- Refresh();
+ // tagService.AddTag(Media, tagDef);
+ // Refresh();
}
}
diff --git a/Pages/Component/NsfwSwitch.razor b/Pages/Component/NsfwSwitch.razor
index b96606d..f4f9c1f 100644
--- a/Pages/Component/NsfwSwitch.razor
+++ b/Pages/Component/NsfwSwitch.razor
@@ -1,8 +1,6 @@
-@inject IUserService userService
-
-<Switch InitialValue=userService.UserSessionState.ShowNsfw OnToggle=ToggleNsfw/>
+<Switch InitialValue=false OnToggle=ToggleNsfw/>
@code {
- private void ToggleNsfw(bool showNsfw) =>
- userService.UserSessionState.ShowNsfw = showNsfw;
+ private void ToggleNsfw(bool showNsfw) => _ = 0;
+ // userService.UserSessionState.ShowNsfw = showNsfw;
} \ No newline at end of file
diff --git a/Pages/Component/Switch.razor b/Pages/Component/Switch.razor
index d11ac81..5264094 100644
--- a/Pages/Component/Switch.razor
+++ b/Pages/Component/Switch.razor
@@ -1,6 +1,4 @@
-<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
-
-<label>
+<label>
<input
type="checkbox"
checked=@InitialValue
diff --git a/Pages/Component/TagEditDialog.razor b/Pages/Component/TagEditDialog.razor
index afa312e..14d8c27 100644
--- a/Pages/Component/TagEditDialog.razor
+++ b/Pages/Component/TagEditDialog.razor
@@ -1,5 +1,7 @@
-@inject IDbContextFactory<HBContext> dbFactory;
-@inject ITagService tagService
+@*
+ * @inject IDbContextFactory<HBContext> dbFactory;
+ * @inject ITagService tagService
+ *@
@implements IDialog
<Dialog Title=@Title @ref=dialog>
@@ -80,9 +82,9 @@
private void Submit() {
try {
if(TagDefinition is null) {
- tagService.CreateTagDefinition(tagName, tagNamespace, tagAlias);
+ // tagService.CreateTagDefinition(tagName, tagNamespace, tagAlias);
} else {
- tagService.UpdateTagDefinition(TagDefinition, tagName, tagNamespace, tagAlias);
+ // tagService.UpdateTagDefinition(TagDefinition, tagName, tagNamespace, tagAlias);
}
} catch(ApiModels.TagDuplicateException e) {
nameExists = e.NameExists;
diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor
index d33b178..99321fe 100644
--- a/Pages/Component/TagSelectDialog.razor
+++ b/Pages/Component/TagSelectDialog.razor
@@ -1,6 +1,8 @@
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IUserService userService
+@*
+ * @inject IDbContextFactory<HBContext> dbFactory
+ * @inject ITagService tagService
+ * @inject IUserService userService
+ *@
@implements IDisposable
@implements IDialog
@@ -28,6 +30,7 @@
ns,
alias is not null ? $"({alias})" : null
});
+@*
<input
type="checkbox"
id="tagDef-@tagDefinitions[i].tagDefinition.Guid"
@@ -37,6 +40,7 @@
title=@title>
@tagDefinitions[i].tagDefinition.Name
</label>
+*@
}
</div>
<ButtonContainer>
@@ -67,7 +71,7 @@
private (TagDefinition tagDefinition, bool selected)[] tagDefinitions;
- private HBContext db;
+ // private HBContext db;
private Dialog dialog;
@@ -80,33 +84,33 @@
public void Hide() => Visible = false;
protected override void OnInitialized() {
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
+ // userService.UserSessionState.OnStateChange += ShowNsfwChanged;
LoadTags();
}
private void LoadTags() {
- db = dbFactory.CreateDbContext();
+ // db = dbFactory.CreateDbContext();
- var selected = SelectedTags.Select(td => td.Guid);
+ // var selected = SelectedTags.Select(td => td.Guid);
- int[] nsfwTags = Array.Empty<int>();
- if(!userService.UserSessionState.ShowNsfw)
- nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
- .Select(td => td.ObjectId)
- .ToArray();
+ // int[] nsfwTags = Array.Empty<int>();
+ // if(!userService.UserSessionState.ShowNsfw)
+ // nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
+ // .Select(td => td.ObjectId)
+ // .ToArray();
- tagDefinitions = db.TagDefinitions
- .Include(td => td.ImplicitTags)
- .Where(td => td.Source == ApiModels.TagSource.UserTag)
- .OrderBy(td => td.Name)
- .AsEnumerable()
- .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
- .IntersectBy(nsfwTags, td => td.ObjectId)
- .Any())
- .Select(td => new Tuple<TagDefinition, bool>(
- td,
- selected.Contains(td.Guid)).ToValueTuple())
- .ToArray();
+ // tagDefinitions = db.TagDefinitions
+ // .Include(td => td.ImplicitTags)
+ // .Where(td => td.Source == TagSource.UserTag)
+ // .OrderBy(td => td.Name)
+ // .AsEnumerable()
+ // .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
+ // .IntersectBy(nsfwTags, td => td.ObjectId)
+ // .Any())
+ // .Select(td => new Tuple<TagDefinition, bool>(
+ // td,
+ // selected.Contains(td.Guid)).ToValueTuple())
+ // .ToArray();
}
private void QueryInput(ChangeEventArgs e) {
@@ -141,30 +145,31 @@
}
private bool MatchesQuery(TagDefinition tagDef) {
- TagDefinition? singleTag = null;
+ // TagDefinition? singleTag = null;
- if(string.IsNullOrEmpty(query))
- return true;
+ // if(string.IsNullOrEmpty(query))
+ // return true;
- singleTag = tagDefinitions.FirstOrDefault(
- e => string.Equals(
- e.tagDefinition.Alias,
- query,
- StringComparison.OrdinalIgnoreCase)).tagDefinition;
+ // singleTag = tagDefinitions.FirstOrDefault(
+ // e => string.Equals(
+ // e.tagDefinition.Alias,
+ // query,
+ // StringComparison.OrdinalIgnoreCase)).tagDefinition;
- if(singleTag is not null)
- return tagDef.Guid == singleTag.Guid;
+ // if(singleTag is not null)
+ // return tagDef.Guid == singleTag.Guid;
- singleTag = tagDefinitions.FirstOrDefault(
- e => string.Equals(
- e.tagDefinition.Name,
- query,
- StringComparison.OrdinalIgnoreCase)).tagDefinition;
+ // singleTag = tagDefinitions.FirstOrDefault(
+ // e => string.Equals(
+ // e.tagDefinition.Name,
+ // query,
+ // StringComparison.OrdinalIgnoreCase)).tagDefinition;
- if(singleTag is not null)
- return tagDef.Guid == singleTag.Guid;
+ // if(singleTag is not null)
+ // return tagDef.Guid == singleTag.Guid;
- return tagDef.Name.ToLower().Contains(query.ToLower());
+ // return tagDef.Name.ToLower().Contains(query.ToLower());
+ return false;
}
private async void Submit() {
@@ -179,14 +184,14 @@
StateHasChanged();
}
- public async void ShowNsfwChanged(UserSessionState userSessionState) =>
- await InvokeAsync(() => {
- LoadTags();
- StateHasChanged();
- });
+ // public async void ShowNsfwChanged(UserSessionState userSessionState) =>
+ // await InvokeAsync(() => {
+ // LoadTags();
+ // StateHasChanged();
+ // });
public void Dispose() {
- db.Dispose();
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
+ // db.Dispose();
+ // userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
}
}
diff --git a/Pages/Component/Titlebar.razor b/Pages/Component/Titlebar.razor
index 48257b2..521fb46 100644
--- a/Pages/Component/Titlebar.razor
+++ b/Pages/Component/Titlebar.razor
@@ -1,5 +1,7 @@
@inject IJSRuntime jsRuntime
-@inject IUserService userService
+@inject NavigationManager nav
+@inject HBSession session;
+@* @inject IUserService userService *@
<script suppress-error="BL9992">
async function login() {
@@ -40,48 +42,57 @@
}
</script>
-<AuthorizeView>
- <Authorized>
- <div id="navbar">
- <p class="mobile">HyperBooru</p>
- <a class="mobile menu-button" href="javascript:toggleMobileMenu();">&#x2630</a>
+@if(!IsLoginPage) {
+ <div id="navbar">
+ <p class="mobile">HyperBooru</p>
+ <a class="mobile menu-button" href="javascript:toggleMobileMenu();">&#x2630</a>
- <a class="desktop" href="/">Home</a>
- <a class="desktop" href="/TagDefinitions">Tags</a>
- <a class="desktop" href="/Gallery?ingest=true">Ingest</a>
- <a class="desktop" href="/Upload">Upload</a>
- <a class="desktop" href="javascript:;" @onclick=@(() => aboutDialog.Show())>About</a>
+ <a class="desktop" href="/">Home</a>
+ <a class="desktop" href="/TagDefinitions">Tags</a>
+ <a class="desktop" href="/Gallery?ingest=true">Ingest</a>
+ <a class="desktop" href="/Upload">Upload</a>
+ @* <a class="desktop" href="javascript:;" @onclick=@(() => aboutDialog.Show())>About</a> *@
+ <a class="desktop" href="javascript:;">About</a>
- <p class="desktop" id="nsfw-label">NSFW</p>
- <div id="nsfw-switch" class="desktop">
- <NsfwSwitch/>
- </div>
- <form action="/Gallery" method="get" class="desktop">
- <input type="text" name="q" placeholder="Search"/>
- </form>
- <a class="desktop" href="javascript:logout();">Logout</a>
- </div>
- <AboutDialog @ref=aboutDialog/>
- </Authorized>
- <NotAuthorized>
- <div id="navbar">
- <h2>Login</h2>
- <form class="login" action="javascript:login();">
- <input
- id="username"
- placeholder="Username"
- type="text"
- autocorrect="off"
- autocapitalize="off"
- autocomplete="off"
- autofocus/>
- <input id="password" placeholder="Password" type="password"/>
- </form>
- <a href="javascript:login();">Login</a>
- </div>
- </NotAuthorized>
-</AuthorizeView>
+ <p class="desktop" id="nsfw-label">NSFW</p>
+ <div id="nsfw-switch" class="desktop">
+ <NsfwSwitch/>
+ </div>
+ <form action="/Gallery" method="get" class="desktop">
+ <input type="text" name="q" placeholder="Search"/>
+ </form>
+ <a class="desktop" href="javascript:logout();">Logout</a>
+ </div>
+ @* <AboutDialog @ref=aboutDialog/> *@
+} else {
+ <div id="navbar">
+ <h2>Login</h2>
+ <form class="login" action="javascript:login();">
+ <input
+ id="username"
+ placeholder="Username"
+ type="text"
+ autocorrect="off"
+ autocapitalize="off"
+ autocomplete="off"
+ autofocus
+ @bind=Username/>
+ <input id="password" placeholder="Password" type="password" @bind=Password/>
+ </form>
+ <a @onclick=Login>Login</a>
+ </div>
+}
@code {
- private AboutDialog aboutDialog;
+ // private AboutDialog aboutDialog;
+
+ public string Username { get; set; } = "";
+ public string Password { get; set; } = "";
+
+ private bool IsLoginPage =>
+ new Uri(nav.Uri).AbsolutePath.Equals("/Login", StringComparison.OrdinalIgnoreCase);
+
+ private async void Login() {
+ await session.LoginAsync(Username, Password);
+ }
}
diff --git a/Pages/Gallery.razor b/Pages/Gallery.razor
index 743485e..2ff5486 100644
--- a/Pages/Gallery.razor
+++ b/Pages/Gallery.razor
@@ -1,15 +1,15 @@
@page "/"
@page "/Gallery"
-@inject ITagService tagService
-@inject IFeedService feedService
-@inject IUserService userService
@inject IJSRuntime jsRuntime
-@implements IDisposable
-@attribute [Authorize]
+@inject HBSession hb
+@*
+ * @implements IDisposable
+ * @attribute [Authorize]
+ *@
<PageTitle>@Title</PageTitle>
-@if(Ingest && !userService.UserSessionState.ShowNsfw) {
+@if(Ingest && !hb.HasNsfwClaim) {
<div id="feed-error">
<p><center>Ingest feed is not available unless NSFW mode is enabled!</center></p>
<p><center><i>You must enable NSFW mode to continue...</i></center></p>
@@ -21,12 +21,12 @@
</div>
} else {
<div style="padding:var(--size-default-gap);">
- @foreach(var media in displayMedia) {
+ @foreach(var mediaId in displayMedia) {
// Precalculate thumbnail size to help the browser
// lay out the images during initial page load
- int width = (int) media.CurrentUploadedFile!.Width! * 200 / (int) media.CurrentUploadedFile.Height!;
- <a href="/ViewMedia?m=@(media.Guid)">
- <img src="/media/thumb/@(media.Guid)?h=200" width=@width height="200"/>
+ @* int width = (int) media.CurrentUploadedFile!.Width! * 200 / (int) media.CurrentUploadedFile.Height!; *@
+ <a href="/ViewMedia?m=@mediaId">
+ <img src="/media/thumb/@mediaId?h=200" height="200"/>
</a>
}
<div id="canary" style="height:1px;"></div>
@@ -77,10 +77,10 @@
}
}
- private List<Media> displayMedia;
+ private List<Guid> displayMedia = new();
- protected override void OnInitialized() =>
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
+ // protected override void OnInitialized() =>
+ // userService.UserSessionState.OnStateChange += ShowNsfwChanged;
protected override void OnParametersSet() => LoadMedia(true);
@@ -93,7 +93,8 @@
[JSInvokable("LoadMedia")]
public void LoadMedia(bool initial = false) {
- Media? key = displayMedia?.Any() ?? false && !initial ? displayMedia.Last() : null;
+ Guid? key =
+ displayMedia?.Any() ?? false && !initial ? displayMedia.Last() : null;
if(initial)
displayMedia = new();
@@ -102,40 +103,48 @@
if(Enum.TryParse<ApiModels.SortOrder>(SortOrder, true, out var so))
sortOrder = so;
+ FeedRequest feedRequest = new FeedRequest() {
+ SelectIngest = Ingest,
+ IncludeNsfw = hb.HasNsfwClaim,
+ ContinuationToken = key,
+ Count = PageSize,
+ SortOrder = sortOrder ?? default
+ };
+
if(TagId is not null && Query is null) {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- tagId: (Guid) TagId!,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
+ feedRequest = new FeedTagRequest() {
+ SelectIngest = Ingest,
+ IncludeNsfw = hb.HasNsfwClaim,
+ TagId = (Guid) TagId!,
+ ContinuationToken = key,
+ Count = PageSize,
+ SortOrder = sortOrder ?? default
+ };
} else if(Query is not null && TagId is null) {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- query: string.IsNullOrWhiteSpace(Query) ? null : Query,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
- } else {
- displayMedia!.AddRange(feedService.LoadChunk(
- selectIngest: Ingest,
- includeNsfw: userService.UserSessionState.ShowNsfw,
- key: key,
- count: PageSize,
- sortOrder: sortOrder ?? default));
+ feedRequest = new FeedSearchRequest() {
+ SelectIngest = Ingest,
+ IncludeNsfw = hb.HasNsfwClaim,
+ Query = string.IsNullOrWhiteSpace(Query) ? null : Query,
+ ContinuationToken = key,
+ Count = PageSize,
+ SortOrder = sortOrder ?? default
+ };
}
- StateHasChanged();
+ hb.Feed
+ .LoadChunkAsync(feedRequest)
+ .ContinueWith(async m => {
+ displayMedia!.AddRange(await m);
+ await InvokeAsync(() => StateHasChanged());
+ });
}
- private async void ShowNsfwChanged(UserSessionState userSessionState) {
- await InvokeAsync(() => {
- LoadMedia(true);
- });
- }
+ // private async void ShowNsfwChanged(UserSessionState userSessionState) {
+ // await InvokeAsync(() => {
+ // LoadMedia(true);
+ // });
+ // }
- public void Dispose() =>
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
+ // public void Dispose() =>
+ // userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
}
diff --git a/Pages/Login.razor b/Pages/Login.razor
index 723a78a..bdc6069 100644
--- a/Pages/Login.razor
+++ b/Pages/Login.razor
@@ -1,17 +1,17 @@
@page "/Login"
-@inject NavigationManager navigationManager
+@* @inject NavigationManager navigationManager *@
<PageTitle>HyperBooru Login</PageTitle>
<div/>
@code {
- [CascadingParameter]
- public Task<AuthenticationState> AuthenticationState{ get; set; }
+ // [CascadingParameter]
+ // public Task<AuthenticationState> AuthenticationState{ get; set; }
protected override void OnInitialized() {
- var authState = AuthenticationState.GetAwaiter().GetResult();
- if(authState!.User.Identity?.IsAuthenticated ?? false)
- navigationManager.NavigateTo("/");
+ // var authState = AuthenticationState.GetAwaiter().GetResult();
+ // if(authState!.User.Identity?.IsAuthenticated ?? false)
+ // navigationManager.NavigateTo("/");
}
} \ No newline at end of file
diff --git a/Pages/TagDefinitions.razor b/Pages/TagDefinitions.razor
index 5d02e03..7ce5400 100644
--- a/Pages/TagDefinitions.razor
+++ b/Pages/TagDefinitions.razor
@@ -1,9 +1,10 @@
@page "/TagDefinitions"
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IUserService userService
-@implements IDisposable
-@attribute [Authorize]
+@*
+ * @inject IDbContextFactory<HBContext> dbFactory
+ * @inject ITagService tagService
+ * @inject IUserService userService
+ * @implements IDisposable
+ *@
<PageTitle>Tag Definitions</PageTitle>
@@ -23,25 +24,28 @@
<th></th>
</tr>
@foreach(var tagDef in tagDefinitions.Where(td => td.Namespace == ns)) {
- <tr data-guid="@tagDef.Guid">
+ @* <tr data-guid="@tagDef.Guid"> *@
+ <tr>
<td>@tagDef.Alias</td>
<td>
+@*
<a href="/Gallery?t=@tagDef.Guid" class="nondecorated">
@tagDef.Name
</a>
+*@
</td>
<td>
<i>
@{
- var implicitTags = tagDef.ImplicitTags
- .Where(td => td.Source == ApiModels.TagSource.UserTag);
- foreach(var tag in implicitTags) {
- <a href="/Gallery?t=@tag.Guid" class="nondecorated">
- @tag.Name
- </a>
- if(tag != implicitTags.Last())
- @(", ")
- }
+ // var implicitTags = tagDef.ImplicitTags
+ // .Where(td => td.Source == TagSource.UserTag);
+ // foreach(var tag in implicitTags) {
+ // <a href="/Gallery?t=@tag.Guid" class="nondecorated">
+ // @tag.Name
+ // </a>
+ // if(tag != implicitTags.Last())
+ // @(", ")
+ // }
}
</i>
</td>
@@ -53,11 +57,13 @@
<a href="javascript:;" @onclick=@(() => PromptImplicitTags(tagDef))>
Implicit Tags
</a>
+@*
@if(tagDef.ImplicitTags.Select(td => td.Guid).Contains(HBContext.NsfwTag)) {
<a href="javascript:;" @onclick=@(() => SetNsfw(tagDef, false))>Make SFW</a>
} else {
<a href="javascript:;" @onclick=@(() => SetNsfw(tagDef, true))>Make NSFW</a>
}
+*@
</td>
</tr>
}
@@ -93,35 +99,35 @@
private string?[] tagNamespaces;
- protected override void OnInitialized() =>
- userService.UserSessionState.OnStateChange += ShowNsfwChanged;
+ // protected override void OnInitialized() =>
+ // userService.UserSessionState.OnStateChange += ShowNsfwChanged;
protected override void OnParametersSet() =>
LoadTags();
private void LoadTags() {
- int[] nsfwTags = Array.Empty<int>();
- if(!userService.UserSessionState.ShowNsfw)
- nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
- .Select(td => td.ObjectId)
- .ToArray();
+ // int[] nsfwTags = Array.Empty<int>();
+ // if(!userService.UserSessionState.ShowNsfw)
+ // nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag)
+ // .Select(td => td.ObjectId)
+ // .ToArray();
- tagDefinitions = dbFactory.CreateDbContext().TagDefinitions
- .Include(td => td.ImplicitTags)
- .Where(td => td.Source == ApiModels.TagSource.UserTag)
- .OrderBy(td => td.Namespace)
- .ThenBy(td => td.Name)
- .AsEnumerable()
- .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
- .IntersectBy(nsfwTags, td => td.ObjectId)
- .Any())
- .ToArray();
+ // tagDefinitions = dbFactory.CreateDbContext().TagDefinitions
+ // .Include(td => td.ImplicitTags)
+ // .Where(td => td.Source == TagSource.UserTag)
+ // .OrderBy(td => td.Namespace)
+ // .ThenBy(td => td.Name)
+ // .AsEnumerable()
+ // .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags
+ // .IntersectBy(nsfwTags, td => td.ObjectId)
+ // .Any())
+ // .ToArray();
- tagNamespaces = tagDefinitions
- .Select(td => td.Namespace)
- .Order()
- .Distinct()
- .ToArray();
+ // tagNamespaces = tagDefinitions
+ // .Select(td => td.Namespace)
+ // .Order()
+ // .Distinct()
+ // .ToArray();
}
private void PromptToDelete(TagDefinition toDelete) {
@@ -130,13 +136,13 @@
}
private void DeleteTagDefinition() {
- if(toDelete is null)
- return;
+ // if(toDelete is null)
+ // return;
- tagService.DeleteTagDefinition(toDelete);
- deleteTagDialog.Hide();
- LoadTags();
- StateHasChanged();
+ // tagService.DeleteTagDefinition(toDelete);
+ // deleteTagDialog.Hide();
+ // LoadTags();
+ // StateHasChanged();
}
private void PromptTagCreate() {
@@ -152,36 +158,36 @@
}
private void PromptImplicitTags(TagDefinition toEditImplicit) {
- this.toEditImplicit = toEditImplicit;
- implicitTagDialog.SelectedTags =
- toEditImplicit.ImplicitTags.ToArray();
- implicitTagDialog.Show();
+ // this.toEditImplicit = toEditImplicit;
+ // implicitTagDialog.SelectedTags =
+ // toEditImplicit.ImplicitTags.ToArray();
+ // implicitTagDialog.Show();
}
private void SetImplicitTags(TagDefinition[] tagDefs) {
if(toEditImplicit is null)
return;
- tagService.SetImplicitTags(toEditImplicit, tagDefs);
+ // tagService.SetImplicitTags(toEditImplicit, tagDefs);
LoadTags();
StateHasChanged();
}
private void SetNsfw(TagDefinition tagDef, bool nsfw) {
- if(nsfw)
- tagService.AddImplicitTag(tagDef.Guid, HBContext.NsfwTag);
- else
- tagService.RemoveImplicitTag(tagDef.Guid, HBContext.NsfwTag);
- LoadTags();
- StateHasChanged();
+ // if(nsfw)
+ // tagService.AddImplicitTag(tagDef.Guid, HBContext.NsfwTag);
+ // else
+ // tagService.RemoveImplicitTag(tagDef.Guid, HBContext.NsfwTag);
+ // LoadTags();
+ // StateHasChanged();
}
- private async void ShowNsfwChanged(UserSessionState userSessionState) =>
- await InvokeAsync(() => {
- LoadTags();
- StateHasChanged();
- });
+ // private async void ShowNsfwChanged(UserSessionState userSessionState) =>
+ // await InvokeAsync(() => {
+ // LoadTags();
+ // StateHasChanged();
+ // });
- public void Dispose() =>
- userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
+ // public void Dispose() =>
+ // userService.UserSessionState.OnStateChange -= ShowNsfwChanged;
}
diff --git a/Pages/Upload.razor b/Pages/Upload.razor
index 6d6e8bc..74cfd64 100644
--- a/Pages/Upload.razor
+++ b/Pages/Upload.razor
@@ -1,5 +1,4 @@
@page "/Upload"
-@attribute [Authorize]
<div id="dropzone">
<p></p>
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor
index 46cbc45..e210e79 100644
--- a/Pages/ViewMedia.razor
+++ b/Pages/ViewMedia.razor
@@ -1,11 +1,7 @@
@page "/ViewMedia"
-@using HyperBooru.Util
+@* @using HyperBooru.Util*@
+@inject HBSession hb
@inject IJSRuntime jsRuntime
-@inject IDbContextFactory<HBContext> dbFactory
-@inject ITagService tagService
-@inject IMediaService mediaService
-@inject ISourceService sourceService
-@attribute [Authorize]
<PageTitle>@title</PageTitle>
@@ -33,11 +29,14 @@
<div id="vcontainer">
<div id="hcontainer">
<div id="image-container" class="mobile-pane-image visible">
+ <img src="/media/@(MediaId)"/>
+@*
<img
src="/media/@(media.Guid)"
width=@media.CurrentUploadedFile.Width
height=@media.CurrentUploadedFile.Height/>
- </div>
+*@
+ </div>
<div id="metadata-show-button">
<a href="javascript:toggleSidebar();" title="Toggle sidebar (S)"></a>
</div>
@@ -45,6 +44,7 @@
<div id="metadata-container">
<div id="metadata-fileinfo">
@if(infoEditMode) {
+@*
<form action="javascript:;" @onsubmit=@(() => ApplyInfoEdit(true))>
<table id="edit-metadata">
<tr>
@@ -57,11 +57,13 @@
</tr>
</table>
</form>
+*@
} else {
- <p>Title: <i>@(media.ShortDescription ?? "None")</i></p>
- <p class="newlines">Description:<br/><i>@(media.LongDescription ?? "None")</i></p>
+ <p>Title: <i>@(media?.ShortDescription ?? "None")</i></p>
+ <p class="newlines">Description:<br/><i>@(media?.LongDescription ?? "None")</i></p>
}
- <p>Resolution: @(media.CurrentUploadedFile.Width)x@(media.CurrentUploadedFile.Height)</p>
+@*
+ <p>Resolution: @(media.CurrentUploadedFile.Width)x@(media.CurrentUploadedFile.Height)</p>
<p class="heading">Upload history</p>
<hr/>
<table id="uploaded-files" class="data-table">
@@ -102,16 +104,18 @@
</tr>
}
</table>
+*@
</div>
<div id="metadata-tags">
<p class="heading">Tags</p>
<hr/>
- <MediaTagTable Media=media @ref=mediaTagTable/>
+ <MediaTagTable MediaId=MediaId @ref=mediaTagTable/>
</div>
</div>
<div id="button-container">
<ButtonContainer>
- <button @onclick=@(() => deleteDialog.Show()) class="warning" data-keyboard-shortcut="d">
+@*
+ <button @onclick=@(() => deleteDialog.Show()) class="warning" data-keyboard-shortcut="d">
<img src="/images/trash.svg"/>
<p><u>D</u>elete</p>
</button>
@@ -123,8 +127,10 @@
<img src="/images/book.svg"/>
<p>View <u>O</u>CR</p>
</button>
- @if(infoEditMode) {
- <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">
+*@
+ @if(infoEditMode) {
+@*
+ <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">
<img src="/images/cross.svg"/>
<p>Cancel</p>
</button>
@@ -132,23 +138,26 @@
<img src="/images/checkmark.svg"/>
<p>Apply</p>
</button>
- } else {
+*@
+ } else {
<button @onclick=@(() => InfoEditMode = true) class="secondary" data-keyboard-shortcut="e">
<img src="/images/edit.svg"/>
<p><u>E</u>dit Info</p>
</button>
}
- @if(media.IsIngest) {
+@*
+ @if(media.IsIngest) {
<button @onclick=@(() => SetIngest(false)) data-keyboard-shortcut="c">
<img src="/images/checkmark.svg"/>
<p>Mark Tagging <u>C</u>omplete</p>
</button>
} else {
- <button class="secondary" @onclick=@(() => SetIngest(true)) data-keyboard-shortcut="c">
+*@
+ <button class="secondary" @onclick=@(() => SetIngest(true)) data-keyboard-shortcut="c">
<img src="/images/cross.svg"/>
<p>Mark Tagging In<u>c</u>omplete</p>
</button>
- }
+ @* } *@
</ButtonContainer>
</div>
</div>
@@ -159,6 +168,7 @@
</div>
</div>
+@*
<Dialog Title="Delete this media?" @ref=deleteDialog>
<ButtonContainer>
<button @onclick=@(() => deleteDialog.Hide()) class="secondary">Cancel</button>
@@ -181,56 +191,59 @@
Title="Select one or more tag(s) to add"
OnSubmit=AddTags
@ref=tagDialog/>
+*@
@code {
- [Parameter]
- [SupplyParameterFromQuery(Name = "m")]
- public Guid MediaId { get; set; }
+ [Parameter]
+ [SupplyParameterFromQuery(Name = "m")]
+ public Guid MediaId { get; set; }
- private Media media;
+ private ApiModels.Media media;
- private string title;
+ private string title;
- private bool infoEditMode = false;
- private string? shortDescription;
- private string? longDescription;
+ private bool infoEditMode = false;
+ private string? shortDescription;
+ private string? longDescription;
- private MediaTagTable mediaTagTable;
- private Dialog deleteDialog;
- private Dialog ocrDialog;
- private TagSelectDialog tagDialog;
+ private MediaTagTable mediaTagTable;
+ // private Dialog deleteDialog;
+ // private Dialog ocrDialog;
+ // private TagSelectDialog tagDialog;
- private ElementReference shortDescriptionInput;
+ private ElementReference shortDescriptionInput;
- protected override void OnInitialized() =>
- LoadMedia();
+ protected override void OnInitialized() =>
+ LoadMedia();
- protected override async void OnAfterRender(bool firstRender) {
- if(infoEditMode)
- await shortDescriptionInput.FocusAsync();
- }
+ protected override async void OnAfterRender(bool firstRender) {
+ if(infoEditMode)
+ await shortDescriptionInput.FocusAsync();
+ }
- private void LoadMedia() {
- using var db = dbFactory.CreateDbContext();
- media = db.Media
- .Include(m => m.Tags)
- .ThenInclude(t => t.TagDefinition)
- .Include(m => m.CurrentUploadedFile)
- .Include(m => m.UploadedFiles)
- .Include(m => m.OcrData)
- .First(m => m.Guid == MediaId);
+ private async void LoadMedia() {
+ media = await hb.Media.GetAsync(MediaId);
+ // using var db = dbFactory.CreateDbContext();
+ // media = db.Media
+ // .Include(m => m.Tags)
+ // .ThenInclude(t => t.TagDefinition)
+ // .Include(m => m.CurrentUploadedFile)
+ // .Include(m => m.UploadedFiles)
+ // .Include(m => m.OcrData)
+ // .First(m => m.Guid == MediaId);
- title = media.DisplayName ?? "Media View";
- }
+ // title = media.DisplayName ?? "Media View";
+ // InvokeAsync(() => StateHasChanged());
+ }
- private void AddTags(TagDefinition[] tagDefs) {
- foreach(var tagDef in tagDefs)
- tagService.AddTag(media, tagDef);
- mediaTagTable.Refresh();
- }
+ // private void AddTags(TagDefinition[] tagDefs) {
+ // foreach(var tagDef in tagDefs)
+ // tagService.AddTag(media, tagDef);
+ // mediaTagTable.Refresh();
+ // }
private async void SetIngest(bool ingest) {
- mediaService.SetIngest(media, ingest);
+ // mediaService.SetIngest(media, ingest);
LoadMedia();
if(ingest)
@@ -249,17 +262,17 @@
}
}
- private void ApplyInfoEdit(bool apply) {
- if(apply) {
- mediaService.SetDescription(media, shortDescription, longDescription);
- LoadMedia();
- }
+ // private void ApplyInfoEdit(bool apply) {
+ // if(apply) {
+ // mediaService.SetDescription(media, shortDescription, longDescription);
+ // LoadMedia();
+ // }
- infoEditMode = false;
- }
+ // infoEditMode = false;
+ // }
- private async void DeleteMedia() {
- mediaService.Delete(media);
- await jsRuntime.InvokeVoidAsync("history.back");
- }
+ // private async void DeleteMedia() {
+ // mediaService.Delete(media);
+ // await jsRuntime.InvokeVoidAsync("history.back");
+ // }
}