mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
Regatta list - Show live races in regatta progress bar
This commit is contained in:
1 parent
7f7e6b9c21
commit
11e951dfc2
4 files changed
+22
-15
No files matched your search
+9
-10
@@ -41,12 +41,6 @@ public class MultiRegattaListStepsBody extends UIObject implements RequiresResiz
|
||||
nameUi.getStyle().setVisibility(Visibility.HIDDEN);
|
||||
seriesName = DEFAULT_SERIES_NAME.equals(seriesProgress.getName()) ? I18N.races() : seriesProgress.getName();
|
||||
nameUi.setInnerText(seriesName);
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
@Override
|
||||
public void execute() {
|
||||
renderNames();
|
||||
}
|
||||
});
|
||||
if (seriesProgress.isCompleted()) {
|
||||
progressUi.setInnerText(String.valueOf(seriesProgress.getTotalRaceCount()));
|
||||
} else {
|
||||
@@ -55,21 +49,26 @@ public class MultiRegattaListStepsBody extends UIObject implements RequiresResiz
|
||||
seriesProgress.getProgressRaceCount(), seriesProgress.getTotalRaceCount()));
|
||||
}
|
||||
addFleetProgresses(seriesProgress.getFleetState(), seriesProgress.getTotalRaceCount());
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
@Override
|
||||
public void execute() {
|
||||
renderNames();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void addFleetProgresses(Map<FleetMetadataDTO, RegattaProgressFleetDTO> fleetStates, int totalRaceCount) {
|
||||
double height = fleetStates.isEmpty() ? 100.0 : 100.0 / fleetStates.size();
|
||||
for (Entry<FleetMetadataDTO, RegattaProgressFleetDTO> fleetState : fleetStates.entrySet()) {
|
||||
double fleetWidth = (fleetState.getValue().getFinishedRaceCount() * 100.0) / totalRaceCount;
|
||||
double finishedWidth = (fleetState.getValue().getFinishedRaceCount() * 100.0) / totalRaceCount;
|
||||
double liveWidth = (fleetState.getValue().getFinishedAndLiveRaceCount() * 100.0) / totalRaceCount;
|
||||
String fleetColor = fleetState.getKey().getFleetColor();
|
||||
MultiRegattaListStepsBodyFleet fleet = new MultiRegattaListStepsBodyFleet(fleetWidth, height, fleetColor);
|
||||
MultiRegattaListStepsBodyFleet fleet = new MultiRegattaListStepsBodyFleet(finishedWidth, liveWidth, height, fleetColor);
|
||||
fleetsContainerUi.appendChild(fleet.getElement());
|
||||
}
|
||||
}
|
||||
|
||||
private void renderNames() {
|
||||
|
||||
if (getElement().getOffsetWidth() < nameUi.getOffsetWidth() + checkUi.getOffsetWidth()
|
||||
+ progressUi.getOffsetWidth()) {
|
||||
String[] tokens = seriesName.split(" ");
|
||||
|
||||
+6
-3
@@ -16,12 +16,15 @@ public class MultiRegattaListStepsBodyFleet extends UIObject {
|
||||
}
|
||||
|
||||
@UiField DivElement fleetProgressBarUi;
|
||||
@UiField DivElement fleetProgressBarLiveUi;
|
||||
|
||||
public MultiRegattaListStepsBodyFleet(double width, double height, String color) {
|
||||
public MultiRegattaListStepsBodyFleet(double finishedWidth, double liveWidth, double height, String color) {
|
||||
setElement(uiBinder.createAndBindUi(this));
|
||||
getElement().getStyle().setHeight(height, Unit.PCT);
|
||||
fleetProgressBarUi.getStyle().setWidth(width, Unit.PCT);
|
||||
fleetProgressBarUi.getStyle().setWidth(finishedWidth, Unit.PCT);
|
||||
fleetProgressBarUi.getStyle().setBackgroundColor(color);
|
||||
fleetProgressBarLiveUi.getStyle().setWidth(liveWidth, Unit.PCT);
|
||||
fleetProgressBarLiveUi.getStyle().setBackgroundColor("#ff4040");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+3
-2
@@ -4,7 +4,8 @@
|
||||
<ui:with field="i18n" type="com.sap.sailing.gwt.ui.client.StringMessages" />
|
||||
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
|
||||
<ui:with field="local_res" type="com.sap.sailing.gwt.home.client.place.event.partials.multiRegattaList.MultiRegattaListResources" />
|
||||
<div class="{local_res.css.regattalistitem_steps_step_fleets_fleet}">
|
||||
<div class="{local_res.css.regattalistitem_steps_step_fleets_fleet_progress}" ui:field="fleetProgressBarUi"></div>
|
||||
<div class="{local_res.css.regattalistitem_steps_step_fleets_fleet}" style="position:relative;">
|
||||
<div class="{local_res.css.regattalistitem_steps_step_fleets_fleet_progress}" style="position:absolute; top:0;" ui:field="fleetProgressBarLiveUi"></div>
|
||||
<div class="{local_res.css.regattalistitem_steps_step_fleets_fleet_progress}" style="position:absolute; top:0;" ui:field="fleetProgressBarUi"></div>
|
||||
</div>
|
||||
</ui:UiBinder>
|
||||
+4
@@ -22,4 +22,8 @@ public class RegattaProgressFleetDTO implements DTO {
|
||||
public int getLiveRaceCount() {
|
||||
return liveRaceCount;
|
||||
}
|
||||
|
||||
public int getFinishedAndLiveRaceCount() {
|
||||
return finishedRaceCount + liveRaceCount;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user