Skip to content

Commit

Permalink
feat(#193): include room ui as java application page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jumpy-Squirrel committed Nov 9, 2024
1 parent a47432c commit 02281f6
Show file tree
Hide file tree
Showing 21 changed files with 138 additions and 27 deletions.
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,25 @@ jar {
task runExecutableJar(type: JavaExec) {
classpath = files(tasks.jar)
}

task downloadJavascriptDependencies() {
ext.downloadFile = { localPath, remoteURL ->
def f = new File(localPath)
if (!f.exists()) {
new URL(remoteURL).withInputStream{ i -> f.withOutputStream{ it << i }}
}
}

doLast {
// https://github.com/vuejs/
downloadFile('./src/html/common/vue/vue.global.prod.js', 'https://unpkg.com/[email protected]/dist/vue.global.prod.js')

// https://github.com/intlify/vue-i18n
downloadFile('./src/html/common/vue/vue-i18n.global.prod.js', 'https://unpkg.com/[email protected]/dist/vue-i18n.global.prod.js')

// https://github.com/axios/axios
downloadFile('./src/html/common/vue/axios.min.js', 'https://unpkg.com/[email protected]/dist/axios.min.js')
}
}

jar.dependsOn(downloadJavascriptDependencies)
2 changes: 2 additions & 0 deletions doc/config-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ sepa:
subject_prefix: 'AWECON'
success_redirect: 'http://localhost:10000/app/register'
failure_redirect: 'http://localhost:10000/app/register'
rooms:
manage: false
choices:
flags:
hc:
Expand Down
4 changes: 1 addition & 3 deletions src/html/common/vue/localizations/de-DE.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export const de_DE = {
rooms: {
app: {
title: 'Zimmerverwaltung',
},
list: {
title: 'Zimmerliste',
empty: 'Aktuell sind keine Zimmer definiert. Du solltest welche anlegen.',
header: {
no: "Nr.",
Expand Down
4 changes: 1 addition & 3 deletions src/html/common/vue/localizations/en-US.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export const en_US = {
rooms: {
app: {
title: 'Manage Rooms',
},
list: {
title: 'Current Rooms',
empty: 'There are currently no rooms. You should create one.',
header: {
no: "No.",
Expand Down
8 changes: 4 additions & 4 deletions src/html/common/vue/rooms/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export const App = {
RoomList,
RoomCreateForm,
},
template: `<td class="contentbox">
<div class="headline"><br/>{{ $t('rooms.app.title') }}</div>
<hr class="contentbox"/>
template: `
<ErrorList />
<div class="headline"><br/>{{ $t('rooms.list.title') }}</div>
<hr class="contentbox"/>
<RoomList />
<div class="headline"><br/>{{ $t('rooms.create.title') }}</div>
<hr class="contentbox"/>
<RoomCreateForm />
</td>`
`
}
17 changes: 0 additions & 17 deletions src/html/common/vue/rooms/index.html

This file was deleted.

4 changes: 4 additions & 0 deletions src/html/common/vue/rooms/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// main entry point of the room application, for use in a script tag of type module
//
// see templates rooms_js.vm and rooms.vm

import { de_DE } from '../localizations/de-DE.js'
import { en_US } from '../localizations/en-US.js'
import { App } from './app.js'
Expand Down
1 change: 1 addition & 0 deletions src/java/org/eurofurence/regsys/backend/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ public class Strings extends StringsEF {
public static SepaPageMsgs sepaPage = new SepaPageMsgs();
public static StartPageMsgs startPage = new StartPageMsgs();
public static StatsPageMsgs statsPage = new StatsPageMsgs();
public static RoomsPageMsgs roomsPage = new RoomsPageMsgs();
}
4 changes: 4 additions & 0 deletions src/java/org/eurofurence/regsys/backend/StringsEF.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,8 @@ public String timeUntilStart(long days, long hours, long mins, long secs) {
public static class StatsPageMsgs {
public String pageTitle = "Statistics";
}

public static class RoomsPageMsgs {
public String pageTitle = "Rooms";
}
}
4 changes: 4 additions & 0 deletions src/java/org/eurofurence/regsys/backend/StringsMMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,8 @@ public String timeUntilStart(long days, long hours, long mins, long secs) {
public static class StatsPageMsgs {
public String pageTitle = "Statistiken";
}

public static class RoomsPageMsgs {
public String pageTitle = "Zimmer";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ public static class SepaConfig {
public String failureRedirect;
}

public static class RoomsConfig {
@JsonProperty("manage")
public boolean manage;
}

@JsonProperty("choices")
public Choices choices;

Expand All @@ -193,4 +198,7 @@ public static class SepaConfig {

@JsonProperty("sepa")
public SepaConfig sepa;

@JsonProperty("rooms")
public RoomsConfig rooms;
}
12 changes: 12 additions & 0 deletions src/java/org/eurofurence/regsys/web/forms/NavbarForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.eurofurence.regsys.backend.Strings;
import org.eurofurence.regsys.backend.enums.RoomManagementOption;
import org.eurofurence.regsys.repositories.attendees.Attendee;
import org.eurofurence.regsys.repositories.config.Configuration;
import org.eurofurence.regsys.repositories.errors.UnauthorizedException;

import java.util.function.Predicate;
Expand Down Expand Up @@ -167,6 +168,17 @@ public String getSendAnnouncementsURL() {
return "bulkmail";
}

// rooms

public boolean showManageRooms() {
Configuration conf = getPage().getConfiguration();
return conf.rooms != null && conf.rooms.manage;
}

public String getManageRoomsURL() {
return "rooms";
}

// edit own registration

private boolean loggedInRegisteredAttendeeStatusCondition(Predicate<Constants.MemberStatus> condition) {
Expand Down
47 changes: 47 additions & 0 deletions src/java/org/eurofurence/regsys/web/pages/RoomsPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.eurofurence.regsys.web.pages;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.eurofurence.regsys.backend.Strings;

import java.util.ArrayList;
import java.util.HashMap;

public class RoomsPage extends Page {
@Override
public String handleRequest() throws ServletException {
refreshSessionTimeout();

HashMap<String, Object> veloContext = new HashMap<>();

veloContext.put("navbar", getNavbarForm());
veloContext.put("page", this);

return Page.renderTemplate(getServletContext(), "html.vm", veloContext);
}

@Override
protected String getPageTitle() {
return Strings.roomsPage.pageTitle;
}

@Override
public String getPageTemplateFile() {
return "rooms.vm";
}

@Override
public ArrayList<String> getHeaderJsFileList() {
ArrayList<String> lst = new ArrayList<>();
lst.add("js/rooms_js.vm");
return lst;
}

@Override
public void initialize(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
super.initialize(servletContext, request, response, session);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PageRequestHandlerFactory {
suppliersByPathInfo.put("/list", ListPage::new);
suppliersByPathInfo.put("/mass-approve", MassApprovePage::new);
suppliersByPathInfo.put("/payment", PaymentPage::new);
suppliersByPathInfo.put("/rooms", RoomsPage::new);
suppliersByPathInfo.put("/search", SearchPage::new);
suppliersByPathInfo.put("/sepa", SepaPage::new);
suppliersByPathInfo.put("/start", StartPage::new);
Expand Down
4 changes: 4 additions & 0 deletions src/tpl/common/pages/js/rooms_js.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script src="../vue/vue.global.prod.js"></script>
<script src="../vue/vue-i18n.global.prod.js"></script>
<script src="../vue/axios.min.js"></script>
<script src="../vue/rooms/index.js" type="module"></script>
3 changes: 3 additions & 0 deletions src/tpl/common/pages/navbar.vm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#if( $navbar.showAnnouncementsEditAndSend() )##
<img src="$pathImages/bullet.jpg"/>&nbsp;<a class="navigation" HREF="$navbar.EditAnnouncementsURL">$strNavEditAnnouncements</a><br/>
#end##
#if( $navbar.showManageRooms() )##
<img src="$pathImages/bullet.jpg"/>&nbsp;<a class="navigation" HREF="$navbar.ManageRoomsURL">$strNavManageRooms</a><br/>
#end##
##
##
#if( $navbar.showEditOwnRegistration() )##
Expand Down
10 changes: 10 additions & 0 deletions src/tpl/common/pages/rooms.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#parse( "strings/rooms.strings.vm" )
<td class="contentbox">
#parse( "local/localmessage.vm" )

<div class="pageheader">$strRoomManagementTitle</div>
<hr class="contentbox"/>

<noscript><b>$strJavascriptDisabled</b> $strPleaseEnableJavascript</noscript>
<div id="app"></div>
</td>
1 change: 1 addition & 0 deletions src/tpl/common/pages/strings/navbar.strings.vm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#set($strNavExport = "Export")##
#set($strNavManageBans = "Manage&nbsp;Bans")##
#set($strNavEditAnnouncements = "Edit&nbsp;Announcements")##
#set($strNavManageRooms = "Rooms")##
#set($strNavMarkOverdue = "Mark&nbsp;Overdue")##
#set($strNavSendNotifications = "Send&nbsp;Notifications")##
#set($strNavEditOwnRegistration = "Edit&nbsp;my&nbsp;Registration")##
Expand Down
4 changes: 4 additions & 0 deletions src/tpl/common/pages/strings/rooms.strings.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Strings used in the room management template wrapper
#set( $strRoomManagementTitle = "Manage Rooms")##
#set( $strJavascriptDisabled = "Javascript is disabled!")##
#set( $strPleaseEnableJavascript = "Please enable it to use this page.")##
1 change: 1 addition & 0 deletions src/tpl/mmc/pages/strings/navbar.strings.vm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#set($strNavExport = "Exportieren")##
#set($strNavManageBans = "Sperrungen&nbsp;verwalten")##
#set($strNavEditAnnouncements = "Bearbeite&nbsp;Ank&uuml;ndigungen")##
#set($strNavManageRooms = "Zimmer")##
#set($strNavMarkOverdue = "Markiere&nbsp;offene&nbsp;Zahlungen")##
#set($strNavSendNotifications = "Sende&nbsp;Benachrichtigungen")##
#set($strNavEditOwnRegistration = "Bearbeite&nbsp;meine&nbsp;Registrierung")##
Expand Down
4 changes: 4 additions & 0 deletions src/tpl/mmc/pages/strings/rooms.strings.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Strings used in the room management template wrapper
#set( $strRoomManagementTitle = "Zimmerverwaltung")##
#set( $strJavascriptDisabled = "Javascript ist deaktiviert!")##
#set( $strPleaseEnableJavascript = "Bitte einschalten, um diese Seite zu benutzen.")##

0 comments on commit 02281f6

Please sign in to comment.