mongo data grid works

This commit is contained in:
Jan Prochazka
2021-04-02 19:54:09 +02:00
parent 55cc51d24a
commit 18860c823d
5 changed files with 45 additions and 30 deletions

View File

@@ -96,7 +96,7 @@ module.exports = {
async collectionData({ conid, database, options }) { async collectionData({ conid, database, options }) {
const opened = await this.ensureOpened(conid, database); const opened = await this.ensureOpened(conid, database);
const res = await this.sendRequest(opened, { msgtype: 'collectionData', options }); const res = await this.sendRequest(opened, { msgtype: 'collectionData', options });
return res; return res.result;
}, },
status_meta: 'get', status_meta: 'get',

View File

@@ -10,37 +10,41 @@ export class CollectionGridDisplay extends GridDisplay {
config: GridConfig, config: GridConfig,
setConfig: ChangeConfigFunc, setConfig: ChangeConfigFunc,
cache: GridCache, cache: GridCache,
setCache: ChangeCacheFunc setCache: ChangeCacheFunc,
loadedRows
) { ) {
super(config, setConfig, cache, setCache, driver); super(config, setConfig, cache, setCache, driver);
this.columns = []; this.columns = this.getDisplayColumns(loadedRows || []);
this.filterable = true; this.filterable = true;
this.sortable = true; this.sortable = true;
this.editable = false; this.editable = false;
this.supportsReload = true; this.supportsReload = true;
} }
// getDisplayColumns(view: ViewInfo) { getDisplayColumns(rows) {
// return ( const res = [];
// view?.columns for (const row of rows) {
// ?.map(col => this.getDisplayColumn(view, col)) for (const name of Object.keys(row)) {
// ?.map(col => ({ if (res.find(x => x.columnName == name)) continue;
// ...col, res.push(this.getDisplayColumn(name));
// isChecked: this.isColumnChecked(col), }
// })) || [] }
// ); return (
// } res.map(col => ({
...col,
isChecked: this.isColumnChecked(col),
})) || []
);
}
// getDisplayColumn(view: ViewInfo, col: ColumnInfo) { getDisplayColumn(columnName: string) {
// const uniquePath = [col.columnName]; const uniquePath = [columnName];
// const uniqueName = uniquePath.join('.'); const uniqueName = uniquePath.join('.');
// return { return {
// ...col, columnName,
// pureName: view.pureName, headerText: columnName,
// schemaName: view.schemaName, uniqueName,
// headerText: col.columnName, uniquePath,
// uniqueName, };
// uniquePath, }
// };
// }
} }

View File

@@ -11,6 +11,7 @@
}, },
data: { data: {
options: { options: {
pureName: props.pureName,
limit, limit,
skip: offset, skip: offset,
}, },
@@ -22,9 +23,10 @@
} }
function dataPageAvailable(props) { function dataPageAvailable(props) {
const { display } = props; return true;
const sql = display.getPageQuery(0, 1); // const { display } = props;
return !!sql; // const sql = display.getPageQuery(0, 1);
// return !!sql;
} }
async function loadRowCount(props) { async function loadRowCount(props) {
@@ -39,6 +41,7 @@
}, },
data: { data: {
options: { options: {
pureName: props.pureName,
countDocuments: true, countDocuments: true,
}, },
}, },
@@ -77,7 +80,7 @@
// export let onChangeGrider = undefined; // export let onChangeGrider = undefined;
let loadedRows = []; export let loadedRows = [];
// $: console.log('loadedRows BIND', loadedRows); // $: console.log('loadedRows BIND', loadedRows);
$: grider = new ChangeSetGrider( $: grider = new ChangeSetGrider(

View File

@@ -27,6 +27,8 @@
export let showReferences = false; export let showReferences = false;
export let showMacros; export let showMacros;
export let loadedRows;
let selectedCellsPublished = []; let selectedCellsPublished = [];
const selectedMacro = writable(null); const selectedMacro = writable(null);
@@ -93,6 +95,7 @@
macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)} macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)}
macroPreview={$selectedMacro} macroPreview={$selectedMacro}
{selectedCellsPublished} {selectedCellsPublished}
bind:loadedRows
/> />
{/if} {/if}
</svelte:fragment> </svelte:fragment>

View File

@@ -28,6 +28,8 @@
export let schemaName; export let schemaName;
export let pureName; export let pureName;
let loadedRows;
const config = useGridConfig(tabid); const config = useGridConfig(tabid);
const cache = writable(createGridCache()); const cache = writable(createGridCache());
@@ -50,12 +52,15 @@
$config, $config,
config.update, config.update,
$cache, $cache,
cache.update cache.update,
loadedRows
) )
: null; : null;
// $: console.log('LOADED ROWS MONGO', loadedRows);
</script> </script>
<DataGrid <DataGrid
bind:loadedRows
{...$$props} {...$$props}
config={$config} config={$config}
setConfig={config.update} setConfig={config.update}