mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-10 03:58:54 +08:00
events refactor
This commit is contained in:
@@ -79,13 +79,9 @@ class Database {
|
||||
this.dbName = file ? fu.getFileName(file) : 'database'
|
||||
this.refreshSchema()
|
||||
|
||||
send({
|
||||
category: 'database',
|
||||
action: 'import',
|
||||
value: file ? file.size : 0,
|
||||
label: file
|
||||
? 'from=sqlite new_db=true'
|
||||
: 'from=none new_db=true'
|
||||
send('database.import', file ? file.size : 0, {
|
||||
from: file ? 'sqlite' : 'none',
|
||||
new_db: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,12 +121,7 @@ class Database {
|
||||
throw new Error(data.error)
|
||||
}
|
||||
fu.exportToFile(data, fileName)
|
||||
send({
|
||||
category: 'database',
|
||||
action: 'export',
|
||||
value: data.byteLength,
|
||||
label: 'to=sqlite'
|
||||
})
|
||||
send('database.export', data.byteLength, { to: 'sqlite' })
|
||||
}
|
||||
|
||||
async validateTableName (name) {
|
||||
|
||||
@@ -106,11 +106,7 @@ export default {
|
||||
.then(str => {
|
||||
const inquires = this.deserialiseInquiries(str)
|
||||
|
||||
send({
|
||||
category: 'inquiry',
|
||||
action: 'import',
|
||||
value: inquires.length
|
||||
})
|
||||
send('inquiry.import', inquires.length)
|
||||
|
||||
return inquires
|
||||
})
|
||||
@@ -119,11 +115,7 @@ export default {
|
||||
const jsonStr = this.serialiseInquiries(inquiryList)
|
||||
fu.exportToFile(jsonStr, fileName)
|
||||
|
||||
send({
|
||||
category: 'inquiry',
|
||||
action: 'export',
|
||||
value: inquiryList.length
|
||||
})
|
||||
send('inquiry.export', inquiryList.length)
|
||||
},
|
||||
|
||||
async readPredefinedInquiries () {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
export function send (payload) {
|
||||
console.log(payload)
|
||||
export function send (name, value, labels) {
|
||||
console.log(name, value, labels)
|
||||
|
||||
const event = new CustomEvent('sqliteviz-app-event', {
|
||||
detail: payload
|
||||
detail: {
|
||||
name,
|
||||
value,
|
||||
labels
|
||||
}
|
||||
})
|
||||
window.dispatchEvent(event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user