1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 02:28:54 +08:00

3 Commits

Author SHA1 Message Date
lana-k
db3dbdf993 Merge branch 'master' of github.com:lana-k/sqliteviz 2023-05-17 21:41:17 +02:00
lana-k
4e13a16e33 No blocking while loading predifined #107 2023-05-17 21:37:41 +02:00
lana-k
6320f818cb fix undefined in tests and chart metrics 2022-07-30 16:42:30 +02:00
7 changed files with 84 additions and 23 deletions

22
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "sqliteviz", "name": "sqliteviz",
"version": "0.18.1", "version": "0.22.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sqliteviz", "name": "sqliteviz",
"version": "0.18.1", "version": "0.22.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"codemirror": "^5.57.0", "codemirror": "^5.57.0",
@@ -5248,9 +5248,9 @@
"dev": true "dev": true
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001352", "version": "1.0.30001488",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001352.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001488.tgz",
"integrity": "sha512-GUgH8w6YergqPQDGWhJGt8GDRnY0L/iJVQcU3eJ46GYf52R8tk0Wxp0PymuFVZboJYXGiCqwozAYZNRjVj6IcA==", "integrity": "sha512-NORIQuuL4xGpIy6iCCQGN4iFjlBXtfKWIenlUuyZJumLRIindLb7wXM+GO8erEhb7vXfcnf4BAg2PrSDN5TNLQ==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@@ -5260,6 +5260,10 @@
{ {
"type": "tidelift", "type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite" "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
} }
] ]
}, },
@@ -27489,7 +27493,6 @@
"integrity": "sha512-iFv9J3F5VKUPcbx+TqW5qhGmAVyXQxPRpKpPOuTLFIVTzg+iwJnrqVbL4kJU5ECGDxPESW2oCVgxv9bTlDPu7w==", "integrity": "sha512-iFv9J3F5VKUPcbx+TqW5qhGmAVyXQxPRpKpPOuTLFIVTzg+iwJnrqVbL4kJU5ECGDxPESW2oCVgxv9bTlDPu7w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/core": "^7.11.0",
"@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-compilation-targets": "^7.9.6",
"@babel/helper-module-imports": "^7.8.3", "@babel/helper-module-imports": "^7.8.3",
"@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3",
@@ -27502,7 +27505,6 @@
"@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-plugin-jsx": "^1.0.3",
"@vue/babel-preset-jsx": "^1.2.4", "@vue/babel-preset-jsx": "^1.2.4",
"babel-plugin-dynamic-import-node": "^2.3.3", "babel-plugin-dynamic-import-node": "^2.3.3",
"core-js": "^3.6.5",
"core-js-compat": "^3.6.5", "core-js-compat": "^3.6.5",
"semver": "^6.1.0" "semver": "^6.1.0"
} }
@@ -29627,9 +29629,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001352", "version": "1.0.30001488",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001352.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001488.tgz",
"integrity": "sha512-GUgH8w6YergqPQDGWhJGt8GDRnY0L/iJVQcU3eJ46GYf52R8tk0Wxp0PymuFVZboJYXGiCqwozAYZNRjVj6IcA==", "integrity": "sha512-NORIQuuL4xGpIy6iCCQGN4iFjlBXtfKWIenlUuyZJumLRIindLb7wXM+GO8erEhb7vXfcnf4BAg2PrSDN5TNLQ==",
"dev": true "dev": true
}, },
"canvas-fit": { "canvas-fit": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "sqliteviz", "name": "sqliteviz",
"version": "0.21.1", "version": "0.22.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@@ -53,5 +53,11 @@ export default {
}, },
updatePredefinedInquiries (state, inquiries) { updatePredefinedInquiries (state, inquiries) {
state.predefinedInquiries = Array.isArray(inquiries) ? inquiries : [inquiries] state.predefinedInquiries = Array.isArray(inquiries) ? inquiries : [inquiries]
},
setLoadingPredefinedInquiries (state, value) {
state.loadingPredefinedInquiries = value
},
setPredefinedInquiriesLoaded (state, value) {
state.predefinedInquiriesLoaded = value
} }
} }

View File

@@ -4,5 +4,7 @@ export default {
currentTabId: null, currentTabId: null,
untitledLastIndex: 0, untitledLastIndex: 0,
predefinedInquiries: [], predefinedInquiries: [],
loadingPredefinedInquiries: false,
predefinedInquiriesLoaded: false,
db: null db: null
} }

View File

@@ -1,11 +1,18 @@
<template> <template>
<div> <div id="my-inquiries-container">
<div id="start-guide" v-if="allInquiries.length === 0"> <div id="start-guide" v-if="allInquiries.length === 0">
You don't have saved inquiries so far. You don't have saved inquiries so far.
<span class="link" @click="$root.$emit('createNewInquiry')">Create</span> <span class="link" @click="$root.$emit('createNewInquiry')">Create</span>
the one from scratch or the one from scratch or
<span @click="importInquiries" class="link">import</span> from a file. <span @click="importInquiries" class="link">import</span> from a file.
</div> </div>
<div
id="loading-predefined-status"
v-if="$store.state.loadingPredefinedInquiries"
>
<loading-indicator/>
Loading predefined inquiries...
</div>
<div id="my-inquiries-content" ref="my-inquiries-content" v-show="allInquiries.length > 0"> <div id="my-inquiries-content" ref="my-inquiries-content" v-show="allInquiries.length > 0">
<div id="my-inquiries-toolbar"> <div id="my-inquiries-toolbar">
<div id="toolbar-buttons"> <div id="toolbar-buttons">
@@ -157,6 +164,7 @@ import DeleteIcon from './svg/delete'
import CloseIcon from '@/components/svg/close' import CloseIcon from '@/components/svg/close'
import TextField from '@/components/TextField' import TextField from '@/components/TextField'
import CheckBox from '@/components/CheckBox' import CheckBox from '@/components/CheckBox'
import LoadingIndicator from '@/components/LoadingIndicator'
import tooltipMixin from '@/tooltipMixin' import tooltipMixin from '@/tooltipMixin'
import storedInquiries from '@/lib/storedInquiries' import storedInquiries from '@/lib/storedInquiries'
@@ -169,7 +177,8 @@ export default {
DeleteIcon, DeleteIcon,
CloseIcon, CloseIcon,
TextField, TextField,
CheckBox CheckBox,
LoadingIndicator
}, },
mixins: [tooltipMixin], mixins: [tooltipMixin],
data () { data () {
@@ -248,15 +257,21 @@ export default {
} }
} }
}, },
created () { async created () {
storedInquiries.readPredefinedInquiries() this.inquiries = storedInquiries.getStoredInquiries()
.then(inquiries => { const loadingPredefinedInquiries = this.$store.state.loadingPredefinedInquiries
const predefinedInquiriesLoaded = this.$store.state.predefinedInquiriesLoaded
if (!predefinedInquiriesLoaded && !loadingPredefinedInquiries) {
try {
this.$store.commit('setLoadingPredefinedInquiries', true)
const inquiries = await storedInquiries.readPredefinedInquiries()
this.$store.commit('updatePredefinedInquiries', inquiries) this.$store.commit('updatePredefinedInquiries', inquiries)
}) this.$store.commit('setPredefinedInquiriesLoaded', true)
.catch(console.error) } catch (e) {
.finally(() => { console.error(e)
this.inquiries = storedInquiries.getStoredInquiries() }
}) this.$store.commit('setLoadingPredefinedInquiries', false)
}
}, },
mounted () { mounted () {
this.resizeObserver = new ResizeObserver(this.calcMaxTableHeight) this.resizeObserver = new ResizeObserver(this.calcMaxTableHeight)
@@ -441,6 +456,21 @@ export default {
</script> </script>
<style scoped> <style scoped>
#my-inquiries-container {
position: relative;
}
#loading-predefined-status {
position: absolute;
right: 0;
display: flex;
gap: 4px;
font-size: 12px;
color: var(--color-text-light-2);
align-items: center;
padding: 8px;
}
#start-guide { #start-guide {
position: absolute; position: absolute;
top: 50%; top: 50%;

View File

@@ -66,7 +66,8 @@ export default {
notifyOnLogging: 1 notifyOnLogging: 1
}) })
this.$watch( this.$watch(
() => this.state.data.map(trace => `${trace.type}-${trace.mode}`) () => this.state && this.state.data && this.state.data
.map(trace => `${trace.type}${trace.mode ? '-' + trace.mode : ''}`)
.join(','), .join(','),
(value) => { (value) => {
events.send('viz_plotly.render', null, { events.send('viz_plotly.render', null, {

View File

@@ -7,7 +7,9 @@ const {
setCurrentTabId, setCurrentTabId,
setCurrentTab, setCurrentTab,
updatePredefinedInquiries, updatePredefinedInquiries,
setDb setDb,
setLoadingPredefinedInquiries,
setPredefinedInquiriesLoaded
} = mutations } = mutations
describe('mutations', () => { describe('mutations', () => {
@@ -377,4 +379,22 @@ describe('mutations', () => {
updatePredefinedInquiries(state, inquiries) updatePredefinedInquiries(state, inquiries)
expect(state.predefinedInquiries).to.eql(inquiries) expect(state.predefinedInquiries).to.eql(inquiries)
}) })
it('setLoadingPredefinedInquiries', () => {
const state = {
loadingPredefinedInquiries: false
}
setLoadingPredefinedInquiries(state, true)
expect(state.loadingPredefinedInquiries).to.equal(true)
})
it('setPredefinedInquiriesLoaded', () => {
const state = {
predefinedInquiriesLoaded: false
}
setPredefinedInquiriesLoaded(state, true)
expect(state.predefinedInquiriesLoaded).to.equal(true)
})
}) })