mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 03:24:01 +00:00
show json icon in perspectives
This commit is contained in:
@@ -7,7 +7,7 @@ import _isBoolean from 'lodash/isBoolean';
|
|||||||
import _isArray from 'lodash/isArray';
|
import _isArray from 'lodash/isArray';
|
||||||
import { safeJsonParse } from 'dbgate-tools';
|
import { safeJsonParse } from 'dbgate-tools';
|
||||||
|
|
||||||
export type PerspectiveDataPatternColumnType = 'null' | 'string' | 'number' | 'boolean' | 'json';
|
export type PerspectiveDataPatternColumnType = 'null' | 'oid' | 'string' | 'number' | 'boolean' | 'json';
|
||||||
|
|
||||||
export interface PerspectiveDataPatternColumn {
|
export interface PerspectiveDataPatternColumn {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -29,6 +29,7 @@ function detectValueType(value): PerspectiveDataPatternColumnType {
|
|||||||
if (_isString(value)) return 'string';
|
if (_isString(value)) return 'string';
|
||||||
if (_isNumber(value)) return 'number';
|
if (_isNumber(value)) return 'number';
|
||||||
if (_isBoolean(value)) return 'boolean';
|
if (_isBoolean(value)) return 'boolean';
|
||||||
|
if (value?.$oid) return 'oid';
|
||||||
if (_isPlainObject(value) || _isArray(value)) return 'json';
|
if (_isPlainObject(value) || _isArray(value)) return 'json';
|
||||||
if (value == null) return 'null';
|
if (value == null) return 'null';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -818,6 +818,9 @@ export class PerspectivePatternColumnNode extends PerspectiveTreeNode {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
get icon() {
|
get icon() {
|
||||||
|
if (this.column.types.includes('json')) {
|
||||||
|
return 'img json';
|
||||||
|
}
|
||||||
return 'img column';
|
return 'img column';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,6 +888,10 @@ export class PerspectivePatternColumnNode extends PerspectiveTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get filterInfo(): PerspectiveFilterColumnInfo {
|
get filterInfo(): PerspectiveFilterColumnInfo {
|
||||||
|
if (this.isChildColumn) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columnName: this.columnName,
|
columnName: this.columnName,
|
||||||
filterType: this.filterType,
|
filterType: this.filterType,
|
||||||
|
|||||||
@@ -61,6 +61,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$: sortOrderProps = settings?.getSortOrderProps ? settings?.getSortOrderProps(designerId, column.columnName) : null;
|
$: sortOrderProps = settings?.getSortOrderProps ? settings?.getSortOrderProps(designerId, column.columnName) : null;
|
||||||
|
$: iconOverride = settings?.getColumnIconOverride
|
||||||
|
? settings?.getColumnIconOverride(designerId, column.columnName)
|
||||||
|
: null;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -144,7 +147,7 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<ColumnLabel {...column} {foreignKey} forceIcon />
|
<ColumnLabel {...column} {foreignKey} forceIcon {iconOverride} />
|
||||||
{#if designerColumn?.filter}
|
{#if designerColumn?.filter}
|
||||||
<FontIcon icon="img filter" />
|
<FontIcon icon="img filter" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
export let foreignKey;
|
export let foreignKey;
|
||||||
export let conid = undefined;
|
export let conid = undefined;
|
||||||
export let database = undefined;
|
export let database = undefined;
|
||||||
|
export let iconOverride = undefined;
|
||||||
|
|
||||||
$: icon = getColumnIcon($$props, forceIcon);
|
$: icon = iconOverride || getColumnIcon($$props, forceIcon);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span class="label" class:notNull>
|
<span class="label" class:notNull>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<span class="null"> (no image)</span>
|
<span class="null"> (no image)</span>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if _.isArray(value) || _.isPlainObject(value)}
|
{:else if !value.$oid && (_.isArray(value) || _.isPlainObject(value))}
|
||||||
<JSONTree {value} slicedKeyCount={1} disableContextMenu />
|
<JSONTree {value} slicedKeyCount={1} disableContextMenu />
|
||||||
{:else}
|
{:else}
|
||||||
<CellValue {rowData} {value} />
|
<CellValue {rowData} {value} />
|
||||||
|
|||||||
@@ -241,6 +241,14 @@
|
|||||||
const orderIndex = sort.length > 1 ? _.findIndex(sort, x => x.columnName == columnName) : -1;
|
const orderIndex = sort.length > 1 ? _.findIndex(sort, x => x.columnName == columnName) : -1;
|
||||||
return { order, orderIndex };
|
return { order, orderIndex };
|
||||||
},
|
},
|
||||||
|
getColumnIconOverride: (designerId, columnName) => {
|
||||||
|
const pattern = dataPatterns?.[designerId];
|
||||||
|
const column = pattern?.columns.find(x => x.name == columnName);
|
||||||
|
if (column?.types?.includes('json')) {
|
||||||
|
return 'img json';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
isColumnFiltered: (designerId, columnName) => {
|
isColumnFiltered: (designerId, columnName) => {
|
||||||
return !!config.nodes.find(x => x.designerId == designerId)?.filters?.[columnName];
|
return !!config.nodes.find(x => x.designerId == designerId)?.filters?.[columnName];
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user