diff --git a/.github/workflows/autodeploy.yml b/.github/workflows/autodeploy.yml deleted file mode 100644 index 8f28cc84..00000000 --- a/.github/workflows/autodeploy.yml +++ /dev/null @@ -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/ \ No newline at end of file diff --git a/src/app/components/ModalShoppingList.jsx b/src/app/components/ModalShoppingList.jsx index cd2e2ec3..b1f21e15 100644 --- a/src/app/components/ModalShoppingList.jsx +++ b/src/app/components/ModalShoppingList.jsx @@ -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
e.stopPropagation() }>

{translate('PHRASE_SHOPPING_MATS')}

- +

{translate('PHRASE_DIFFERENT_ROLLS')}

+ {/*
@@ -316,20 +370,26 @@ export default class ModalShoppingList extends TranslatedComponent {
- + */}