Skip to content

Commit

Permalink
Zip updates for diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
kglovern committed Dec 9, 2024
1 parent 05232fb commit fca820d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gSender",
"version": "1.4.10",
"version": "1.4.11",
"description": "Electron sender for GRBL based CNC machines",
"author": {
"name": "Sienci Labs <hi@sienci.com>",
Expand Down Expand Up @@ -254,6 +254,7 @@
"is-online": "^9.0.1",
"js-polyfills": "~0.1.42",
"jsonwebtoken": "~8.5.1",
"jszip": "^3.10.1",
"lodash": "~4.17.11",
"memoize-one": "~5.0.4",
"method-override": "~3.0.0",
Expand Down
22 changes: 21 additions & 1 deletion src/app/lib/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import pkg from '../../package.json';
import { GRBLHAL, LASER_MODE, METRIC_UNITS, WORKSPACE_MODE } from '../constants';
import api from 'app/api';
import { homingString } from './eeprom';
import JSZip from 'jszip';


const styles = StyleSheet.create({
body: {
Expand Down Expand Up @@ -768,12 +770,30 @@ function generateSupportFile() {
const currentDate = date.toLocaleDateString().replaceAll('/', '-');
const currentTime = date.toLocaleTimeString('it-IT').replaceAll(':', '-');

saveAs(blob, 'diagnostics_' + currentDate + '_' + currentTime + '.pdf');
const zip = new JSZip();
const diagnosticPDFLabel = `diagnostics_${currentDate}_${currentTime}.pdf`;
const senderSettings = await exportSenderSettings();

zip.file(diagnosticPDFLabel, blob);
zip.file(`gSenderSettings_${currentDate}_${currentTime}.json`, senderSettings);
zip.generateAsync({ type: 'blob' }).then((content) => {
saveAs(content, 'diagnostics_' + currentDate + '_' + currentTime + '.zip');
});
};

return (
<ToolModalButton icon="fas fa-file-pdf" onClick={submitForm}>Download Now!</ToolModalButton>
);
}

async function exportSenderSettings() {
const settings = store.get();
settings.commandKeys = Object.fromEntries(Object.entries(settings.commandKeys).filter(([key, shortcut]) => shortcut.category !== 'Macros'));
delete settings.session;
const res = await api.events.fetch();
const events = res.body.records;
const settingsJSON = JSON.stringify({ settings, events }, null, 3);
return new Blob([settingsJSON], { type: 'application/json' });
}

export default generateSupportFile;
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gSender",
"version": "1.4.10",
"version": "1.4.11",
"productName": "gSender",
"description": "CNC Milling Controller",
"author": {
Expand Down

0 comments on commit fca820d

Please sign in to comment.