diff --git a/README.md b/README.md index 6a3365f..b9b55bc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ With Meteor 3.4 introducing the Rspack bundler, modern build optimizations, and Each example doubles as a reference for [community packages](https://docs.meteor.com/community-packages/) and the conventions you'll find in real-world Meteor apps. Several apps push the Rspack bundler further to integrate with the wider JS ecosystem (PostCSS, SWC, Workbox, Lingui, Tailwind v4, and more), replacing legacy Meteor approaches with tooling the rest of the JavaScript world already uses. -The six apps maintained in this repository target Meteor 3.6. Task Manager, +The seven apps maintained in this repository target Meteor 3.6.1. Task Manager, Tic-Tac-Toe, and Complex Todos demonstrate native Meteor TypeScript declarations with a `meteor npm run typecheck` command; Notes Offline uses them for JavaScript editor support. External examples below retain their independently maintained versions. @@ -53,47 +53,48 @@ the compatible fallback. Hosts that meet the requirement can keep `uws` enabled. - Demo: https://task-manager.sandbox.galaxycloud.app/ - Why: Task management with CRUD, status workflows, priority filtering, real-time dashboard, and type-safe RPC - Stack: Meteor, Rspack, TypeScript, React, Meteor-RPC, shadcn/ui, Tailwind CSS v4, React Query, Zod, Mocha, Biome, Playwright -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ### Notes Offline - Repository: [meteor/examples/notes-offline](./notes-offline) - Demo: https://notes-offline.sandbox.galaxycloud.app/ - Why: Offline-first PWA notes app with auto-save, markdown, search, tagging, pinning, trash/recovery, import/export, cross-tab sync, per-device scoping, and multi-language UI (en/es/pt) - Stack: Meteor, Rspack, React, Mantine UI, jam:offline, jam:method, jam:pub-sub, jam:soft-delete, Zod, Workbox, LinguiJS, Mocha, ESLint, Prettier, Playwright -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ### Simple Blog - Repository: [dupontbertrand/meteor-blog](https://github.com/dupontbertrand/meteor-blog) +- Demo: https://example-simple-blog.sandbox.galaxycloud.app/ - Why: Mini blog with role-based access control, post/comment management, email notifications, and dev-mode mail preview - Stack: Meteor, Rspack, Blaze 3, Bootstrap 5, Flow Router, MJML -- Last Updated At: Mar/24/2026 -- Meteor Version: 3.4 +- Last Updated At: Nov/14/2026 +- Meteor Version: 3.6.1 ### Tic-Tac-Toe - Repository: [meteor/examples/tic-tac-toe](./tic-tac-toe) - Demo: https://tic-tac-toe.sandbox.galaxycloud.app/ - Why: Real-time multiplayer game with room-based matchmaking and live state sync via pub/sub - Stack: Meteor, Rspack, TypeScript, React, MUI (Material UI), Mocha, oxlint, Playwright -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ### Parties - Repository: [meteor/examples/parties](./parties) - Demo: https://parties.sandbox.galaxycloud.app/ - Why: One of the original Meteor examples showcasing how to build a nice working application with Blaze with very little code, while taking advantage of optimistic updates - Stack: Meteor, Rspack, Blaze 3, Bootstrap 5, D3.js, RSLint, Playwright -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ### Complex Todos (Svelte) - Repository: [meteor/examples/complex-todos-svelte](./complex-todos-svelte) - Demo: https://complex-todos-svelte.sandbox.galaxycloud.app/ - Why: Production-grade todo app with modular monolith architecture, rate limiting, caching, migrations, scheduled jobs, and E2E tests - Stack: Meteor, Rspack, TypeScript, Svelte 5, Skeleton UI, Tailwind CSS v4, jam:method, Zod, oxlint, Cypress, Mocha, MongoDB -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ### Welcome Meteor Cordova - Repository: [CloudByGalaxy/welcome-meteor-cordova](https://github.com/CloudByGalaxy/welcome-meteor-cordova) @@ -105,9 +106,9 @@ the compatible fallback. Hosts that meet the requirement can keep `uws` enabled. ### Instrumentation Dashboard - Repository: [meteor/examples/instrumentation-dashboard](./instrumentation-dashboard) - Why: Admin dashboard built on Meteor's instrumentation package: method calls, latency percentiles, errors and DDP connections, with bounded storage that works across several server instances -- Stack: Meteor, Rspack, Blaze 3, Chart.js, MongoDB, Mocha, RSLint, Playwright -- Last Updated At: Nov/01/2026 -- Meteor Version: 3.6 +- Stack: Meteor, Rspack, Blaze 3, Chart.js, dupontbertrand:gridstack, MongoDB, Mocha, RSLint, Playwright +- Last Updated At: Nov/14/2026 +- Meteor Version: 3.6.1 ## Other examples @@ -152,8 +153,8 @@ Additional examples covering tutorials, integrations, and specialized use cases. - Repository: [meteor/examples/nft-marketplace](./nft-marketplace) - Why: Decentralized NFT marketplace for minting, listing, and buying NFTs with wallet auth and on-chain transactions - Stack: Meteor, Rspack, React, Tailwind CSS v3, Polygon, Solidity, Hardhat, Ethers.js, IPFS -- Last Updated At: Nov/10/2026 -- Meteor Version: 3.6 +- Last Updated At: Nov/13/2026 +- Meteor Version: 3.6.1 ## How to add your example? diff --git a/complex-todos-svelte/.meteor/packages b/complex-todos-svelte/.meteor/packages index 525a582..f3f8a97 100644 --- a/complex-todos-svelte/.meteor/packages +++ b/complex-todos-svelte/.meteor/packages @@ -6,7 +6,7 @@ meteor-base@1.5.2 # Packages every Meteor app needs to have mobile-experience@1.1.2 # Packages for a great mobile UX -mongo@2.6.0 # The database Meteor supports right now +mongo@2.6.1 # The database Meteor supports right now reactive-var@1.0.13 # Reactive variable for tracker tracker@1.3.5 # Meteor's client-side reactive programming library @@ -24,7 +24,7 @@ rspack@1.4.0 # # Accounts # -accounts-password@3.3.2 +accounts-password@3.3.3 # # Methods diff --git a/complex-todos-svelte/.meteor/release b/complex-todos-svelte/.meteor/release index 6cf7cce..36f52ca 100644 --- a/complex-todos-svelte/.meteor/release +++ b/complex-todos-svelte/.meteor/release @@ -1 +1 @@ -METEOR@3.6 +METEOR@3.6.1 diff --git a/complex-todos-svelte/.meteor/versions b/complex-todos-svelte/.meteor/versions index b9253b2..97217e5 100644 --- a/complex-todos-svelte/.meteor/versions +++ b/complex-todos-svelte/.meteor/versions @@ -1,5 +1,5 @@ -accounts-base@3.4.0 -accounts-password@3.3.2 +accounts-base@3.4.1 +accounts-password@3.3.3 allow-deny@2.1.2 autoupdate@2.0.2 babel-compiler@7.15.2 @@ -15,7 +15,7 @@ ddp@1.4.3 ddp-client@3.4.2 ddp-common@1.4.6 ddp-rate-limiter@1.3.1 -ddp-server@3.6.0 +ddp-server@3.6.1 diff-sequence@1.2.1 dynamic-import@0.8.1 ecmascript@0.19.2 @@ -43,14 +43,14 @@ meteortesting:mocha@3.3.0 meteortesting:mocha-core@8.2.0 minifier-css@2.0.2 minifier-js@3.3.2 -minimongo@2.2.1 +minimongo@2.2.2 mobile-experience@1.1.2 mobile-status-bar@1.1.1 modern-browsers@0.2.4 modules@0.20.3 modules-runtime@0.13.2 modules-runtime-hot@0.14.3 -mongo@2.6.0 +mongo@2.6.1 mongo-decimal@0.2.0 mongo-dev-server@1.1.1 mongo-id@1.0.10 @@ -76,6 +76,6 @@ tools-core@1.4.0 tracker@1.3.5 typescript@5.11.2 url@1.3.7 -webapp@2.4.0 +webapp@2.4.1 webapp-hashing@1.1.3 zodern:types@1.0.13 diff --git a/complex-todos-svelte/README.md b/complex-todos-svelte/README.md index 5154cc9..dc3c420 100755 --- a/complex-todos-svelte/README.md +++ b/complex-todos-svelte/README.md @@ -2,7 +2,7 @@ Same idea as the [simple Svelte tutorial](https://github.com/meteor/meteor3-svelte/tree/3.4-rspack), but not simple. This app covers things you'll actually run into when building something real: module boundaries, validation, rate limiting, caching, migrations, jobs, and proper separation of concerns. -Built with Meteor 3.6, Svelte 5, Skeleton UI, and Tailwind CSS v4. +Built with Meteor 3.6.1, Svelte 5, Skeleton UI, and Tailwind CSS v4. Demo: https://complex-todos-svelte.sandbox.galaxycloud.app/ @@ -10,7 +10,7 @@ Demo: https://complex-todos-svelte.sandbox.galaxycloud.app/ | | | |---|---| -| Runtime | Meteor 3.6 | +| Runtime | Meteor 3.6.1 | | Frontend | Svelte 5 (runes) | | UI | Skeleton UI v4 + Tailwind CSS v4, Cerberus theme | | Build | Rspack | diff --git a/examples.json b/examples.json index a74b698..cb936ff 100644 --- a/examples.json +++ b/examples.json @@ -44,8 +44,8 @@ "Biome", "Playwright" ], - "lastUpdatedAt": "Nov/10/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/13/2026", + "meteorVersion": "3.6.1" }, { "title": "Notes Offline", @@ -74,13 +74,13 @@ "Prettier", "Playwright" ], - "lastUpdatedAt": "Nov/10/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/13/2026", + "meteorVersion": "3.6.1" }, { "title": "Simple Blog", "slug": "simple-blog", - "demo": null, + "demo": "https://example-simple-blog.sandbox.galaxycloud.app", "tutorial": null, "repository": "dupontbertrand/meteor-blog", "repositoryUrl": "https://github.com/dupontbertrand/meteor-blog", @@ -95,8 +95,8 @@ "Flow Router", "MJML" ], - "lastUpdatedAt": "Mar/24/2026", - "meteorVersion": "3.4" + "lastUpdatedAt": "Nov/14/2026", + "meteorVersion": "3.6.1" }, { "title": "Tic-Tac-Toe", @@ -118,8 +118,8 @@ "oxlint", "Playwright" ], - "lastUpdatedAt": "Nov/10/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/13/2026", + "meteorVersion": "3.6.1" }, { "title": "Parties", @@ -140,8 +140,8 @@ "RSLint", "Playwright" ], - "lastUpdatedAt": "Nov/10/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/13/2026", + "meteorVersion": "3.6.1" }, { "title": "Complex Todos (Svelte)", @@ -167,8 +167,8 @@ "Mocha", "MongoDB" ], - "lastUpdatedAt": "Nov/10/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/13/2026", + "meteorVersion": "3.6.1" }, { "title": "Welcome Meteor Cordova", @@ -202,12 +202,13 @@ "Rspack", "Blaze 3", "Chart.js", + "dupontbertrand:gridstack", "MongoDB", "Mocha", "RSLint", "Playwright" ], - "lastUpdatedAt": "Nov/01/2026", - "meteorVersion": "3.6" + "lastUpdatedAt": "Nov/14/2026", + "meteorVersion": "3.6.1" } ] diff --git a/instrumentation-dashboard/.meteor/packages b/instrumentation-dashboard/.meteor/packages index 03e0b58..73c60be 100644 --- a/instrumentation-dashboard/.meteor/packages +++ b/instrumentation-dashboard/.meteor/packages @@ -6,7 +6,7 @@ meteor-base@1.5.2 # Packages every Meteor app needs to have mobile-experience@1.1.2 # Packages for a great mobile UX -mongo@2.6.0 # The database Meteor supports right now +mongo@2.6.1 # The database Meteor supports right now blaze-html-templates # Compile .html files into Meteor Blaze views jquery # Wrapper package for npm-installed jquery reactive-var@1.0.13 # Reactive variable for tracker @@ -28,3 +28,4 @@ rspack@1.4.0 # Integrate Rspack into Meteor for client and serv instrumentation@0.0.1 # Read-only lifecycle events for methods, publications and DDP connections check@1.5.1 # Argument validation for methods meteortesting:mocha # Test driver +dupontbertrand:gridstack@0.2.1 diff --git a/instrumentation-dashboard/.meteor/release b/instrumentation-dashboard/.meteor/release index 6cf7cce..36f52ca 100644 --- a/instrumentation-dashboard/.meteor/release +++ b/instrumentation-dashboard/.meteor/release @@ -1 +1 @@ -METEOR@3.6 +METEOR@3.6.1 diff --git a/instrumentation-dashboard/.meteor/versions b/instrumentation-dashboard/.meteor/versions index 2c29cbf..9f8e89a 100644 --- a/instrumentation-dashboard/.meteor/versions +++ b/instrumentation-dashboard/.meteor/versions @@ -17,8 +17,9 @@ core-runtime@1.0.0 ddp@1.4.3 ddp-client@3.4.2 ddp-common@1.4.6 -ddp-server@3.6.0 +ddp-server@3.6.1 diff-sequence@1.2.1 +dupontbertrand:gridstack@0.2.1 dynamic-import@0.8.1 ecmascript@0.19.2 ecmascript-runtime@0.8.3 @@ -46,14 +47,14 @@ meteortesting:mocha@3.4.0 meteortesting:mocha-core@8.2.0 minifier-css@2.0.2 minifier-js@3.3.2 -minimongo@2.2.1 +minimongo@2.2.2 mobile-experience@1.1.2 mobile-status-bar@1.1.1 modern-browsers@0.2.4 modules@0.20.3 modules-runtime@0.13.2 modules-runtime-hot@0.14.3 -mongo@2.6.0 +mongo@2.6.1 mongo-decimal@0.2.0 mongo-dev-server@1.1.1 mongo-id@1.0.10 @@ -78,8 +79,10 @@ templating@1.4.5 templating-compiler@2.0.1 templating-runtime@2.0.2 templating-tools@2.0.1 +tmeasday:check-npm-versions@2.1.0 tools-core@1.4.0 tracker@1.3.5 typescript@5.11.2 -webapp@2.4.0 +webapp@2.4.1 webapp-hashing@1.1.3 +zodern:types@1.0.13 diff --git a/instrumentation-dashboard/README.md b/instrumentation-dashboard/README.md index a530e30..50cb8c2 100644 --- a/instrumentation-dashboard/README.md +++ b/instrumentation-dashboard/README.md @@ -8,10 +8,11 @@ The point is the pattern, not the charts: observing an app without slowing its m | | | |---|---| -| Runtime | Meteor 3.6 | +| Runtime | Meteor 3.6.1 | | Observability | `instrumentation` (Meteor core) | | Frontend | Blaze 3 | | Chart | Chart.js 4 | +| Layout | [`dupontbertrand:gridstack`](https://github.com/dupontbertrand/blaze-gridstack) (gridstack.js 14) | | Database | MongoDB | | Tests | Mocha (`meteortesting:mocha`), Playwright | | Code Quality | RSLint | @@ -44,6 +45,7 @@ Before running E2E tests for the first time, install Playwright's browsers with - The task app (`/`) adds, checks and removes tasks through methods and a publication: that is the traffic being observed. - The dashboard (`/admin`) shows, for the last 5 minutes, the number of method calls, the p95 duration, the error rate and the open DDP connections, a per-method table (calls, errors, p50, p95), a chart of calls and errors per minute over the last hour, and the 50 most recent events. - Clicking an event opens its payload as JSON text. +- The panels can be dragged by their title and resized from their corner. The layout is saved and shared: every open dashboard follows a move at once. **Reset layout** puts them back. On a narrow screen they stack in one column, and that is not saved. - In development, **Generate sample traffic** makes twenty method calls, three of which fail validation on purpose. ## How it works @@ -70,6 +72,7 @@ task app (/) dashboard (/admin) - **Counters survive write failures.** Once the raw events are stored, their per-minute counters wait in memory until the rollup write succeeds. After a partial failure only the operations MongoDB reported as failed are retried. - **Several instances.** Every process writes into the same collections, tagged with its instance id. A compare-and-set lease on the snapshot document lets one process recompute the summary each round without a leader election, and any process can serve the dashboard. - **One document to publish.** The dashboard subscribes to a single summary document: counts, percentiles, the chart series and the 50 most recent events. Viewers never subscribe to the raw collections. +- **A layout shared live.** The grid's `items` come from one `admin_layouts` document, so a move saved by one dashboard reaches the others through the publication. The grid's `onChange` saves what a person drags or resizes in the full 12-column grid; on a narrow screen the panels stack in one column, which the component does not report, and back at full width they go where the saved layout says. The Method stores positions only, each panel once, within the 12 columns and no smaller than the panel allows; titles and templates stay in the code (`imports/admin/layout.js`). - **Private by default.** Client IP addresses are not captured. Method arguments are not captured either, except for a projection on `tasks.insert` that records the length of the text, never the text itself (`imports/observability/policy.js`). The recent events do carry user ids, error messages and instance names, for the people `requireAdmin()` lets in. ## How it's structured @@ -79,10 +82,11 @@ client/ main.html, main.js # Layout and the two pages, chosen by path main.css server/ - main.js # Starts the collector, publishes admin.snapshot + main.js # Starts the collector, publishes admin.snapshot and admin.layout imports/ admin/ authorization.js # requireAdmin(): the single place to plug real permissions + layout.js # The panels, their default layout, the Methods that save and reset it api/tasks/ # Tasks collection, methods and publication observability/ policy.js # Instrumentation.configure() and the tasks.insert projection @@ -92,7 +96,7 @@ imports/ snapshot.js # Bounded reads and the compare-and-set refresh server.js # Storage setup (capped collection, TTL indexes) and startup settings.js # Defaults, overridable in settings.json - ui/ # Tasks page, admin page and chart + ui/ # Tasks page, admin page (a grid of panels) and chart tests/ # Unit tests and a server integration test (Mocha) e2e/ # Playwright specs ``` @@ -123,4 +127,4 @@ e2e/ # Playwright specs - [Meteor docs](https://docs.meteor.com/) · [Instrumentation API](https://docs.meteor.com/api/instrumentation) - [Blaze docs](https://www.blazejs.org/) -- [Chart.js](https://www.chartjs.org/) +- [Chart.js](https://www.chartjs.org/) · [gridstack.js](https://gridstackjs.com/) diff --git a/instrumentation-dashboard/client/main.css b/instrumentation-dashboard/client/main.css index ac32f88..69c4f0d 100644 --- a/instrumentation-dashboard/client/main.css +++ b/instrumentation-dashboard/client/main.css @@ -128,11 +128,55 @@ button { gap: 1rem; } +.admin-actions { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; +} + +/* A grid item: the title is the drag handle, the body scrolls. */ +.panel { + display: flex; + flex-direction: column; + height: 100%; + background: var(--surface); + border: 1px solid var(--border); + border-radius: 0.5rem; + overflow: hidden; +} + +.panel-title { + margin: 0; + padding: 0.5rem 0.75rem; + font-size: 0.85rem; + font-weight: 600; + color: var(--muted); + cursor: grab; + user-select: none; +} + +.panel-body { + flex: 1; + min-height: 0; + overflow: auto; + padding: 0 0.75rem 0.75rem; +} + +.grid-stack { + margin: 0 -6px; +} + .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; - margin: 1rem 0; +} + +/* Stacked in one column, the panel is short: the tiles stay on one row and scroll. */ +.gs-1 .tiles { + grid-auto-flow: column; + grid-template-columns: none; + grid-auto-columns: minmax(9rem, 1fr); } .tile { @@ -157,11 +201,8 @@ button { } .chart { - height: 14rem; - padding: 0.75rem; - background: var(--surface); - border: 1px solid var(--border); - border-radius: 0.5rem; + position: relative; + height: 100%; } .methods { @@ -212,13 +253,21 @@ button { } .instances { - display: flex; - flex-wrap: wrap; - gap: 1rem; + display: grid; + gap: 0.5rem; + margin: 0; + padding: 0; + list-style: none; color: var(--muted); font-size: 0.85rem; } +.instance-id { + display: block; + color: var(--text); + font-family: ui-monospace, monospace; +} + .inspector { max-width: min(40rem, 90vw); border: 1px solid var(--border); diff --git a/instrumentation-dashboard/e2e/dashboard.spec.js b/instrumentation-dashboard/e2e/dashboard.spec.js index be6aa3a..dce52f6 100644 --- a/instrumentation-dashboard/e2e/dashboard.spec.js +++ b/instrumentation-dashboard/e2e/dashboard.spec.js @@ -32,3 +32,64 @@ test('the admin dashboard reflects generated traffic', async ({ page }) => { await inspector.getByRole('button', { name: 'Close' }).click(); await expect(inspector).toBeHidden(); }); + +// gridstack animates moves: grab a panel's title once it has stopped. +async function dragServersLeft(page) { + const title = page.locator('.panel[data-panel="instances"] .panel-title'); + let box; + for (let previous = null; ; previous = box) { + box = await title.boundingBox(); + if (previous && previous.x === box.x && previous.y === box.y) break; + await page.waitForTimeout(200); + } + await page.mouse.move(box.x + 20, box.y + 10); + await page.mouse.down(); + await page.mouse.move(box.x - 700, box.y + 10, { steps: 12 }); + await page.mouse.up(); +} + +test('a panel moved on one dashboard moves on the others, until the layout is reset', async ({ browser }) => { + const pages = []; + for (let index = 0; index < 2; index += 1) { + const page = await (await browser.newContext({ viewport: { width: 1280, height: 1000 } })).newPage(); + await page.goto('/admin'); + await expect(page.locator('.panel[data-panel="instances"]')).toBeVisible(); + pages.push(page); + } + const [mover, watcher] = pages; + await mover.getByRole('button', { name: 'Reset layout' }).click(); + const column = (page) => page.locator('.grid-stack-item[gs-id="instances"]'); + await expect(column(watcher)).toHaveAttribute('gs-x', '8'); + + await expect(column(mover)).toHaveAttribute('gs-x', '8'); + // Drag the Servers panel by its title to the left edge. + await dragServersLeft(mover); + await expect(column(mover)).toHaveAttribute('gs-x', '0'); + await expect(column(watcher)).toHaveAttribute('gs-x', '0'); + + await watcher.getByRole('button', { name: 'Reset layout' }).click(); + await expect(column(mover)).toHaveAttribute('gs-x', '8'); + await Promise.all(pages.map((page) => page.context().close())); +}); + +test('a narrow screen neither saves its one column nor brings back an old layout when it widens', async ({ browser }) => { + const wide = await (await browser.newContext({ viewport: { width: 1280, height: 1000 } })).newPage(); + await wide.goto('/admin'); + await wide.getByRole('button', { name: 'Reset layout' }).click(); + const servers = (page) => page.locator('.grid-stack-item[gs-id="instances"]'); + await expect(servers(wide)).toHaveAttribute('gs-x', '8'); + await dragServersLeft(wide); + await expect(servers(wide)).toHaveAttribute('gs-x', '0'); + + // A phone opens the dashboard, then turns to landscape. + const phone = await (await browser.newContext({ viewport: { width: 400, height: 900 } })).newPage(); + await phone.goto('/admin'); + await expect(phone.locator('.grid-stack.gs-1')).toBeVisible(); + await phone.setViewportSize({ width: 1280, height: 900 }); + await expect(phone.locator('.grid-stack.gs-12')).toBeVisible(); + await expect(servers(phone)).toHaveAttribute('gs-x', '0'); + // Give a stray save the time to reach the other dashboard. + await wide.waitForTimeout(1000); + await expect(servers(wide)).toHaveAttribute('gs-x', '0'); + await Promise.all([wide, phone].map((page) => page.context().close())); +}); diff --git a/instrumentation-dashboard/imports/admin/layout.js b/instrumentation-dashboard/imports/admin/layout.js new file mode 100644 index 0000000..b20f871 --- /dev/null +++ b/instrumentation-dashboard/imports/admin/layout.js @@ -0,0 +1,50 @@ +import { Meteor } from 'meteor/meteor'; +import { Mongo } from 'meteor/mongo'; +import { check, Match } from 'meteor/check'; +import { requireAdmin } from './authorization'; + +// Where the dashboard's panels sit, in a 12-column grid. One document, 'admin', +// shared by everyone who opens the dashboard: move a panel and the other open +// dashboards follow. With accounts, key it by user instead. +export const Layouts = new Mongo.Collection('admin_layouts'); + +export const COLUMNS = 12; +export const PANELS = [ + { id: 'tiles', title: 'Overview', template: 'adminTiles', x: 0, y: 0, w: 12, h: 2, minW: 3, minH: 2 }, + { id: 'chart', title: 'Calls per minute', template: 'adminChart', x: 0, y: 2, w: 8, h: 4, minW: 4, minH: 3 }, + { id: 'instances', title: 'Servers', template: 'adminInstances', x: 8, y: 2, w: 4, h: 4, minW: 3, minH: 2 }, + { id: 'methods', title: 'Methods', template: 'adminMethods', x: 0, y: 6, w: 6, h: 5, minW: 4, minH: 3 }, + { id: 'events', title: 'Recent events', template: 'adminEvents', x: 6, y: 6, w: 6, h: 5, minW: 4, minH: 3 }, +]; + +// The panels, where the saved layout puts them. +export function panelsIn(layout) { + const saved = new Map((layout?.panels ?? []).map((panel) => [panel.id, panel])); + return PANELS.map((panel) => ({ ...panel, ...saved.get(panel.id) })); +} + +const Cell = (max) => Match.Where((value) => Number.isInteger(value) && value >= 0 && value <= max); +const Position = Match.Where((panel) => { + check(panel, { id: Match.Where((id) => PANELS.some((known) => known.id === id)), x: Cell(COLUMNS - 1), y: Cell(1000), w: Cell(COLUMNS), h: Cell(100) }); + const { minW, minH } = PANELS.find((known) => known.id === panel.id); + return panel.w >= minW && panel.h >= minH && panel.x + panel.w <= COLUMNS; +}); +// Each panel at most once. +const Positions = Match.Where((panels) => { + check(panels, [Position]); + return panels.length <= PANELS.length && new Set(panels.map((panel) => panel.id)).size === panels.length; +}); + +// Loaded on both sides: the stub keeps this dashboard's copy in step with its +// grid at once, the server saves the layout for everyone. +Meteor.methods({ + async 'admin.saveLayout'(panels) { + check(panels, Positions); + if (!(await requireAdmin(this.userId))) throw new Meteor.Error('not-authorized'); + await Layouts.upsertAsync('admin', { $set: { panels } }); + }, + async 'admin.resetLayout'() { + if (!(await requireAdmin(this.userId))) throw new Meteor.Error('not-authorized'); + await Layouts.removeAsync('admin'); + }, +}); diff --git a/instrumentation-dashboard/imports/ui/admin.html b/instrumentation-dashboard/imports/ui/admin.html index f3856f2..f41fbd3 100644 --- a/instrumentation-dashboard/imports/ui/admin.html +++ b/instrumentation-dashboard/imports/ui/admin.html @@ -7,18 +7,15 @@
{{dropped}} events were dropped since the servers started because the collector queue was full.
{{/if}} @@ -29,41 +26,8 @@Waiting for the first snapshot…
{{/with}} - - - {{#with snapshot}} -| Method | Calls | Errors | p50 | p95 |
|---|---|---|---|---|
| {{method.name}} | {{method.calls}} | {{method.errors}} | {{ms method.p50}} | {{ms method.p95}} |
| No method calls in this window. | ||||
- {{#each instance in instances}} - {{instance._id}}: {{instance.connections}} connections, {{instance.publications}} subscriptions - {{/each}} -
- {{/with}} +Drag a panel by its title, resize it from its corner: everyone who has the dashboard open sees the new layout.
+ {{> gridStack items=panels itemTemplate="adminPanel" options=gridOptions onChange=saveLayout}} + + + +| Method | Calls | Errors | p50 | p95 |
|---|---|---|---|---|
| {{method.name}} | {{method.calls}} | {{method.errors}} | {{ms method.p50}} | {{ms method.p95}} |
| No method calls in this window. | ||||