mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes for SQL console
This commit is contained in:
parent
c41448f5da
commit
e212a37c84
@ -206,7 +206,8 @@ export default class Entrypoints extends Component {
|
||||
}
|
||||
|
||||
async runActiveNoteCommand() {
|
||||
const note = appContext.tabManager.getActiveTabNote();
|
||||
const tabContext = appContext.tabManager.getActiveTabContext();
|
||||
const note = tabContext.note;
|
||||
|
||||
// ctrl+enter is also used elsewhere so make sure we're running only when appropriate
|
||||
if (!note || note.type !== 'code') {
|
||||
@ -220,7 +221,7 @@ export default class Entrypoints extends Component {
|
||||
} else if (note.mime === 'text/x-sqlite;schema=trilium') {
|
||||
const result = await server.post("sql/execute/" + note.noteId);
|
||||
|
||||
this.triggerEvent('sqlQueryResults', {results: result.results});
|
||||
this.triggerEvent('sqlQueryResults', {tabId: tabContext.tabId, results: result.results});
|
||||
}
|
||||
|
||||
toastService.showMessage("Note executed");
|
||||
|
@ -1,9 +1,4 @@
|
||||
import TabAwareWidget from "./tab_aware_widget.js";
|
||||
import treeService from "../services/tree.js";
|
||||
import linkService from "../services/link.js";
|
||||
import hoistedNoteService from "../services/hoisted_note.js";
|
||||
import server from "../services/server.js";
|
||||
import toastService from "../services/toast.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="sql-result-widget">
|
||||
@ -30,11 +25,15 @@ export default class SqlResultWidget extends TabAwareWidget {
|
||||
this.$sqlConsoleResultContainer = this.$widget.find('.sql-console-result-container');
|
||||
}
|
||||
|
||||
async sqlQueryResultsEvent({results}) {
|
||||
async sqlQueryResultsEvent({tabId, results}) {
|
||||
if (!this.isTab(tabId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$sqlConsoleResultContainer.empty();
|
||||
|
||||
for (const rows of results) {
|
||||
if (rows.length === 0) {
|
||||
if (!rows.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -5,23 +5,19 @@ import keyboardActionService from "../../services/keyboard_actions.js";
|
||||
const TPL = `
|
||||
<div class="note-detail-code note-detail-printable">
|
||||
<style>
|
||||
.note-detail-code {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.note-detail-code-editor {
|
||||
min-height: 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<button data-trigger-command="runActiveNote"
|
||||
class="no-print execute-button btn btn-sm"
|
||||
style="position: absolute; top: 0px; right: 10px; z-index: 1000;">
|
||||
Execute
|
||||
</button>
|
||||
|
||||
<div class="note-detail-code-editor"></div>
|
||||
|
||||
<div style="text-align: center">
|
||||
<button data-trigger-command="runActiveNote"
|
||||
class="no-print execute-button btn btn-sm">
|
||||
Execute <kbd data-command="runActiveNote"></kbd>
|
||||
</button>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
export default class EditableCodeTypeWidget extends TypeWidget {
|
||||
|
Loading…
x
Reference in New Issue
Block a user