misc stuff + start staff page

This commit is contained in:
MiniDigger 2020-07-12 17:41:52 +02:00
parent 6fb1fe8dd7
commit 147ce209d7
8 changed files with 53 additions and 40 deletions

View File

@ -0,0 +1,13 @@
package me.minidigger.hangar.controller;
import org.springframework.web.servlet.ModelAndView;
import me.minidigger.hangar.model.ModelData;
public abstract class HangarController {
protected ModelAndView fillModel(ModelAndView mav) {
mav.addObject("modelData", new ModelData());
return mav;
}
}

View File

@ -4,18 +4,11 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import me.minidigger.hangar.model.ModelData;
@Controller
public class HomeController {
public class HomeController extends HangarController{
@GetMapping("/")
public ModelAndView home() {
return fillModel( new ModelAndView("home"));
}
private ModelAndView fillModel(ModelAndView mav) {
mav.addObject("modelData", new ModelData());
return mav;
}
}

View File

@ -0,0 +1,14 @@
package me.minidigger.hangar.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class UserController extends HangarController {
@GetMapping("/staff")
public ModelAndView home() {
return fillModel( new ModelAndView("users/staff"));
}
}

View File

@ -6,6 +6,6 @@
<div class="container-error container">
<img src="<@spring.url "images/ore-dark.png" />" alt="Hangar logo"/>
<h1 class="minor"><@spring.message "error.notFound.title" /></h1>
<h3 class="minor"><@spring.messageArgs "error.notFound.message" springMacroRequestContext.requestUri /></h3>
<h3 class="minor"><@spring.messageArgs code="error.notFound.message" args=[springMacroRequestContext.requestUri] /></h3>
</div>
</@base.base>

View File

@ -21,7 +21,7 @@ sorted according to different criteria.
</#macro>
<#macro stylesheets>
<link rel="stylesheet" type="text/css" href="@routes.Assets.versioned("build/home.css")" />
<link rel="stylesheet" type="text/css" href="<@spring.url "build/home.css" />" />
</#macro>
<#macro meta>

View File

@ -89,7 +89,7 @@
<#if modelData.hasNotice()>
<span class="unread"></span>
</#if>
<img height="32" width="32" class="user-avatar" src="${cu.avatarUrl}" alt="@cu.name"/>
<img height="32" width="32" class="user-avatar" src="${cu.avatarUrl}" alt="${cu.name}"/>
<span class="caret"></span>
</a>
<ul class="user-dropdown dropdown-menu" aria-label="<@spring.messageArgs code="aria.dropdown.menu" args=[1] />">

View File

@ -26,11 +26,11 @@ Versions page within Project overview.
window.PROJECT_OWNER = '@p.project.ownerName';
window.PROJECT_SLUG = '@p.project.slug';
</script>
<script type="text/javascript" src="@routes.Assets.versioned("build/version-list.js")"></script>
<script type="text/javascript" src="<@spring.url "build/version-list.js" />"></script>
}
@stylesheets = {
<link rel="stylesheet" type="text/css" href="@routes.Assets.versioned("build/version-list.css")" />
<link rel="stylesheet" type="text/css" href="<@spring.url "build/version-list.css" />" />
}
@projects.view(p, sp, "#versions", additionalScripts = scripts, additionalStyling = stylesheets) {

View File

@ -1,18 +1,10 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/layout/base.ftlh" as base>
@import java.time.OffsetDateTime
@import controllers.sugar.Requests.OreRequest
@import db.impl.access.UserBase.UserOrdering
@import ore.OreConfig
@import ore.models.user.User
@import ore.permission.role.Role
@import util.StringFormatterUtils._
@import util.syntax._
@import views.html.helper.CSPNonce
@import views.html.utils.userAvatar
<#--
@(staff: Seq[(String, Role, Option[OffsetDateTime], OffsetDateTime)], ordering: String, page: Int)(implicit messages: Messages, request: OreRequest[_], config: OreConfig, flash: Flash, assetsFinder: AssetsFinder)
-->
@pageSize = @{ config.ore.users.authorPageSize }
@direction = @{ if (ordering.startsWith("-")) "chevron-down" else "chevron-up" }
@ -22,12 +14,13 @@
sort.equalsIgnoreCase(td)
}
@scripts = {
<#macro scripts>
<script type="text/javascript" src="<@spring.url "javascripts/userList.js" />"></script>
<script @CSPNonce.attr>CURRENT_PAGE = @page;</script>
}
</#macro>
@layout.base("Staff - Hangar", scripts) {
<#assign scriptsVar><@scripts /></#assign>
<@base.base title="Staff - Hangar" additionalScripts=scriptsVar>
<div class="panel panel-default">
<table class="table table-users">
@ -49,44 +42,44 @@
</tr>
</thead>
<tbody>
@staff.map { case (name, role, joinDate, createdAt) =>
<#list staff as user>
<tr>
<td>@userAvatar(Some(name), User.avatarUrl(name), clazz = "user-avatar-xs")</td>
<td>@userAvatar(user.name, User.avatarUrl(name), clazz = "user-avatar-xs")</td>
<td>
<a href="@routes.Application.showActivities(name)">@name</a>
<a href="@routes.Application.showActivities(name)">${user.name}</a>
</td>
<td>
<span class="user-role channel" style="background-color: @role.color.hex">
@role.title
<span class="user-role channel" style="background-color: ${user.role.color.hex}">
${user.role.title}
</span>
</td>
<td>@prettifyDate(joinDate.getOrElse(createdAt))</td>
</tr>
}
</#list>
@if(page > 1 || staff.size >= pageSize) {
<#if page gt 1 || staff.size gte pageSize>
<tr class="authors-footer">
<td></td>
<td></td>
<td></td>
<td>
@if(staff.size >= pageSize) {
<#if staff.size gte pageSize>
<a href="@routes.Users.showStaff(Some(ordering), Some(page + 1))" class="btn btn-default">
<i class="fas fa-arrow-right"></i>
</a>
}
</#if>
@if(page > 1) {
<#if page gt 1>
<a href="@routes.Users.showStaff(Some(ordering), Some(page - 1))" class="btn btn-default">
<i class="fas fa-arrow-left"></i>
</a>
}
</#if>
</td>
</tr>
}
</#if>
</tbody>
</table>
</div>
}
</@base.base>