未验证 提交 ef07200c 编写于 作者: J Jacob Schatz 提交者: Luke "Jared" Bennett

Get initial sql values back from file which is database

上级 acea881b
import Vue from 'vue';
import sqljs from 'sql.js';
export default class BalsamiqViewer {
constructor(el) {
this.el = el;
this.loadSqlFile();
}
loadSqlFile() {
var xhr = new XMLHttpRequest();
console.log(this.el)
xhr.open('GET', this.el.dataset.endpoint, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var uInt8Array = new Uint8Array(this.response);
var db = new SQL.Database(uInt8Array);
var contents = db.exec("SELECT * FROM thumbnails");
console.log(contents)
// contents is now [{columns:['col1','col2',...], values:[[first row], [second row], ...]}]
};
xhr.send();
}
}
\ No newline at end of file
import BalsamiqViewer from './balsamiq';
document.addEventListener('DOMContentLoaded', () => {
new BalsamiqViewer(document.getElementById('js-balsamiq-viewer'));
});
\ No newline at end of file
import renderBalsamiq from './balsamiq';
document.addEventListener('DOMContentLoaded', renderBalsamiq);
\ No newline at end of file
......@@ -15,6 +15,10 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var WEBPACK_REPORT = process.env.WEBPACK_REPORT;
var config = {
// because sqljs requires fs.
node: {
fs: "empty"
},
context: path.join(ROOT_PATH, 'app/assets/javascripts'),
entry: {
common: './commons/index.js',
......@@ -118,6 +122,7 @@ var config = {
'merge_conflicts',
'notebook_viewer',
'pdf_viewer',
'balsamiq_viewer',
'vue_pipelines',
],
minChunks: function(module, count) {
......
......@@ -4154,6 +4154,10 @@ sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
sql.js@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/sql.js/-/sql.js-0.4.0.tgz#23be9635520eb0ff43a741e7e830397266e88445"
sshpk@^1.7.0:
version "1.10.2"
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.2.tgz#d5a804ce22695515638e798dbe23273de070a5fa"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册