Skip to content

Commit

Permalink
Added simple error handling to SQL query editor
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Jan 23, 2024
1 parent d6cf46b commit 97f9ee8
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use_db("todo")
pane_sql_queryResults: [],
pane_sql_query: "",
pane_sql_tabulator: null,
pane_sql_message: null
}
},
template: `<div style='background-color:white; ' >
Expand Down Expand Up @@ -361,6 +362,14 @@ use_db("todo")
v-on:click="pane_sql_executeQuery()" >Run</button>
</div>
<div style="width: 78% ;border: 1px solid blue;display: inline-block;height:300px;vertical-align: top;padding: 10px;"
v-if='pane_sql_message && (selectedTab=="sql")'>
<div style="height: 300px;display: inline-block; width:100%;color: red">
{{ pane_sql_message }}
</div>
</div>
<div style="width: 78% ;border: 1px solid blue;display: inline-block;height:300px;vertical-align: top;"
v-if='pane_sql_queryResults && (pane_sql_queryResults.length > 0) && (selectedTab=="sql")'>
<div id="pane_sql_db_editor_grid_view_parent" style="height: 300px;display: inline-block; width:100%;">
Expand All @@ -374,6 +383,8 @@ use_db("todo")
</div>
</div>
<pre v-if='$DEBUGUI == "true"' style="margin-top: 500px;border: solid 1px blue;padding: 5px;">
--------------------------------------------------------------------
Expand Down Expand Up @@ -1390,20 +1401,25 @@ use_db("todo")
// SQL Pane
pane_sql_executeQuery: async function ( ) {
let mm = this
mm.pane_sql_message = null
let codeId = await mm.getCurrentCommitId()
let baseComponentId = yz.helpers.getValueOfCodeString(mm.text,"base_component_id")
let results = await sqlRx( codeId , baseComponentId , mm.pane_sql_query )
mm.pane_sql_queryResults = results
if (mm.pane_sql_tabulator != null) {
mm.pane_sql_tabulator = null
let parentEl = document.getElementById("pane_sql_db_editor_grid_view_parent")
if (parentEl) {
parentEl.innerHTML = '';
}
}
if (typeof(results) == "undefined") {
mm.pane_sql_message = "An error occurred"
} else {
mm.pane_sql_queryResults = results

if (mm.pane_sql_queryResults.length > 0) {
await mm.pane_sql_drawTabulatorGrid()
if (mm.pane_sql_queryResults.length > 0) {
await mm.pane_sql_drawTabulatorGrid()
}
}
},
pane_sql_drawTabulatorGrid: async function ( ) {
Expand Down

0 comments on commit 97f9ee8

Please sign in to comment.