Skip to content

Build your personal knowledge base with Trilium Notes

global actions context menu, logout

azivner78d9fac1e673
diff --git a/src/public/javascripts/services/context_menu.js b/src/public/javascripts/services/context_menu.js
index 72585ea170..d3ac95686a 100644
--- a/src/public/javascripts/services/context_menu.js
+++ b/src/public/javascripts/services/context_menu.js
@@ -6,8 +6,6 @@ function initContextMenu(event, itemContainer, selectContextMenuItem) {
$contextMenuContainer.empty();
for (const item of itemContainer.getItems()) {
- console.log("Adding " + item.title);
-
if (item.title === '----') {
$contextMenuContainer.append($("<div>").addClass("dropdown-divider"));
} else {
diff --git a/src/public/javascripts/services/mobile.js b/src/public/javascripts/services/mobile.js
index af4c804e63..4b3741ca1a 100644
--- a/src/public/javascripts/services/mobile.js
+++ b/src/public/javascripts/services/mobile.js
@@ -90,21 +90,36 @@ $("#note-menu-button").click(async e => {
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
- contextMenuWidget.initContextMenu(e, itemsContainer, noteContextMenuHandler);
-});
+ contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
+ if (cmd === "delete") {
+ treeChangesService.deleteNodes([node]);
-async function noteContextMenuHandler(event, cmd) {
- const node = treeService.getCurrentNode();
+ // move to the tree
+ togglePanes();
+ }
+ else {
+ throw new Error("Unrecognized command " + cmd);
+ }
+ });
+});
- if (cmd === "delete") {
- treeChangesService.deleteNodes([node]);
+$("#global-actions-button").click(async e => {
+ const itemsContainer = new ContextMenuItemsContainer([
+ {title: "Switch to desktop version", cmd: "switch-to-desktop", uiIcon: "computer"},
+ {title: "Logout", cmd: "log-out", uiIcon: "log-out"}
+ ]);
- // move to the tree
- togglePanes();
- }
- else {
- throw new Error("Unrecognized command " + cmd);
- }
-}
+ contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
+ if (cmd === "switch-to-desktop") {
+ alert("switch to desktop");
+ }
+ else if (cmd === 'log-out') {
+ $("#logout-form").submit();
+ }
+ else {
+ throw new Error("Unrecognized command " + cmd);
+ }
+ });
+});
showTree();
\ No newline at end of file
diff --git a/src/views/mobile.ejs b/src/views/mobile.ejs
index 1800d1388e..d58f2c3e61 100644
--- a/src/views/mobile.ejs
+++ b/src/views/mobile.ejs
@@ -14,6 +14,8 @@
<a id="collapse-tree-button" title="Collapse note tree. Shortcut ALT+C" class="icon-action jam jam-layers"></a>
<a id="scroll-to-current-note-button" title="Scroll to current note. Shortcut CTRL+." class="icon-action jam jam-download"></a>
+
+ <a id="global-actions-button" title="Global actions" class="icon-action jam jam-cogs"></a>
</div>
<div id="tree"></div>
@@ -54,6 +56,8 @@
<% include dialogs/protected_session_password.ejs %>
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
+
+ <form action="logout" id="logout-form" method="POST" style="display: none;"></form>
</div>
<script type="text/javascript">