mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 14:33:59 +00:00
mongo data grid works
This commit is contained in:
@@ -96,7 +96,7 @@ module.exports = {
|
||||
async collectionData({ conid, database, options }) {
|
||||
const opened = await this.ensureOpened(conid, database);
|
||||
const res = await this.sendRequest(opened, { msgtype: 'collectionData', options });
|
||||
return res;
|
||||
return res.result;
|
||||
},
|
||||
|
||||
status_meta: 'get',
|
||||
|
||||
@@ -10,37 +10,41 @@ export class CollectionGridDisplay extends GridDisplay {
|
||||
config: GridConfig,
|
||||
setConfig: ChangeConfigFunc,
|
||||
cache: GridCache,
|
||||
setCache: ChangeCacheFunc
|
||||
setCache: ChangeCacheFunc,
|
||||
loadedRows
|
||||
) {
|
||||
super(config, setConfig, cache, setCache, driver);
|
||||
this.columns = [];
|
||||
this.columns = this.getDisplayColumns(loadedRows || []);
|
||||
this.filterable = true;
|
||||
this.sortable = true;
|
||||
this.editable = false;
|
||||
this.supportsReload = true;
|
||||
}
|
||||
|
||||
// getDisplayColumns(view: ViewInfo) {
|
||||
// return (
|
||||
// view?.columns
|
||||
// ?.map(col => this.getDisplayColumn(view, col))
|
||||
// ?.map(col => ({
|
||||
// ...col,
|
||||
// isChecked: this.isColumnChecked(col),
|
||||
// })) || []
|
||||
// );
|
||||
// }
|
||||
getDisplayColumns(rows) {
|
||||
const res = [];
|
||||
for (const row of rows) {
|
||||
for (const name of Object.keys(row)) {
|
||||
if (res.find(x => x.columnName == name)) continue;
|
||||
res.push(this.getDisplayColumn(name));
|
||||
}
|
||||
}
|
||||
return (
|
||||
res.map(col => ({
|
||||
...col,
|
||||
isChecked: this.isColumnChecked(col),
|
||||
})) || []
|
||||
);
|
||||
}
|
||||
|
||||
// getDisplayColumn(view: ViewInfo, col: ColumnInfo) {
|
||||
// const uniquePath = [col.columnName];
|
||||
// const uniqueName = uniquePath.join('.');
|
||||
// return {
|
||||
// ...col,
|
||||
// pureName: view.pureName,
|
||||
// schemaName: view.schemaName,
|
||||
// headerText: col.columnName,
|
||||
// uniqueName,
|
||||
// uniquePath,
|
||||
// };
|
||||
// }
|
||||
getDisplayColumn(columnName: string) {
|
||||
const uniquePath = [columnName];
|
||||
const uniqueName = uniquePath.join('.');
|
||||
return {
|
||||
columnName,
|
||||
headerText: columnName,
|
||||
uniqueName,
|
||||
uniquePath,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
},
|
||||
data: {
|
||||
options: {
|
||||
pureName: props.pureName,
|
||||
limit,
|
||||
skip: offset,
|
||||
},
|
||||
@@ -22,9 +23,10 @@
|
||||
}
|
||||
|
||||
function dataPageAvailable(props) {
|
||||
const { display } = props;
|
||||
const sql = display.getPageQuery(0, 1);
|
||||
return !!sql;
|
||||
return true;
|
||||
// const { display } = props;
|
||||
// const sql = display.getPageQuery(0, 1);
|
||||
// return !!sql;
|
||||
}
|
||||
|
||||
async function loadRowCount(props) {
|
||||
@@ -39,6 +41,7 @@
|
||||
},
|
||||
data: {
|
||||
options: {
|
||||
pureName: props.pureName,
|
||||
countDocuments: true,
|
||||
},
|
||||
},
|
||||
@@ -77,7 +80,7 @@
|
||||
|
||||
// export let onChangeGrider = undefined;
|
||||
|
||||
let loadedRows = [];
|
||||
export let loadedRows = [];
|
||||
|
||||
// $: console.log('loadedRows BIND', loadedRows);
|
||||
$: grider = new ChangeSetGrider(
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
export let showReferences = false;
|
||||
export let showMacros;
|
||||
|
||||
export let loadedRows;
|
||||
|
||||
let selectedCellsPublished = [];
|
||||
|
||||
const selectedMacro = writable(null);
|
||||
@@ -93,6 +95,7 @@
|
||||
macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)}
|
||||
macroPreview={$selectedMacro}
|
||||
{selectedCellsPublished}
|
||||
bind:loadedRows
|
||||
/>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
export let schemaName;
|
||||
export let pureName;
|
||||
|
||||
let loadedRows;
|
||||
|
||||
const config = useGridConfig(tabid);
|
||||
const cache = writable(createGridCache());
|
||||
|
||||
@@ -50,12 +52,15 @@
|
||||
$config,
|
||||
config.update,
|
||||
$cache,
|
||||
cache.update
|
||||
cache.update,
|
||||
loadedRows
|
||||
)
|
||||
: null;
|
||||
// $: console.log('LOADED ROWS MONGO', loadedRows);
|
||||
</script>
|
||||
|
||||
<DataGrid
|
||||
bind:loadedRows
|
||||
{...$$props}
|
||||
config={$config}
|
||||
setConfig={config.update}
|
||||
|
||||
Reference in New Issue
Block a user