2
0
mirror of https://github.com/HangarMC/Hangar.git synced 2025-03-19 15:40:50 +08:00

Fix user log context displays

This commit is contained in:
KennyTV 2020-09-04 12:06:27 +02:00
parent 9949c3e6cc
commit 19318e81a5
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 15 additions and 12 deletions
src/main
java/io/papermc/hangar/db/mappers
resources/templates/users/admin

@ -20,6 +20,7 @@ import java.sql.SQLException;
import java.time.OffsetDateTime;
public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewModel<?>> {
@Override
public LoggedActionViewModel<?> map(ResultSet rs, StatementContext ctx) throws SQLException {
long userId = rs.getLong("user_id");
@ -31,6 +32,13 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
OffsetDateTime createdAt = ctx.findColumnMapperFor(OffsetDateTime.class).get().map(rs, "created_at", ctx);
int contextType = rs.getInt("context_type");
final LoggedProject project = new LoggedProject(
rs.getLong("p_id"),
rs.getString("p_plugin_id"),
rs.getString("p_slug"),
rs.getString("p_owner_name")
);
switch (contextType) {
case 0:
return new LoggedActionViewModel<>(userId,
@ -40,12 +48,7 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
ProjectContext.of(rs.getLong("p_id")),
newState,
oldState,
new LoggedProject(
rs.getLong("p_id"),
rs.getString("p_plugin_id"),
rs.getString("p_slug"),
rs.getString("p_owner_name")
),
project,
null,
null,
null,
@ -59,7 +62,7 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
VersionContext.of(rs.getLong("p_id"), rs.getLong("pv_id")),
newState,
oldState,
null,
project,
new LoggedProjectVersion(
rs.getLong("pv_id"),
rs.getString("pv_version_string")
@ -77,7 +80,7 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
ProjectPageContext.of(rs.getLong("p_id"), rs.getLong("pp_id")),
newState,
oldState,
null,
project,
null,
new LoggedProjectPage(
rs.getLong("pp_id"),
@ -96,7 +99,7 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
UserContext.of(rs.getLong("s_id")),
newState,
oldState,
null,
project,
null,
null,
new LoggedSubject(
@ -114,7 +117,7 @@ public class LoggedActionViewModelMapper implements RowMapper<LoggedActionViewMo
OrganizationContext.of(rs.getLong("s_id")),
newState,
oldState,
null,
project,
null,
null,
new LoggedSubject(

@ -78,7 +78,7 @@
<a href="${routes.getRouteUrl("users.showProjects", action.subject.username!"Unknown")}">${action.subject.username}</a>
<small class="filter-subject">(<a href="${routes.getRouteUrl("showLog", page?string, userFilter, projectFilter, versionFilter, pageFilter, actionFilter, action.subject.username)}">${action.subject.username}</a>)</small>
</td>
<#elseif !action.project?? || !action.project.id??>
<#elseif !action.project.id??>
<td>
Resource deleted
<#if action.actionContext.class.simpleName == "ProjectContext" || action.actionContext.class.simpleName == "ProjectPageContext">
@ -96,7 +96,7 @@
<td>
<a href="${routes.getRouteUrl("pages.show", action.project.owner!"Unknown", action.project.slug!"Unknown", action.page.slug!"Unknown")}">${action.project.owner!"Unknown"}/${action.project.slug!"Unknown"}/${action.page.slug!"Unknown"}</a>
<small class="filter-project">(<a href="${routes.getRouteUrl("showLog", page?string, userFilter, action.project.pluginId, versionFilter, pageFilter, actionFilter, subjectFilter)}">${action.project.pluginId}</a>)</small>
<small class="filter-page">(<a href="${routes.getRouteUrl("showLog", page?string, userFilter, projectFilter, versionFilter, action.page.id, actionFilter, subjectFilter)}">${action.page.id}</a>)</small>
<small class="filter-page">(<a href="${routes.getRouteUrl("showLog", page?string, userFilter, projectFilter, versionFilter, action.page.id?string, actionFilter, subjectFilter)}">${action.page.id}</a>)</small>
</td>
<#elseif action.actionContext.class.simpleName == "VersionContext">
<td>