Skip to content

Commit 54a8156

Browse files
authored
feat: Prefetch info panel data with config options prefetchObjects and prefetchStale (#2915)
1 parent 9ea7e2e commit 54a8156

File tree

4 files changed

+215
-69
lines changed

4 files changed

+215
-69
lines changed

README.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ Parse Dashboard is a standalone dashboard for managing your [Parse Server](https
6161
- [Data Browser](#data-browser)
6262
- [Filters](#filters)
6363
- [Info Panel](#info-panel)
64-
- [Segments](#segments)
65-
- [Text Item](#text-item)
66-
- [Key-Value Item](#key-value-item)
67-
- [Table Item](#table-item)
68-
- [Image Item](#image-item)
69-
- [Video Item](#video-item)
70-
- [Audio Item](#audio-item)
71-
- [Button Item](#button-item)
72-
- [Panel Item](#panel-item)
64+
- [Response](#response)
65+
- [Segments](#segments)
66+
- [Text Item](#text-item)
67+
- [Key-Value Item](#key-value-item)
68+
- [Table Item](#table-item)
69+
- [Image Item](#image-item)
70+
- [Video Item](#video-item)
71+
- [Audio Item](#audio-item)
72+
- [Button Item](#button-item)
73+
- [Panel Item](#panel-item)
74+
- [Prefetching](#prefetching)
7375
- [Freeze Columns](#freeze-columns)
7476
- [Browse as User](#browse-as-user)
7577
- [Change Pointer Key](#change-pointer-key)
@@ -140,6 +142,8 @@ Parse Dashboard is continuously tested with the most recent releases of Node.js
140142
| `infoPanel[*].title` | String | no | - | `User Details` | The panel title. |
141143
| `infoPanel[*].classes` | Array<String> | no | - | `["_User"]` | The classes for which the info panel should be displayed. |
142144
| `infoPanel[*].cloudCodeFunction` | String | no | - | `getUserDetails` | The Cloud Code Function which received the selected object in the data browser and returns the response to be displayed in the info panel. |
145+
| `infoPanel[*].prefetchObjects` | Number | yes | `0` | `2` | Number of next rows to prefetch when browsing sequential rows. For example, `2` means the next 2 rows will be fetched in advance. |
146+
| `infoPanel[*].prefetchStale` | Number | yes | `0` | `10` | Duration in seconds after which prefetched data is discarded as stale. |
143147
| `apps.scripts` | Array<Object> | yes | `[]` | `[{ ... }, { ... }]` | The scripts that can be executed for that app. |
144148
| `apps.scripts.title` | String | no | - | `'Delete User'` | The title that will be displayed in the data browser context menu and the script run confirmation dialog. |
145149
| `apps.scripts.classes` | Array<String> | no | - | `['_User']` | The classes of Parse Objects for which the scripts can be executed. |
@@ -873,7 +877,9 @@ The following example dashboard configuration shows an info panel for the `_User
873877
{
874878
"title": "User Details",
875879
"classes": ["_User"],
876-
"cloudCodeFunction": "getUserDetails"
880+
"cloudCodeFunction": "getUserDetails",
881+
"prefetchObjects": 2,
882+
"prefetchStale": 10
877883
}
878884
]
879885
}
@@ -882,7 +888,9 @@ The following example dashboard configuration shows an info panel for the `_User
882888

883889
The Cloud Code Function receives the selected object in the payload and returns a response that can include various items.
884890

885-
#### Segments
891+
#### Response
892+
893+
##### Segments
886894

887895
The info panel can contain multiple segments to display different groups of information.
888896

@@ -918,7 +926,7 @@ Example:
918926

919927
The items array can include various types of content such as text, key-value pairs, tables, images, videos, audios, and buttons. Each type offers a different way to display information within the info panel, allowing for a customizable and rich user experience. Below is a detailed explanation of each type.
920928

921-
#### Text Item
929+
##### Text Item
922930

923931
A simple text field.
924932

@@ -938,7 +946,7 @@ Example:
938946
}
939947
```
940948

941-
#### Key-Value Item
949+
##### Key-Value Item
942950

943951
A text item that consists of a key and a value. The value can optionally be linked to a URL.
944952

@@ -1009,7 +1017,7 @@ const item = {
10091017
}
10101018
```
10111019

1012-
#### Table Item
1020+
##### Table Item
10131021

10141022
A table with columns and rows to display data in a structured format.
10151023

@@ -1051,7 +1059,7 @@ Example:
10511059
}
10521060
```
10531061

1054-
#### Image Item
1062+
##### Image Item
10551063

10561064
An image to be displayed in the panel.
10571065

@@ -1071,7 +1079,7 @@ Example:
10711079
}
10721080
```
10731081

1074-
#### Video Item
1082+
##### Video Item
10751083

10761084
A video to be displayed in the panel.
10771085

@@ -1091,7 +1099,7 @@ Example:
10911099
}
10921100
```
10931101

1094-
#### Audio Item
1102+
##### Audio Item
10951103

10961104
An audio file to be played in the panel.
10971105

@@ -1111,7 +1119,7 @@ Example:
11111119
}
11121120
```
11131121

1114-
#### Button Item
1122+
##### Button Item
11151123

11161124
A button that triggers an action when clicked.
11171125

@@ -1146,7 +1154,7 @@ Example:
11461154
}
11471155
```
11481156

1149-
#### Panel Item
1157+
##### Panel Item
11501158

11511159
A sub-panel whose data is loaded on-demand by expanding the item.
11521160

@@ -1168,6 +1176,17 @@ Example:
11681176
}
11691177
```
11701178

1179+
#### Prefetching
1180+
1181+
To reduce the time for info panel data to appear, data can be prefetched.
1182+
1183+
| Parameter | Type | Optional | Default | Example | Description |
1184+
|--------------------------------|--------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------|
1185+
| `infoPanel[*].prefetchObjects` | Number | yes | `0` | `2` | Number of next rows to prefetch when browsing sequential rows. For example, `2` means the next 2 rows will be fetched in advance. |
1186+
| `infoPanel[*].prefetchStale` | Number | yes | `0` | `10` | Duration in seconds after which prefetched data is discarded as stale. |
1187+
1188+
Prefetching is particularly useful when navigating through lists of objects. To optimize performance and avoid unnecessary data loading, prefetching is triggered only after the user has moved through 3 consecutive rows using the keyboard down-arrow key or by mouse click.
1189+
11711190
### Freeze Columns
11721191

11731192
▶️ *Core > Browser > Freeze column*

src/components/BrowserCell/BrowserCell.react.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,6 @@ export default class BrowserCell extends Component {
567567
current,
568568
onEditChange,
569569
setCopyableValue,
570-
selectedObjectId,
571-
setSelectedObjectId,
572-
callCloudFunction,
573-
isPanelVisible,
574570
onPointerCmdClick,
575571
row,
576572
col,
@@ -580,7 +576,6 @@ export default class BrowserCell extends Component {
580576
markRequiredFieldRow,
581577
handleCellClick,
582578
selectedCells,
583-
setShowAggregatedData,
584579
} = this.props;
585580

586581
const classes = [...this.state.classes];
@@ -653,18 +648,7 @@ export default class BrowserCell extends Component {
653648
onPointerCmdClick(value);
654649
} else {
655650
setCopyableValue(hidden ? undefined : this.copyableValue);
656-
if (selectedObjectId !== this.props.objectId) {
657-
setShowAggregatedData(true);
658-
setSelectedObjectId(this.props.objectId);
659-
if (
660-
this.props.objectId &&
661-
isPanelVisible &&
662-
((e.shiftKey && !this.props.firstSelectedCell) || !e.shiftKey)
663-
) {
664-
callCloudFunction(this.props.objectId, this.props.className, this.props.appId);
665-
}
666-
}
667-
handleCellClick(e, row, col);
651+
handleCellClick(e, row, col, this.props.objectId);
668652
}
669653
}}
670654
onDoubleClick={() => {

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ class Browser extends DashboardView {
461461
title: panel.title,
462462
cloudCodeFunction: panel.cloudCodeFunction,
463463
classes: panel.classes,
464+
prefetchObjects: panel.prefetchObjects || 0,
465+
prefetchStale: panel.prefetchStale || 0,
464466
});
465467
});
466468
});

0 commit comments

Comments
 (0)