Skip to content

Commit

Permalink
Small updates and fixed match-test view.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-flynn committed Oct 9, 2019
1 parent b502da7 commit 4b1095f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ interface IState {

class MatchPlayScreen extends React.Component<IProps, IState> {
private _timer: MatchTimer;
private _matchEnded: boolean;

constructor(props: IProps) {
super(props);

this._timer = new MatchTimer();
this._matchEnded = false;

this.state = {
match: this.props.match,
Expand All @@ -68,6 +70,7 @@ class MatchPlayScreen extends React.Component<IProps, IState> {
this._timer.removeAllListeners("match-tele");
this._timer.removeAllListeners("match-endgame");
this._timer.removeAllListeners("match-abort");
this._matchEnded = true;
});
this._timer.start();
this.updateTimer();
Expand All @@ -92,18 +95,20 @@ class MatchPlayScreen extends React.Component<IProps, IState> {
this._timer.removeAllListeners("match-end");
});
SocketProvider.on("score-update", (matchJSON: any) => {
const oldMatch = this.props.match;
const match: Match = new Match().fromJSON(matchJSON);
const seasonKey: string = match.matchKey.split("-")[0];
match.matchDetails = Match.getDetailsFromSeasonKey(seasonKey).fromJSON(matchJSON.details);
match.participants = matchJSON.participants.map((pJSON: any) => new MatchParticipant().fromJSON(pJSON));
match.participants.sort((a: MatchParticipant, b: MatchParticipant) => a.station - b.station);
for (let i = 0; i < match.participants.length; i++) {
if (typeof oldMatch.participants !== "undefined" && typeof oldMatch.participants[i].team !== "undefined") {
match.participants[i].team = oldMatch.participants[i].team; // Both are sorted by station, so we can safely assume/do this.
if (!this._matchEnded) {
const oldMatch = this.props.match;
const match: Match = new Match().fromJSON(matchJSON);
const seasonKey: string = match.matchKey.split("-")[0];
match.matchDetails = Match.getDetailsFromSeasonKey(seasonKey).fromJSON(matchJSON.details);
match.participants = matchJSON.participants.map((pJSON: any) => new MatchParticipant().fromJSON(pJSON));
match.participants.sort((a: MatchParticipant, b: MatchParticipant) => a.station - b.station);
for (let i = 0; i < match.participants.length; i++) {
if (typeof oldMatch.participants !== "undefined" && typeof oldMatch.participants[i].team !== "undefined") {
match.participants[i].team = oldMatch.participants[i].team; // Both are sorted by station, so we can safely assume/do this.
}
}
this.setState({match: match});
}
this.setState({match: match});
});
}

Expand Down
2 changes: 1 addition & 1 deletion ems-core/package.electron.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ems-core",
"author": "The Orange Alliance",
"description": "An improved event experience.",
"version": "2.15.0",
"version": "2.16.0",
"private": true,
"main": "public/desktop/electron.js",
"homepage": "./public/desktop/",
Expand Down
2 changes: 1 addition & 1 deletion ems-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ems-core",
"version": "2.15.0",
"version": "2.16.0",
"private": true,
"main": "build/electron.js",
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions ems-core/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class App extends React.Component<IProps> {
}

public componentDidMount() {
if (this.props.toaConfig.enabled) {
UploadManager.initialize(1, this.props.toaConfig);
}
UploadManager.initialize(1, this.props.toaConfig);

this.initializeSocket(this.props.networkHost);
WebProvider.initialize(this.props.networkHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OceanOpportunitiesTeamStatus extends React.Component<IProps> {
const teamsView = participants.map((p: MatchParticipant) => {
return (
<Grid.Row key={p.matchParticipantKey} className="match-play-team">
<Grid.Column largeScreen={8} widescreen={10} className="center-left-items"><Form.Dropdown disabled={!canChangeTeam || disabled} fluid={true} search={true} selection={true} value={p.teamKey} options={this.getTeamOptions()} onChange={this.updateParticipant.bind(this, p)}/></Grid.Column>
<Grid.Column largeScreen={7} widescreen={9} className="center-left-items"><Form.Dropdown disabled={!canChangeTeam || disabled} fluid={true} search={true} selection={true} value={p.teamKey} options={this.getTeamOptions()} onChange={this.updateParticipant.bind(this, p)}/></Grid.Column>
<Grid.Column largeScreen={8} widescreen={6}><Button onClick={this.changeCardStatus.bind(this, p)} disabled={disabled} color={this.getButtonColor(p.cardStatus)} fluid={true}>{this.getButtonText(p.cardStatus)}</Button></Grid.Column>
</Grid.Row>
);
Expand Down
16 changes: 15 additions & 1 deletion ems-core/src/managers/UploadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class UploadManager {
TOAProvider.initialize(toaConfig);
}
if (this._type === UploadManager.FGC) {
FGCProvider.initialize("127.0.0.1", 8088); // DEBUG
FGCProvider.initialize("173.231.247.208", 8088); // DEBUG
}
}

Expand Down Expand Up @@ -79,6 +79,20 @@ class UploadManager {
}
}

public testConnection(): Promise<any> {
if (this._type === UploadManager.TOA) {
return TOAProvider.ping();
} else if (this._type === UploadManager.FGC) {
return FGCProvider.ping();
} else {
return new Promise<any>((resolve, reject) => reject());
}
}

public get type(): number {
return this._type;
}

}

export const TOA = UploadManager.TOA;
Expand Down
5 changes: 3 additions & 2 deletions ems-core/src/views/match-test/MatchTestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "@the-orange-alliance/lib-ems";
import ExplanationIcon from "../../components/ExplanationIcon";
import NumericInput from "../../components/NumericInput";
import UploadManager from "../../managers/UploadManager";

interface IProps {
slaveModeEnabled?: boolean,
Expand Down Expand Up @@ -128,7 +129,7 @@ class MatchTestView extends React.Component<IProps, IState> {
<Grid.Column width={2}><h3>REST API {slaveModeEnabled ? "(MASTER)" : ""}</h3></Grid.Column>
<Grid.Column width={2}><h3>SocketIO Server</h3></Grid.Column>
<Grid.Column width={2}><h3>Web Server</h3></Grid.Column>
<Grid.Column width={2}><h3>TheOrangeAlliance</h3></Grid.Column>
<Grid.Column width={2}><h3>{UploadManager.type === 0 ? "TheOrangeAlliance" : "TheGlobalAlliance"}</h3></Grid.Column>
<Grid.Column width={2}><h3>Audience Display</h3></Grid.Column>
<Grid.Column width={3}/>
</Grid.Row>
Expand Down Expand Up @@ -305,7 +306,7 @@ class MatchTestView extends React.Component<IProps, IState> {

private testTOA() {
this.setState({toaTesting: true});
TOAProvider.ping().then(() => {
UploadManager.testConnection().then(() => {
this.setState({toaConnected: true, toaTested: true, toaTesting: false});
}).catch((error: HttpError) => {
DialogManager.showErrorBox(error);
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-management-system",
"description": "Hub for all programs in the EMS suite.",
"version": "2.15.0",
"version": "2.16.0",
"private": true,
"scripts": {
"api": "cd ems-api/ && npm start",
Expand All @@ -15,10 +15,11 @@
"build-ref": "cd ref-tablet/ && npm run build && cd ../",
"build-pit": "cd pit-display/ && npm run build && cd ../",
"build-core": "cd ems-core/ && npm run build && cd ../",
"build-home": "cd ems-home/ && npm run build && cd ../",
"build-api": "cd ems-api/ && npm run build && cd ../",
"build-sck": "cd ems-socket/ && npm run build && cd ../",
"build-web": "cd ems-web/ && npm run build && cd ../",
"build-webapps": "npm run build-audience && npm run build-ref && npm run build-core",
"build-webapps": "npm run build-audience && npm run build-ref && npm run build-core && npm run build-home",
"build-services": "npm run build-api && npm run build-sck && npm run build-web",
"prebuild": "gulp prebuild:prod",
"build": "npm run build-services && npm run build-webapps",
Expand Down

0 comments on commit 4b1095f

Please sign in to comment.