Skip to content

Commit

Permalink
Update React Native to add 2019 views
Browse files Browse the repository at this point in the history
0d581d7d Add 2019 Event Insights (#14)
1401d7c Add 2019 match breakdown (#10)
2445721 fix bucket path
d4dcc09 add missing function
bcd046f fix deploy script
20bb731 travis fixes
0af7ec6 set up travis for prod (#9)
7bf22b9 Travis auto build/deploy setup (now with documentation!) (#7)

git-subtree-dir: subtrees/the-blue-alliance-react
git-subtree-split: 0d581d7d78c3f677cb021bdd4a9326b2b36c3f1d
  • Loading branch information
ZachOrr authored Feb 17, 2019
1 parent 7d099ca commit 76299e2
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 8 deletions.
7 changes: 6 additions & 1 deletion subtrees/the-blue-alliance-react/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ node_modules
.nvm

ios/
ios.zip
android/
react-native.zip
gcp-service-key.json
*-tba-dev-*.json
*-firebase-*.json
ops/deploy_keys.tar
34 changes: 34 additions & 0 deletions subtrees/the-blue-alliance-react/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
language: node_js

branches:
only:
- master

before_install:
- nvm install 9

install:
- travis_retry npm install
- travis_retry npm install -g react-native-cli

before_deploy:
- openssl aes-256-cbc -K $encrypted_e4ef44d57242_key -iv $encrypted_e4ef44d57242_iv -in ops/deploy_keys.tar.enc -out ops/deploy_keys.tar -d
- ./ops/manage_deploy_keys.sh -x

stages:
- test
- name: deploy
if: (type = push) AND (branch = master)

jobs:
include:
- script: npm test
- stage: deploy
script: skip
deploy:
skip_cleanup: true
provider: script
script: ./ops/travis-deploy.sh
on:
branch: master

16 changes: 9 additions & 7 deletions subtrees/the-blue-alliance-react/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The Blue Alliance - Rect Native
The Blue Alliance - React Native
===

React Native code used in The Blue Alliance's iOS app
Expand Down Expand Up @@ -29,23 +29,25 @@ You can test the React Native code locally with [The Blue Alliance for iOS](http
* To view RN logs: `react-native log-ios`
* Debugging is easier if you install [react-devtools](https://github.com/facebook/react-devtools/tree/master/packages/react-devtools)


Building
Building Locally
===
For compiling the React Native bundle to be used offline. The iOS app expects the hosted files to be zipped in a file called `ios.zip`
For compiling the React Native bundle to be used offline. The iOS app expects the hosted files to be zipped in a file called `react-native.zip`

```
$ mkdir ios
$ react-native bundle --platform ios --dev false --assets-dest ios --entry-file index.ios.js --bundle-output ios/main.jsbundle --reset-cache
$ zip -r ios.zip ios/
$ zip -r react-native.zip ios/
```

Building and Deploying with Travis
===
For building and deploying with Travis, follow the setup guide available [HERE](travis-setup.md).

Contributing
============

Want to add features, fix bugs, or just poke around the code? No problem!

Project Communication
Project Communication
---
- Keep up to date with the [mailing list](https://groups.google.com/forum/#!forum/thebluealliance-developers).
- Chat with us on our [Slack team](https://the-blue-alliance.slack.com/). (Request an invite in the mailing list.)
111 changes: 111 additions & 0 deletions subtrees/the-blue-alliance-react/app/views/EventInsights2019.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
'use strict';

import React from 'react';
import {
Text,
View
} from 'react-native';
import TableSectionHeader from '../componets/TableSectionHeader';
import InsightRow from '../componets/InsightRow';
import { round } from '../helpers/number';
import {
scoreFor,
percentageFor,
bonusStat,
highScoreString,
} from '../helpers/insights';

export default class EventInsights2019 extends React.Component {
render() {
return (
<View>
{/* Match Stats */}
<TableSectionHeader>Match Stats</TableSectionHeader>

<InsightRow title='High Score'
qual={highScoreString(this.props.qual, 'high_score')}
playoff={highScoreString(this.props.playoff, 'high_score')}/>

<InsightRow title='Average Match Score'
qual={scoreFor(this.props.qual, 'average_score')}
playoff={scoreFor(this.props.playoff, 'average_score')}/>

<InsightRow title='Average Winning Score'
qual={scoreFor(this.props.qual, 'average_win_score')}
playoff={scoreFor(this.props.playoff, 'average_win_score')}/>

<InsightRow title='Average Win Margin'
qual={scoreFor(this.props.qual, 'average_win_margin')}
playoff={scoreFor(this.props.playoff, 'average_win_margin')}/>

<InsightRow title='Average Sandstorm Bonus Points'
qual={scoreFor(this.props.qual, 'average_sandstorm_bonus_auto')}
playoff={scoreFor(this.props.playoff, 'average_sandstorm_bonus_auto')}/>

<InsightRow title='Average Hatch Panel Points'
qual={scoreFor(this.props.qual, 'average_hatch_panel_points')}
playoff={scoreFor(this.props.playoff, 'average_hatch_panel_points')}/>

<InsightRow title='Average Cargo Points'
qual={scoreFor(this.props.qual, 'average_cargo_points')}
playoff={scoreFor(this.props.playoff, 'average_cargo_points')}/>

<InsightRow title='Average HAB Climb Points'
qual={percentageFor(this.props.qual, 'average_hab_climb_teleop')}
playoff={percentageFor(this.props.playoff, 'average_hab_climb_teleop')}/>

<InsightRow title='Average Foul Points'
qual={scoreFor(this.props.qual, 'average_foul_score')}
playoff={scoreFor(this.props.playoff, 'average_foul_score')}/>

<InsightRow title='Average Score'
qual={scoreFor(this.props.qual, 'average_score')}
playoff={scoreFor(this.props.playoff, 'average_score')}/>

{/* Match Stats */}
<TableSectionHeader>Bonus Stats (# successful / # opportunities)</TableSectionHeader>

<InsightRow title='Cross HAB Line'
qual={bonusStat(this.props.qual, 'cross_hab_line_count')}
playoff={bonusStat(this.props.playoff, 'cross_hab_line_count')}/>

<InsightRow title='Cross HAB Line in Sandstorm'
qual={bonusStat(this.props.qual, 'cross_hab_line_sandstorm_count')}
playoff={bonusStat(this.props.playoff, 'cross_hab_line_sandstorm_count')}/>

<InsightRow title='Complete 1 Rocket'
qual={bonusStat(this.props.qual, 'complete_1_rocket_count')}
playoff={bonusStat(this.props.playoff, 'complete_1_rocket_count')}/>

<InsightRow title='Complete 2 Rockets'
qual={bonusStat(this.props.qual, 'complete_2_rockets_count')}
playoff={bonusStat(this.props.playoff, 'complete_2_rockets_count')}/>

<InsightRow title='Complete Rocket RP'
qual={bonusStat(this.props.qual, 'rocket_rp_achieved')}
playoff={bonusStat(this.props.playoff, 'rocket_rp_achieved')}/>

<InsightRow title='Level 1 HAB Climb'
qual={bonusStat(this.props.qual, 'level1_climb_count')}
playoff={bonusStat(this.props.playoff, 'level1_climb_count')}/>

<InsightRow title='Level 2 HAB Climb'
qual={bonusStat(this.props.qual, 'level2_climb_count')}
playoff={bonusStat(this.props.playoff, 'level2_climb_count')}/>

<InsightRow title='Level 3 HAB Climb'
qual={bonusStat(this.props.qual, 'level3_climb_count')}
playoff={bonusStat(this.props.playoff, 'level3_climb_count')}/>

<InsightRow title='"HAB Docking RP'
qual={bonusStat(this.props.qual, 'climb_rp_achieved')}
playoff={bonusStat(this.props.playoff, 'climb_rp_achieved')}/>

<InsightRow title='"Unicorn Matches" (Win + Complete Rocket + HAB Docking)'
qual={bonusStat(this.props.qual, 'unicorn_matches')}
playoff={bonusStat(this.props.playoff, 'unicorn_matches')}/>

</View>
);
}
}
169 changes: 169 additions & 0 deletions subtrees/the-blue-alliance-react/app/views/MatchBreakdown2019.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import React from 'react';
import ReactNative from 'react-native';
import {
Text,
View
} from 'react-native';
import BreakdownRow from '../componets/BreakdownRow';
import breakdown from '../styles/breakdown';
import images from '../config/images';

// Override our Image and Text to have specific sizes
const Image = ({ style, ...props }) => <ReactNative.Image style={[breakdown.imageSize, style]} {...props} />;

export default class MatchBreakdown2019 extends React.Component {

checkImage() {
return (
<Image source={images.check} />
);
}

xImage() {
return (
<Image source={images.clear} />
);
}

getSandstormBonusFor(breakdown, robotNumber) {
if (breakdown["habLineRobot" + robotNumber] == "CrossedHabLineInSandstorm") {
let result = breakdown["preMatchLevelRobot" + robotNumber]
if (result.includes("HabLevel")) {
return `Level ${result.substr(-1)}`
}
}
return "--"
}

getHABClimbFor(breakdown, robotNumber) {
let result = breakdown["endgameRobot" + robotNumber]
if (result.includes("HabLevel")) {
return `Level ${result.substr(-1)}`
}
return "--"
}

getCargoShipDataFor(breakdown) {
var panelCount = 0
var cargoCount = 0

for (let i = 1; i <= 8; i++) {
if (breakdown["bay" + i].includes("Panel")) {
panelCount++
}
if (breakdown["bay" + i].includes("Cargo")) {
panelCount++
}
}
return `${panelCount} / ${cargoCount}`
}

getRocketShipDataFor(breakdown, rocketLocation) {
var locations = [
"topLeftRocket",
"topRightRocket",
"midLeftRocket",
"midRightRocket",
"lowLeftRocket",
"lowRightRocket"
]
var panelCount = 0
var cargoCount = 0
locations.forEach(location => {
if (breakdown[location + rocketLocation].includes("Panel")) {
panelCount++
}
if (breakdown[location + rocketLocation].includes("Cargo")) {
cargoCount++
}
});
return `${panelCount} / ${cargoCount}`
}


render() {
return (
<View style={breakdown.container}>

<BreakdownRow data={["Teams", this.props.redTeams, this.props.blueTeams]} vertical={true} subtotal={true} />

<BreakdownRow data={["Robot 1 Sandstorm Bonus",
this.getSandstormBonusFor(this.props.redBreakdown, 1),
this.getSandstormBonusFor(this.props.blueBreakdown, 1)]} />

<BreakdownRow data={["Robot 2 Sandstorm Bonus",
this.getSandstormBonusFor(this.props.redBreakdown, 2),
this.getSandstormBonusFor(this.props.blueBreakdown, 2)]} />

<BreakdownRow data={["Robot 3 Sandstorm Bonus",
this.getSandstormBonusFor(this.props.redBreakdown, 3),
this.getSandstormBonusFor(this.props.blueBreakdown, 3)]} />

<BreakdownRow data={["Total Sandstorm Bonus",
this.props.redBreakdown.sandStormBonusPoints,
this.props.blueBreakdown.sandStormBonusPoints]} total={true} />

<BreakdownRow data={["Cargo Ship: # Hatch Panels / # Cargo",
this.getCargoShipDataFor(this.props.redBreakdown),
this.getCargoShipDataFor(this.props.blueBreakdown)]} />

<BreakdownRow data={["Rocket 1: # Hatch Panels / # Cargo",
this.getRocketShipDataFor(this.props.redBreakdown, "Near"),
this.getRocketShipDataFor(this.props.blueBreakdown, "Near")]} />

<BreakdownRow data={["Rocket 2: # Hatch Panels / # Cargo",
this.getRocketShipDataFor(this.props.redBreakdown, "Far"),
this.getRocketShipDataFor(this.props.blueBreakdown, "Far")]} />

<BreakdownRow data={["Total Points: Hatch Panels / Cargo",
`${this.props.redBreakdown.hatchPanelPoints} / ${this.props.redBreakdown.cargoPoints}`,
`${this.props.blueBreakdown.hatchPanelPoints} / ${this.props.blueBreakdown.cargoPoints}`]} subtotal={true} />

<BreakdownRow data={["Robot 1 HAB Climb",
this.getHABClimbFor(this.props.redBreakdown, 1),
this.getHABClimbFor(this.props.blueBreakdown, 1)]} />

<BreakdownRow data={["Robot 2 HAB Climb",
this.getHABClimbFor(this.props.redBreakdown, 2),
this.getHABClimbFor(this.props.blueBreakdown, 2)]} />

<BreakdownRow data={["Robot 3 HAB Climb",
this.getHABClimbFor(this.props.redBreakdown, 3),
this.getHABClimbFor(this.props.blueBreakdown, 3)]} />

<BreakdownRow data={["HAB Climb Points",
this.props.redBreakdown.habClimbPoints,
this.props.blueBreakdown.habClimbPoints]} subtotal={true} />

<BreakdownRow data={["Total Teleop",
this.props.redBreakdown.teleopPoints,
this.props.blueBreakdown.teleopPoints]} total={true} />

<BreakdownRow data={["Complete Rocket",
this.props.redBreakdown.completeRocketRankingPoint ? this.checkImage() : this.xImage(),
this.props.blueBreakdown.completeRocketRankingPoint ? this.checkImage() : this.xImage()]} />

<BreakdownRow data={["HAB Docking",
this.props.redBreakdown.habDockingRankingPoint ? this.checkImage() : this.xImage(),
this.props.blueBreakdown.habDockingRankingPoint ? this.checkImage() : this.xImage()]} />

<BreakdownRow data={["Fouls",
["+", this.props.redBreakdown.foulPoints],
["+", this.props.blueBreakdown.foulPoints]]} />

<BreakdownRow data={["Adjustments",
this.props.redBreakdown.adjustPoints,
this.props.blueBreakdown.adjustPoints]} />

<BreakdownRow data={["Total Score",
this.props.redBreakdown.totalPoints,
this.props.blueBreakdown.totalPoints]} total={true} />

{this.props.compLevel == "qm" ? <BreakdownRow data={["Ranking Points",
["+", this.props.redBreakdown.rp, " RP"],
["+", this.props.blueBreakdown.rp, " RP"]]} /> : null}

</View>
);
}
}
4 changes: 4 additions & 0 deletions subtrees/the-blue-alliance-react/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import MatchBreakdown2015 from './app/views/MatchBreakdown2015';
import MatchBreakdown2016 from './app/views/MatchBreakdown2016';
import MatchBreakdown2017 from './app/views/MatchBreakdown2017';
import MatchBreakdown2018 from './app/views/MatchBreakdown2018';
import MatchBreakdown2019 from './app/views/MatchBreakdown2019';
import EventInsights2016 from './app/views/EventInsights2016';
import EventInsights2017 from './app/views/EventInsights2017';
import EventInsights2018 from './app/views/EventInsights2018';
import EventInsights2019 from './app/views/EventInsights2019';

AppRegistry.registerComponent('MatchBreakdown2015', () => MatchBreakdown2015);
AppRegistry.registerComponent('MatchBreakdown2016', () => MatchBreakdown2016);
AppRegistry.registerComponent('MatchBreakdown2017', () => MatchBreakdown2017);
AppRegistry.registerComponent('MatchBreakdown2018', () => MatchBreakdown2018);
AppRegistry.registerComponent('MatchBreakdown2019', () => MatchBreakdown2019);
AppRegistry.registerComponent('EventInsights2016', () => EventInsights2016);
AppRegistry.registerComponent('EventInsights2017', () => EventInsights2017);
AppRegistry.registerComponent('EventInsights2018', () => EventInsights2018);
AppRegistry.registerComponent('EventInsights2019', () => EventInsights2019);
Empty file.
Binary file not shown.
Loading

0 comments on commit 76299e2

Please sign in to comment.