Skip to content

Commit

Permalink
fixed public scoreboard switching
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Sep 22, 2023
1 parent 9ca1658 commit 48f075f
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 118 deletions.
2 changes: 1 addition & 1 deletion launch/owlcms h2 no reset.launch
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="owlcms"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="owlcms"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dvaadin.frontend.hotdeploy=false&#13;&#10; -Dvaadin.devmode.devTools.enabled=true&#13;&#10; -Dlogback.configurationFile=logback-console.xml"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dvaadin.frontend.hotdeploy=true&#13;&#10; -Dvaadin.devmode.devTools.enabled=true&#13;&#10; -Dlogback.configurationFile=logback-console.xml"/>
</launchConfiguration>
7 changes: 5 additions & 2 deletions owlcms/frontend/components/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class Results extends LitElement {
</td>
<td class="${"club " + (item?.flagClass ?? "")}">
<div class="${item?.flagClass}" .innerHTML="${item?.flagURL} "></div>
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}"> ${item?.teamName}
<div class="clubName">
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}">${item?.teamName}</div>
</div>
</td>
<td class="vspacer"></td>
Expand Down Expand Up @@ -189,7 +190,9 @@ class Results extends LitElement {
<td class="custom2" style="${this.leadingAthleteStyles()} "> <div>${item?.custom2}</div></td>
<td class="${"club " + (item?.flagClass ?? "")} ">
<div class="${item?.flagClass}" .innerHTML="${item?.flagURL}"></div>
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}"> ${item?.teamName} </div>
<div class="clubName">
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}">${item?.teamName}</div>
</div>
</td>
<td class="vspacer"></td>
${(item?.sattempts ?? []).map(
Expand Down
7 changes: 5 additions & 2 deletions owlcms/frontend/components/ResultsLeadersRanks.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class ResultsFull extends LitElement {
</td>
<td class="${"club " + (item?.flagClass ?? "")}">
<div class="${item?.flagClass}" .innerHTML="${item?.flagURL} "></div>
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}"> ${item?.teamName}
<div class="clubName">
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}">${item?.teamName}</div>
</div>
</td>
<td class="vspacer"></td>
Expand Down Expand Up @@ -238,7 +239,9 @@ class ResultsFull extends LitElement {
<td class="custom2" style="${this.leadingAthleteStyles()} "> <div>${item?.custom2}</div></td>
<td class="${"club " + (item?.flagClass ?? "")} ">
<div class="${item?.flagClass}" .innerHTML="${item?.flagURL}"></div>
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}"> ${item?.teamName} </div>
<div class="clubName">
<div class="ellipsis" style="${"width: " + (item?.teamLength ?? "")}">${item?.teamName}</div>
</div>
</td>
<td class="vspacer"></td>
${(item?.sattempts ?? []).map(
Expand Down
16 changes: 8 additions & 8 deletions owlcms/frontend/components/ResultsMedals.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ class ResultsMedals extends LitElement {
${this.medalCategories
? html`
<table
<!-- <table
class="${"results medals " + (this.noLiftRanks ?? "")}"
style="${(this.hiddenGridStyle ?? "") +
"; padding-top: 0.5em; " +
(this.twOverride ?? "")}"
>
> -->
<table class="${this.athleteClasses()}" style="${this.athleteStyles()}">
${(this.medalCategories ?? []).map(
(mc) => html`
<tr class="head" style="${this.leadersDisplay}">
Expand Down Expand Up @@ -111,7 +112,9 @@ class ResultsMedals extends LitElement {
</td>
<td class="${"club " + (leader.flagClass ?? "")}">
<div class="${leader.flagClass}" .innerHTML="${leader.flagURL}"></div>
<div class="ellipsis">${leader.teamName}</div>
<div class="clubName">
<div class="ellipsis" style="${"width: " + (leader?.teamLength ?? "")}">${leader?.teamName}</div>
</div>
</td>
<td class="vspacer"></td>
${(leader.sattempts ?? []).map(
Expand Down Expand Up @@ -266,17 +269,14 @@ class ResultsMedals extends LitElement {

athleteClasses() {
//return "results " + (this.noLiftRanks ?? "") + " " + (this.noBest ?? "")
return "results "
return "results medals "
+ (this.showLiftRanks ? "" : " noranks")
+ (this.showBest ? "" : " nobest")
+ (this.showSinclair ? " sinclair" : " nosinclair");
}

athleteStyles() {
return (this.mode === "WAIT" ? "display: none" : "display:grid")
+ "; --top: calc(" + (this.resultLines ?? "") + " + 1)"
+ "; --bottom: " + (this.leaderLines ?? "")
+ "; --nbRanks: " + (this.nbRanks ?? "")
return "display:grid"
+ "; " + (this.leadersLineHeight ?? "")
+ "; " + (this.twOverride ?? "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class GroupSelectionMenu extends MenuBar {
static Icon xIcon;
Logger logger = (Logger) LoggerFactory.getLogger(GroupSelectionMenu.class);
{
xIcon = new Icon(VaadinIcon.CLOSE);
xIcon = new Icon(VaadinIcon.CLOSE_SMALL);
xIcon.getElement().setAttribute("style", "margin: 0px; padding: 0px");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ public void setRecordsDisplay(boolean b) {

@Override
public final void setRouteParameter(String routeParameter) {
logger.warn("setting routeParameter = {}",routeParameter);
this.routeParameter = routeParameter;
}

Expand Down Expand Up @@ -446,8 +447,12 @@ final public void setUrlParameterMap(Map<String, List<String>> parametersMap) {
this.urlParameterMap = parametersMap;
}

/**
* @see app.owlcms.apputils.queryparameters.DisplayParameters#setVideo(boolean)
*/
@Override
public void setVideo(boolean b) {
logger.warn("setVideo {} from {}", b, LoggerUtils.whereFrom());
this.video = b;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import com.google.common.eventbus.Subscribe;
import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.function.SerializableConsumer;

import app.owlcms.apputils.SoundUtils;
import app.owlcms.apputils.queryparameters.DisplayParameters;
Expand All @@ -45,7 +43,6 @@
import app.owlcms.nui.lifting.UIEventProcessor;
import app.owlcms.uievents.CeremonyType;
import app.owlcms.uievents.UIEvent;
import app.owlcms.uievents.UIEvent.LiftingOrderUpdated;
import app.owlcms.utils.URLUtils;
import ch.qos.logback.classic.Logger;
import elemental.json.Json;
Expand Down Expand Up @@ -162,14 +159,6 @@ public void setCategory(Category category) {
public void setSilenced(boolean silent) {
}

/**
* @see app.owlcms.apputils.queryparameters.DisplayParameters#setTeamWidth(java.lang.Double)
*/
@Override
public void setTeamWidth(Double teamWidth) {
pushTeamWidth();
}

@Override
public void setVideo(boolean video) {
}
Expand Down Expand Up @@ -253,13 +242,13 @@ public void slaveStartLifting(UIEvent.StartLifting e) {
setDisplay();
// If this page was opened in replacement of a display, go back to the display.
unregister(this, uiEventBus);
retrieveFromSessionStorage("pageURL", result -> {
if (result != null && !result.isBlank()) {
UI.getCurrent().getPage().setLocation(result);
} else {
this.getElement().callJsFunction("reset");
}
});
// retrieveFromSessionStorage("pageURL", result -> {
// if (result != null && !result.isBlank()) {
// UI.getCurrent().getPage().setLocation(result);
// } else {
// this.getElement().callJsFunction("reset");
// }
// });
});
}

Expand Down Expand Up @@ -291,20 +280,20 @@ protected void doEmpty() {
protected void doUpdate(UIEvent e) {
// logger.trace("---------- doUpdate {} {} {}", e != null ?
// e.getClass().getSimpleName() : "no event");
boolean leaveTopAlone = false;
if (e instanceof UIEvent.LiftingOrderUpdated) {
LiftingOrderUpdated e2 = (UIEvent.LiftingOrderUpdated) e;
if (e2.isInBreak()) {
leaveTopAlone = !e2.isDisplayToggle();
} else {
leaveTopAlone = !e2.isCurrentDisplayAffected();
}
}
//boolean leaveTopAlone = false;
// if (e instanceof UIEvent.LiftingOrderUpdated) {
// LiftingOrderUpdated e2 = (UIEvent.LiftingOrderUpdated) e;
// if (e2.isInBreak()) {
// leaveTopAlone = !e2.isDisplayToggle();
// } else {
// leaveTopAlone = !e2.isCurrentDisplayAffected();
// }
// }

FieldOfPlay fop = OwlcmsSession.getFop();
if (!leaveTopAlone) {
this.getElement().callJsFunction("reset");
}
// if (!leaveTopAlone) {
// this.getElement().callJsFunction("reset");
// }
logger.debug("updating bottom");
updateBottom(null, fop);
}
Expand Down Expand Up @@ -668,10 +657,10 @@ private boolean isMedalist(Athlete a) {
return false;
}

private void retrieveFromSessionStorage(String key, SerializableConsumer<String> resultHandler) {
getElement().executeJs("return window.sessionStorage.getItem($0);", key)
.then(String.class, resultHandler);
}
// private void retrieveFromSessionStorage(String key, SerializableConsumer<String> resultHandler) {
// getElement().executeJs("return window.sessionStorage.getItem($0);", key)
// .then(String.class, resultHandler);
// }

private void setDisplay() {
OwlcmsSession.withFop(fop -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import java.io.FileNotFoundException;

import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.dom.Element;

import app.owlcms.data.config.Config;
import app.owlcms.utils.ResourceWalker;
import ch.qos.logback.classic.Logger;

public interface VideoCSSOverride {

Expand All @@ -15,14 +18,18 @@ public interface VideoCSSOverride {
public boolean isVideo();

public default void checkVideo(String cssPath, String routeParameter, Component component) {
Logger logger = (Logger)LoggerFactory.getLogger(VideoCSSOverride.class);
try {
setVideo(routeParameter != null && routeParameter.contentEquals("video"));
boolean b = routeParameter != null && routeParameter.contentEquals("video");
setVideo(b);
logger.warn("checking video {} {}", routeParameter, b);
// use video override if /video is in the URL and the override stylesheet exists.
ResourceWalker.getFileOrResourcePath(cssPath);
Element element = component.getElement();
element.setProperty("stylesDir", Config.getCurrent().getParamStylesDir());
element.setProperty("video", routeParameter != null ? routeParameter + "/" : "");
} catch (FileNotFoundException e) {
logger.warn("not video!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.router.QueryParameters;
import com.vaadin.flow.router.Route;

import app.owlcms.apputils.queryparameters.DisplayParameters;
import app.owlcms.apputils.queryparameters.SoundParameters;
import app.owlcms.data.config.Config;
import app.owlcms.displays.scoreboard.Results;
import app.owlcms.init.OwlcmsSession;
import ch.qos.logback.classic.Logger;

Expand All @@ -22,6 +20,12 @@ public class PublicNoLeadersPage extends PublicScoreboardPage {

Logger logger = (Logger) LoggerFactory.getLogger(PublicNoLeadersPage.class);

/**
* To avoid components being injected more than once, the initialization work
* is done in an init() method that is overridden as required.
*
* @see PublicScoreboardPage#init()
*/
public PublicNoLeadersPage() {
// intentionally empty. superclass will call init() as required.
}
Expand All @@ -32,13 +36,7 @@ public String getPageTitle() {
}

@Override
protected void init() {
// only difference is the default values
var board = new Results();
this.setBoard(board);
this.addComponent(board);
this.ui = UI.getCurrent();

public void setDefaultParameters() {
// when navigating to the page, Vaadin will call setParameter+readParameters
// these parameters will be applied.
setDefaultParameters(QueryParameters.simple(Map.of(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
package app.owlcms.nui.displays.scoreboards;

import java.util.Map;

import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.router.QueryParameters;
import com.vaadin.flow.router.Route;

import app.owlcms.apputils.queryparameters.DisplayParameters;
import app.owlcms.apputils.queryparameters.SoundParameters;
import app.owlcms.data.config.Config;
import app.owlcms.displays.scoreboard.ResultsRankingOrder;
import app.owlcms.init.OwlcmsSession;
import ch.qos.logback.classic.Logger;

Expand All @@ -32,20 +24,7 @@ public String getPageTitle() {
}

@Override
protected void init() {
var board = new ResultsRankingOrder();
this.setBoard(board);
this.addComponent(board);
this.ui = UI.getCurrent();

setDefaultParameters(QueryParameters.simple(Map.of(
SoundParameters.SILENT, "true",
SoundParameters.DOWNSILENT, "true",
DisplayParameters.DARK, "true",
DisplayParameters.LEADERS, "true",
DisplayParameters.RECORDS, "true",
DisplayParameters.ABBREVIATED,
Boolean.toString(Config.getCurrent().featureSwitch("shortScoreboardNames")))));
public void setDefaultParameters() {
super.setDefaultParameters();
}

}
Loading

0 comments on commit 48f075f

Please sign in to comment.