mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 10:08:52 +08:00
2 lines
31 KiB
JavaScript
2 lines
31 KiB
JavaScript
(function(e){function t(t){for(var a,r,o=t[0],c=t[1],l=t[2],d=0,f=[];d<o.length;d++)r=o[d],Object.prototype.hasOwnProperty.call(s,r)&&s[r]&&f.push(s[r][0]),s[r]=0;for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&(e[a]=c[a]);u&&u(t);while(f.length)f.shift()();return i.push.apply(i,l||[]),n()}function n(){for(var e,t=0;t<i.length;t++){for(var n=i[t],a=!0,o=1;o<n.length;o++){var c=n[o];0!==s[c]&&(a=!1)}a&&(i.splice(t--,1),e=r(r.s=n[0]))}return e}var a={},s={app:0},i=[];function r(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=a,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/";var o=window["webpackJsonp"]=window["webpackJsonp"]||[],c=o.push.bind(o);o.push=t,o=o.slice();for(var l=0;l<o.length;l++)t(o[l]);var u=c;i.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},"017d":function(e,t,n){},"034f":function(e,t,n){"use strict";var a=n("85ec"),s=n.n(a);s.a},"048e":function(e,t,n){},"0ca3":function(e,t,n){e.exports=n.p+"img/chevron.47c36bae.svg"},"18cf":function(e,t,n){},"1b84":function(e,t,n){},"27e6":function(e,t,n){"use strict";var a=n("4014"),s=n.n(a);s.a},"2eb2":function(e,t,n){},"33da":function(e,t,n){},3742:function(e,t,n){},"3cec":function(e,t,n){},"3e43":function(e,t,n){"use strict";var a=n("5d2b"),s=n.n(a);s.a},4014:function(e,t,n){},4531:function(e,t,n){},4680:function(e,t,n){"use strict";var a=n("600a"),s=n.n(a);s.a},"47b0":function(e,t,n){"use strict";var a=n("d2c9"),s=n.n(a);s.a},4906:function(e,t,n){"use strict";var a=n("fd9a"),s=n.n(a);s.a},"52c7":function(e,t,n){"use strict";var a=n("048e"),s=n.n(a);s.a},5384:function(e,t,n){"use strict";var a=n("ea6d"),s=n.n(a);s.a},"56d7":function(e,t,n){"use strict";n.r(t);n("e260"),n("e6cf"),n("cca6"),n("a79d");var a=n("2b0e"),s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)},i=[],r=(n("034f"),n("2877")),o={},c=Object(r["a"])(o,s,i,!1,null,null,null),l=c.exports,u=n("8c4f"),d=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("splitpanes",{staticClass:"schema-tabs-splitter",attrs:{before:{size:20,max:30},after:{size:80,max:100}}},[n("div",{attrs:{slot:"left-pane"},slot:"left-pane"},[n("schema")],1),n("div",{attrs:{slot:"right-pane"},slot:"right-pane"},[n("tabs")],1)])],1)},f=[],h=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"container",class:["splitpanes","splitpanes--"+(e.horizontal?"horizontal":"vertical"),{"splitpanes--dragging":e.touch.dragging}]},[n("div",{ref:"left",staticClass:"splitpanes__pane",style:e.styles[0],attrs:{size:e.paneBefore.size,"max-size":"30"}},[e._t("left-pane")],2),n("splitter",{attrs:{expanded:0!==e.paneBefore.size},on:{mousedown:e.onMouseDown,toggle:e.toggleFirstPane}}),n("div",{ref:"right",staticClass:"splitpanes__pane",style:e.styles[1]},[e._t("right-pane")],2)],1)},m=[],v=n("ade3"),p=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"splitpanes__splitter",on:{mousedown:function(t){return e.$emit("mousedown")},touchstart:function(t){return e.$emit("mousedown")}}},[a("div",{staticClass:"toggle-btn",on:{click:function(t){return e.$emit("toggle")}}},[a("img",{staticClass:"direction-icon",style:e.directionIconStyle,attrs:{src:n("0ca3")}})])])},b=[],g={name:"splitter",props:["expanded"],computed:{directionIconStyle:function(){var e="translate(-50%, -50%)";return this.$parent.horizontal?{transform:"".concat(e," ").concat(this.expanded?"rotate(-90deg)":"rotate(90deg)")}:{transform:"".concat(e," ").concat(this.expanded?"rotate(180deg)":"")}}}},w=g,x=(n("3e43"),Object(r["a"])(w,p,b,!1,null,null,null)),C=x.exports,y={name:"splitpanes",components:{Splitter:C},props:{horizontal:{type:Boolean,default:!1},before:{type:Object},after:{type:Object}},data:function(){return{container:null,paneBefore:null,paneAfter:null,beforeMinimising:20,touch:{mouseDown:!1,dragging:!1}}},computed:{styles:function(){return[Object(v["a"])({},this.horizontal?"height":"width","".concat(this.paneBefore.size,"%")),Object(v["a"])({},this.horizontal?"height":"width","".concat(this.paneAfter.size,"%"))]}},methods:{bindEvents:function(){document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),"ontouchstart"in window&&(document.addEventListener("touchmove",this.onMouseMove,{passive:!1}),document.addEventListener("touchend",this.onMouseUp))},unbindEvents:function(){document.removeEventListener("mousemove",this.onMouseMove,{passive:!1}),document.removeEventListener("mouseup",this.onMouseUp),"ontouchstart"in window&&(document.removeEventListener("touchmove",this.onMouseMove,{passive:!1}),document.removeEventListener("touchend",this.onMouseUp))},onMouseDown:function(){this.bindEvents(),this.touch.mouseDown=!0},onMouseMove:function(e){this.touch.mouseDown&&(e.preventDefault(),this.touch.dragging=!0,this.calculatePanesSize(this.getCurrentMouseDrag(e)))},onMouseUp:function(){var e=this;this.touch.mouseDown=!1,setTimeout((function(){e.touch.dragging=!1,e.unbindEvents()}),100)},getCurrentMouseDrag:function(e){var t=this.container.getBoundingClientRect(),n="ontouchstart"in window&&e.touches?e.touches[0]:e,a=n.clientX,s=n.clientY;return{x:a-t.left,y:s-t.top}},getCurrentDragPercentage:function(e){e=e[this.horizontal?"y":"x"];var t=this.container[this.horizontal?"clientHeight":"clientWidth"];return 100*e/t},calculatePanesSize:function(e){var t=this.getCurrentDragPercentage(e),n=this.paneBefore,a=this.paneAfter,s=n.max<100&&t>=n.max,i=a.max<100&&t<=100-a.max;s||i?s?(n.size=n.max,a.size=Math.max(100-n.max,0)):(n.size=Math.max(100-a.max,0),a.size=a.max):(n.size=Math.min(Math.max(t,0),n.max),a.size=Math.min(Math.max(100-t,0),a.max))},toggleFirstPane:function(){this.paneBefore.size>0?(this.beforeMinimising=this.paneBefore.size,this.paneBefore.size=0):this.paneBefore.size=this.beforeMinimising,this.paneAfter.size=100-this.paneBefore.size}},mounted:function(){this.container=this.$refs.container},created:function(){this.paneBefore=this.before,this.paneAfter=this.after}},_=y,L=(n("94b3"),Object(r["a"])(_,h,m,!1,null,null,null)),$=L.exports,M=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("input",{attrs:{type:"text",placeholder:"Search table"}}),n("div",{attrs:{id:"db"}},[n("div",{staticClass:"db-name",on:{click:function(t){e.schemaVisible=!e.schemaVisible}}},[n("svg",{staticClass:"chevron-icon",style:{transform:e.schemaVisible?"rotate(90deg)":"rotate(0)"},attrs:{width:"9",height:"9",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M0.721924 9.93097L4.85292 5.79997L0.721924 1.66897L1.99992 0.399973L7.39992 5.79997L1.99992 11.2L0.721924 9.93097Z",fill:e.schemaVisible?"#506784":"rgba(80, 103, 132, 0.5)"}})]),e._v(" "+e._s(e.dbName)+" ")]),n("div",{staticClass:"db-edit"},[n("input",{ref:"dbfile",attrs:{type:"file",id:"actual-btn",hidden:""},on:{change:e.changeDb}}),n("label",{attrs:{for:"actual-btn"}},[n("svg",{staticClass:"db-edit-icon",attrs:{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M3 10.5V12.75C3 14.25 5.2875 15.54 8.25 15.75V13.5825L8.3475 13.5C5.34 13.32 3 12.045 3 10.5ZM9 9.75C5.685 9.75 3 8.4075 3 6.75V9C3 10.6575 5.685 12 9 12C9.2925 12 9.5775 12 9.87 12L12.75 9.09C11.55 9.54 10.2825 9.75 9 9.75ZM9 2.25C5.685 2.25 3 3.5925 3 5.25C3 6.9075 5.685 8.25 9 8.25C12.315 8.25 15 6.9075 15 5.25C15 3.5925 12.315 2.25 9 2.25ZM15.75 8.3475C15.6375 8.3475 15.5325 8.3925 15.4575 8.475L14.7075 9.225L16.245 10.725L16.995 9.975C17.1525 9.825 17.16 9.57 16.995 9.3975L16.065 8.475C15.99 8.3925 15.885 8.3475 15.78 8.3475H15.75ZM14.28 9.66L9.75 14.205V15.75H11.295L15.84 11.1975L14.28 9.66Z",fill:"#A2B1C6"}})])]),n("span",{staticClass:"db-edit-tooltip"},[e._v("Change database")])])]),n("div",{directives:[{name:"show",rawName:"v-show",value:e.schemaVisible,expression:"schemaVisible"}],staticClass:"schema"},e._l(e.schema,(function(e,t){return n("table-description",{key:t,attrs:{name:e[0],sql:e[1]}})})),1)])},T=[],k=(n("baa5"),n("d3b7"),n("ddb0"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"table-name",on:{click:function(t){e.colVisible=!e.colVisible}}},[n("svg",{staticClass:"chevron-icon",style:{transform:e.colVisible?"rotate(90deg)":"rotate(0)"},attrs:{width:"9",height:"9",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M0.721924 9.93097L4.85292 5.79997L0.721924 1.66897L1.99992 0.399973L7.39992 5.79997L1.99992 11.2L0.721924 9.93097Z",fill:e.colVisible?"#506784":"rgba(80, 103, 132, 0.5)"}})]),e._v(" "+e._s(e.name)+" ")]),n("div",{directives:[{name:"show",rawName:"v-show",value:e.colVisible,expression:"colVisible"}],staticClass:"columns"},e._l(e.columns,(function(t,a){return n("div",{key:a,staticClass:"column"},[e._v(" "+e._s(t.name)+" "),n("span",{staticClass:"column-type"},[e._v(e._s(t.type))])])})),0)])}),S=[],E=(n("4160"),n("b0c0"),n("159b"),n("6283")),O=n.n(E),V={name:"TableDescription",props:["name","sql"],data:function(){return{colVisible:!1}},computed:{ast:function(){return O()(this.sql)},columns:function(){var e=[];return this.ast.statement[0].definition.forEach((function(t){if("column"===t.variant){var n=t.datatype.variant;t.datatype.args&&(n=n+"("+t.datatype.args.expression[0].value,2===t.datatype.args.expression.length&&(n=n+", "+t.datatype.args.expression[1].value),n+=")"),e.push({name:t.name,type:n})}})),e}}},H=V,I=(n("5384"),Object(r["a"])(H,k,S,!1,null,"38d0b4fd",null)),z=I.exports,D={name:"Schema",components:{TableDescription:z},data:function(){return{schemaVisible:!0,worker:this.$store.state.worker}},computed:{schema:function(){return this.$store.state.schema},dbName:function(){return this.$store.state.dbName}},methods:{changeDb:function(){var e=this,t=this.$refs.dbfile.value.substr(this.$refs.dbfile.value.lastIndexOf("\\")+1);this.$store.commit("saveDbName",t);var n=this.$refs.dbfile.files[0],a=new FileReader;a.onload=function(){e.worker.onmessage=function(){var t="\n SELECT name, sql\n FROM sqlite_master\n WHERE type='table' AND name NOT LIKE 'sqlite_%';";e.worker.onmessage=function(t){e.$store.commit("saveSchema",t.data.results[0].values)},e.worker.postMessage({action:"exec",sql:t})},e.$store.commit("saveDbFile",a.result);try{e.worker.postMessage({action:"open",buffer:a.result},[a.result])}catch(t){e.worker.postMessage({action:"open",buffer:a.result})}},a.readAsArrayBuffer(n)}}},q=D,N=(n("ef69"),Object(r["a"])(q,M,T,!1,null,"fac73ce8",null)),j=N.exports,P=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{attrs:{id:"tabs__header"}},e._l(e.tabs,(function(t,a){return n("div",{key:t.id,class:[{tab__selected:t.id===e.selectedIndex},"tab"],on:{click:function(n){return e.selectTab(t.id)}}},[n("div",{staticClass:"tab-name"},[n("span",{directives:[{name:"show",rawName:"v-show",value:t.isUnsaved,expression:"tab.isUnsaved"}]},[e._v("*")]),t.name?n("span",[e._v(e._s(t.name))]):n("span",{staticClass:"tab-untitled"},[e._v(e._s(t.tempName))])]),n("div",[n("svg",{staticClass:"close-icon",attrs:{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},on:{click:function(t){return t.stopPropagation(),e.closeTab(a)}}},[n("path",{attrs:{d:"M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z",fill:"#A2B1C6"}})])])])})),0),e._l(e.tabs,(function(e,t){return n("tab-content",{key:e.id,attrs:{id:e.id,"init-name":e.name,"tab-index":t}})}))],2)},B=[],A=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.isActive,expression:"isActive"}],staticClass:"tab-content-container"},[n("splitpanes",{staticClass:"query-results-splitter",attrs:{horizontal:"",before:{size:50,max:50},after:{size:50,max:100}}},[n("div",{staticClass:"query-editor",attrs:{slot:"left-pane"},slot:"left-pane"},[n("div",{staticClass:"codemirror-container"},[n("codemirror",{ref:"codemirror",attrs:{options:e.cmOptions},on:{changes:e.onCmChange},model:{value:e.query,callback:function(t){e.query=t},expression:"query"}})],1),n("div",{staticClass:"run-btn-container"},[n("button",{staticClass:"primary run-btn",on:{click:e.execEditorContents}},[e._v("Run")])])]),n("div",{ref:"bottomPane",attrs:{slot:"right-pane",id:"bottomPane"},slot:"right-pane"},[n("view-switcher",{attrs:{view:e.view},on:{"update:view":function(t){e.view=t}}}),n("div",{directives:[{name:"show",rawName:"v-show",value:"table"===e.view,expression:"view === 'table'"}],staticClass:"table-view"},[e.result?n("sql-table",{attrs:{data:e.result,height:e.tableViewHeight}}):e._e()],1),n("PlotlyEditor",{directives:[{name:"show",rawName:"v-show",value:"chart"===e.view,expression:"view === 'chart'"}],attrs:{data:e.state.data,layout:e.state.layout,frames:e.state.frames,config:{editable:!0},dataSources:e.dataSources,dataSourceOptions:e.dataSourceOptions,plotly:e.plotly,useResizeHandler:!0,debug:!0,advancedTraceTypeSelector:!0},on:{onUpdate:e.update}})],1)])],1)},U=[],Z=(n("d81d"),n("fb6a"),n("b64b"),n("3835")),W=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"rounded-bg"},[n("div",{ref:"header-container",staticClass:"header-container"},[n("div",e._l(e.header,(function(t,a){return n("div",{key:a,staticClass:"fixed-header",style:{width:t.width+"px"}},[e._v(" "+e._s(t.name)+" ")])})),0)]),n("div",{ref:"table-container",staticClass:"table-container",style:{height:e.height+"px"},on:{scroll:e.onScrollTable}},[n("table",{ref:"table"},[n("thead",[n("tr",e._l(e.data.columns,(function(t,a){return n("th",{key:a,ref:"th",refInFor:!0},[n("div",{staticClass:"cell-data",style:e.cellStyle},[e._v(e._s(t))])])})),0)]),n("tbody",e._l(e.currentPageData,(function(t,a){return n("tr",{key:a},e._l(t,(function(t,a){return n("td",{key:a},[n("div",{staticClass:"cell-data",style:e.cellStyle},[e._v(e._s(t))])])})),0)})),0)])])]),n("div",{staticClass:"table-footer"},[n("div",{staticClass:"table-footer-count"},[e._v(" "+e._s(e.data.values.length)+" "+e._s(1===e.data.values.length?"row":"rows")+" retrieved ")]),n("pager",{directives:[{name:"show",rawName:"v-show",value:e.pageCount>1,expression:"pageCount > 1"}],attrs:{"page-count":e.pageCount},model:{value:e.currentPage,callback:function(t){e.currentPage=t},expression:"currentPage"}})],1)])},F=[],R=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("paginate",{attrs:{"page-count":e.pageCount,"page-range":5,"margin-pages":1,"prev-text":e.chevron,"next-text":e.chevron,"no-li-surround":!0,"container-class":"paginator-continer","page-link-class":"paginator-page-link","active-class":"paginator-active-page","break-view-link-class":"paginator-break","next-link-class":"paginator-next","prev-link-class":"paginator-prev","disabled-class":"paginator-disabled"},model:{value:e.page,callback:function(t){e.page=t},expression:"page"}})},Q=[],J=n("8832"),G=n.n(J),K={name:"Pager",components:{Paginate:G.a},props:["pageCount","value"],data:function(){return{page:this.value,chevron:'\n <svg width="9" height="9" viewBox="0 0 8 12" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0.721924 9.93097L4.85292 5.79997L0.721924 1.66897L1.99992 0.399973L7.39992 5.79997L1.99992 11.2L0.721924 9.93097Z" fill="#506784"/>\n </svg>\n '}},watch:{page:function(){this.$emit("input",this.page)},value:function(){this.page=this.value}}},X=K,Y=(n("b7c0"),Object(r["a"])(X,R,Q,!1,null,"526c1dd2",null)),ee=Y.exports,te={name:"SqlTable",components:{Pager:ee},props:["data","height"],data:function(){return{header:null,tableWidth:null,currentPage:1}},computed:{cellStyle:function(){var e=this.tableWidth/this.data.columns.length;return{maxWidth:"".concat(Math.max(e,100),"px")}},pageSize:function(){return Math.max(Math.floor(this.height/40),20)},pageCount:function(){return Math.ceil(this.data.values.length/this.pageSize)},currentPageData:function(){var e=(this.currentPage-1)*this.pageSize;return this.data.values.slice(e,e+this.pageSize)}},methods:{calculateHeadersWidth:function(){var e=this;this.tableWidth=this.$refs["table-container"].offsetWidth,this.$nextTick((function(){e.header=e.$refs.th.map((function(e){return{name:e.innerText,width:e.offsetWidth}}))}))},onScrollTable:function(){this.$refs["header-container"].scrollLeft=this.$refs["table-container"].scrollLeft},functionName:function(){}},mounted:function(){new ResizeObserver(this.calculateHeadersWidth).observe(this.$refs.table),this.calculateHeadersWidth()},watch:{currentPageData:"calculateHeadersWidth",data:function(){this.currentPage=1}}},ne=te,ae=Object(r["a"])(ne,W,F,!1,null,"1b374097",null),se=ae.exports,ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"view-switcher"},[n("div",{class:["table-mode",{"active-mode":"table"===e.view}],on:{click:function(t){return e.$emit("update:view","table")}}},[e._v(" Table ")]),n("div",{class:["chart-mode",{"active-mode":"chart"===e.view}],on:{click:function(t){return e.$emit("update:view","chart")}}},[e._v(" Chart ")])])},re=[],oe={name:"ViewSwitcher",props:["view"]},ce=oe,le=(n("76c2"),Object(r["a"])(ce,ie,re,!1,null,"6204f3ca",null)),ue=le.exports,de=n("f794"),fe=n.n(de),he=(n("0848"),n("56b3")),me=n.n(he),ve=n("8f94"),pe=(n("a7be"),n("ffda"),n("d5db"),n("9b74"),n("f6b6"),n("991c"),{name:"TabContent",props:["id","initName","initQuery","initPlotly","tabIndex"],components:{codemirror:ve["codemirror"],SqlTable:se,Splitpanes:$,ViewSwitcher:ue},data:function(){return{plotly:fe.a,state:{data:[],layout:{},frames:[]},query:"select * from albums",cmOptions:{tabSize:4,mode:"text/x-mysql",theme:"neo",lineNumbers:!0,line:!0},result:null,view:"table",tableViewHeight:0,worker:this.$store.state.worker,isUnsaved:!this.name}},computed:{isActive:function(){return this.id===this.$store.state.currentTabId},dataSources:function(){if(!this.result)return{};var e={},t=this.result.values,n=Object(Z["a"])(t,1),a=n[0],s=a.map((function(e,n){return t.map((function(e){return e[n]}))}));return this.result.columns.forEach((function(t,n){e[t]=s[n]})),e},dataSourceOptions:function(){return Object.keys(this.dataSources).map((function(e){return{value:e,label:e}}))}},created:function(){this.$store.commit("setCurrentTab",this)},mounted:function(){new ResizeObserver(this.calculateTableHeight).observe(this.$refs.bottomPane),this.calculateTableHeight()},watch:{isActive:function(){this.isActive&&this.$store.commit("setCurrentTab",this)},query:function(){this.isUnsaved=!0},isUnsaved:function(){this.$store.commit("updateTabState",{index:this.tabIndex,newValue:this.isUnsaved})}},methods:{update:function(e,t,n){this.state={data:e,layout:t,frames:n},this.isUnsaved=!0,console.log(this.state)},onCmChange:function(e){var t=e.getTokenAt(e.getCursor()).string.slice(-1);if(t&&" "!==t&&";"!==t){var n={completeSingle:!1,completeOnSingleClick:!0};me.a.showHint(e,me.a.hint.sql,n)}},execute:function(e){var t=this;this.worker.onmessage=function(e){t.result=e.data.results[0],t.result||console.log(e.data.error)},this.worker.postMessage({action:"exec",sql:e})},execEditorContents:function(){this.execute(this.query+";")},calculateTableHeight:function(){var e=this.$refs.bottomPane,t=e.offsetHeight-88-42-30-5-40;this.tableViewHeight=t-t%40}}}),be=pe,ge=(n("27e6"),Object(r["a"])(be,A,U,!1,null,"5c0e1488",null)),we=ge.exports,xe={components:{TabContent:we},data:function(){return{}},computed:{tabs:function(){return this.$store.state.tabs},selectedIndex:function(){return this.$store.state.currentTabId}},methods:{selectTab:function(e){this.$store.commit("setCurrentTabId",e)},closeTab:function(e){this.$store.commit("deleteTab",e)}}},Ce=xe,ye=(n("47b0"),Object(r["a"])(Ce,P,B,!1,null,null,null)),_e=ye.exports,Le={name:"Editor",components:{Schema:j,Splitpanes:$,Tabs:_e}},$e=Le,Me=(n("c212"),Object(r["a"])($e,d,f,!1,null,null,null)),Te=Me.exports,ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{attrs:{id:"my-queries-content"}},[e._m(0),n("div",{staticClass:"rounded-bg"},[n("div",{staticClass:"header-container"},[n("div",[n("div",{ref:"name-th",staticClass:"fixed-header"},[e._v(" Name ")]),n("div",{staticClass:"fixed-header"},[e._v(" Created at ")])])]),n("div",{ref:"table-container",staticClass:"table-container"},[n("table",{ref:"table"},[n("tbody",e._l(e.queries,(function(t,a){return n("tr",{key:t.id,on:{click:function(t){return e.openQuery(a)}}},[n("td",{ref:"name-td",refInFor:!0},[e._v(" "+e._s(t.name)+" ")]),n("td",[n("div",{staticClass:"second-column"},[n("div",{staticClass:"date-container"},[e._v(e._s(e._f("date")(t.createdAt)))]),n("div",{staticClass:"icons-container"},[n("rename-icon"),n("copy-icon"),n("export-icon"),n("delete-icon")],1)])])])})),0)])])])])])},Se=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"my-queries-toolbar"}},[n("div",{attrs:{id:"toolbar-buttons"}},[n("button",{staticClass:"toolbar"},[e._v("Import")]),n("button",{staticClass:"toolbar"},[e._v("Export")]),n("button",{staticClass:"toolbar"},[e._v("Delete")])]),n("div",{attrs:{id:"toolbar-search"}},[n("input",{attrs:{type:"text",placeholder:"Search query by name"}})])])}],Ee=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",{staticClass:"icon",attrs:{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M10.545 6.75L11.25 7.455L4.44 14.25H3.75V13.56L10.545 6.75ZM13.245 2.25C13.0575 2.25 12.8625 2.325 12.72 2.4675L11.3475 3.84L14.16 6.6525L15.5325 5.28C15.825 4.9875 15.825 4.5 15.5325 4.2225L13.7775 2.4675C13.6275 2.3175 13.44 2.25 13.245 2.25ZM10.545 4.6425L2.25 12.9375V15.75H5.0625L13.3575 7.455L10.545 4.6425Z",fill:"#A2B1C6"}})])},Oe=[],Ve={name:"RenameIcon"},He=Ve,Ie=(n("d60e"),Object(r["a"])(He,Ee,Oe,!1,null,"7fc41f4e",null)),ze=Ie.exports,De=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",{staticClass:"icon",attrs:{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M14.25 15.75H6V5.25H14.25V15.75ZM14.25 3.75H6C5.60218 3.75 5.22064 3.90804 4.93934 4.18934C4.65804 4.47064 4.5 4.85218 4.5 5.25V15.75C4.5 16.1478 4.65804 16.5294 4.93934 16.8107C5.22064 17.092 5.60218 17.25 6 17.25H14.25C14.6478 17.25 15.0294 17.092 15.3107 16.8107C15.592 16.5294 15.75 16.1478 15.75 15.75V5.25C15.75 4.85218 15.592 4.47064 15.3107 4.18934C15.0294 3.90804 14.6478 3.75 14.25 3.75ZM12 0.75H3C2.60218 0.75 2.22064 0.908035 1.93934 1.18934C1.65804 1.47064 1.5 1.85218 1.5 2.25V12.75H3V2.25H12V0.75Z",fill:"#A2B1C6"}})])},qe=[],Ne={name:"CopyIcon"},je=Ne,Pe=(n("8bcf7"),Object(r["a"])(je,De,qe,!1,null,"09a8a912",null)),Be=Pe.exports,Ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",{staticClass:"icon",attrs:{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M10.5 1.5H4.5C3.675 1.5 3 2.175 3 3V15C3 15.825 3.675 16.5 4.5 16.5H13.5C14.325 16.5 15 15.825 15 15V6L10.5 1.5ZM13.5 15H4.5V3H9.75V6.75H13.5V15ZM12 8.25V13.575L10.425 12L8.325 14.1L6.225 12L8.325 9.9L6.675 8.25H12Z",fill:"#A2B1C6"}})])},Ue=[],Ze={name:"ExportIcon"},We=Ze,Fe=(n("4906"),Object(r["a"])(We,Ae,Ue,!1,null,"f0d82ba4",null)),Re=Fe.exports,Qe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",{staticClass:"icon",attrs:{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},[n("path",{attrs:{d:"M6.75 2.25V3H3V4.5H3.75V14.25C3.75 14.6478 3.90804 15.0294 4.18934 15.3107C4.47064 15.592 4.85218 15.75 5.25 15.75H12.75C13.1478 15.75 13.5294 15.592 13.8107 15.3107C14.092 15.0294 14.25 14.6478 14.25 14.25V4.5H15V3H11.25V2.25H6.75ZM5.25 4.5H12.75V14.25H5.25V4.5ZM6.75 6V12.75H8.25V6H6.75ZM9.75 6V12.75H11.25V6H9.75Z",fill:"#A2B1C6"}})])},Je=[],Ge={name:"DeleteIcon"},Ke=Ge,Xe=(n("4680"),Object(r["a"])(Ke,Qe,Je,!1,null,"2849f01c",null)),Ye=Xe.exports,et={name:"MyQueries",components:{RenameIcon:ze,CopyIcon:Be,ExportIcon:Re,DeleteIcon:Ye},data:function(){return{queries:[]}},created:function(){this.queries=JSON.parse(localStorage.getItem("myQueries"))},mounted:function(){new ResizeObserver(this.calcNameWidth).observe(this.$refs.table),this.calcNameWidth()},filters:{date:function(e){if(!e)return"";var t={year:"numeric",month:"long",day:"numeric"},n={hour12:!1,hour:"2-digit",minute:"2-digit"};return new Date(e).toLocaleDateString("en-GB",t)+" "+new Date(e).toLocaleTimeString("en-GB",n)}},methods:{calcNameWidth:function(){this.$refs["name-th"].style="width: ".concat(this.$refs["name-td"][0].offsetWidth,"px")},openQuery:function(e){var t=this.queries[e];t.isUnsaved=!1,this.$store.commit("addTab",t),this.$store.commit("setCurrentTabId",t.id),this.$router.push("/editor")}}},tt=et,nt=(n("db9c"),Object(r["a"])(tt,ke,Se,!1,null,"2b803c6e",null)),at=nt.exports,st=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"dbloader-container"}},[n("h1",[e._v("Sqliteviz")]),n("label",{attrs:{for:"assetsFieldHandle"}},[n("div",{attrs:{id:"drop-area"},on:{dragover:e.dragover,dragleave:e.dragleave,drop:e.drop}},[n("input",{ref:"file",attrs:{type:"file",id:"assetsFieldHandle",accept:".db"},on:{change:e.loadDb}}),n("div",[e._v(" Drop the database file to upload here or click to choose a file from your computer. ")])])]),n("div",{staticClass:"error",attrs:{id:"error"}})])},it=[],rt={name:"DbUpload",data:function(){return{worker:this.$store.state.worker}},methods:{loadDb:function(){var e=this,t=this.$refs.file.value.substr(this.$refs.file.value.lastIndexOf("\\")+1);this.$store.commit("saveDbName",t);var n=this.$refs.file.files[0],a=new FileReader;a.onload=function(){e.worker.onmessage=function(){var t="\n SELECT name, sql\n FROM sqlite_master\n WHERE type='table' AND name NOT LIKE 'sqlite_%';";e.worker.onmessage=function(t){e.$store.commit("saveSchema",t.data.results[0].values),e.$router.push("/editor")},e.worker.postMessage({action:"exec",sql:t})},e.$store.commit("saveDbFile",a.result);try{e.worker.postMessage({action:"open",buffer:a.result},[a.result])}catch(t){e.worker.postMessage({action:"open",buffer:a.result})}},a.readAsArrayBuffer(n)},dragover:function(e){e.preventDefault(),e.currentTarget.classList.contains("bg-green-300")||(e.currentTarget.classList.remove("bg-gray-100"),e.currentTarget.classList.add("bg-green-300"))},dragleave:function(e){e.currentTarget.classList.add("bg-gray-100"),e.currentTarget.classList.remove("bg-green-300")},drop:function(e){e.preventDefault(),this.$refs.file.files=e.dataTransfer.files,this.loadDb(),e.currentTarget.classList.add("bg-gray-100"),e.currentTarget.classList.remove("bg-green-300")}}},ot=rt,ct=(n("bfbb"),Object(r["a"])(ot,st,it,!1,null,"4abd87ab",null)),lt=ct.exports,ut=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("main-menu"),n("keep-alive",{attrs:{include:"Editor"}},[n("router-view",{attrs:{id:"main-view"}})],1)],1)},dt=[],ft=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("nav",[n("div",[n("router-link",{attrs:{to:"/editor"}},[e._v("Editor")]),n("router-link",{attrs:{to:"/my-queries"}},[e._v("My queries")])],1),n("div",[e.$store.state.tabs.length>0?n("button",{staticClass:"primary",attrs:{disabled:!e.$store.state.currentTab.isUnsaved},on:{click:e.saveQuery}},[e._v(" Save ")]):e._e(),n("button",{staticClass:"primary",on:{click:e.createNewQuery}},[e._v("Create")])])])},ht=[],mt=(n("c740"),n("a9e3"),{name:"MainMenu",methods:{createNewQuery:function(){var e={id:Number(new Date),name:null,tempName:this.$store.state.untitledLastIndex?"Untitled ".concat(this.$store.state.untitledLastIndex):"Untitled",isUnsaved:!0};this.$store.commit("addTab",e),this.$store.commit("setCurrentTabId",e.id),this.$store.commit("updateUntitledLastIndex")},saveQuery:function(){var e=this.$store.state.currentTab,t=!this.$store.state.currentTab.initName,n={id:e.id,query:e.query};t?(n.name=prompt("query name"),this.$store.commit("updateTabName",{index:e.tabIndex,newName:n.name}),n.createdAt=new Date):n.name=e.initName;var a=JSON.parse(localStorage.getItem("myQueries"));if(a)if(t)a.push(n);else{var s=a.findIndex((function(t){return t.id===e.id}));n.createdAt=a[s].createdAt,a[s]=n}else a=[n];localStorage.setItem("myQueries",JSON.stringify(a)),e.isUnsaved=!1}}}),vt=mt,pt=(n("d131"),Object(r["a"])(vt,ft,ht,!1,null,"b6b8732c",null)),bt=pt.exports,gt=(n("e506"),{name:"MainView",components:{MainMenu:bt}}),wt=gt,xt=(n("52c7"),Object(r["a"])(wt,ut,dt,!1,null,"91443d3a",null)),Ct=xt.exports;a["a"].use(u["a"]);var yt=[{path:"/",name:"Welcome",component:lt},{path:"/",name:"MainView",component:Ct,children:[{path:"/editor",name:"Editor",component:Te},{path:"/my-queries",name:"MyQueries",component:at}]}],_t=new u["a"]({routes:yt}),Lt=_t,$t=(n("a434"),n("2f62"));a["a"].use($t["a"]);var Mt=new $t["a"].Store({state:{schema:null,dbFile:null,dbName:null,worker:new Worker("/js/worker.sql-wasm.js"),tabs:[],currentTab:null,currentTabId:null,untitledLastIndex:0},mutations:{saveSchema:function(e,t){e.schema=t},saveDbFile:function(e,t){e.dbFile=t},saveDbName:function(e,t){e.dbName=t},addTab:function(e,t){e.tabs.push(t)},updateTabName:function(e,t){var n=t.index,s=t.newName,i=e.tabs[n];i.name=s,a["a"].set(e.tabs,n,i)},updateTabState:function(e,t){var n=t.index,s=t.newValue;console.log(n,s);var i=e.tabs[n];i.isUnsaved=s,a["a"].set(e.tabs,n,i)},deleteTab:function(e,t){e.tabs[t].id!==e.currentTabId||(t<e.tabs.length-1?e.currentTabId=e.tabs[t+1].id:t>0?e.currentTabId=e.tabs[t-1].id:(e.currentTabId=null,e.untitledLastIndex=0)),e.tabs.splice(t,1)},setCurrentTabId:function(e,t){e.currentTabId=t},setCurrentTab:function(e,t){e.currentTab=t},updateUntitledLastIndex:function(e){e.untitledLastIndex+=1}},actions:{},modules:{}}),Tt=n("6643"),kt=n.n(Tt),St=n("b1c6"),Et=n.n(St);n("017d"),n("33da"),n("2eb2"),n("6d26");a["a"].use(kt.a),a["a"].react("PlotlyEditor",Et.a),a["a"].config.productionTip=!1,new a["a"]({router:Lt,store:Mt,render:function(e){return e(l)}}).$mount("#app")},"5b57":function(e,t,n){},"5d2b":function(e,t,n){},"600a":function(e,t,n){},"6d26":function(e,t,n){},"6e4c":function(e,t,n){},"76c2":function(e,t,n){"use strict";var a=n("9790"),s=n.n(a);s.a},"85ec":function(e,t,n){},"8bcf7":function(e,t,n){"use strict";var a=n("e135"),s=n.n(a);s.a},"94b3":function(e,t,n){"use strict";var a=n("5b57"),s=n.n(a);s.a},9790:function(e,t,n){},b7c0:function(e,t,n){"use strict";var a=n("4531"),s=n.n(a);s.a},bfbb:function(e,t,n){"use strict";var a=n("6e4c"),s=n.n(a);s.a},c212:function(e,t,n){"use strict";var a=n("d883"),s=n.n(a);s.a},d131:function(e,t,n){"use strict";var a=n("18cf"),s=n.n(a);s.a},d2c9:function(e,t,n){},d60e:function(e,t,n){"use strict";var a=n("3742"),s=n.n(a);s.a},d883:function(e,t,n){},db9c:function(e,t,n){"use strict";var a=n("3cec"),s=n.n(a);s.a},e135:function(e,t,n){},e506:function(e,t,n){},ea6d:function(e,t,n){},ef69:function(e,t,n){"use strict";var a=n("1b84"),s=n.n(a);s.a},fd9a:function(e,t,n){}});
|
|
//# sourceMappingURL=app.ea875e01.js.map
|