|
@@ -1,10 +1,10 @@
|
|
import { useState, useEffect, useRef, useContext } from 'react';
|
|
import { useState, useEffect, useRef, useContext } from 'react';
|
|
-import { TextField } from '@material-ui/core';
|
|
|
|
|
|
+import { TextField, Typography } from '@material-ui/core';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useParams } from 'react-router-dom';
|
|
import { useParams } from 'react-router-dom';
|
|
import { rootContext } from '@/context';
|
|
import { rootContext } from '@/context';
|
|
import { DataService } from '@/http';
|
|
import { DataService } from '@/http';
|
|
-import { useQuery, useSearchResult } from '@/hooks';
|
|
|
|
|
|
+import { useQuery } from '@/hooks';
|
|
import { saveCsvAs } from '@/utils';
|
|
import { saveCsvAs } from '@/utils';
|
|
import icons from '@/components/icons/Icons';
|
|
import icons from '@/components/icons/Icons';
|
|
import CustomButton from '@/components/customButton/CustomButton';
|
|
import CustomButton from '@/components/customButton/CustomButton';
|
|
@@ -25,6 +25,7 @@ import {
|
|
import CustomSelector from '@/components/customSelector/CustomSelector';
|
|
import CustomSelector from '@/components/customSelector/CustomSelector';
|
|
import EmptyDataDialog from '../dialogs/EmptyDataDialog';
|
|
import EmptyDataDialog from '../dialogs/EmptyDataDialog';
|
|
import ImportSampleDialog from '../dialogs/ImportSampleDialog';
|
|
import ImportSampleDialog from '../dialogs/ImportSampleDialog';
|
|
|
|
+import { detectItemType } from '@/utils';
|
|
|
|
|
|
const Query = () => {
|
|
const Query = () => {
|
|
// get collection name from url
|
|
// get collection name from url
|
|
@@ -110,6 +111,7 @@ const Query = () => {
|
|
expr,
|
|
expr,
|
|
queryResult,
|
|
queryResult,
|
|
setPageSize,
|
|
setPageSize,
|
|
|
|
+ consistencyLevel,
|
|
setConsistencyLevel,
|
|
setConsistencyLevel,
|
|
setCurrentPage,
|
|
setCurrentPage,
|
|
setExpr,
|
|
setExpr,
|
|
@@ -130,9 +132,6 @@ const Query = () => {
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
- // Format result list
|
|
|
|
- const queryResultMemo = useSearchResult(queryResult.data);
|
|
|
|
-
|
|
|
|
// Toolbar settings
|
|
// Toolbar settings
|
|
const toolbarConfigs: ToolBarConfig[] = [
|
|
const toolbarConfigs: ToolBarConfig[] = [
|
|
{
|
|
{
|
|
@@ -152,6 +151,7 @@ const Query = () => {
|
|
defaultSelectedCollection={collectionName}
|
|
defaultSelectedCollection={collectionName}
|
|
// user can't select partition on collection page, so default value is ''
|
|
// user can't select partition on collection page, so default value is ''
|
|
defaultSelectedPartition={''}
|
|
defaultSelectedPartition={''}
|
|
|
|
+ collections={[collection.data]}
|
|
onInsert={() => {}}
|
|
onInsert={() => {}}
|
|
/>
|
|
/>
|
|
),
|
|
),
|
|
@@ -223,7 +223,7 @@ const Query = () => {
|
|
type: 'button',
|
|
type: 'button',
|
|
btnVariant: 'text',
|
|
btnVariant: 'text',
|
|
onClick: async () => {
|
|
onClick: async () => {
|
|
- const json = JSON.stringify(selectedData);
|
|
|
|
|
|
+ let json = JSON.stringify(selectedData);
|
|
try {
|
|
try {
|
|
await navigator.clipboard.writeText(json);
|
|
await navigator.clipboard.writeText(json);
|
|
alert(`${selectedData.length} rows copied to clipboard`);
|
|
alert(`${selectedData.length} rows copied to clipboard`);
|
|
@@ -324,7 +324,7 @@ const Query = () => {
|
|
{/* </div> */}
|
|
{/* </div> */}
|
|
<CustomSelector
|
|
<CustomSelector
|
|
options={CONSISTENCY_LEVEL_OPTIONS}
|
|
options={CONSISTENCY_LEVEL_OPTIONS}
|
|
- value={collection.consistencyLevel}
|
|
|
|
|
|
+ value={consistencyLevel}
|
|
label={collectionTrans('consistency')}
|
|
label={collectionTrans('consistency')}
|
|
wrapperClass={classes.selector}
|
|
wrapperClass={classes.selector}
|
|
disabled={!collection.loaded}
|
|
disabled={!collection.loaded}
|
|
@@ -363,18 +363,32 @@ const Query = () => {
|
|
</div>
|
|
</div>
|
|
<AttuGrid
|
|
<AttuGrid
|
|
toolbarConfigs={[]}
|
|
toolbarConfigs={[]}
|
|
- colDefinitions={collection.fields.map((i: any) => ({
|
|
|
|
- id: i.name,
|
|
|
|
- align: 'left',
|
|
|
|
- disablePadding: false,
|
|
|
|
- needCopy: true,
|
|
|
|
- label:
|
|
|
|
- i.name === DYNAMIC_FIELD ? searchTrans('dynamicFields') : i.name,
|
|
|
|
- }))}
|
|
|
|
|
|
+ colDefinitions={collection.fields.map((i: any) => {
|
|
|
|
+ return {
|
|
|
|
+ id: i.name,
|
|
|
|
+ align: 'left',
|
|
|
|
+ disablePadding: false,
|
|
|
|
+ needCopy: true,
|
|
|
|
+ formatter(_: any, cellData: any) {
|
|
|
|
+ const itemType = detectItemType(cellData);
|
|
|
|
+ switch (itemType) {
|
|
|
|
+ case 'json':
|
|
|
|
+ case 'array':
|
|
|
|
+ case 'bool':
|
|
|
|
+ const res = JSON.stringify(cellData);
|
|
|
|
+ return <Typography title={res}>{res}</Typography>;
|
|
|
|
+ default:
|
|
|
|
+ return cellData;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ label:
|
|
|
|
+ i.name === DYNAMIC_FIELD ? searchTrans('dynamicFields') : i.name,
|
|
|
|
+ };
|
|
|
|
+ })}
|
|
primaryKey={collection.primaryKey.value}
|
|
primaryKey={collection.primaryKey.value}
|
|
openCheckBox={true}
|
|
openCheckBox={true}
|
|
isLoading={!!tableLoading}
|
|
isLoading={!!tableLoading}
|
|
- rows={queryResultMemo}
|
|
|
|
|
|
+ rows={queryResult.data}
|
|
rowCount={total}
|
|
rowCount={total}
|
|
selected={selectedData}
|
|
selected={selectedData}
|
|
setSelected={onSelectChange}
|
|
setSelected={onSelectChange}
|