fix(admin): broken report controls (#12)
This commit is contained in:
parent
7782bb1ba5
commit
edb36f406d
@ -434,9 +434,7 @@ fn sidebar_interaction_script() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn admin_acls_from(
|
fn admin_acls_from(current_admin: Option(UserLookupResult)) -> List(String) {
|
||||||
current_admin: Option(UserLookupResult),
|
|
||||||
) -> List(String) {
|
|
||||||
case current_admin {
|
case current_admin {
|
||||||
option.Some(admin) -> admin.acls
|
option.Some(admin) -> admin.acls
|
||||||
option.None -> []
|
option.None -> []
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import fluxer_admin/components/flash
|
|||||||
import fluxer_admin/components/layout
|
import fluxer_admin/components/layout
|
||||||
import fluxer_admin/components/message_list
|
import fluxer_admin/components/message_list
|
||||||
import fluxer_admin/components/ui
|
import fluxer_admin/components/ui
|
||||||
import fluxer_admin/web.{type Context, type Session, href}
|
import fluxer_admin/web.{type Context, type Session, action, href}
|
||||||
import gleam/list
|
import gleam/list
|
||||||
import gleam/option
|
import gleam/option
|
||||||
import gleam/string
|
import gleam/string
|
||||||
@ -378,19 +378,27 @@ fn render_actions_card(ctx: Context, report: reports.Report) {
|
|||||||
h.div([a.class("space-y-3")], [
|
h.div([a.class("space-y-3")], [
|
||||||
case report.status {
|
case report.status {
|
||||||
0 ->
|
0 ->
|
||||||
h.button(
|
h.form(
|
||||||
[
|
[
|
||||||
a.class(
|
a.method("post"),
|
||||||
"w-full px-4 py-2 bg-neutral-900 text-white rounded-lg label hover:bg-neutral-800 transition-colors",
|
action(ctx, "/reports/" <> report.report_id <> "/resolve"),
|
||||||
),
|
|
||||||
a.attribute(
|
a.attribute(
|
||||||
"onclick",
|
"onsubmit",
|
||||||
"if(confirm('Resolve this report?')) { fetch('/reports/"
|
"if(!confirm('Resolve this report?')) return false;",
|
||||||
<> report.report_id
|
),
|
||||||
<> "/resolve', { method: 'POST', headers: { 'Content-Type': 'application/json' } }).then(() => location.reload()) }",
|
],
|
||||||
|
[
|
||||||
|
h.input([a.type_("hidden"), a.name("public_comment"), a.value("")]),
|
||||||
|
h.button(
|
||||||
|
[
|
||||||
|
a.type_("submit"),
|
||||||
|
a.class(
|
||||||
|
"w-full px-4 py-2 bg-neutral-900 text-white rounded-lg label hover:bg-neutral-800 transition-colors",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[element.text("Resolve Report")],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[element.text("Resolve Report")],
|
|
||||||
)
|
)
|
||||||
_ -> element.none()
|
_ -> element.none()
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import fluxer_admin/components/date_time
|
|||||||
import fluxer_admin/components/flash
|
import fluxer_admin/components/flash
|
||||||
import fluxer_admin/components/layout
|
import fluxer_admin/components/layout
|
||||||
import fluxer_admin/components/ui
|
import fluxer_admin/components/ui
|
||||||
import fluxer_admin/web.{type Context, type Session, href}
|
import fluxer_admin/web.{type Context, type Session, action, href}
|
||||||
import gleam/int
|
import gleam/int
|
||||||
import gleam/list
|
import gleam/list
|
||||||
import gleam/option
|
import gleam/option
|
||||||
@ -756,7 +756,7 @@ fn render_actions_cell(ctx: Context, report: reports.SearchReportResult) {
|
|||||||
h.form(
|
h.form(
|
||||||
[
|
[
|
||||||
a.method("post"),
|
a.method("post"),
|
||||||
a.attribute("action", "/reports/" <> report.report_id <> "/resolve"),
|
action(ctx, "/reports/" <> report.report_id <> "/resolve"),
|
||||||
a.attribute("data-report-action", "resolve"),
|
a.attribute("data-report-action", "resolve"),
|
||||||
a.attribute("data-report-id", report.report_id),
|
a.attribute("data-report-id", report.report_id),
|
||||||
a.attribute("data-confirm", "Resolve this report?"),
|
a.attribute("data-confirm", "Resolve this report?"),
|
||||||
@ -1073,7 +1073,14 @@ fn reports_script() -> element.Element(a) {
|
|||||||
|
|
||||||
function markResolved(reportId) {
|
function markResolved(reportId) {
|
||||||
const pill = table.querySelector('[data-status-pill=\"' + reportId + '\"]');
|
const pill = table.querySelector('[data-status-pill=\"' + reportId + '\"]');
|
||||||
if (pill) pill.textContent = 'Resolved';
|
if (pill) {
|
||||||
|
const inner = pill.querySelector('span');
|
||||||
|
if (inner) {
|
||||||
|
inner.textContent = 'Resolved';
|
||||||
|
inner.classList.remove('bg-yellow-100', 'text-yellow-700');
|
||||||
|
inner.classList.add('bg-green-100', 'text-green-700');
|
||||||
|
}
|
||||||
|
}
|
||||||
const form = table.querySelector('form[data-report-id=\"' + reportId + '\"]');
|
const form = table.querySelector('form[data-report-id=\"' + reportId + '\"]');
|
||||||
if (form) {
|
if (form) {
|
||||||
form.remove();
|
form.remove();
|
||||||
|
|||||||
@ -37,22 +37,16 @@ pub fn view(
|
|||||||
ui.heading_page("You find yourself in a strange place..."),
|
ui.heading_page("You find yourself in a strange place..."),
|
||||||
ui.card(ui.PaddingMedium, [
|
ui.card(ui.PaddingMedium, [
|
||||||
ui.stack("4", [
|
ui.stack("4", [
|
||||||
h.p(
|
h.p([a.class("text-neutral-700 leading-relaxed")], [
|
||||||
[a.class("text-neutral-700 leading-relaxed")],
|
element.text(
|
||||||
[
|
"Your account is authenticated, but no admin tabs are available for your current permissions.",
|
||||||
element.text(
|
),
|
||||||
"Your account is authenticated, but no admin tabs are available for your current permissions.",
|
]),
|
||||||
),
|
h.p([a.class("text-neutral-600 leading-relaxed")], [
|
||||||
],
|
element.text(
|
||||||
),
|
"If you believe this is a mistake, reach out to an administrator to request the necessary access.",
|
||||||
h.p(
|
),
|
||||||
[a.class("text-neutral-600 leading-relaxed")],
|
]),
|
||||||
[
|
|
||||||
element.text(
|
|
||||||
"If you believe this is a mistake, reach out to an administrator to request the necessary access.",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import fluxer_admin/api/users
|
|||||||
import fluxer_admin/components/errors
|
import fluxer_admin/components/errors
|
||||||
import fluxer_admin/components/flash
|
import fluxer_admin/components/flash
|
||||||
import fluxer_admin/constants
|
import fluxer_admin/constants
|
||||||
|
import fluxer_admin/navigation
|
||||||
import fluxer_admin/oauth2
|
import fluxer_admin/oauth2
|
||||||
import fluxer_admin/pages/archives_page
|
import fluxer_admin/pages/archives_page
|
||||||
import fluxer_admin/pages/asset_purge_page
|
import fluxer_admin/pages/asset_purge_page
|
||||||
@ -55,7 +56,6 @@ import fluxer_admin/pages/users_page
|
|||||||
import fluxer_admin/pages/voice_regions_page
|
import fluxer_admin/pages/voice_regions_page
|
||||||
import fluxer_admin/pages/voice_servers_page
|
import fluxer_admin/pages/voice_servers_page
|
||||||
import fluxer_admin/session
|
import fluxer_admin/session
|
||||||
import fluxer_admin/navigation
|
|
||||||
import fluxer_admin/web.{type Context, prepend_base_path}
|
import fluxer_admin/web.{type Context, prepend_base_path}
|
||||||
import gleam/http.{Get, Post}
|
import gleam/http.{Get, Post}
|
||||||
import gleam/http/request
|
import gleam/http/request
|
||||||
@ -238,7 +238,8 @@ pub fn handle_request(req: Request, ctx: Context) -> Response {
|
|||||||
case wisp.get_cookie(req, "session", wisp.Signed) {
|
case wisp.get_cookie(req, "session", wisp.Signed) {
|
||||||
Ok(cookie) ->
|
Ok(cookie) ->
|
||||||
case session.get(ctx, cookie) {
|
case session.get(ctx, cookie) {
|
||||||
Ok(_session) -> wisp.redirect(prepend_base_path(ctx, "/dashboard"))
|
Ok(_session) ->
|
||||||
|
wisp.redirect(prepend_base_path(ctx, "/dashboard"))
|
||||||
Error(_) -> login_page.view(ctx, error_msg)
|
Error(_) -> login_page.view(ctx, error_msg)
|
||||||
}
|
}
|
||||||
Error(_) -> login_page.view(ctx, error_msg)
|
Error(_) -> login_page.view(ctx, error_msg)
|
||||||
|
|||||||
@ -34,6 +34,8 @@ export const AuditLogMiddleware = createMiddleware<HonoEnv>(async (ctx, next) =>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
ctx.set('auditLogReason', result.data);
|
ctx.set('auditLogReason', result.data);
|
||||||
|
} else {
|
||||||
|
ctx.set('auditLogReason', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user