mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
#115 add styles for blob and null
This commit is contained in:
@@ -107,3 +107,9 @@ table.sqliteviz-table {
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: var(--color-text-base);
|
color: var(--color-text-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sqliteviz-table tbody td[data-isNull="true"],
|
||||||
|
.sqliteviz-table tbody td[data-isBlob="true"] {
|
||||||
|
color: var(--color-text-light-2);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,12 +38,14 @@
|
|||||||
:data-col="colIndex"
|
:data-col="colIndex"
|
||||||
:data-row="rowIndex - 1"
|
:data-row="rowIndex - 1"
|
||||||
:data-record="pageSize * (currentPage - 1) + rowIndex - 1"
|
:data-record="pageSize * (currentPage - 1) + rowIndex - 1"
|
||||||
|
:data-isNull="isNull(getCellValue(col, rowIndex))"
|
||||||
|
:data-isBlob="isBlob(getCellValue(col, rowIndex))"
|
||||||
:key="colIndex"
|
:key="colIndex"
|
||||||
:aria-selected="false"
|
:aria-selected="false"
|
||||||
@click="onCellClick"
|
@click="onCellClick"
|
||||||
>
|
>
|
||||||
<div class="cell-data" :style="cellStyle">
|
<div class="cell-data" :style="cellStyle">
|
||||||
{{ dataSet.values[col][rowIndex - 1 + currentPageData.start] }}
|
{{ getCellText(col, rowIndex) }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -57,7 +59,11 @@
|
|||||||
<span v-if="preview">for preview</span>
|
<span v-if="preview">for preview</span>
|
||||||
<span v-if="time">in {{ time }}</span>
|
<span v-if="time">in {{ time }}</span>
|
||||||
</div>
|
</div>
|
||||||
<pager v-show="pageCount > 1" :page-count="pageCount" v-model="currentPage" />
|
<pager
|
||||||
|
v-show="pageCount > 1"
|
||||||
|
:page-count="pageCount"
|
||||||
|
v-model="currentPage"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -133,6 +139,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
isBlob (value) {
|
||||||
|
return value && ArrayBuffer.isView(value)
|
||||||
|
},
|
||||||
|
isNull (value) {
|
||||||
|
return value === null
|
||||||
|
},
|
||||||
|
getCellValue (col, rowIndex) {
|
||||||
|
return this.dataSet.values[col][rowIndex - 1 + this.currentPageData.start]
|
||||||
|
},
|
||||||
|
getCellText (col, rowIndex) {
|
||||||
|
const value = this.getCellValue(col, rowIndex)
|
||||||
|
if (this.isNull(value)) {
|
||||||
|
return 'NULL'
|
||||||
|
}
|
||||||
|
if (this.isBlob(value)) {
|
||||||
|
return 'BLOB'
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
},
|
||||||
calculateHeadersWidth () {
|
calculateHeadersWidth () {
|
||||||
this.tableWidth = this.$refs['table-container'].offsetWidth
|
this.tableWidth = this.$refs['table-container'].offsetWidth
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ function _getDataSourcesFromSqlResult (sqlResult) {
|
|||||||
if (!sqlResult) {
|
if (!sqlResult) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
const dataSorces = {}
|
const dataSources = {}
|
||||||
sqlResult.columns.forEach((column, index) => {
|
sqlResult.columns.forEach((column, index) => {
|
||||||
dataSorces[column] = sqlResult.values.map(row => row[index])
|
dataSources[column] = sqlResult.values.map(row => row[index])
|
||||||
})
|
})
|
||||||
return dataSorces
|
return dataSources
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Sql {
|
export default class Sql {
|
||||||
|
|||||||
@@ -23,12 +23,14 @@
|
|||||||
<td
|
<td
|
||||||
:data-col="1"
|
:data-col="1"
|
||||||
:data-row="index"
|
:data-row="index"
|
||||||
|
:data-isNull="isNull(getCellValue(col))"
|
||||||
|
:data-isBlob="isBlob(getCellValue(col))"
|
||||||
:key="index"
|
:key="index"
|
||||||
:aria-selected="false"
|
:aria-selected="false"
|
||||||
@click="onCellClick"
|
@click="onCellClick"
|
||||||
>
|
>
|
||||||
<div class="cell-data">
|
<div class="cell-data">
|
||||||
{{ dataSet.values[col][currentRowIndex] }}
|
{{ getCellText(col) }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -89,6 +91,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
isBlob (value) {
|
||||||
|
return value && ArrayBuffer.isView(value)
|
||||||
|
},
|
||||||
|
isNull (value) {
|
||||||
|
return value === null
|
||||||
|
},
|
||||||
|
getCellValue (col) {
|
||||||
|
return this.dataSet.values[col][this.currentRowIndex]
|
||||||
|
},
|
||||||
|
getCellText (col) {
|
||||||
|
const value = this.getCellValue(col)
|
||||||
|
if (this.isNull(value)) {
|
||||||
|
return 'NULL'
|
||||||
|
}
|
||||||
|
if (this.isBlob(value)) {
|
||||||
|
return 'BLOB'
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
},
|
||||||
onTableKeydown (e) {
|
onTableKeydown (e) {
|
||||||
const keyCodeMap = {
|
const keyCodeMap = {
|
||||||
38: 'up',
|
38: 'up',
|
||||||
|
|||||||
@@ -26,7 +26,10 @@
|
|||||||
:value="formattedJson"
|
:value="formattedJson"
|
||||||
:options="cmOptions"
|
:options="cmOptions"
|
||||||
/>
|
/>
|
||||||
<div v-if="currentFormat === 'text'" class="text-value">
|
<div
|
||||||
|
v-if="currentFormat === 'text'"
|
||||||
|
:class="['text-value', { 'meta-value': isNull || isBlob }]"
|
||||||
|
>
|
||||||
{{ cellValue }}
|
{{ cellValue }}
|
||||||
</div>
|
</div>
|
||||||
<logs
|
<logs
|
||||||
@@ -56,7 +59,9 @@ export default {
|
|||||||
Logs
|
Logs
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
cellValue: [String, Number]
|
cellValue: [String, Number],
|
||||||
|
isNull: Boolean,
|
||||||
|
isBlob: Boolean
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -84,12 +89,12 @@ export default {
|
|||||||
this.messages = []
|
this.messages = []
|
||||||
this.formattedJson = ''
|
this.formattedJson = ''
|
||||||
if (this.currentFormat === 'json') {
|
if (this.currentFormat === 'json') {
|
||||||
this.formatJson(this.cellValue)
|
this.formatJson(this.isNull ? null : this.cellValue)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cellValue () {
|
cellValue () {
|
||||||
if (this.currentFormat === 'json') {
|
if (this.currentFormat === 'json') {
|
||||||
this.formatJson(this.cellValue)
|
this.formatJson(this.isNull ? null : this.cellValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -139,6 +144,11 @@ export default {
|
|||||||
color: var(--color-text-base);
|
color: var(--color-text-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-value.meta-value {
|
||||||
|
font-style: italic;
|
||||||
|
color: var(--color-text-light-2);
|
||||||
|
}
|
||||||
|
|
||||||
.messages {
|
.messages {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
<value-viewer
|
<value-viewer
|
||||||
v-show="selectedCell"
|
v-show="selectedCell"
|
||||||
:cellValue="selectedCell ? selectedCell.innerText : ''"
|
:cellValue="selectedCell ? selectedCell.innerText : ''"
|
||||||
|
:is-null="selectedCell && selectedCell.dataset.isnull === 'true'"
|
||||||
|
: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
|
||||||
|
|||||||
Reference in New Issue
Block a user