diff --git a/ElectronClient/app/bridge.js b/ElectronClient/app/bridge.js index c5d55aed9..da7995fb8 100644 --- a/ElectronClient/app/bridge.js +++ b/ElectronClient/app/bridge.js @@ -39,10 +39,22 @@ class Bridge { return this.window().setSize(width, height); } + showSaveDialog(options) { + const {dialog} = require('electron'); + if (!options) options = {}; + if (!('defaultPath' in options) && this.lastSelectedPath_) options.defaultPath = this.lastSelectedPath_; + const filePath = dialog.showSaveDialog(options); + if (filePath) { + this.lastSelectedPath_ = filePath; + } + return filePath; + } + showOpenDialog(options) { const {dialog} = require('electron'); if (!options) options = {}; if (!('defaultPath' in options) && this.lastSelectedPath_) options.defaultPath = this.lastSelectedPath_; + if (!('createDirectory' in options)) options.createDirectory = true; const filePaths = dialog.showOpenDialog(options); if (filePaths && filePaths.length) { this.lastSelectedPath_ = dirname(filePaths[0]); @@ -71,6 +83,15 @@ class Bridge { return result === 0; } + showInfoMessageBox(message) { + const result = this.showMessageBox({ + type: 'info', + message: message, + buttons: [_('OK')], + }); + return result === 0; + } + get Menu() { return require('electron').Menu; } diff --git a/ElectronClient/app/gui/StatusScreen.jsx b/ElectronClient/app/gui/StatusScreen.jsx index 148d994da..5717ac280 100644 --- a/ElectronClient/app/gui/StatusScreen.jsx +++ b/ElectronClient/app/gui/StatusScreen.jsx @@ -7,6 +7,7 @@ const { Header } = require('./Header.min.js'); const { themeStyle } = require('../theme.js'); const { _ } = require('lib/locale.js'); const { ReportService } = require('lib/services/report.js'); +const fs = require('fs-extra'); class StatusScreenComponent extends React.Component { @@ -27,6 +28,21 @@ class StatusScreenComponent extends React.Component { this.setState({ report: report }); } + async exportDebugReportClick() { + const filename = 'syncReport-' + (new Date()).getTime() + '.csv'; + + const filePath = bridge().showSaveDialog({ + title: _('Please select where the sync status should be exported to'), + defaultPath: filename, + }); + + if (!filePath) return; + + const service = new ReportService(); + const csv = await service.basicItemList({ format: 'csv' }); + await fs.writeFileSync(filePath, csv); + } + render() { const theme = themeStyle(this.props.theme); const style = this.props.style; @@ -97,6 +113,7 @@ class StatusScreenComponent extends React.Component {
diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index 32991398f..448c3672e 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -218,7 +218,7 @@ class ScreenHeaderComponent extends Component { const itemListCsv = await service.basicItemList({ format: 'csv' }); const filePath = RNFS.ExternalDirectoryPath + '/syncReport-' + (new Date()).getTime() + '.txt'; - const finalText = [logItemCsv, itemListCsv].join("\n--------------------------------------------------------------------------------"); + const finalText = [logItemCsv, itemListCsv].join("\n================================================================================\n"); await RNFS.writeFile(filePath, finalText); alert('Debug report exported to ' + filePath);