From de1cb901fc51a7db0b8437bf49e36688ddb0ee2e Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sat, 28 Jul 2018 11:36:44 +1000 Subject: [PATCH] more WIP for orbis --- package-lock.json | 85 ++++-------------------- package.json | 2 +- src/app/components/ModalOrbis.jsx | 61 ++++++++++++++--- src/app/components/ModalShoppingList.jsx | 2 +- src/app/components/SvgIcons.jsx | 24 +++++++ src/app/i18n/en.json | 5 +- src/app/pages/OutfittingPage.jsx | 33 ++++++++- src/app/stores/Persist.js | 24 +++++++ src/app/utils/ShortenUrl.js | 58 ++++++++++------ 9 files changed, 190 insertions(+), 104 deletions(-) diff --git a/package-lock.json b/package-lock.json index 13b10ba3..43c25f9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1627,15 +1627,6 @@ "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", "dev": true }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "dev": true, - "requires": { - "hoek": "4.x.x" - } - }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", @@ -3853,26 +3844,6 @@ "which": "^1.2.9" } }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "dev": true, - "requires": { - "boom": "5.x.x" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "dev": true, - "requires": { - "hoek": "4.x.x" - } - } - } - }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -5573,9 +5544,9 @@ "dev": true }, "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", "dev": true }, "fast-json-parse": { @@ -6940,9 +6911,9 @@ }, "dependencies": { "ajv": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", - "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { "co": "^4.6.0", @@ -6996,18 +6967,6 @@ "minimalistic-assert": "^1.0.0" } }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "dev": true, - "requires": { - "boom": "4.x.x", - "cryptiles": "3.x.x", - "hoek": "4.x.x", - "sntp": "2.x.x" - } - }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", @@ -7025,12 +6984,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==", - "dev": true - }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -9512,9 +9465,9 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "lodash.assignin": { "version": "4.2.0", @@ -11851,9 +11804,9 @@ } }, "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", "dev": true, "requires": { "aws-sign2": "~0.7.0", @@ -11864,7 +11817,6 @@ "forever-agent": "~0.6.1", "form-data": "~2.3.1", "har-validator": "~5.0.3", - "hawk": "~6.0.2", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -11874,7 +11826,6 @@ "performance-now": "^2.1.0", "qs": "~6.5.1", "safe-buffer": "^5.1.1", - "stringstream": "~0.0.5", "tough-cookie": "~2.3.3", "tunnel-agent": "^0.6.0", "uuid": "^3.1.0" @@ -12261,15 +12212,6 @@ "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "dev": true, - "requires": { - "hoek": "4.x.x" - } - }, "sockjs": { "version": "0.3.18", "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.18.tgz", @@ -12546,7 +12488,8 @@ "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", - "dev": true + "dev": true, + "optional": true }, "strip-ansi": { "version": "3.0.1", diff --git a/package.json b/package.json index 21975896..9c30e406 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "d3": "4.8.0", "detect-browser": "^1.7.0", "fbemitter": "^2.1.1", - "lodash": "^4.17.4", + "lodash": "^4.17.10", "lz-string": "^1.4.4", "pako": "^1.0.6", "prop-types": "^15.5.8", diff --git a/src/app/components/ModalOrbis.jsx b/src/app/components/ModalOrbis.jsx index b7d72b94..4a12ac54 100644 --- a/src/app/components/ModalOrbis.jsx +++ b/src/app/components/ModalOrbis.jsx @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import TranslatedComponent from './TranslatedComponent'; import { orbisUpload } from '../utils/ShortenUrl'; +import Persist from '../stores/Persist'; /** * Permalink modal @@ -20,18 +21,53 @@ export default class ModalOrbis extends TranslatedComponent { super(props); this.state = { - orbisUrl: 'Shortening...' + orbisCreds: Persist.getOrbisCreds(), + orbisUrl: '...' }; } /** - * Shorten URL on mount + * Send ship to Orbis.zone + * @param {SyntheticEvent} e React Event */ - componentWillMount() { - orbisUpload(this.props.ship, - (orbisUrl) => this.setState({ orbisUrl }), - (error) => this.setState({ orbisUrl: 'Error - ' + error }) - ); + sendToOrbis(e) { + const target = e.target; + target.disabled = true; + this.setState({ orbisUrl: 'Sending...' }, () => { + console.log(this.props); + console.log(this.state) + orbisUpload(this.props.ship, this.state.orbisCreds) + .then(orbisUrl => { + target.disabled = false; + this.setState({ orbisUrl }); + }) + .catch(err => { + target.disabled = false; + this.setState({ orbisUrl: 'Error - ' + err }); + }); + }); + } + + /** + * Handler for changing cmdr name + * @param {SyntheticEvent} e React Event + */ + orbisPasswordHandler(e) { + let password = e.target.value; + this.setState({ orbisCreds: { email: this.state.orbisCreds.email, password } }, () => { + Persist.setOrbisCreds(this.state.orbisCreds); + }); + } + + /** + * Handler for changing cmdr name + * @param {SyntheticEvent} e React Event + */ + orbisUsername(e) { + let orbisUsername = e.target.value; + this.setState({ orbisCreds: { email: orbisUsername, password: this.state.orbisCreds.password } }, () => { + Persist.setOrbisCreds(this.state.orbisCreds); + }); } /** @@ -40,16 +76,23 @@ export default class ModalOrbis extends TranslatedComponent { */ render() { let translate = this.context.language.translate; + this.orbisPasswordHandler = this.orbisPasswordHandler.bind(this); + this.orbisUsername = this.orbisUsername.bind(this); + this.sendToOrbis = this.sendToOrbis.bind(this); return
e.stopPropagation() }>

{translate('permalink')}


-

{translate('URL')}

- e.target.select() }/> +

{translate('orbis email')}

+ e.target.select() }/> +

+

{translate('orbis password')}

+ e.target.select() }/>

{translate('shortened')}

e.target.select() }/>

+
; } diff --git a/src/app/components/ModalShoppingList.jsx b/src/app/components/ModalShoppingList.jsx index 047e69bb..7c92a919 100644 --- a/src/app/components/ModalShoppingList.jsx +++ b/src/app/components/ModalShoppingList.jsx @@ -208,7 +208,7 @@ export default class ModalShoppingList extends TranslatedComponent { } /** - * Handler for changing roll amounts + * Handler for changing cmdr name * @param {SyntheticEvent} e React Event */ cmdrChangeHandler(e) { diff --git a/src/app/components/SvgIcons.jsx b/src/app/components/SvgIcons.jsx index 2933ac32..c226f892 100644 --- a/src/app/components/SvgIcons.jsx +++ b/src/app/components/SvgIcons.jsx @@ -228,6 +228,30 @@ export class LinkIcon extends SvgIcon { } } +/** + * Link / Permalink / Chain + */ +export class OrbisIcon extends SvgIcon { + /** + * Generate the SVG + * @return {React.Component} SVG Contents + */ + svg() { + return ( + + + + + + + + + + ); + } +} + + /** * Material */ diff --git a/src/app/i18n/en.json b/src/app/i18n/en.json index 4836723f..6ccb8418 100644 --- a/src/app/i18n/en.json +++ b/src/app/i18n/en.json @@ -335,6 +335,9 @@ "horizons": "Horizons", "horizons required": "Only available to those who have purchased Elite Dangerous: Horizons", "horizons early adoption": "Horizons Early Adopter", + "PHASE_UPLOAD_ORBIS": "Upload to orbis.zone (Coming soon!)", + "orbis username": "Username/email for orbis.zone", + "orbis password": "Password for orbis.zone", "horizons early adoption required": "Only available to those who purchased Elite Dangerous: Horizons on PC before February 5, 2016 or on Xbox One before July 30, 2016", "HELP_TEXT": "\n

Introduction

\nCoriolis is a ship builder for Elite: Dangerous. This help file provides you with the information you need to use Coriolis.\n\n

Importing Your Ship Into Coriolis

\nOften, you will want to start with your existing ship in Coriolis and see how particular changes might affect it, for example upgrading your FSD. There are a number of tools that can be used to import your ship without you having to create it manually. This has the added benefit of copying over any engineering modifications that have taken place as well.

\n\n

Importing Your Ship From EDDI

\nTo import your ship from EDDI first ensure that your connection to the Frontier servers' companion API is working. To do this check the 'Companion App' tab where you should see \"Your connection to the companion app is operational\". If not then follow the instructions in the companion app tab in EDDI to connect to the Frontier servers.

\n\nOnce you have a working companion API connection go to the 'Shipyard' tab. At the right-hand side of each ship is an 'Export to Coriolis' button that will open your default web browser in Coriolis with the ship's build.

\n\nNote that Internet Explorer and Edge might not import correctly, due to their internal restrictions on URL length. If you find that this is the case then please change your default browser to Chrome.

\n\nAlso, the imported information does not provide any data on the power priority or enabled status of your cargo hatch. Coriolis sets this item to have a power priority of \"5\" and to be disabled by default. You can change this after import in the Power Management section.

\n\n

Importing Your Ship From EDMC

\nTo import your ship from EDMC once your connection to the Frontier servers' companion API is working go to 'Settings ->Configuration' and set the 'Preferred Shipyard' to 'Coriolis'. Once this is set up clicking on your ship in the main window will open your default web browser in Coriolis with the ship's build.

\n\nNote that Internet Explorer and Edge might not import correctly, due to their internal restrictions on URL length. If you find that this is the case then please change your default browser to Chrome.

\n\n

Understanding And Using The Outfitting Panels

\nThe outfitting page is where you will spend most of your time, and contains the information for your ship. Information on each of the panels is provided below.

\n\n

Key Values

\nAlong the top of the screen are some of the key values for your build. This is a handy reference for the values, but more information is provided for the values in the further panels.

\n\nHere, along with most places in Coriolis, acronyms will have tooltips explaining what they mean. Hover over the acronym to obtain more detail, or look in the glossary at the end of this help.

\n\nAll values are the highest possible, assuming that you an optimal setup for that particular value (maximum pips in ENG for speed, minimum fuel for jump range, etc.). This means that these values will not be affected by changes to pip settings. Details of the specific setup for each value are listed in the associated tootip.

\n\n

Modules

\nThe next set of panels laid out horizontally across the screen contain the modules you have put in your build. From left to right these are the core modules, the internal modules, the hardpoints and the utility mounts. These represent the available slots in your ship and cannot be altered. Each slot has a class, or size, and in general any module up to a given size can fit in a given slot (exceptions being bulkheads, life support and sensors in core modules and restricted internal slots, which can only take a subset of module depending on their restrictions).

\n\nTo add a module to a slot left-click on the slot and select the required module. Only the modules capable of fitting in the selected slot will be shown.

\n\nTo remove a module from a slot right-click on the module.

\n\nTo move a module from one slot to another drag it. If you instead want to copy the module drag it whilst holding down the 'Alt' key.

\n\nClicking on the headings for each set of modules gives you the ability to either select an overall role for your ship (when clicking the core internal header) or a specific module with which you want to fill all applicable slots (when clicking the other headers).

\n\n

Ship Controls

\nThe ship controls allow you to set your pips, boost, and amount of fuel and cargo that your build carries. The changes made here will effect the information supplied in the subsequent panels, giving you a clearer view of what effect different changing these items will have.

\n\nShip control settings are saved as part of a build.

\n\n

Opponent

\nThe opponet selection allows you to choose your opponent. The opponent can be either a stock build of a ship or one of your own saved builds. You can also set the engagement range between you and your opponent. Your selection here will effect the information supplied in the subsequent panels, specifically the Offence and Defence panels.

\n\nOpponent settings are saved as part of a build.

\n\n

Power and Costs Sub-panels

\n

Power

\nThe power management panel provides information about power usage and priorities. It allows you to enable and disable individual modules, as well as set power priorities for each module. Disabled modules will not be included in the build's statistics, with the exception of Shield Cell Banks as they are usually disabled when not in use and only enabled when required.

\n\n

Costs

\nThe costs panel provides information about the costs for each of your modules, and the total cost and insurance for your build. By default Coriolis uses the standard costs, however discounts for your ship, modules and insurance can be altered in the 'Settings' at the top-right of the page.

\n\nThe retrofit costs provides information about the costs of changing the base build for your ship, or your saved build, to the current build.

\n\nThe reload costs provides information about the costs of reloading your current build.

\n\n

Profiles

\nProfiles provide graphs that show the general performance of modules in your build\n\n

Engine Profile

\nThe engine profile panel provides information about the capabilities of your current thrusters. The graph shows you how the maximum speed alters with the overall mass of your build. The vertical dashed line on the graph shows your current mass. Your engine profile can be altered by obtaining different thrusters or engineering your existing thrusters, and you can increase your maximum speed by adding pips to the ENG capacitor as well as reducing the amount of fuel and cargo you are carrying as well as reducing the overall weight of the build. You can also temporarily increase your speed by hitting the boost button.

\n\n

FSD Profile

\nThe FSD profile panel provides information about the capabilities of your current frame shift drive. The graph shows you how the maximum jump range alters with the overall mass of your build. The vertical dashed line on the graph shows your current maximum single jump range. Your FSD profile can be altered by obtaining a different FSD or engineering your existing FSD, and you can increase your maximum jump range by reducing the amount of fuel and cargo you are carrying as well as reducing the overall weight of the build,

\n\n

Movement Profile

\nThe movement profile panel provides information about the capabilities of your current thrusters with your current overall mass and ENG pips settings. The diagram shows your ability to move and rotate in the different axes:\n\n
\n
Speed
The fastest the ship can move, in metres per second
\n
Pitch
The fastest the ship can raise or lower its nose, in degrees per second
\n
Roll
The fastest the ship can roll its body, in degrees per second
\n
Yaw
The fastest the ship can turn its nose left or right, in degrees per second
\n
\n\nYour movement profile can be altered by obtaining different thrusters or engineering your existing thrusters, and you can increase your movement values by adding pips to the ENG capacitor as well as reducing the amount of fuel and cargo you are carrying as well as reducing the overall weight of the build. You can also temporarily increase your movement profile by hitting the boost button.

\n\n

Damage Profile

\nThe damage profile provides two graphs showing how the the build's damage to the opponent's shields and hull change with engagement range. The vertical dashed line on the graph shows your current engagement range. This combines information about the build's weapons with the opponent's shields and hull to provide an accurate picture of sustained damage that can be inflicted on the opponent.

\n\n

Offence

\n

Summary

\nThe offence summary provides per-weapon information about sustained damage per second inflicted to shields and hull, along with a measure of effectiveness of that weapon. The effectiveness value has a tooltip that provides a breakdown of the effectiveness, and can include reductions or increases due to range, resistance, and either power distributor (for shields) or hardness (for hull). The final effectiveness value is calculated by multiplying these percentages together.

\n\n

Offence Metrics

\nThe offence metrics panel provides information about your offence.

\n\nTime to drain is a measure of how quickly your WEP capacitor will drain when firing all weapons. It is affected by the number of pips you have in your WEP capacitor, with more pips resulting in a higher WEP recharge rate and hence a longer time to drain.

\n\nThe next value is the time it will take you to remove your opponent's shields. This assumes that you have 100% time on target and that your engagement range stays constant. Note that if your time to remove shields is longer than your time to drain this assumes that you continue firing throughout, inflicting lower damage due to the reduced energy in your WEP capacitor.

\n\nThe next value is the time it will take you to remove your opponent's armour. This follows the same logic as the time to remove shields.

\n\n

Shield Damage Sources

\nThe shield damage sources provides information about the sources of damage to your opponent by damage type. For each applicable type of damage (absolute explosive, kinetic, thermal) a sustained damage per second value is provided.

\n\n

Hull Damage Sources

\nThe hull damage sources provides information about the sources of damage to your opponent by damage type. For each applicable type of damage (absolute explosive, kinetic, thermal) a sustained damage per second value is provided.

\n\n

Defence

\n

Shield Metrics

\nThe shield metrics provides information about your shield defence.

\n\nRaw shield strength is the sum of the shield from your generator, boosters and shield cell banks. A tooltip provides a breakdown of these values.

\n\nThe time the shields will hold for is the time it will take your opponent' to remove your shields. This assumes that they have 100% time on target and that the engagement range stays constant. It also assumes that you fire all of your shield cell banks prior to your shields being lost.

\n\nThe time the shields will recover in is the time it will take your shields to go from collapsed (0%) to recovered (50%). This is affected by the number of pips you have in your SYS capacitor.

\n\nThe time the shields will recharge in is the time it will take your shields to go from recovered (50%) to full (100%). This is affected by the number of pips you have in your SYS capacitor.

\n\nShield Sources\nThis chart provides information about the sources of your shields. For each applicable source of shields (generator, boosters, shield cell banks) a value is provided.

\n\nDamage Taken\nThis graph shows how the initial damage from the weapons of each type are reduced before their damage is applied to the shields. For each type of damage (absolute, explosive, kinetic, thermal) a percentage of the initial damage is provided. A tooltip provides a breakdown of these values.

\n\nEffective Shield\nThis graph shows the effective shield for each damage type, found by dividing the raw shield value by the damage taken for that type.

\n\n

Amour Metrics

\nThe armour metrics provides information about your armour defence.

\n\nRaw armour strength is the sum of the armour from your bulkheads and hull reinforcement packages. A tooltip provides a breakdown of these values.

\n\nThe time the armour will hold for is the time it will take your opponent' to take your armour to 0. This assumes that they have 100% time on target, the engagement range stays constant, and that all damage is dealt to the armour rather than modules.

\n\nRaw module armour is the sum of the protection from your module reinforcement packages.

\n\nProtection for hardpoints is the amount of protection that your module reinforcement packages provide to hardpoints. This percentage of damage to the hardpoints will be diverted to the module reinforcement packages.

\n\nProtection for all other modules is the amount of protection that your module reinforcement packages provide to everything other than hardpoints. This percentage of damage to the modules will be diverted to the module reinforcement packages.

\n\nArmour Sources\nThis chart provides information about the sources of your armour. For each applicable source of shields (bulkheads, hull reinforcement packages) a value is provided.

\n\nDamage Taken\nThis graph shows how the initial damage from the weapons of each type are reduced before their damage is applied to the armour. For each type of damage (absolute, explosive, kinetic, thermal) a percentage of the initial damage is provided. A tooltip provides a breakdown of these values.

\n\nEffective Armour\nThis graph shows the effective armour for each damage type, found by dividing the raw armour value by the damage taken for that type.

\n\n

Keyboard Shortcuts

\n
\n
Ctrl-b
toggle boost
\n
Ctrl-e
open export dialogue (outfitting page only)
\n
Ctrl-h
open help dialogue
\n
Ctrl-i
open import dialogue
\n
Ctrl-o
open shortlink dialogue
\n
Ctrl-left-arrow
increase SYS capacitor
\n
Ctrl-up-arrow
increase ENG capacitor
\n
Ctrl-right-arrow
increase WEP capacitor
\n
Ctrl-down-arrow
reset power distributor
\n
Esc
close any open dialogue
\n
\n

Glossary

\n
\n
Absolute damage
A type of damage, without any protection. Absolute damage is always dealt at 100% regardless of if the damage is to shields, hull or modules, and irrespective of resistances
\n
DPS
Damage per second; the amount of damage that a weapon or a ship can deal per second to a target under optimum conditions
\n
EPS
Energy per second; the amount of energy that a weapon or a ship drains from the weapons capacitor per second when firing
\n
HPS
Heat per second; the amount of heat that a weapon or a ship generates per second when firing
\n
Effectivness
A comparison of the maximum DPS of a given weapon to the actual DPS of the given weapon in a specific situation. DPS can be reduced by range to the target, the target's hull and shield resistances, and the target's hardness
\n
Explosive damage
A type of damage, protected against by explosive resistance
\n
Hardness
The inherent resistance to damage of a ship's hull. Hardness is defined on a per-ship basis and there is currently nothing that can be done to change it. Hardness of a ship's hull is compared to the piercing of weapons: if piercing is higher than hardness the weapon does 100% damage, otherwise it does a fraction of its damage calculated as piercing/hardness
\n
Falloff
The distance at which a weapons starts to do less damage than its stated DPS
\n
Kinetic damage
A type of damage, protected against by kinetic resistance
\n
SDPS
Sustained damage per second; the amount of damage that a weapon or a ship can deal per second to a target, taking in to account ammunition reload
\n
SEPS
Sustained energy per second; the amount of energy that a weapon or a ship drains from the weapons capacitor per second when firing, taking in to account ammunition reload
\n
SHPS
Sustained heat per second; the amount of heat that a weapon or a ship generates per second when firing, taking in to account ammunition reload
\n
Thermal damage
A type of damage, protected against by thermal resistance
\n
\n\n " -} \ No newline at end of file +} diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index 16c7f500..b26d09ce 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -7,9 +7,20 @@ import Router from '../Router'; import Persist from '../stores/Persist'; import * as Utils from '../utils/UtilityFunctions'; import Ship from '../shipyard/Ship'; +import * as _ from 'lodash'; import { toDetailedBuild } from '../shipyard/Serializer'; import { outfitURL } from '../utils/UrlGenerators'; -import { FloppyDisk, Bin, Switch, Download, Reload, LinkIcon, ShoppingIcon, MatIcon } from '../components/SvgIcons'; +import { + FloppyDisk, + Bin, + Switch, + Download, + Reload, + LinkIcon, + ShoppingIcon, + MatIcon, + OrbisIcon +} from '../components/SvgIcons'; import LZString from 'lz-string'; import ShipSummaryTable from '../components/ShipSummaryTable'; import StandardSlotSection from '../components/StandardSlotSection'; @@ -26,6 +37,7 @@ import OutfittingSubpages from '../components/OutfittingSubpages'; import ModalExport from '../components/ModalExport'; import ModalPermalink from '../components/ModalPermalink'; import ModalShoppingList from '../components/ModalShoppingList'; +import ModalOrbis from '../components/ModalOrbis'; /** * Document Title Generator @@ -493,6 +505,22 @@ export default class OutfittingPage extends Page { this.context.showModal(); } + /** + * Generate Orbis link + */ + _genOrbis() { + const data = {}; + const ship = _.cloneDeep(this.state.ship); + console.log(this.state); + ship.coriolisId = ship.id; + data.coriolisShip = ship; + data.title = this.state.buildName; + data.description = this.state.buildName; + data.ShipName = ship.id; + data.Ship = ship.id; + this.context.showModal(); + } + /** * Open up a window for EDDB with a shopping list of our components */ @@ -616,6 +644,9 @@ export default class OutfittingPage extends Page { + diff --git a/src/app/stores/Persist.js b/src/app/stores/Persist.js index 2d00628e..e2724dbd 100644 --- a/src/app/stores/Persist.js +++ b/src/app/stores/Persist.js @@ -15,6 +15,7 @@ const LS_KEY_SIZE_RATIO = 'sizeRatio'; const LS_KEY_TOOLTIPS = 'tooltips'; const LS_KEY_MODULE_RESISTANCES = 'moduleResistances'; const LS_KEY_ROLLS = 'matsPerGrade'; +const LS_KEY_ORBIS = 'orbis'; let LS; @@ -95,6 +96,7 @@ export class Persist extends EventEmitter { let buildJson = _get(LS_KEY_BUILDS); let comparisonJson = _get(LS_KEY_COMPARISONS); + this.orbisCreds = _get(LS_KEY_ORBIS) || { email: '', password: '' }; this.onStorageChange = this.onStorageChange.bind(this); this.langCode = _getString(LS_KEY_LANG) || 'en'; this.insurance = insurance && Insurance[insurance.toLowerCase()] !== undefined ? insurance : 'standard'; @@ -168,6 +170,10 @@ export class Persist extends EventEmitter { this.matsPerGrade = JSON.parse(newValue); this.emit('matsPerGrade', this.matsPerGrade); break; + case LS_KEY_ORBIS: + this.orbisCreds = JSON.parse(newValue); + this.emit('orbis', this.orbisCreds); + break; } } catch (e) { // On JSON.Parse Error - don't sync or do anything @@ -193,6 +199,24 @@ export class Persist extends EventEmitter { this.emit('language', langCode); } + /** + * Get the current orbis.zone credentials + * @return {String} language code + */ + getOrbisCreds() { + return this.orbisCreds; + }; + + /** + * Update and save the orbis.zone credentials + * @param {Object} creds object with username and password properties. + */ + setOrbisCreds(creds) { + this.langCode = creds; + _put(LS_KEY_ORBIS, creds); + this.emit('orbis', creds); + } + /** * Show tooltips setting * @param {boolean} show Optional - update setting diff --git a/src/app/utils/ShortenUrl.js b/src/app/utils/ShortenUrl.js index c7e413d4..934c2173 100644 --- a/src/app/utils/ShortenUrl.js +++ b/src/app/utils/ShortenUrl.js @@ -1,5 +1,6 @@ import request from 'superagent'; +const agent = request.agent(); /** * Shorten a URL @@ -95,29 +96,46 @@ function orbisShorten(url, success, error) { } const API_ORBIS = 'http://localhost:3000/builds/add'; +const API_ORBIS_LOGIN = 'http://localhost:3000/login'; + /** * Upload to Orbis * @param {object} ship The URL to shorten - * @param {function} success Success callback - * @param {function} error Failure/Error callback + * @param {object} creds Orbis credentials + * @return {Promise} Either a URL or error message. */ -export function orbisUpload(ship, success, error) { - if (window.navigator.onLine) { - try { - request.post(API_ORBIS) - .send(ship) - .end(function(err, response) { - if (err) { - error('Bad Request'); - } else { - success(response.body.link); - } - }); - } catch (e) { - console.log(e); - error(e.message ? e.message : e); +export function orbisUpload(ship, creds) { + return new Promise(async (resolve, reject) => { + if (window.navigator.onLine) { + try { + agent + .post(API_ORBIS_LOGIN) + .send(creds) + .withCredentials() + .end(function(err) { + if (err) { + reject('Bad Request'); + } else { + agent + .post(API_ORBIS) + .withCredentials() + .set('Content-Type', 'application/json') + .send(ship) + .end(function(err, response) { + if (err) { + reject('Bad Request'); + } else { + resolve(response.body.link); + } + }); + } + }); + } catch (e) { + console.log(e); + reject(e.message ? e.message : e); + } + } else { + reject('Not Online'); } - } else { - error('Not Online'); - } + }); }