mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 14:33:22 +00:00
Merge pull request #767 from Brighter-Applications/Issue_703_EDOMH_integration
Issue 703 edomh integration
This commit is contained in:
28
.github/workflows/autodeploy.yml
vendored
28
.github/workflows/autodeploy.yml
vendored
@@ -1,28 +0,0 @@
|
||||
# This is a basic deployment workflow triggered by pushes to the alpha branch.
|
||||
|
||||
name: Auto-Deploy
|
||||
|
||||
# Controls when the action will run. Workflow runs when the alpha branch receives a push event
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- alpha
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
downloadcode:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
rm -Rf ./coriolis
|
||||
rm -Rf ./coriolis-data
|
||||
git clone https://github.com/alex-williams/coriolis.git --single-branch --branch alpha
|
||||
git clone https://github.com/alex-williams/coriolis-data.git --single-branch --branch alpha
|
||||
cd coriolis-data
|
||||
npm install
|
||||
cd ../coriolis
|
||||
npm install
|
||||
npm run build
|
||||
sudo -u www-data cp -r ./build/* /var/www/newdisk/coriolis.brighter-applications.co.uk/
|
||||
@@ -12,7 +12,8 @@ const base64url = require('base64url');
|
||||
export default class ModalShoppingList extends TranslatedComponent {
|
||||
|
||||
static propTypes = {
|
||||
ship: PropTypes.object.isRequired
|
||||
ship: PropTypes.object.isRequired,
|
||||
buildName: PropTypes.string
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -90,8 +91,10 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
request
|
||||
.get('http://localhost:44405/commanders')
|
||||
.end((err, res) => {
|
||||
this.display = 'block';
|
||||
if (err) {
|
||||
console.log(err);
|
||||
this.display = 'none';
|
||||
return this.setState({ failed: true });
|
||||
}
|
||||
const cmdrs = JSON.parse(res.text);
|
||||
@@ -147,6 +150,34 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix issues with the item name for bulkheads when sending to EDOMH
|
||||
* @param {*} ship Ship object
|
||||
* @param {*} item Item name
|
||||
* @returns updated item name
|
||||
*/
|
||||
fixArmourItemNameForEDOMH(ship, item) {
|
||||
// The module blueprint fdname contains "Armour_" it's a bulkhead and we need to pre-populate the item field with the correct name from the ship object
|
||||
switch (ship.bulkheads.m.name){
|
||||
case "Lightweight Alloy":
|
||||
item = ship.id + "_Armour_Grade1";
|
||||
break;
|
||||
case "Reinforced Alloy":
|
||||
item = ship.id + "_Armour_Grade2";
|
||||
break;
|
||||
case "Military Grade Composite":
|
||||
item = ship.id + "_Armour_Grade3";
|
||||
break;
|
||||
case "Mirrored Surface Composite":
|
||||
item = ship.id + "_Armour_Mirrored";
|
||||
break;
|
||||
case "Reactive Surface Composite":
|
||||
item = ship.id + "_Armour_Reactive";
|
||||
break;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send all blueprints to EDOMH. This is a modified copy of registerBPs because this.state.blueprints was empty when I tried to modify sendToEDEng and I couldn't figure out why
|
||||
* @param {Event} event React event
|
||||
@@ -154,6 +185,7 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
sendToEDOMH(event) {
|
||||
event.preventDefault();
|
||||
const ship = this.props.ship;
|
||||
const buildName = this.props.buildName;
|
||||
let blueprints = [];
|
||||
|
||||
//create the json
|
||||
@@ -166,20 +198,38 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
continue;
|
||||
}
|
||||
if (module.m.blueprint.special) {
|
||||
let item = "";
|
||||
// If the module blueprint fdname contains "Armour_" it's a bulkhead and we need to pre-populate the item field with the correct name from the ship object
|
||||
if (module.m.blueprint.fdname.includes("Armour_")) {
|
||||
item = this.fixArmourItemNameForEDOMH(ship, item)
|
||||
}
|
||||
else {
|
||||
item = module.m.symbol;
|
||||
}
|
||||
|
||||
blueprints.push({
|
||||
"item": module.m.symbol,
|
||||
"item": item,
|
||||
"blueprint": module.m.blueprint.special.edname
|
||||
});
|
||||
}
|
||||
for (const g in module.m.blueprint.grades) {
|
||||
for (let g in module.m.blueprint.grades) {
|
||||
if (!module.m.blueprint.grades.hasOwnProperty(g)) {
|
||||
continue;
|
||||
}
|
||||
if (g < module.m.blueprint.grade) {
|
||||
// We only want the grade that the module is currently at, not every grade up to that point
|
||||
if (Number(g) !== module.m.blueprint.grade) {
|
||||
continue;
|
||||
}
|
||||
let item = "";
|
||||
// If the module blueprint fdname contains "Armour_" it's a bulkhead and we need to pre-populate the item field with the correct name from the ship object
|
||||
if (module.m.blueprint.fdname.includes("Armour_")) {
|
||||
item = this.fixArmourItemNameForEDOMH(ship, item)
|
||||
}
|
||||
else {
|
||||
item = module.m.symbol;
|
||||
}
|
||||
blueprints.push({
|
||||
"item": module.m.symbol,
|
||||
"item": item,
|
||||
"blueprint": module.m.blueprint.fdname,
|
||||
"grade": module.m.blueprint.grade,
|
||||
"highestGradePercentage":1.0
|
||||
@@ -188,10 +238,12 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
}
|
||||
}
|
||||
|
||||
let shipName = buildName + " - " + ship.name;
|
||||
|
||||
//create JSON to encode
|
||||
let baseJson = {
|
||||
"version":1,
|
||||
"name":ship.name, // TO-DO: Import build name and put that here correctly
|
||||
"name": shipName, // TO-DO: Import build name and put that here correctly
|
||||
"items": blueprints
|
||||
}
|
||||
|
||||
@@ -219,14 +271,15 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
if (!module.m.blueprint.grade || !module.m.blueprint.grades) {
|
||||
continue;
|
||||
}
|
||||
for (const g in module.m.blueprint.grades) {
|
||||
for (let g in module.m.blueprint.grades) {
|
||||
if (!module.m.blueprint.grades.hasOwnProperty(g)) {
|
||||
continue;
|
||||
}
|
||||
if (g > module.m.blueprint.grade) {
|
||||
// Ignore grades higher than the grade selected
|
||||
if (Number(g) > module.m.blueprint.grade) {
|
||||
continue;
|
||||
}
|
||||
for (const i in module.m.blueprint.grades[g].components) {
|
||||
for (let i in module.m.blueprint.grades[g].components) {
|
||||
if (!module.m.blueprint.grades[g].components.hasOwnProperty(i)) {
|
||||
continue;
|
||||
}
|
||||
@@ -236,16 +289,16 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
mats[i] = module.m.blueprint.grades[g].components[i] * this.state.matsPerGrade[g];
|
||||
}
|
||||
}
|
||||
if (module.m.blueprint.special) {
|
||||
for (const j in module.m.blueprint.special.components) {
|
||||
if (!module.m.blueprint.special.components.hasOwnProperty(j)) {
|
||||
continue;
|
||||
}
|
||||
if (mats[j]) {
|
||||
mats[j] += module.m.blueprint.special.components[j];
|
||||
} else {
|
||||
mats[j] = module.m.blueprint.special.components[j];
|
||||
}
|
||||
}
|
||||
if (module.m.blueprint.special) {
|
||||
for (const j in module.m.blueprint.special.components) {
|
||||
if (!module.m.blueprint.special.components.hasOwnProperty(j)) {
|
||||
continue;
|
||||
}
|
||||
if (mats[j]) {
|
||||
mats[j] += module.m.blueprint.special.components[j];
|
||||
} else {
|
||||
mats[j] = module.m.blueprint.special.components[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +356,8 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
this.sendToEDOMH = this.sendToEDOMH.bind(this);
|
||||
return <div className='modal' onClick={ (e) => e.stopPropagation() }>
|
||||
<h2>{translate('PHRASE_SHOPPING_MATS')}</h2>
|
||||
<label>{translate('Grade 1 rolls ')}</label>
|
||||
<p>{translate('PHRASE_DIFFERENT_ROLLS')}</p>
|
||||
{/* <label>{translate('Grade 1 rolls ')}</label>
|
||||
<input id={1} type={'number'} min={0} defaultValue={this.state.matsPerGrade[1]} onChange={this.changeHandler} />
|
||||
<br/>
|
||||
<label>{translate('Grade 2 rolls ')}</label>
|
||||
@@ -316,20 +370,26 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
<input id={4} type={'number'} min={0} value={this.state.matsPerGrade[4]} onChange={this.changeHandler} />
|
||||
<br/>
|
||||
<label>{translate('Grade 5 rolls ')}</label>
|
||||
<input id={5} type={'number'} min={0} value={this.state.matsPerGrade[5]} onChange={this.changeHandler} />
|
||||
<input id={5} type={'number'} min={0} value={this.state.matsPerGrade[5]} onChange={this.changeHandler} /> */}
|
||||
<div>
|
||||
<textarea className='cb json' readOnly value={this.state.matsList} />
|
||||
</div>
|
||||
<label hidden={!compatible} className={'l cap'}>{translate('CMDR Name')}</label>
|
||||
<br/>
|
||||
<select hidden={!compatible} className={'cmdr-select l cap'} onChange={this.cmdrChangeHandler} defaultValue={this.state.cmdrName}>
|
||||
{this.state.cmdrs.map(e => <option key={e}>{e}</option>)}
|
||||
</select>
|
||||
<br/>
|
||||
<p hidden={!this.state.failed} id={'failed'} className={'l'}>{translate('PHRASE_FAIL_EDENGINEER')}</p>
|
||||
<p hidden={compatible} id={'browserbad'} className={'l'}>{translate('PHRASE_FIREFOX_EDENGINEER')}</p>
|
||||
<button className={'l cb dismiss cap'} disabled={!!this.state.failed || !compatible} onClick={this.sendToEDEng}>{translate('Send to EDEngineer')}</button>
|
||||
<button style={{marginTop: 5}} className={'l cb dismiss cap'} disabled={!!this.state.failed} onClick={this.sendToEDOMH}>{translate('Send to EDOMH')}</button>
|
||||
<p hidden={!this.state.failed} id={'failed'} className={'l'}>{translate('PHRASE_FAILED_TO_FIND_EDENGINEER')}</p>
|
||||
<div id='edengineer' display={this.display} hidden={!!this.state.failed && !compatible}>
|
||||
<label hidden={!compatible || !!this.state.failed} className={'l cap'}>{translate('CMDR Name')}</label>
|
||||
<br/>
|
||||
<select hidden={!compatible || !!this.state.failed} className={'cmdr-select l cap'} onChange={this.cmdrChangeHandler} defaultValue={this.state.cmdrName}>
|
||||
{this.state.cmdrs.map(e => <option key={e}>{e}</option>)}
|
||||
</select>
|
||||
<br/>
|
||||
<button className={'l cb dismiss cap'} hidden={!this.state.failed} disabled={!!this.state.failed || !compatible} onClick={this.sendToEDEng}>{translate('Send to EDEngineer')}</button>
|
||||
</div>
|
||||
<div id='edomh'>
|
||||
<p>{translate('PHRASE_ENSURE_EDOMH')}</p>
|
||||
<button style={{marginTop: 5}} className={'l cb dismiss cap'} onClick={this.sendToEDOMH}>{translate('Send to EDOMH')}</button>
|
||||
</div>
|
||||
|
||||
<button className={'r dismiss cap'} onClick={this.context.hideModal}>{translate('close')}</button>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"PHRASE_NO_SPECIAL": "No experimental effect",
|
||||
"PHRASE_SHOPPING_LIST": "Stations that sell this build",
|
||||
"PHRASE_SHOPPING_MATS": "Materials needed for this build",
|
||||
"PHRASE_DIFFERENT_ROLLS": "NOTE: ED Engineer and/or EDOMH likely have their own 'rolls' configuration, so material requirements may differ!",
|
||||
"PHRASE_REFIT_SHOPPING_LIST": "Stations that sell required modules",
|
||||
"PHRASE_TOTAL_EFFECTIVE_SHIELD": "Total amount of damage that can be taken from each damage type, if using all shield cells",
|
||||
"PHRASE_TIME_TO_LOSE_SHIELDS": "Shields will hold for",
|
||||
@@ -81,8 +82,10 @@
|
||||
"TT_SUMMARY_UNLADEN_TOTAL_JUMP": "Farthest possible range with no cargo, a full fuel tank, and jumping as far as possible each time",
|
||||
"TT_SUMMARY_LADEN_TOTAL_JUMP": "Farthest possible range with full cargo, a full fuel tank, and jumping as far as possible each time",
|
||||
"HELP_MODIFICATIONS_MENU": "Click on a number to enter a new value, or drag along the bar for small changes",
|
||||
"PHRASE_FAIL_EDENGINEER": "Failed to send to EDEngineer (Launch EDEngineer and make sure the API is started then refresh the page.)",
|
||||
"PHRASE_FIREFOX_EDENGINEER": "Sending to EDEngineer is not compatible with Firefox's security settings. Please try again with Chrome.",
|
||||
"PHRASE_FAIL_EDENGINEER": "Failed to send to EDEngineer (Launch EDEngineer and make sure the API is started then refresh the page.)",
|
||||
"PHRASE_ENSURE_EDOMH": "Ensure EDO Material Helper is installed and registered to handle edomh:// urls, else this button will do nothing!",
|
||||
"PHRASE_FIREFOX_EDENGINEER": "Sending to EDEngineer is not compatible with Firefox's security settings. Please try again with Chrome.",
|
||||
"PHRASE_FAILED_TO_FIND_EDENGINEER": "Failed to find ED Engineer API. Please ensure it is running and try again.",
|
||||
"MISSING_MODULES": "Missing Modules",
|
||||
"am": "Auto Field-Maintenance Unit",
|
||||
"bh": "Bulkheads",
|
||||
|
||||
@@ -700,7 +700,9 @@ export default class OutfittingPage extends Page {
|
||||
* Generates the shopping list
|
||||
*/
|
||||
_genShoppingList() {
|
||||
this.context.showModal(<ModalShoppingList ship={this.state.ship} />);
|
||||
this.context.showModal(<ModalShoppingList
|
||||
ship={this.state.ship}
|
||||
buildName={this.state.buildName} />);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,6 +41,15 @@
|
||||
h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
clear: left;
|
||||
padding: 30, 0, 0, 0;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 100px, 0;
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
||||
Reference in New Issue
Block a user