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

#115 add split in result set

This commit is contained in:
lana-k
2023-10-25 20:43:22 +02:00
parent 8aac7af481
commit bec3d9c737
2 changed files with 91 additions and 32 deletions

View File

@@ -1,6 +1,63 @@
<template> <template>
<div class="run-result-panel" ref="runResultPanel"> <div class="run-result-panel">
<div class="run-result-panel-content"> <component
:is="viewValuePanelVisible ? 'splitpanes':'div'"
:before="{ size: 50, max: 100 }"
:after="{ size: 50, max: 100 }"
:default="{ before: 50, after: 50 }"
class="run-result-panel-content"
>
<template #left-pane>
<div :id="'run-result-left-pane-'+tab.id" class="result-set-container"/>
</template>
<div :id="'run-result-result-set-'+tab.id" class="result-set-container"/>
<template #right-pane v-if="viewValuePanelVisible">
<div>hello</div>
</template>
</component>
<side-tool-bar @switchTo="$emit('switchTo', $event)" panel="table">
<icon-button
:disabled="!result"
tooltip="Export result set to CSV file"
tooltip-position="top-left"
@click="exportToCsv"
>
<export-to-csv-icon/>
</icon-button>
<icon-button
:disabled="!result"
tooltip="Copy result set to clipboard"
tooltip-position="top-left"
@click="prepareCopy"
>
<clipboard-icon/>
</icon-button>
<icon-button
:disabled="!result"
tooltip="View value"
tooltip-position="top-left"
@click="toggleViewValuePanel"
>
<clipboard-icon/>
</icon-button>
</side-tool-bar>
<loading-dialog
loadingMsg="Building CSV..."
successMsg="CSV is ready"
actionBtnName="Copy"
name="prepareCSVCopy"
title="Copy to clipboard"
:loading="preparingCopy"
@action="copyToClipboard"
@cancel="cancelCopy"
/>
<teleport :to="resultSetTeleportTarget">
<div ref="runResultPanel">
<div <div
v-show="result === null && !isGettingResults && !error" v-show="result === null && !isGettingResults && !error"
class="table-preview result-before" class="table-preview result-before"
@@ -26,36 +83,7 @@
class="straight" class="straight"
/> />
</div> </div>
<side-tool-bar @switchTo="$emit('switchTo', $event)" panel="table"> </teleport>
<icon-button
:disabled="!result"
tooltip="Export result set to CSV file"
tooltip-position="top-left"
@click="exportToCsv"
>
<export-to-csv-icon/>
</icon-button>
<icon-button
:disabled="!result"
tooltip="Copy result set to clipboard"
tooltip-position="top-left"
@click="prepareCopy"
>
<clipboard-icon/>
</icon-button>
</side-tool-bar>
<loading-dialog
loadingMsg="Building CSV..."
successMsg="CSV is ready"
actionBtnName="Copy"
name="prepareCSVCopy"
title="Copy to clipboard"
:loading="preparingCopy"
@action="copyToClipboard"
@cancel="cancelCopy"
/>
</div> </div>
</template> </template>
@@ -63,7 +91,8 @@
import Logs from '@/components/Logs' import Logs from '@/components/Logs'
import SqlTable from '@/components/SqlTable' import SqlTable from '@/components/SqlTable'
import LoadingIndicator from '@/components/LoadingIndicator' import LoadingIndicator from '@/components/LoadingIndicator'
import SideToolBar from './SideToolBar' import SideToolBar from '../SideToolBar'
import Splitpanes from '@/components/Splitpanes'
import ExportToCsvIcon from '@/components/svg/exportToCsv' import ExportToCsvIcon from '@/components/svg/exportToCsv'
import ClipboardIcon from '@/components/svg/clipboard' import ClipboardIcon from '@/components/svg/clipboard'
import IconButton from '@/components/IconButton' import IconButton from '@/components/IconButton'
@@ -73,16 +102,24 @@ import cIo from '@/lib/utils/clipboardIo'
import time from '@/lib/utils/time' import time from '@/lib/utils/time'
import loadingDialog from '@/components/LoadingDialog' import loadingDialog from '@/components/LoadingDialog'
import events from '@/lib/utils/events' import events from '@/lib/utils/events'
import Teleport from 'vue2-teleport'
export default { export default {
name: 'RunResult', name: 'RunResult',
props: ['result', 'isGettingResults', 'error', 'time'], props: {
tab: Object,
result: Object,
isGettingResults: Boolean,
error: Object,
time: [String, Number]
},
data () { data () {
return { return {
resizeObserver: null, resizeObserver: null,
pageSize: 20, pageSize: 20,
preparingCopy: false, preparingCopy: false,
dataToCopy: null dataToCopy: null,
viewValuePanelVisible: false
} }
}, },
components: { components: {
@@ -93,7 +130,19 @@ export default {
ExportToCsvIcon, ExportToCsvIcon,
IconButton, IconButton,
ClipboardIcon, ClipboardIcon,
loadingDialog loadingDialog,
Splitpanes,
Teleport
},
computed: {
resultSetTeleportTarget () {
const base = `#${this.viewValuePanelVisible
? 'run-result-left-pane'
: 'run-result-result-set'
}`
const tabIdPostfix = `-${this.tab.id}`
return base + tabIdPostfix
}
}, },
mounted () { mounted () {
this.resizeObserver = new ResizeObserver(this.handleResize) this.resizeObserver = new ResizeObserver(this.handleResize)
@@ -167,6 +216,10 @@ export default {
cancelCopy () { cancelCopy () {
this.dataToCopy = null this.dataToCopy = null
this.$modal.hide('prepareCSVCopy') this.$modal.hide('prepareCSVCopy')
},
toggleViewValuePanel () {
this.viewValuePanelVisible = !this.viewValuePanelVisible
} }
} }
} }
@@ -180,10 +233,15 @@ export default {
} }
.run-result-panel-content { .run-result-panel-content {
position: relative;
flex-grow: 1; flex-grow: 1;
height: 100%; height: 100%;
width: 0; width: 0;
}
.result-set-container {
position: relative;
height: 100%;
width: 100%;
box-sizing: border-box; box-sizing: border-box;
} }

View File

@@ -29,6 +29,7 @@
<teleport :to="`#${tab.layout.table}-${tab.id}`"> <teleport :to="`#${tab.layout.table}-${tab.id}`">
<run-result <run-result
:tab="tab"
:result="tab.result" :result="tab.result"
:is-getting-results="tab.isGettingResults" :is-getting-results="tab.isGettingResults"
:error="tab.error" :error="tab.error"