Get initial sql values back from file which is database
This commit is contained in:
parent
acea881bb0
commit
ef07200cd0
6 changed files with 42 additions and 3 deletions
27
app/assets/javascripts/blob/balsamiq/index.js
Normal file
27
app/assets/javascripts/blob/balsamiq/index.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
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();
|
||||
}
|
||||
}
|
5
app/assets/javascripts/blob/balsamiq_viewer.js
Normal file
5
app/assets/javascripts/blob/balsamiq_viewer.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import BalsamiqViewer from './balsamiq';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
new BalsamiqViewer(document.getElementById('js-balsamiq-viewer'));
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
import renderBalsamiq from './balsamiq';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', renderBalsamiq);
|
|
@ -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) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"raphael": "^2.2.7",
|
||||
"raw-loader": "^0.5.1",
|
||||
"select2": "3.5.2-browserify",
|
||||
"sql.js": "^0.4.0",
|
||||
"stats-webpack-plugin": "^0.4.3",
|
||||
"three": "^0.84.0",
|
||||
"three-orbit-controls": "^82.1.0",
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue