mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
add switch to manually enter/leave protected session, fixes #107
This commit is contained in:
parent
8bf4633cd0
commit
5dde2752d2
@ -12,6 +12,7 @@ import recentChangesDialog from "../dialogs/recent_changes.js";
|
||||
import sqlConsoleDialog from "../dialogs/sql_console.js";
|
||||
import searchTreeService from "./search_tree.js";
|
||||
import labelsDialog from "../dialogs/labels.js";
|
||||
import protectedSessionService from "./protected_session.js";
|
||||
|
||||
function registerEntrypoints() {
|
||||
// hot keys are active also inside inputs and content editables
|
||||
@ -31,6 +32,9 @@ function registerEntrypoints() {
|
||||
|
||||
$("#recent-changes-button").click(recentChangesDialog.showDialog);
|
||||
|
||||
$("#protected-session-on").click(protectedSessionService.enterProtectedSession);
|
||||
$("#protected-session-off").click(protectedSessionService.leaveProtectedSession);
|
||||
|
||||
$("#recent-notes-button").click(recentNotesDialog.showDialog);
|
||||
utils.bindShortcut('ctrl+e', recentNotesDialog.showDialog);
|
||||
|
||||
|
@ -11,9 +11,23 @@ const $password = $("#protected-session-password");
|
||||
const $noteDetailWrapper = $("#note-detail-wrapper");
|
||||
const $protectButton = $("#protect-button");
|
||||
const $unprotectButton = $("#unprotect-button");
|
||||
const $protectedSessionOnButton = $("#protected-session-on");
|
||||
const $protectedSessionOffButton = $("#protected-session-off");
|
||||
|
||||
let protectedSessionDeferred = null;
|
||||
|
||||
async function enterProtectedSession() {
|
||||
if (!protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
await ensureProtectedSession(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
async function leaveProtectedSession() {
|
||||
if (protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
utils.reloadApp();
|
||||
}
|
||||
}
|
||||
|
||||
function ensureProtectedSession(requireProtectedSession, modal) {
|
||||
const dfd = $.Deferred();
|
||||
|
||||
@ -46,7 +60,7 @@ async function setupProtectedSession() {
|
||||
const password = $password.val();
|
||||
$password.val("");
|
||||
|
||||
const response = await enterProtectedSession(password);
|
||||
const response = await enterProtectedSessionOnServer(password);
|
||||
|
||||
if (!response.success) {
|
||||
infoService.showError("Wrong password.");
|
||||
@ -67,6 +81,9 @@ async function setupProtectedSession() {
|
||||
|
||||
protectedSessionDeferred.resolve();
|
||||
|
||||
$protectedSessionOnButton.addClass('active');
|
||||
$protectedSessionOffButton.removeClass('active');
|
||||
|
||||
protectedSessionDeferred = null;
|
||||
}
|
||||
}
|
||||
@ -81,7 +98,7 @@ function ensureDialogIsClosed() {
|
||||
$password.val('');
|
||||
}
|
||||
|
||||
async function enterProtectedSession(password) {
|
||||
async function enterProtectedSessionOnServer(password) {
|
||||
return await server.post('login/protected', {
|
||||
password: password
|
||||
});
|
||||
@ -138,5 +155,7 @@ export default {
|
||||
protectNoteAndSendToServer,
|
||||
unprotectNoteAndSendToServer,
|
||||
protectBranch,
|
||||
ensureDialogIsClosed
|
||||
ensureDialogIsClosed,
|
||||
enterProtectedSession,
|
||||
leaveProtectedSession
|
||||
};
|
@ -371,4 +371,12 @@ div.ui-tooltip {
|
||||
#history-navigation {
|
||||
margin: 0 20px 0 5px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.btn.active {
|
||||
background-color: #ddd;
|
||||
}
|
@ -23,10 +23,18 @@
|
||||
style="background: url('/images/icons/forward.png')"></a>
|
||||
</div>
|
||||
|
||||
<div style="flex-grow: 100;">
|
||||
<div style="flex-grow: 100; display: flex;">
|
||||
<button class="btn btn-xs" id="jump-to-note-button" title="CTRL+J">Jump to note</button>
|
||||
<button class="btn btn-xs" id="recent-notes-button" title="CTRL+E">Recent notes</button>
|
||||
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
|
||||
<div>
|
||||
<span style="font-size: smaller">Protected session:</span>
|
||||
|
||||
<div class="btn-group btn-group-xs">
|
||||
<button type="button" class="btn" id="protected-session-on">On</button>
|
||||
<button type="button" class="btn active" id="protected-session-off">Off</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="plugin-buttons">
|
||||
|
Loading…
x
Reference in New Issue
Block a user