mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
#115 fix new lines - use pre
This commit is contained in:
@@ -36,8 +36,7 @@
|
|||||||
<td
|
<td
|
||||||
v-for="(col, colIndex) in columns"
|
v-for="(col, colIndex) in columns"
|
||||||
:data-col="colIndex"
|
:data-col="colIndex"
|
||||||
:data-row="rowIndex - 1"
|
:data-row="pageSize * (currentPage - 1) + rowIndex - 1"
|
||||||
:data-record="pageSize * (currentPage - 1) + rowIndex - 1"
|
|
||||||
:data-isNull="isNull(getCellValue(col, rowIndex))"
|
:data-isNull="isNull(getCellValue(col, rowIndex))"
|
||||||
:data-isBlob="isBlob(getCellValue(col, rowIndex))"
|
:data-isBlob="isBlob(getCellValue(col, rowIndex))"
|
||||||
:key="colIndex"
|
:key="colIndex"
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
<tr v-for="(col, index) in columns" :key="index">
|
<tr v-for="(col, index) in columns" :key="index">
|
||||||
<th>{{ col }}</th>
|
<th>{{ col }}</th>
|
||||||
<td
|
<td
|
||||||
:data-col="1"
|
:data-col="index"
|
||||||
:data-row="index"
|
:data-row="currentRowIndex"
|
||||||
:data-isNull="isNull(getCellValue(col))"
|
:data-isNull="isNull(getCellValue(col))"
|
||||||
:data-isBlob="isBlob(getCellValue(col))"
|
:data-isBlob="isBlob(getCellValue(col))"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -75,7 +75,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
const cell = this.$refs.table
|
const cell = this.$refs.table
|
||||||
.querySelector(`td[data-col="1"][data-row="${this.selectedColumnIndex}"]`)
|
.querySelector(`td[data-col="${this.selectedColumnIndex}"][data-row="${this.currentRowIndex}"]`)
|
||||||
if (cell) {
|
if (cell) {
|
||||||
this.selectCell(cell)
|
this.selectCell(cell)
|
||||||
}
|
}
|
||||||
@@ -153,13 +153,13 @@ export default {
|
|||||||
this.$emit('updateSelectedCell', this.selectedCellElement)
|
this.$emit('updateSelectedCell', this.selectedCellElement)
|
||||||
},
|
},
|
||||||
moveFocusInTable (initialCell, direction) {
|
moveFocusInTable (initialCell, direction) {
|
||||||
const currentRowIndex = +initialCell.dataset.row
|
const currentColIndex = +initialCell.dataset.col
|
||||||
const newRowIndex = direction === 'up'
|
const newColIndex = direction === 'up'
|
||||||
? currentRowIndex - 1
|
? currentColIndex - 1
|
||||||
: currentRowIndex + 1
|
: currentColIndex + 1
|
||||||
|
|
||||||
const newCell = this.$refs.table
|
const newCell = this.$refs.table
|
||||||
.querySelector(`td[data-col="1"][data-row="${newRowIndex}"]`)
|
.querySelector(`td[data-col="${newColIndex}"][data-row="${this.currentRowIndex}"]`)
|
||||||
if (newCell) {
|
if (newCell) {
|
||||||
this.selectCell(newCell)
|
this.selectCell(newCell)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,10 @@
|
|||||||
:value="formattedJson"
|
:value="formattedJson"
|
||||||
:options="cmOptions"
|
:options="cmOptions"
|
||||||
/>
|
/>
|
||||||
<div
|
<pre
|
||||||
v-if="currentFormat === 'text'"
|
v-if="currentFormat === 'text'"
|
||||||
:class="['text-value', { 'meta-value': isNull || isBlob }]"
|
:class="['text-value', { 'meta-value': isNull || isBlob }]"
|
||||||
>
|
>{{ cellText }}</pre>
|
||||||
{{ cellValue }}
|
|
||||||
</div>
|
|
||||||
<logs
|
<logs
|
||||||
v-if="messages && messages.length > 0"
|
v-if="messages && messages.length > 0"
|
||||||
:messages="messages"
|
:messages="messages"
|
||||||
@@ -59,9 +57,7 @@ export default {
|
|||||||
Logs
|
Logs
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
cellValue: [String, Number],
|
cellValue: [String, Number, Uint8Array]
|
||||||
isNull: Boolean,
|
|
||||||
isBlob: Boolean
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -84,17 +80,35 @@ export default {
|
|||||||
messages: []
|
messages: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isBlob () {
|
||||||
|
return this.cellValue && ArrayBuffer.isView(this.cellValue)
|
||||||
|
},
|
||||||
|
isNull () {
|
||||||
|
return this.cellValue === null
|
||||||
|
},
|
||||||
|
cellText () {
|
||||||
|
const value = this.cellValue
|
||||||
|
if (this.isNull) {
|
||||||
|
return 'NULL'
|
||||||
|
}
|
||||||
|
if (this.isBlob) {
|
||||||
|
return 'BLOB'
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentFormat () {
|
currentFormat () {
|
||||||
this.messages = []
|
this.messages = []
|
||||||
this.formattedJson = ''
|
this.formattedJson = ''
|
||||||
if (this.currentFormat === 'json') {
|
if (this.currentFormat === 'json') {
|
||||||
this.formatJson(this.isNull ? null : this.cellValue)
|
this.formatJson(this.cellValue)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cellValue () {
|
cellValue () {
|
||||||
if (this.currentFormat === 'json') {
|
if (this.currentFormat === 'json') {
|
||||||
this.formatJson(this.isNull ? null : this.cellValue)
|
this.formatJson(this.cellValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
<div class="value-viewer-container">
|
<div class="value-viewer-container">
|
||||||
<value-viewer
|
<value-viewer
|
||||||
v-show="selectedCell"
|
v-show="selectedCell"
|
||||||
:cellValue="selectedCell ? selectedCell.innerText : ''"
|
:cellValue="selectedCell
|
||||||
:is-null="selectedCell && selectedCell.dataset.isnull === 'true'"
|
? result.values[result.columns[selectedCell.dataset.col]][selectedCell.dataset.row]
|
||||||
:is-blob="selectedCell && selectedCell.dataset.isblob === 'true'"
|
: ''"
|
||||||
/>
|
/>
|
||||||
<div v-show="!selectedCell" class="table-preview">
|
<div v-show="!selectedCell" class="table-preview">
|
||||||
No cell selected to view
|
No cell selected to view
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
:data-set="result"
|
:data-set="result"
|
||||||
:time="time"
|
:time="time"
|
||||||
:selected-column-index="selectedCell ? +selectedCell.dataset.col : 0"
|
:selected-column-index="selectedCell ? +selectedCell.dataset.col : 0"
|
||||||
:rowIndex="selectedCell ? +selectedCell.dataset.record : 0"
|
:rowIndex="selectedCell ? +selectedCell.dataset.row : 0"
|
||||||
@updateSelectedCell="onUpdateSelectedCell"
|
@updateSelectedCell="onUpdateSelectedCell"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -277,8 +277,8 @@ export default {
|
|||||||
toggleViewRecord () {
|
toggleViewRecord () {
|
||||||
if (this.viewRecord) {
|
if (this.viewRecord) {
|
||||||
this.defaultSelectedCell = {
|
this.defaultSelectedCell = {
|
||||||
row: (this.$refs.recordView.currentRowIndex + this.pageSize) % this.pageSize,
|
row: this.$refs.recordView.currentRowIndex,
|
||||||
col: this.selectedCell ? +this.selectedCell.dataset.row : 0
|
col: this.selectedCell ? +this.selectedCell.dataset.col : 0
|
||||||
}
|
}
|
||||||
this.defaultPage = Math.ceil(
|
this.defaultPage = Math.ceil(
|
||||||
(this.$refs.recordView.currentRowIndex + 1) / this.pageSize
|
(this.$refs.recordView.currentRowIndex + 1) / this.pageSize
|
||||||
|
|||||||
Reference in New Issue
Block a user