mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
fix SQL console
This commit is contained in:
@@ -8,6 +8,10 @@ const TPL = `
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="sql-query-no-rows alert alert-info" style="display: none;">
|
||||
No rows have been returned for this query.
|
||||
</div>
|
||||
|
||||
<div class="sql-console-result-container"></div>
|
||||
</div>`;
|
||||
|
||||
@@ -21,7 +25,8 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
|
||||
this.$sqlConsoleResultContainer = this.$widget.find('.sql-console-result-container');
|
||||
this.$resultContainer = this.$widget.find('.sql-console-result-container');
|
||||
this.$noRowsAlert = this.$widget.find('.sql-query-no-rows');
|
||||
}
|
||||
|
||||
async sqlQueryResultsEvent({ntxId, results}) {
|
||||
@@ -29,7 +34,10 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$sqlConsoleResultContainer.empty();
|
||||
this.$noRowsAlert.toggle(results.length === 1 && results[0].length === 0);
|
||||
this.$resultContainer.toggle(results.length > 1 || results[0].length > 0);
|
||||
|
||||
this.$resultContainer.empty();
|
||||
|
||||
for (const rows of results) {
|
||||
if (!rows.length) {
|
||||
@@ -37,7 +45,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
const $table = $('<table class="table table-striped">');
|
||||
this.$sqlConsoleResultContainer.append($table);
|
||||
this.$resultContainer.append($table);
|
||||
|
||||
const result = rows[0];
|
||||
const $row = $("<tr>");
|
||||
|
||||
Reference in New Issue
Block a user