Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/three-0.91.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 authored Mar 15, 2018
2 parents 12c4444 + 2a3c1c5 commit 2f1d2ba
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 66 deletions.
8 changes: 4 additions & 4 deletions src/components/generic/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const TypingField = ({
onChange={onChange}
onBlur={onBlur}
style={compStyle}
value={value}
value={value || ""}
/>
);
}
Expand All @@ -105,7 +105,7 @@ export const TypingField = ({
onChange={onChange}
onBlur={onBlur}
style={compStyle}
defaultValue={value}
defaultValue={value || ""}
/>
);
}
Expand All @@ -119,7 +119,7 @@ export const TypingField = ({
onChange={onChange}
onBlur={onBlur}
style={compStyle}
value={value}
value={value || ""}
/>
);
}
Expand All @@ -131,7 +131,7 @@ export const TypingField = ({
onChange={onChange}
onBlur={onBlur}
style={compStyle}
defaultValue={value}
defaultValue={value || ""}
/>
);
};
16 changes: 12 additions & 4 deletions src/components/views/Clients/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const TEMPLATE_SUB = gql`
}
`;

class Template extends Component {
class ClientCore extends Component {
sub = null;
componentWillReceiveProps(nextProps) {
if (!this.internalSub && !nextProps.data.loading) {
Expand Down Expand Up @@ -84,7 +84,11 @@ class Template extends Component {
{Object.keys(Views)
.concat()
.sort()
.map(v => <option value={v}>{titleCase(v)}</option>)}
.map((v, i) => (
<option key={`${i}-${v}`} value={v}>
{titleCase(v)}
</option>
))}
</Input>
{clients.map(c => (
<div key={c.id}>
Expand All @@ -101,7 +105,11 @@ class Template extends Component {
{Object.keys(Views)
.concat()
.sort()
.map(v => <option value={v}>{titleCase(v)}</option>)}
.map((v, i) => (
<option key={`client-${i}-${v}`} value={v}>
{titleCase(v)}
</option>
))}
</Input>
</div>
))}
Expand Down Expand Up @@ -129,4 +137,4 @@ export default graphql(TEMPLATE_QUERY, {
simulatorId: ownProps.simulator.id
}
})
})(withApollo(Template));
})(withApollo(ClientCore));
1 change: 1 addition & 0 deletions src/components/views/CommInterception/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class LongRangeComm extends Component {
const { data: { loading, longRangeCommunications } } = this.props;
if (loading || !longRangeCommunications) return null;
const lrComm = longRangeCommunications[0];
if (!lrComm) return <p>No Long Range Comm</p>;
const { interception, locked, decoded } = lrComm;
return (
<div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/views/EngineControl/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class EngineCoreView extends Component {
}
getCurrentSpeed() {
if (!this.props.data.engines) return;
if (!this.props.data.engines[0]) return;
const velocity = this.props.data.engines[0].velocity;
const speed = this.props.data.engines
.reduce((prev, next) => {
Expand Down Expand Up @@ -123,6 +124,7 @@ class EngineCoreView extends Component {
<p>Velocity</p>
{this.getCurrentSpeed()} -{" "}
{this.props.data.engines &&
this.props.data.engines[0] &&
`${this.props.data.engines[0].velocity.toLocaleString()} km/s`}
</Col>
</Row>
Expand Down
1 change: 1 addition & 0 deletions src/components/views/ProbeNetwork/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ProbeNetworkCore extends Component {
};
render() {
if (this.props.data.loading || !this.props.data.probes) return null;
if (!this.props.data.probes[0]) return <p>No Probes</p>;
const probes = this.props.data.probes[0].probes;
const network = {};
probes.forEach(p => (network[p.name] = p.launched));
Expand Down
123 changes: 66 additions & 57 deletions src/components/views/ReactorControl/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, Fragment } from "react";
import gql from "graphql-tag";
import { InputField } from "../../generic/core";
import { graphql, withApollo } from "react-apollo";
Expand Down Expand Up @@ -180,8 +180,8 @@ class ReactorControl extends Component {
render() {
if (this.props.data.loading || !this.props.data.reactors) return null;
const { reactors } = this.props.data;
const reactor = reactors.find(r => r.model === "reactor") || {};
const battery = reactors.find(r => r.model === "battery") || {};
const reactor = reactors.find(r => r.model === "reactor");
const battery = reactors.find(r => r.model === "battery");
if (!reactor) return <p>No Reactor</p>;
const efficiencies = [
{
Expand Down Expand Up @@ -216,60 +216,69 @@ class ReactorControl extends Component {
<Container className="reactor-control-core">
<Row>
<Col sm={12}>
<p>Reactor Output:</p>
<InputField
prompt="What is the new power output?"
onClick={this.setPowerLevel}
>
{reactor.powerOutput}
</InputField>
<p>Reactor Efficiency:</p>
<Input
size="sm"
type="select"
onChange={evt => this.setEfficiency(evt.target.value)}
value={reactor.efficiency}
>
{efficiencies.map(e => (
<option key={e.label} value={e.efficiency}>
{e.label}
</option>
))}
</Input>
<p>Heat Rate:</p>
<Input
size="sm"
type="select"
onChange={evt => this.setHeatRate(evt.target.value)}
value={reactor.heatRate}
>
<option value={1.5}>Fast</option>
<option value={1}>Normal</option>
<option value={0.5}>Slow</option>
<option value={0}>Stop</option>
<option value={-1}>Reverse</option>
</Input>
<p>Reactor Heat:</p>
<InputField
prompt="What is the new reactor heat?"
onClick={this.updateHeat}
>
{Math.round(reactor.heat * 1000) / 10}%
</InputField>
<p>Battery Output:</p>
<InputField
prompt="What is the new battery charge level?"
onClick={this.setChargeLevel}
>
{Math.round(battery.batteryChargeLevel * 100)}%
</InputField>
<p>Battery Rate:</p>
<InputField
prompt="What is the new battery charge rate?"
onClick={this.setChargeRate}
>
{battery.batteryChargeRate * 100}
</InputField>
{reactor && (
<Fragment>
<p>Reactor Output:</p>
<InputField
prompt="What is the new power output?"
onClick={this.setPowerLevel}
>
{reactor.powerOutput}
</InputField>
<p>Reactor Efficiency:</p>
<Input
size="sm"
type="select"
onChange={evt => this.setEfficiency(evt.target.value)}
value={reactor.efficiency}
>
{efficiencies.map(e => (
<option key={e.label} value={e.efficiency}>
{e.label}
</option>
))}
</Input>
<p>Heat Rate:</p>
<Input
size="sm"
type="select"
onChange={evt => this.setHeatRate(evt.target.value)}
value={reactor.heatRate}
>
<option value={1.5}>Fast</option>
<option value={1}>Normal</option>
<option value={0.5}>Slow</option>
<option value={0}>Stop</option>
<option value={-1}>Reverse</option>
</Input>
<p>Reactor Heat:</p>
<InputField
prompt="What is the new reactor heat?"
onClick={this.updateHeat}
>
{Math.round(reactor.heat * 1000) / 10}%
</InputField>
</Fragment>
)}
{battery && (
<Fragment>
{" "}
<p>Battery Output:</p>
<InputField
prompt="What is the new battery charge level?"
onClick={this.setChargeLevel}
>
{Math.round(battery.batteryChargeLevel * 100)}%
</InputField>
<p>Battery Rate:</p>
<InputField
prompt="What is the new battery charge rate?"
onClick={this.setChargeRate}
>
{battery.batteryChargeRate * 100}
</InputField>
</Fragment>
)}
</Col>
</Row>
</Container>
Expand Down
1 change: 1 addition & 0 deletions src/components/views/Sensors/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class SensorsCore extends Component {
height: 22
};
const { selectedScan } = this.state;
if (!sensor) return <p>No Sensors</p>;
const scan = sensor.scans.find(s => s.id === selectedScan);
if (this.props.data.loading) return <span>Loading...</span>;
return (
Expand Down
1 change: 1 addition & 0 deletions src/components/views/TorpedoLoading/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TorpedoLoadingCore extends Component {
nextProps.data.torpedos.find(
t => t.id === this.state.selectedTorpedo
) || nextProps.data.torpedos[0];
if (!torpedos) return;
let { type } = this.state;
const loadedTorp = torpedos.inventory.find(t => t.id === torpedos.loaded);
if (loadedTorp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const PlasmaRipples = ({
edit,
color = "blue"
}) => {
const alpha = level || inputs[0] || 0;
const alpha = level || (level === 0 ? 0 : inputs[0]) || 0;
return (
<div style={{ transform: `scale(${scale})` }}>
{page &&
Expand Down

0 comments on commit 2f1d2ba

Please sign in to comment.