Skip to content

Instantly share code, notes, and snippets.

@krisrice
Created October 31, 2023 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisrice/eda9e01e9068112ccfbe2961680b32e0 to your computer and use it in GitHub Desktop.
Save krisrice/eda9e01e9068112ccfbe2961680b32e0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<title>QuickSQL Standalone</title>
<style>
html, body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
</style>
<body>
<script type="module">
import * as monaco from 'https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/+esm';
import * as ddl from 'https://cdn.jsdelivr.net/gh/oracle/quicksql@main/dist/quick-sql.js';
window.editor = monaco.editor.create(document.querySelector('.monacoQuickSQL'));
window.editorSQL = monaco.editor.create(document.querySelector('.monocoSQL'),
{theme: "vs-dark",
automaticLayout: true,
readOnly: true});
window.editor.getModel().setValue(`
Sample Standalone QuickSQL usage
CDN : https://cdn.jsdelivr.net/gh/oracle/quicksql@main/
Open the Command Pallete (F1) for examples
`);
window.editor.onDidChangeModelContent(e => {
var sql = ddl.toDDL(window.editor.getModel().getValue());
window.editorSQL.getModel().setValue(sql);
});
//
//
// Load up examples from the /test/ regression files
//
//
var exampleBase = "https://cdn.jsdelivr.net/gh/oracle/quicksql@main/";
var exampleFiles=["test/experimental/region_countries.qsql","test/forrestclinic.quicksql","test/empty_emp.quicksql","test/department_employees.quicksql","test/Bug35756025/4.qsql","test/Bug35756025/5.qsql","test/Bug35756025/2.qsql","test/Bug35756025/3.qsql","test/Bug35756025/1.qsql","test/bugs/Bug35637603.quicksql","test/bugs/Bug35649666.quicksql","test/bugs/Bug35063257.quicksql","test/bugs/Bug35775070.qsql","test/bugs/Bug35665146.quicksql","test/bugs/Bug35659128.quicksql","test/bugs/Bug35637614.quicksql","test/bugs/Bug35901476.qsql","test/bugs/Bug35637619.quicksql","test/bugs/35950582.qsql","test/bugs/Bug35669377.quicksql","test/bugs/Bug35637622.quicksql","test/bugs/Bug35667673.quicksql","test/bugs/Bug35650535.quicksql","test/bugs/Bug35637632.quicksql","test/bugs/35923103.qsql","test/bugs/Bug35714343.quicksql","test/bugs/Bug35637611.quicksql","test/timecard.quicksql","test/star/sales_product_customers.qsql","test/departments_employees_skills.quicksql","test/DV/car_racing/2.qsql","test/DV/car_racing/1.qsql","test/to_dos.quicksql","test/erd/Bug35814250/4.qsql","test/erd/Bug35814250/5.qsql","test/erd/Bug35814250/1-3.qsql","test/medipay.quicksql","test/project_management.quicksql"];
// load up the examples in the command pallette
// f1 to open
// add Actions
exampleFiles.forEach(example=>{
var action = {
id : example,
label : "_qs/"+example, // prefix with _ to sort to the top
type: "quickSQLExample",
value: example,
run: function (ed) {
var path = this.id;
// get the source from the CDN/GitHub
fetch(exampleBase + example)
.then(response => response.text())
.then(data => {
window.editor.getModel().setValue(data);
});
}
};
window.editor.addAction(action)
});
</script>
<div style="width: 100%;height: 100%">
<div class="monacoQuickSQL" style="width: 50%; height:100%; float: left;"> </div>
<div class="monocoSQL" style="margin-left: 50%; height: 100%; "> </div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment