You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Electron: Added dialog to export sync status
This commit is contained in:
@@ -39,10 +39,22 @@ class Bridge {
|
|||||||
return this.window().setSize(width, height);
|
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) {
|
showOpenDialog(options) {
|
||||||
const {dialog} = require('electron');
|
const {dialog} = require('electron');
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
if (!('defaultPath' in options) && this.lastSelectedPath_) options.defaultPath = this.lastSelectedPath_;
|
if (!('defaultPath' in options) && this.lastSelectedPath_) options.defaultPath = this.lastSelectedPath_;
|
||||||
|
if (!('createDirectory' in options)) options.createDirectory = true;
|
||||||
const filePaths = dialog.showOpenDialog(options);
|
const filePaths = dialog.showOpenDialog(options);
|
||||||
if (filePaths && filePaths.length) {
|
if (filePaths && filePaths.length) {
|
||||||
this.lastSelectedPath_ = dirname(filePaths[0]);
|
this.lastSelectedPath_ = dirname(filePaths[0]);
|
||||||
@@ -71,6 +83,15 @@ class Bridge {
|
|||||||
return result === 0;
|
return result === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showInfoMessageBox(message) {
|
||||||
|
const result = this.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
message: message,
|
||||||
|
buttons: [_('OK')],
|
||||||
|
});
|
||||||
|
return result === 0;
|
||||||
|
}
|
||||||
|
|
||||||
get Menu() {
|
get Menu() {
|
||||||
return require('electron').Menu;
|
return require('electron').Menu;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const { Header } = require('./Header.min.js');
|
|||||||
const { themeStyle } = require('../theme.js');
|
const { themeStyle } = require('../theme.js');
|
||||||
const { _ } = require('lib/locale.js');
|
const { _ } = require('lib/locale.js');
|
||||||
const { ReportService } = require('lib/services/report.js');
|
const { ReportService } = require('lib/services/report.js');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
class StatusScreenComponent extends React.Component {
|
class StatusScreenComponent extends React.Component {
|
||||||
|
|
||||||
@@ -27,6 +28,21 @@ class StatusScreenComponent extends React.Component {
|
|||||||
this.setState({ report: report });
|
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() {
|
render() {
|
||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
const style = this.props.style;
|
const style = this.props.style;
|
||||||
@@ -97,6 +113,7 @@ class StatusScreenComponent extends React.Component {
|
|||||||
<div style={style}>
|
<div style={style}>
|
||||||
<Header style={headerStyle} />
|
<Header style={headerStyle} />
|
||||||
<div style={containerStyle}>
|
<div style={containerStyle}>
|
||||||
|
<a style={theme.textStyle} onClick={() => this.exportDebugReportClick()}href="#">Export debug report</a>
|
||||||
{body}
|
{body}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class ScreenHeaderComponent extends Component {
|
|||||||
const itemListCsv = await service.basicItemList({ format: 'csv' });
|
const itemListCsv = await service.basicItemList({ format: 'csv' });
|
||||||
const filePath = RNFS.ExternalDirectoryPath + '/syncReport-' + (new Date()).getTime() + '.txt';
|
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);
|
await RNFS.writeFile(filePath, finalText);
|
||||||
alert('Debug report exported to ' + filePath);
|
alert('Debug report exported to ' + filePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user