Compare commits

...

16 Commits

Author SHA1 Message Date
David Sangrey
4b5940e651 Merge pull request #767 from Brighter-Applications/Issue_703_EDOMH_integration
Issue 703 edomh integration
2024-06-09 17:24:50 -04:00
Alex Williams
06552dd860 Removing debugging console.log entries that are no longer needed for EDOMH fix 2024-06-07 18:24:57 +01:00
Alex Williams
ca91401507 Removing Autodeploy from this branch, it was merged in by github 2024-06-07 11:58:38 +01:00
Alex Williams
ed5ffbc9f8 Fixed issue with special blueprint item not being correctly jsonified for export to EDOMH 2024-06-07 11:58:38 +01:00
Alex Williams
45935b90e4 Adding fix for broken Armour Module Selection 2024-06-07 11:58:38 +01:00
Alex Williams
5d41575e66 Adding tag to manual dispatch of workflow 2024-06-07 11:58:38 +01:00
Alex Williams
b86e90de4b Issue 764 unknown modules are selectable (#11)
* Adds valid module checking to all types of modules on import

* Adds the Advanced MC's, AX MC's, AX MR's and Nanite Torpedo

* Changes as per comments on the PR

* Fixed 'Missing Module' category showing up in Optional Selection drop-down and fixed 'Missing Power Plant', 'Missing Power Distributor' and 'Missing Frameshift Drive' showing up in the Selection drop-downs for those module slots.

---------

Co-authored-by: David Sangrey <davidsangrey@gmail.com>
Co-authored-by: Felix Linker <linkerfelix@gmail.com>
2024-06-07 11:58:38 +01:00
Alex Williams
105fc60f43 Issue 703 edomh integration (#10)
* Adds valid module checking to all types of modules on import

* Adds the Advanced MC's, AX MC's, AX MR's and Nanite Torpedo

* Changes as per comments on the PR

* Modified export to EDOMH/EDEngineer page to be less 'bodged', allow EDOMH button to be clickable without checking for EDEngineer API (If they have EDOMH, they probably don't have EDEngineer...) and added a workaround for Coriolis sending bogus data for bulkheads.

* Fixed autodeploy to do latest coriolis-data dist. Fixed sendToEDOMH function to only send the blueprint at the selected grade, not each grade up to that grade.

* Fixed miscalculation of mats and got rid of unhelpful 'rolls' table, as the mats are calculated for the whole build and some blueprints may not be all the way up to g5.

* Removed console.log lines which were only needed for testing.

---------

Co-authored-by: David Sangrey <davidsangrey@gmail.com>
Co-authored-by: Felix Linker <linkerfelix@gmail.com>
2024-06-07 11:58:11 +01:00
Alex Williams
7ccfa09ddd Issue 703 edomh integration (#9)
* Adds valid module checking to all types of modules on import

* Adds the Advanced MC's, AX MC's, AX MR's and Nanite Torpedo

* Changes as per comments on the PR

* Modified export to EDOMH/EDEngineer page to be less 'bodged', allow EDOMH button to be clickable without checking for EDEngineer API (If they have EDOMH, they probably don't have EDEngineer...) and added a workaround for Coriolis sending bogus data for bulkheads.

* Fixed autodeploy to do latest coriolis-data dist. Fixed sendToEDOMH function to only send the blueprint at the selected grade, not each grade up to that grade.

* Fixed miscalculation of mats and got rid of unhelpful 'rolls' table, as the mats are calculated for the whole build and some blueprints may not be all the way up to g5.

---------

Co-authored-by: David Sangrey <davidsangrey@gmail.com>
Co-authored-by: Felix Linker <linkerfelix@gmail.com>
2024-06-07 11:58:11 +01:00
Alex Williams
ab3c93d52d Issue 703 edomh integration (#8)
* Adds valid module checking to all types of modules on import

* Adds the Advanced MC's, AX MC's, AX MR's and Nanite Torpedo

* Changes as per comments on the PR

* Modified export to EDOMH/EDEngineer page to be less 'bodged', allow EDOMH button to be clickable without checking for EDEngineer API (If they have EDOMH, they probably don't have EDEngineer...) and added a workaround for Coriolis sending bogus data for bulkheads.

* Fixed autodeploy to do latest coriolis-data dist. Fixed sendToEDOMH function to only send the blueprint at the selected grade, not each grade up to that grade.

---------

Co-authored-by: David Sangrey <davidsangrey@gmail.com>
Co-authored-by: Felix Linker <linkerfelix@gmail.com>
2024-06-07 11:57:22 +01:00
Alex Williams
ee04416e2b Adding in buildname to EDOMH Export 2024-06-07 11:57:22 +01:00
Alex Williams
4efc47dff0 Removed console.log lines which were only needed for testing. 2024-06-07 11:56:42 +01:00
Alex Williams
bd2e6eaf51 Fixed miscalculation of mats and got rid of unhelpful 'rolls' table, as the mats are calculated for the whole build and some blueprints may not be all the way up to g5. 2024-06-07 11:56:42 +01:00
Alex Williams
42b2e39064 Issue 703 edomh integration (#7)
* Adds valid module checking to all types of modules on import

* Adds the Advanced MC's, AX MC's, AX MR's and Nanite Torpedo

* Changes as per comments on the PR

* Modified export to EDOMH/EDEngineer page to be less 'bodged', allow EDOMH button to be clickable without checking for EDEngineer API (If they have EDOMH, they probably don't have EDEngineer...) and added a workaround for Coriolis sending bogus data for bulkheads.

---------

Co-authored-by: David Sangrey <davidsangrey@gmail.com>
Co-authored-by: Felix Linker <linkerfelix@gmail.com>
2024-06-07 11:56:42 +01:00
Alex Williams
d1217439bd Fixed autodeploy to do latest coriolis-data dist. Fixed sendToEDOMH function to only send the blueprint at the selected grade, not each grade up to that grade. 2024-06-07 11:53:43 +01:00
Alex Williams
2a6ae0f2ff Modified export to EDOMH/EDEngineer page to be less 'bodged', allow EDOMH button to be clickable without checking for EDEngineer API (If they have EDOMH, they probably don't have EDEngineer...) and added a workaround for Coriolis sending bogus data for bulkheads. 2024-06-07 11:53:43 +01:00
6 changed files with 111 additions and 65 deletions

View File

@@ -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/

View File

@@ -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,16 +238,18 @@ 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
}
}
let JSONString = JSON.stringify(baseJson)
let deflated = zlib.deflateSync(JSONString)
//actually encode
let link = base64url.encode(deflated)
link = "edomh://coriolis/?" + link;
@@ -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>;
}

View File

@@ -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",

View File

@@ -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} />);
}
/**

View File

@@ -183,4 +183,4 @@ footer {
.announcement {
border: 1px @secondary solid;
padding: 10px;
}
}

View File

@@ -41,6 +41,15 @@
h2 {
margin: 0;
}
p {
clear: left;
padding: 30, 0, 0, 0;
}
button {
margin: 100px, 0;
}
}
textarea {