Skip to content

Commit

Permalink
gather resources for publicresults styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Aug 7, 2023
1 parent e0316ee commit de97de8
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 159 deletions.
1 change: 1 addition & 0 deletions owlcms/src/main/java/app/owlcms/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public static void injectSuppliers() {
* @throws Exception the exception
*/
public static void main(String... args) throws Exception {
new ResourceWalker().getPRResourceMap(Locale.ENGLISH);
// there is no config read so far.
demoResetDelay = StartupUtils.getIntegerParam("publicDemo", null);
if (demoResetDelay != null) {
Expand Down
1 change: 1 addition & 0 deletions owlcms/src/main/java/app/owlcms/data/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public Locale getLocale() {
public byte[] getLocalZipBlob() {
logger.debug("getLocalZipBlob skip={} localOverride={}",skipReading, localOverride);
if (localOverride == null || skipReading) {
//FIXME: create a zip from ./local
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import app.owlcms.data.competition.Competition;
import app.owlcms.data.config.Config;
import app.owlcms.data.group.Group;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FOPState;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
Expand Down Expand Up @@ -83,7 +83,7 @@
@Route("displays/attemptBoard")

public class AttemptBoard extends PolymerTemplate<TemplateModel> implements DisplayParameters,
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoOverride {
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoCSSOverride {

protected final static Logger logger = (Logger) LoggerFactory.getLogger(AttemptBoard.class);
protected final static Logger uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + logger.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import app.owlcms.data.competition.Competition;
import app.owlcms.data.config.Config;
import app.owlcms.data.group.Group;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FOPState;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
Expand Down Expand Up @@ -80,7 +80,7 @@

public class CurrentAthlete extends PolymerTemplate<TemplateModel>
implements DisplayParameters, SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle,
RequireDisplayLogin, VideoOverride {
RequireDisplayLogin, VideoCSSOverride {

/**
* ScoreboardModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
import app.owlcms.data.competition.Competition;
import app.owlcms.data.config.Config;
import app.owlcms.data.group.Group;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FOPState;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
Expand Down Expand Up @@ -92,7 +92,7 @@

public class Results extends PolymerTemplate<TemplateModel>
implements DisplayParameters, SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle,
RequireDisplayLogin, VideoOverride {
RequireDisplayLogin, VideoCSSOverride {

private static final int DEBOUNCE = 50;
protected JsonArray cattempts;
Expand Down Expand Up @@ -554,7 +554,7 @@ public void setUrlParameterMap(Map<String, List<String>> newParameterMap) {
}

/**
* @see app.owlcms.displays.VideoOverride#setVideo(boolean)
* @see app.owlcms.displays.video.VideoCSSOverride#setVideo(boolean)
*/
@Override
public void setVideo(boolean b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import app.owlcms.data.competition.Competition;
import app.owlcms.data.config.Config;
import app.owlcms.data.group.Group;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsFactory;
Expand Down Expand Up @@ -86,7 +86,7 @@

public class ResultsMedals extends PolymerTemplate<TemplateModel>
implements ContextFreeDisplayParameters, SafeEventBusRegistration, UIEventProcessor, BreakDisplay,
HasDynamicTitle, VideoOverride,
HasDynamicTitle, VideoCSSOverride,
RequireDisplayLogin {

private static final long DEBOUNCE = 50;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import app.owlcms.data.athleteSort.AthleteSorter;
import app.owlcms.data.competition.Competition;
import app.owlcms.data.config.Config;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsFactory;
Expand Down Expand Up @@ -72,7 +72,7 @@
@Route("displays/topsinclair")

public class TopSinclair extends PolymerTemplate<TemplateModel> implements DisplayParameters,
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoOverride {
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoCSSOverride {

final private static Logger logger = (Logger) LoggerFactory.getLogger(TopSinclair.class);
final private static Logger uiEventLogger = (Logger) LoggerFactory.getLogger("UI" + logger.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import app.owlcms.data.team.Team;
import app.owlcms.data.team.TeamResultsTreeData;
import app.owlcms.data.team.TeamTreeItem;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsFactory;
Expand Down Expand Up @@ -81,7 +81,7 @@
@Route("displays/topteams")

public class TopTeams extends PolymerTemplate<TemplateModel> implements DisplayParameters,
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoOverride {
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoCSSOverride {

final private static Logger logger = (Logger) LoggerFactory.getLogger(TopTeams.class);
private static final int SHOWN_ON_BOARD = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import app.owlcms.data.team.Team;
import app.owlcms.data.team.TeamResultsTreeData;
import app.owlcms.data.team.TeamTreeItem;
import app.owlcms.displays.VideoOverride;
import app.owlcms.displays.options.DisplayOptions;
import app.owlcms.displays.video.VideoCSSOverride;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsFactory;
Expand Down Expand Up @@ -82,7 +82,7 @@

public class TopTeamsSinclair extends PolymerTemplate<TemplateModel>
implements DisplayParameters,
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoOverride {
SafeEventBusRegistration, UIEventProcessor, BreakDisplay, HasDynamicTitle, RequireDisplayLogin, VideoCSSOverride {

/**
* Vaadin Flow propagates these variables to the corresponding Polymer template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Non-Profit Open Software License version 3.0 ("NPOSL-3.0")
* License text at https://opensource.org/licenses/NPOSL-3.0
*******************************************************************************/
package app.owlcms.monitors;
package app.owlcms.displays.video;

import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -33,7 +33,6 @@
import app.owlcms.data.athlete.LiftDefinition.Stage;
import app.owlcms.data.config.Config;
import app.owlcms.data.records.RecordEvent;
import app.owlcms.displays.VideoOverride;
import app.owlcms.fieldofplay.FOPState;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
Expand All @@ -49,18 +48,20 @@
import ch.qos.logback.classic.Logger;

/**
* Class EventMonitor
* Class StreamingEventMonitor
*
* Show athlete lifting order
* This shows an overlay when competition events such as a record attempt or jury deliberation take place.
*
*/
//FIXME: show record attempt and new record for a limited duration.

@SuppressWarnings({ "serial", "deprecation" })
@Tag("eventmonitor-template")
@JsModule("./components/EventMonitor.js")
@Route("displays/notifications")

public class EventMonitor extends PolymerTemplate<TemplateModel> implements FOPParameters,
SafeEventBusRegistration, UIEventProcessor, VideoOverride, HasDynamicTitle {
public class StreamingEventMonitor extends PolymerTemplate<TemplateModel> implements FOPParameters,
SafeEventBusRegistration, UIEventProcessor, VideoCSSOverride, HasDynamicTitle {

class Status {
BreakType breakType;
Expand Down Expand Up @@ -98,12 +99,12 @@ public String toString() {
final static int HISTORY_SIZE = 3;

final private static Logger uiEventLogger = (Logger) LoggerFactory
.getLogger("UI" + EventMonitor.class.getSimpleName());
.getLogger("UI" + StreamingEventMonitor.class.getSimpleName());

static {
uiEventLogger.setLevel(Level.WARN);
}
final private Logger logger = (Logger) LoggerFactory.getLogger(EventMonitor.class);
final private Logger logger = (Logger) LoggerFactory.getLogger(StreamingEventMonitor.class);

List<Status> history = new LinkedList<>();

Expand Down Expand Up @@ -143,7 +144,7 @@ public String toString() {
/**
* Instantiates a new results board.
*/
public EventMonitor() {
public StreamingEventMonitor() {
OwlcmsFactory.waitDBInitialized();
this.getElement().setProperty("autoversion", StartupUtils.getAutoVersion());
this.getElement().getStyle().set("width", "100%");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.owlcms.displays;
package app.owlcms.displays.video;

import java.io.FileNotFoundException;

Expand All @@ -8,7 +8,7 @@
import app.owlcms.data.config.Config;
import app.owlcms.utils.ResourceWalker;

public interface VideoOverride {
public interface VideoCSSOverride {

public void setVideo(boolean b);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
import app.owlcms.displays.scoreboard.ResultsNoLeaders;
import app.owlcms.displays.scoreboard.ResultsRankingOrder;
import app.owlcms.displays.scoreboard.ResultsRankings;
import app.owlcms.displays.video.StreamingEventMonitor;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsSession;
import app.owlcms.monitors.EventMonitor;
import app.owlcms.monitors.OBSMonitor;
import app.owlcms.nui.home.HomeNavigationContent;
import app.owlcms.nui.shared.BaseNavigationContent;
Expand Down Expand Up @@ -153,7 +153,7 @@ public VideoNavigationContent() {


Button obsMonitor = openInNewTab(OBSMonitor.class, getTranslation("OBS.MonitoringButton"));
Button eventMonitor = openInNewTab(EventMonitor.class, getTranslation("Video.EventMonitoringButton"), "video");
Button eventMonitor = openInNewTab(StreamingEventMonitor.class, getTranslation("Video.EventMonitoringButton"), "video");
VerticalLayout intro4 = new VerticalLayout();
addP(intro4, getTranslation("Video.EventMonitoringExplanation", getTranslation("Video.EventMonitoringButton")));
addP(intro4, getTranslation("OBS.MonitoringExplanation", getTranslation("OBS.MonitoringButton")));
Expand Down
22 changes: 22 additions & 0 deletions owlcms/src/test/java/app/owlcms/tests/ResourceWalkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.List;
import java.util.Locale;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import app.owlcms.Main;
import app.owlcms.data.config.Config;
import app.owlcms.data.jpa.JPAService;
import app.owlcms.utils.Resource;
import app.owlcms.utils.ResourceWalker;

public class ResourceWalkerTest {

@BeforeClass
public static void setupTests() {
Main.injectSuppliers();
JPAService.init(true, true);
Config.initConfig();
}

@Test
Expand All @@ -48,5 +55,20 @@ public void test() {
assertTrue(walker.matchesLocale("Protocol_en_ZA_JHB.xls", new Locale("en", "ZA", "JHB")));
assertFalse(walker.matchesLocale("Protocol_en_ZA_JHB.xls", new Locale("en", "ZA", "CT")));
}

@Ignore
public void testOverrideList() {
List<Resource> resourceList = new ResourceWalker().getResourceList("",
ResourceWalker::relativeName, null, Locale.ENGLISH,
false);
for (Resource resource: resourceList) {
System.out.println(resource.getFileName());
}
}

@Test
public void testPRList() {
new ResourceWalker().getPRResourceMap(Locale.ENGLISH);
}

}
7 changes: 6 additions & 1 deletion shared/src/main/java/app/owlcms/utils/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.Logger;

public class Resource implements Comparable<Resource> {

String fileName;
Path filePath;
Logger logger = (Logger) LoggerFactory.getLogger(Resource.class);

public Resource(String fileName, Path filePath) {
this.fileName = fileName;
Expand Down Expand Up @@ -51,6 +55,7 @@ public String toString() {
}

public String normalizedName() {
return fileName != null ? fileName.replace('\\', '/') : null;
String string = fileName != null ? fileName.replace('\\', '/') : null;
return string;
}
}
Loading

0 comments on commit de97de8

Please sign in to comment.