[frontend/pages] Add activity responses to debug page
This commit is contained in:
parent
69c5016e94
commit
2f03c8bf97
4 changed files with 26 additions and 2 deletions
|
@ -53,7 +53,7 @@
|
||||||
<JsonViewer Element="element"/>
|
<JsonViewer Element="element"/>
|
||||||
</dd>),
|
</dd>),
|
||||||
JsonValueKind.Number => (@<dd><span class="number">@element.GetDouble()</span></dd>),
|
JsonValueKind.Number => (@<dd><span class="number">@element.GetDouble()</span></dd>),
|
||||||
JsonValueKind.String => (element.GetString() is { } s && Uri.TryCreate(s, UriKind.Absolute, out var _)
|
JsonValueKind.String => (element.GetString() is { } s && s.StartsWith("https://") && Uri.TryCreate(s, UriKind.Absolute, out var _)
|
||||||
? @<dd><a href="@s" target="_blank">@s</a></dd>
|
? @<dd><a href="@s" target="_blank">@s</a></dd>
|
||||||
: @<dd><span class="string">"@element.GetString()?.ReplaceLineEndings("\\n")"</span></dd>),
|
: @<dd><span class="string">"@element.GetString()?.ReplaceLineEndings("\\n")"</span></dd>),
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.json {
|
.json {
|
||||||
|
word-break: break-word;
|
||||||
dt {
|
dt {
|
||||||
color: #66C3CC;
|
color: #66C3CC;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using Iceshrimp.Frontend.Core.Services;
|
using Iceshrimp.Frontend.Core.Services;
|
||||||
using Iceshrimp.Shared.Schemas.Web;
|
using Iceshrimp.Shared.Schemas.Web;
|
||||||
|
|
||||||
|
@ -8,6 +9,11 @@ internal class AdminControllerModel(ApiClient api)
|
||||||
public Task<InviteResponse> GenerateInviteAsync() =>
|
public Task<InviteResponse> GenerateInviteAsync() =>
|
||||||
api.CallAsync<InviteResponse>(HttpMethod.Post, "/invites/generate");
|
api.CallAsync<InviteResponse>(HttpMethod.Post, "/invites/generate");
|
||||||
|
|
||||||
//TODO: ActivityStreams debug endpoints
|
public Task<JsonObject?> GetActivityByNoteIdAsync(string id) =>
|
||||||
|
api.CallNullableAsync<JsonObject>(HttpMethod.Get, $"/admin/activities/notes/{id}");
|
||||||
|
|
||||||
|
public Task<JsonObject?> GetActivityByUserIdAsync(string id) =>
|
||||||
|
api.CallNullableAsync<JsonObject>(HttpMethod.Get, $"/admin/activities/users/{id}");
|
||||||
|
|
||||||
//TODO: other endpoints
|
//TODO: other endpoints
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@inject ApiService Api;
|
@inject ApiService Api;
|
||||||
@inject IStringLocalizer<Localization> Loc;
|
@inject IStringLocalizer<Localization> Loc;
|
||||||
|
@inject SessionService SessionSvc;
|
||||||
|
|
||||||
<HeadTitle Text="@Loc["About"]"/>
|
<HeadTitle Text="@Loc["About"]"/>
|
||||||
|
|
||||||
|
@ -56,6 +57,14 @@
|
||||||
|
|
||||||
Documents.Add(Loc["Note response"], JsonSerializer.SerializeToDocument(noteResponse));
|
Documents.Add(Loc["Note response"], JsonSerializer.SerializeToDocument(noteResponse));
|
||||||
|
|
||||||
|
if (SessionSvc.Current?.IsAdmin is true)
|
||||||
|
{
|
||||||
|
var activity = await Api.Admin.GetActivityByNoteIdAsync(noteResponse.Id);
|
||||||
|
|
||||||
|
if (activity != null)
|
||||||
|
Documents.Add(Loc["Activity"], JsonSerializer.SerializeToDocument(activity));
|
||||||
|
}
|
||||||
|
|
||||||
State = State.Loaded;
|
State = State.Loaded;
|
||||||
}
|
}
|
||||||
else if (User != null)
|
else if (User != null)
|
||||||
|
@ -75,6 +84,14 @@
|
||||||
Documents.Add(Loc["User response"], JsonSerializer.SerializeToDocument(userResponse));
|
Documents.Add(Loc["User response"], JsonSerializer.SerializeToDocument(userResponse));
|
||||||
Documents.Add(Loc["Profile response"], JsonSerializer.SerializeToDocument(profileResponse));
|
Documents.Add(Loc["Profile response"], JsonSerializer.SerializeToDocument(profileResponse));
|
||||||
|
|
||||||
|
if (SessionSvc.Current?.IsAdmin is true)
|
||||||
|
{
|
||||||
|
var activity = await Api.Admin.GetActivityByUserIdAsync(userResponse.Id);
|
||||||
|
|
||||||
|
if (activity != null)
|
||||||
|
Documents.Add(Loc["Activity"], JsonSerializer.SerializeToDocument(activity));
|
||||||
|
}
|
||||||
|
|
||||||
State = State.Loaded;
|
State = State.Loaded;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue