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

events refactor

This commit is contained in:
lana-k
2022-06-25 22:37:09 +02:00
parent 48e311bff8
commit d56604a7d6
14 changed files with 66 additions and 100 deletions

View File

@@ -70,10 +70,9 @@ export default {
this.state.data.map(trace => `${trace.type}-${trace.mode}`)
),
(value) => {
send({
category: 'viz_plotly',
action: 'render',
label: `type=${value} pivot=${this.forPivot ? 'true' : 'false'}`
send('viz_plotly.render', undefined, {
type: value,
pivot: !!this.forPivot
})
},
{ deep: true }

View File

@@ -88,12 +88,16 @@ export default {
'pivotOptions.rendererName': {
immediate: true,
handler () {
this.$emit('update:importToPngEnabled', this.pivotOptions.rendererName !== 'TSV Export')
this.$emit('update:importToSvgEnabled', this.viewStandartChart || this.viewCustomChart)
send({
category: 'viz_pivot',
action: 'render',
label: `type=${this.pivotOptions.rendererName}`
this.$emit(
'update:importToPngEnabled',
this.pivotOptions.rendererName !== 'TSV Export'
)
this.$emit(
'update:importToSvgEnabled',
this.viewStandartChart || this.viewCustomChart
)
send('viz_pivot.render', undefined, {
type: this.pivotOptions.rendererName
})
}
},

View File

@@ -201,13 +201,19 @@ export default {
this.exportSignal('html')
},
exportSignal (to) {
send({
category: this.plotlyInPivot || this.mode === 'chart'
? 'viz_plotly' : 'viz_pivot',
action: 'export',
label: `type=${to}${this.plotlyInPivot
? ' pivot=true' : this.mode === 'chart' ? ' pivot=false' : ''}`
})
const eventLabels = { type: to }
if (this.mode === 'chart' || this.plotlyInPivot) {
eventLabels.pivot = this.plotlyInPivot
}
send(
this.mode === 'chart' || this.plotlyInPivot
? 'viz_plotly.export'
: 'viz_pivot.export',
undefined,
eventLabels
)
}
}
}

View File

@@ -119,12 +119,10 @@ export default {
exportToCsv () {
if (this.result && this.result.values) {
send({
category: 'resultset',
action: 'export',
value: this.result.values[this.result.columns[0]].length,
label: 'to=csv'
})
send('resultset.export',
this.result.values[this.result.columns[0]].length,
{ to: 'csv' }
)
}
fIo.exportToFile(csv.serialize(this.result), 'result_set.csv', 'text/csv')
@@ -132,12 +130,10 @@ export default {
async prepareCopy () {
if (this.result && this.result.values) {
send({
category: 'resultset',
action: 'export',
value: this.result.values[this.result.columns[0]].length,
label: 'to=clipboard'
})
send('resultset.export',
this.result.values[this.result.columns[0]].length,
{ to: 'clipboard' }
)
}
if ('ClipboardItem' in window) {

View File

@@ -109,6 +109,8 @@ export default {
const fromPosition = this.layout[from]
this.layout[from] = this.layout[to]
this.layout[to] = fromPosition
send('inquiry.panel', undefined, { panel: to })
},
onDataViewUpdate () {
this.$store.commit('updateTab', { index: this.tabIndex, isSaved: false })
@@ -124,31 +126,19 @@ export default {
this.time = time.getPeriod(start, new Date())
if (this.result && this.result.values) {
send({
category: 'resultset',
action: 'create',
value: this.result.values[this.result.columns[0]].length
})
send('resultset.create',
this.result.values[this.result.columns[0]].length
)
}
send({
category: 'query',
action: 'run',
value: this.time,
label: 'status=success'
})
send('query.run', parseFloat(this.time), { status: 'success' })
} catch (err) {
this.error = {
type: 'error',
message: err
}
send({
category: 'query',
action: 'run',
value: 0,
label: 'status=error'
})
send('query.run', 0, { status: 'error' })
}
state.db.refreshSchema()
this.isGettingResults = false