Skip to content

Build your personal knowledge base with Trilium Notes

buttons on the left

zadam845f5d15c4a3
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js
index 47ca424af4..8cfeebc6e2 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.js
@@ -38,6 +38,8 @@ import RootContainer from "../widgets/containers/root_container.js";
import NoteUpdateStatusWidget from "../widgets/note_update_status.js";
import SpacerWidget from "../widgets/spacer.js";
import QuickSearchWidget from "../widgets/quick_search.js";
+import ButtonWidget from "../widgets/button_widget.js";
+import ProtectedSessionStatusWidget from "../widgets/protected_session_status.js";
const RIGHT_PANE_CSS = `
<style>
@@ -141,6 +143,29 @@ export default class DesktopLayout {
return new RootContainer()
.setParent(appContext)
+ .child(new FlexContainer("column")
+ .child(new GlobalMenuWidget())
+ .child(new ButtonWidget()
+ .icon("bx-file-blank")
+ .title("New note")
+ .command("createNoteIntoInbox"))
+ .child(new ButtonWidget()
+ .icon("bx-search")
+ .title("Search")
+ .command("searchNotes"))
+ .child(new ButtonWidget()
+ .icon("bx-send")
+ .title("Jump to note")
+ .command("jumpToNote"))
+ .child(new ButtonWidget()
+ .icon("bx-history")
+ .title("Show recent changes")
+ .command("showRecentChanges"))
+ .child(new SpacerWidget())
+ .child(new ProtectedSessionStatusWidget())
+ .child(new SyncStatusWidget())
+ .css("width", "50px")
+ )
.child(new SidePaneContainer('left')
.hideInZenMode()
.css("width", "300px")
@@ -152,16 +177,10 @@ export default class DesktopLayout {
.id('center-pane')
.css("flex-grow", "1")
.child(new FlexContainer('row').overflowing()
- .filling()
- .child(new GlobalMenuWidget())
- .child(new SyncStatusWidget())
- .child(new SpacerWidget())
+ .child(new TabRowWidget())
.child(new TitleBarButtonsWidget())
.css('height', '36px')
)
- .child(new FlexContainer('row').overflowing()
- .child(new TabRowWidget())
- )
.child(new FlexContainer('row').class('title-row')
.css('align-items: center;')
.cssBlock('.title-row > * { margin: 5px; }')
diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js
index b8e3795d14..05f33d7d42 100644
--- a/src/public/app/services/root_command_executor.js
+++ b/src/public/app/services/root_command_executor.js
@@ -3,6 +3,7 @@ import appContext from "./app_context.js";
import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import openService from "./open.js";
+import protectedSessionService from "./protected_session.js";
export default class RootCommandExecutor extends Component {
jumpToNoteCommand() {
@@ -93,4 +94,12 @@ export default class RootCommandExecutor extends Component {
openService.openNoteExternally(noteId);
}
}
+
+ enterProtectedSessionCommand() {
+ protectedSessionService.enterProtectedSession();
+ }
+
+ leaveProtectedSessionCommand() {
+ protectedSessionService.leaveProtectedSession();
+ }
}
diff --git a/src/public/app/widgets/button_widget.js b/src/public/app/widgets/button_widget.js
new file mode 100644
index 0000000000..ed799616ac
--- /dev/null
+++ b/src/public/app/widgets/button_widget.js
@@ -0,0 +1,49 @@
+import BasicWidget from "./basic_widget.js";
+
+const TPL = `
+<span class="button-widget"
+ title="">
+ <span class="bx"></span>
+</span>
+`;
+
+export default class ButtonWidget extends BasicWidget {
+ constructor() {
+ super();
+
+ this.options = {};
+ }
+
+ doRender() {
+ this.$widget = $(TPL);
+ this.refreshIcon();
+ this.overflowing();
+
+ this.$widget.on("click", () => this.triggerCommand(this.options.command));
+
+ super.doRender();
+ }
+
+ refreshIcon() {
+ this.$widget.attr("title", this.options.title);
+ this.$widget.find("span.bx")
+ .removeClass()
+ .addClass("bx")
+ .addClass(this.options.icon);
+ }
+
+ icon(icon) {
+ this.options.icon = icon;
+ return this;
+ }
+
+ title(title) {
+ this.options.title = title;
+ return this;
+ }
+
+ command(command) {
+ this.options.command = command;
+ return this;
+ }
+}
diff --git a/src/public/app/widgets/protected_session_status.js b/src/public/app/widgets/protected_session_status.js
new file mode 100644
index 0000000000..e6f9ccfa43
--- /dev/null
+++ b/src/public/app/widgets/protected_session_status.js
@@ -0,0 +1,33 @@
+import ButtonWidget from "./button_widget.js";
+import protectedSessionHolder from "../services/protected_session_holder.js";
+
+export default class ProtectedSessionStatusWidget extends ButtonWidget {
+ constructor() {
+ super();
+ }
+
+ doRender() {
+ this.updateOptions();
+
+ super.doRender();
+ }
+
+ updateOptions() {
+ this.options.icon = protectedSessionHolder.isProtectedSessionAvailable()
+ ? "bx-shield-quarter"
+ : "bx-log-in";
+
+ this.options.title = protectedSessionHolder.isProtectedSessionAvailable()
+ ? "Protected session is active. Click to leave protected session."
+ : "Click to enter protected session";
+
+ this.options.command = protectedSessionHolder.isProtectedSessionAvailable()
+ ? "leaveProtectedSession"
+ : "enterProtectedSession";
+ }
+
+ protectedSessionStartedEvent() {
+ this.updateOptions();
+ this.refreshIcon();
+ }
+}
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css
index 09a28c4c15..47baca46db 100644
--- a/src/public/stylesheets/style.css
+++ b/src/public/stylesheets/style.css
@@ -928,3 +928,15 @@ ul.fancytree-container li {
padding: 10px;
margin: 10px;
}
+
+.button-widget .bx {
+ font-size: 180%;
+ display: inline-block;
+ position: relative;
+ padding: 10px;
+ cursor: pointer;
+}
+
+.button-widget:hover .bx {
+ background-color: var(--hover-item-background-color);
+}
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index 72b0a79b2f..1353318812 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -16,7 +16,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
collectedNoteIds.add(note.noteId);
- for (const branch of note.parentBranches) {
+ for (const branch of note.getParentBranches()) {
collectedBranchIds.add(branch.branchId);
collectEntityIds(branch.parentNote);
diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js
index 2138e75161..bbf7a924c6 100644
--- a/src/services/search/services/search.js
+++ b/src/services/search/services/search.js
@@ -153,8 +153,6 @@ function findResultsWithQuery(query, searchContext) {
const expression = parseQueryToExpression(query, searchContext);
- console.log("expression", expression);
-
if (!expression) {
return [];
}