1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

CLI: Various UI improvements for E2EE

This commit is contained in:
Laurent Cozic 2017-12-28 19:51:24 +00:00
parent 08d2655f13
commit 9e869a5b1f
4 changed files with 14 additions and 7 deletions

View File

@ -21,10 +21,6 @@ class Command extends BaseCommand {
]; ];
} }
enabled() {
return false;
}
async action(args) { async action(args) {
let title = args['note']; let title = args['note'];
@ -33,6 +29,9 @@ class Command extends BaseCommand {
const content = args.options.verbose ? await Note.serialize(item) : await Note.serializeForEdit(item); const content = args.options.verbose ? await Note.serialize(item) : await Note.serializeForEdit(item);
this.stdout(content); this.stdout(content);
app().gui().showConsole();
app().gui().maximizeConsole();
} }
} }

View File

@ -45,6 +45,8 @@ class Command extends BaseCommand {
} }
if (args.command === 'decrypt') { if (args.command === 'decrypt') {
this.stdout(_('Starting decryption... Please wait as it may take several minutes depending on how much there is to decrypt.'));
while (true) { while (true) {
try { try {
await DecryptionWorker.instance().start(); await DecryptionWorker.instance().start();
@ -65,6 +67,9 @@ class Command extends BaseCommand {
throw error; throw error;
} }
} }
this.stdout(_('Completed decryption.'));
return; return;
} }
} }

View File

@ -44,7 +44,8 @@ class NoteWidget extends TextWidget {
} else if (this.noteId_) { } else if (this.noteId_) {
this.doAsync('loadNote', async () => { this.doAsync('loadNote', async () => {
this.note_ = await Note.load(this.noteId_); this.note_ = await Note.load(this.noteId_);
if (this.note_.encryption_applied) {
if (this.note_ && this.note_.encryption_applied) {
this.text = _('One or more items are currently encrypted and you may need to supply a master password. To do so please type `e2ee decrypt`. If you have already supplied the password, the encrypted items are being decrypted in the background and will be available soon.'); this.text = _('One or more items are currently encrypted and you may need to supply a master password. To do so please type `e2ee decrypt`. If you have already supplied the password, the encrypted items are being decrypted in the background and will be available soon.');
} else { } else {
this.text = this.note_ ? this.note_.title + "\n\n" + this.note_.body : ''; this.text = this.note_ ? this.note_.title + "\n\n" + this.note_.body : '';

View File

@ -105,6 +105,8 @@ class StatusBarWidget extends BaseWidget {
this.term.showCursor(true); this.term.showCursor(true);
const isSecurePrompt = !!this.promptState_.secure;
let options = { let options = {
cancelable: true, cancelable: true,
history: this.history, history: this.history,
@ -112,7 +114,7 @@ class StatusBarWidget extends BaseWidget {
}; };
if ('cursorPosition' in this.promptState_) options.cursorPosition = this.promptState_.cursorPosition; if ('cursorPosition' in this.promptState_) options.cursorPosition = this.promptState_.cursorPosition;
if (this.promptState_.secure) options.echoChar = true; if (isSecurePrompt) options.echoChar = true;
this.inputEventEmitter_ = this.term.inputField(options, (error, input) => { this.inputEventEmitter_ = this.term.inputField(options, (error, input) => {
let resolveResult = null; let resolveResult = null;
@ -127,7 +129,7 @@ class StatusBarWidget extends BaseWidget {
resolveResult = input ? input.trim() : input; resolveResult = input ? input.trim() : input;
// Add the command to history but only if it's longer than one character. // Add the command to history but only if it's longer than one character.
// Below that it's usually an answer like "y"/"n", etc. // Below that it's usually an answer like "y"/"n", etc.
if (input && input.length > 1) this.history_.push(input); if (!isSecurePrompt && input && input.length > 1) this.history_.push(input);
} }
} }