Skip to content

Commit 63bb63a

Browse files
committed
feat: optionally cache dashboard resources
1 parent 755d423 commit 63bb63a

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

Parse-Dashboard/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ module.exports = function(config, options) {
219219
<base href="${mountPath}"/>
220220
<script>
221221
PARSE_DASHBOARD_PATH = "${mountPath}";
222+
PARSE_DASHBOARD_ENABLE_SERVICE_WORKER = ${
223+
config.enableBrowserServiceWorker ? 'true' : 'false'
224+
};
222225
</script>
223226
<title>Parse Dashboard</title>
224227
</head>
@@ -251,6 +254,9 @@ module.exports = function(config, options) {
251254
<base href="${mountPath}"/>
252255
<script>
253256
PARSE_DASHBOARD_PATH = "${mountPath}";
257+
PARSE_DASHBOARD_ENABLE_SERVICE_WORKER = ${
258+
config.enableBrowserServiceWorker ? 'true' : 'false'
259+
};
254260
</script>
255261
<title>Parse Dashboard</title>
256262
</head>

Parse-Dashboard/parse-dashboard-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"secondaryBackgroundColor": ""
1111
}
1212
],
13-
"iconsFolder": "icons"
13+
"iconsFolder": "icons",
14+
"enableBrowserServiceWorker": false
1415
}

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Parse Dashboard is a standalone dashboard for managing your [Parse Server](https
4343
- [Custom order in the filter popup](#custom-order-in-the-filter-popup)
4444
- [Persistent Filters](#persistent-filters)
4545
- [Scripts](#scripts)
46+
- [Browser Service Worker](#browser-service-worker)
4647
- [Running as Express Middleware](#running-as-express-middleware)
4748
- [Deploying Parse Dashboard](#deploying-parse-dashboard)
4849
- [Preparing for Deployment](#preparing-for-deployment)
@@ -510,6 +511,27 @@ Parse.Cloud.define('deleteAccount', async (req) => {
510511

511512
</details>
512513

514+
### Browser Service Worker
515+
516+
Parse Dashboard can cache its bundles in the browser so that opening the dashboard in another tab does not reload the resources.
517+
Enable this feature with `enableBrowserServiceWorker`:
518+
519+
```javascript
520+
const dashboard = new ParseDashboard({
521+
enableBrowserServiceWorker: true,
522+
apps: [
523+
{
524+
serverURL: 'http://localhost:1337/parse',
525+
appId: 'myAppId',
526+
masterKey: 'myMasterKey',
527+
appName: 'MyApp'
528+
}
529+
]
530+
});
531+
```
532+
533+
The service worker is disabled by default.
534+
513535
# Running as Express Middleware
514536

515537
Instead of starting Parse Dashboard with the CLI, you can also run it as an [express](https://github.com/expressjs/express) middleware.

src/registerServiceWorker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
export default function registerServiceWorker() {
2+
if (!window.PARSE_DASHBOARD_ENABLE_SERVICE_WORKER) {
3+
return;
4+
}
25
if ('serviceWorker' in navigator) {
36
window.addEventListener('load', () => {
47
const swPath = `${window.PARSE_DASHBOARD_PATH || '/'}sw.js`;

0 commit comments

Comments
 (0)