mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-19 15:40:50 +08:00
bunch of random fixes
This commit is contained in:
parent
0d549c7097
commit
72f59628ca
@ -1,5 +1,6 @@
|
||||
[#ftl]
|
||||
[#-- @implicitly included --]
|
||||
[#-- @ftlvariable name="cu" type="io.papermc.hangar.db.model.UsersTable" --]
|
||||
[#-- @ftlvariable name="markdownService" type="io.papermc.hangar.service.MarkdownService" --]
|
||||
[#-- @ftlvariable name="utils" type="io.papermc.hangar.util.TemplateHelper" --]
|
||||
[#-- @ftlvariable name="@helper" type="freemarker.template.TemplateHashModel" --]
|
||||
|
@ -5,7 +5,6 @@ import io.papermc.hangar.controller.util.StatusZ;
|
||||
import io.papermc.hangar.db.customtypes.LoggedActionType;
|
||||
import io.papermc.hangar.db.customtypes.LoggedActionType.ProjectContext;
|
||||
import io.papermc.hangar.db.model.Stats;
|
||||
import io.papermc.hangar.db.model.UsersTable;
|
||||
import io.papermc.hangar.model.NamedPermission;
|
||||
import io.papermc.hangar.model.Permission;
|
||||
import io.papermc.hangar.model.Visibility;
|
||||
@ -51,8 +50,6 @@ import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@ -98,6 +95,7 @@ public class ApplicationController extends HangarController {
|
||||
return ResponseEntity.ok(statusZ.getStatus());
|
||||
}
|
||||
|
||||
@GlobalPermission(NamedPermission.REVIEWER)
|
||||
@Secured("ROLE_USER")
|
||||
@GetMapping("/admin/activities/{user}")
|
||||
public ModelAndView showActivities(@PathVariable String user) {
|
||||
@ -120,6 +118,7 @@ public class ApplicationController extends HangarController {
|
||||
return fillModel(mv);
|
||||
}
|
||||
|
||||
@GlobalPermission(NamedPermission.REVIEWER)
|
||||
@Secured("ROLE_USER")
|
||||
@GetMapping("/admin/approval/versions")
|
||||
public ModelAndView showQueue() {
|
||||
@ -171,6 +170,7 @@ public class ApplicationController extends HangarController {
|
||||
return fillModel(mav);
|
||||
}
|
||||
|
||||
@GlobalPermission(NamedPermission.VIEW_LOGS)
|
||||
@Secured("ROLE_USER")
|
||||
@GetMapping("/admin/log")
|
||||
public ModelAndView showLog(@RequestParam(required = false) Integer oPage,
|
||||
@ -200,6 +200,7 @@ public class ApplicationController extends HangarController {
|
||||
return fillModel(mv);
|
||||
}
|
||||
|
||||
@GlobalPermission(NamedPermission.VIEW_STATS)
|
||||
@Secured("ROLE_USER")
|
||||
@GetMapping("/admin/stats")
|
||||
public ModelAndView showStats(@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate from, @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate to) {
|
||||
@ -240,6 +241,7 @@ public class ApplicationController extends HangarController {
|
||||
return fillModel(mav);
|
||||
}
|
||||
|
||||
@GlobalPermission(NamedPermission.EDIT_ALL_USER_SETTINGS)
|
||||
@Secured("ROLE_USER")
|
||||
@PostMapping("/admin/user/{user}/update")
|
||||
public Object updateUser(@PathVariable Object user) {
|
||||
|
@ -632,8 +632,10 @@ public class VersionsController extends HangarController {
|
||||
@Secured("ROLE_USER")
|
||||
@PostMapping("/{author}/{slug}/versions/{version}/recommended")
|
||||
public ModelAndView setRecommended(@PathVariable String author, @PathVariable String slug, @PathVariable String version) {
|
||||
versionData.get().getP().getProject().setRecommendedVersionId(versionData.get().getV().getId());
|
||||
projectDao.get().update(versionData.get().getP().getProject());
|
||||
ProjectsTable project = projectsTable.get();
|
||||
ProjectVersionsTable versionsTable = projectVersionsTable.get();
|
||||
project.setRecommendedVersionId(versionsTable.getId());
|
||||
projectDao.get().update(project);
|
||||
return Routes.VERSIONS_SHOW.getRedirect(author, slug, version);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public interface ProjectStatsTrackerDao {
|
||||
@SqlQuery("SELECT pvdi.cookie " +
|
||||
" FROM project_versions_downloads_individual pvdi" +
|
||||
" WHERE pvdi.address = :address OR " +
|
||||
" (:userId IS NOT NULL AND :userId = pvdi.user_id)")
|
||||
" (:userId IS NOT NULL AND :userId = pvdi.user_id) LIMIT 1")
|
||||
Optional<String> getIndividualDownloadCookie(Long userId, InetAddress address);
|
||||
|
||||
@Timestamped
|
||||
@ -29,7 +29,7 @@ public interface ProjectStatsTrackerDao {
|
||||
@SqlQuery("SELECT pvi.cookie " +
|
||||
" FROM project_views_individual pvi" +
|
||||
" WHERE pvi.address = :address OR " +
|
||||
" (:userId IS NOT NULL AND :userId = pvi.user_id)")
|
||||
" (:userId IS NOT NULL AND :userId = pvi.user_id) LIMIT 1")
|
||||
Optional<String> getIndividualViewCookie(Long userId, InetAddress address);
|
||||
|
||||
@Timestamped
|
||||
|
@ -12,10 +12,11 @@ showFooter: Boolean = true, noContainer: Boolean = false, additionalMeta: Html =
|
||||
<!DOCTYPE html>
|
||||
<html lang="<@spring.message "general.language" />">
|
||||
<head>
|
||||
<link href="<@hangar.config "security.api.url" />" rel="preconnect" crossorigin>
|
||||
<link href="<@hangar.config "app.discourseCdnUrl" />" rel="preconnect" crossorigin>
|
||||
<link href="<@hangar.config "security.api.url" />" rel="dns-prefetch">
|
||||
<link href="<@hangar.config "app.discourseCdnUrl" />" rel="dns-prefetch">
|
||||
<link href="${config.security.api.url}">
|
||||
<link href="${config.security.api.url}" rel="preconnect" crossorigin>
|
||||
<#-- <link href="<@hangar.config "app.discourseCdnUrl" />" rel="preconnect" crossorigin>--><#--TODO this-->
|
||||
<link href="${config.security.api.url}" rel="dns-prefetch">
|
||||
<#-- <link href="<@hangar.config "app.discourseCdnUrl" />" rel="dns-prefetch">--><#--TODO this-->
|
||||
|
||||
<link rel="prefetch" href="<@hangar.url "images/favicon.ico" />">
|
||||
<link rel="prefetch" href="https://fonts.googleapis.com/css?family=Montserrat:400,700">
|
||||
@ -65,8 +66,7 @@ showFooter: Boolean = true, noContainer: Boolean = false, additionalMeta: Html =
|
||||
<#nested>
|
||||
<#else>
|
||||
<div class="container<#if showHeader> site-header-margin</#if>">
|
||||
<#assign var><@hangar.config "ore.staging" /></#assign>
|
||||
<#if var == "true">
|
||||
<#if config.staging>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="staging-warning"><@spring.message "general.stagingWarning" /></div>
|
||||
|
@ -46,6 +46,8 @@
|
||||
</div>
|
||||
|
||||
<#-- Right navbar -->
|
||||
<#assign Permission=@helper["io.papermc.hangar.model.Permission"] />
|
||||
<#-- @ftlvariable name="Permission" type="io.papermc.hangar.model.Permission" -->
|
||||
<#if authEnabled>
|
||||
<ul class="nav navbar-nav navbar-collapse collapse navbar-right">
|
||||
<#if cu??>
|
||||
@ -75,14 +77,14 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<@hangar.hasPerm "IsStaff">
|
||||
<#if headerData.globalPerm(Permission.IsStaff)>
|
||||
<#assign title><@spring.message "project.viewStaff"/></#assign>
|
||||
<li class="nav-icon staff-icon" <@tooltip title=title />>
|
||||
<a href="${Routes.USERS_SHOW_STAFF.getRouteUrl("", "")}">
|
||||
<i class="icon fas fa-user-tie"></i>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
</#if>
|
||||
|
||||
<#-- Show user controls -->
|
||||
<li class="dropdown user-controls nav-icon">
|
||||
@ -113,8 +115,7 @@
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<@hangar.hasPerm "ModNotesAndFlags">
|
||||
<#if headerData.globalPerm(Permission.ModNotesAndFlags)>
|
||||
<li>
|
||||
<a href="${Routes.SHOW_FLAGS.getRouteUrl()}">
|
||||
<i class="fas fa-flag mr-1"></i>
|
||||
@ -126,9 +127,6 @@
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
|
||||
<@hangar.hasPerm "ModNotesAndFlags">
|
||||
<li>
|
||||
<a href="${Routes.SHOW_PROJECT_VISIBILITY.getRouteUrl()}">
|
||||
<i class="fas fa-thumbs-up mr-1"></i>
|
||||
@ -140,9 +138,8 @@
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
|
||||
<@hangar.hasPerm "Reviewer">
|
||||
</#if>
|
||||
<#if headerData.globalPerm(Permission.Reviewer)>
|
||||
<li>
|
||||
<a href="${Routes.SHOW_QUEUE.getRouteUrl()}">
|
||||
<i class="far fa-thumbs-up mr-1"></i>
|
||||
@ -154,34 +151,31 @@
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
|
||||
<@hangar.hasPerm "ViewStats">
|
||||
</#if>
|
||||
<#if headerData.globalPerm(Permission.ViewStats)>
|
||||
<li>
|
||||
<a href="${Routes.SHOW_STATS.getRouteUrl("", "")}">
|
||||
<i class="fas fa-chart-area mr-1"></i>
|
||||
<span><@spring.message "user.stats" /></span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
|
||||
<@hangar.hasPerm "ViewHealth">
|
||||
</#if>
|
||||
<#if headerData.globalPerm(Permission.ViewHealth)>
|
||||
<li>
|
||||
<a href="${Routes.SHOW_HEALTH.getRouteUrl()}">
|
||||
<i class="fas fa-heartbeat mr-1"></i>
|
||||
<span><@spring.message "admin.health.title" /></span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
|
||||
<@hangar.hasPerm "ViewLogs">
|
||||
</#if>
|
||||
<#if headerData.globalPerm(Permission.ViewLogs)>
|
||||
<li>
|
||||
<a href="${Routes.SHOW_LOG.getRouteUrl("", "", "", "", "", "", "")}">
|
||||
<i class="fas fa-list mr-1"></i>
|
||||
<span><@spring.message "admin.log.title" /></span>
|
||||
</a>
|
||||
</li>
|
||||
</@hangar.hasPerm>
|
||||
</#if>
|
||||
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
|
@ -1,15 +1,3 @@
|
||||
<#-- todo implement config lookup -->
|
||||
<#macro config path>
|
||||
${path}
|
||||
</#macro>
|
||||
|
||||
<#-- todo implement perm check -->
|
||||
<#macro hasPerm perm>
|
||||
<#if true>
|
||||
<#nested>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro linkout url>
|
||||
<#--noinspection FtlReferencesInspection-->
|
||||
${Routes.LINK_OUT.getRouteUrl(url)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user