Skip to content

AdaptableTools/report-automation-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Report Automation Demo

Automate AdapTable report downloads using Playwright. This project has two parts:

  1. demo-page/ -- A Vite + React app with an AdapTable grid and pre-configured reports
  2. cli/ -- A Playwright-based CLI tool that can download reports from any AdapTable page

The CLI can be used to open any page with Adaptable in it. For convenience, in this repo, we provide the demo-page.

Quick Start

1. Start the demo page

cd demo-page
npm install
npm run dev

This starts a Vite dev server at http://localhost:5173 with an AdapTable grid loaded with web framework data.

The page exposes the AdapTable API on window.__adaptableApi for automation (it's not mandatory, but we you can do it if you control the page you're targeting).

2. Install the CLI

cd cli
npm install
npx playwright install chromium

3. Download a report (one-shot)

npx tsx src/index.ts download-report --url http://localhost:5173 --report "All Data" --format CSV

This will:

  • Launch a headless browser
  • Navigate to the demo page
  • Wait for AdapTable to initialize
  • Trigger an export of the "All Data" report as CSV
  • Save the downloaded file to ./downloads/
  • Exit

4. Watch for scheduled reports (long-running)

npx tsx src/index.ts watch-reports --url http://localhost:5173

This will:

  • Navigate to the demo page with the headless browser
  • Listen for any browser downloads (triggered by AdapTable scheduled reports)
  • Save each download with a timestamp to ./downloads/
  • Run until you press Ctrl+C

Or with more CLI args

npx tsx src/index.ts watch-reports --url http://localhost:5173 --output ./downloads --no-headless

This will:

  • Launch a visible browser window
  • Navigate to the demo page
  • Listen for any browser downloads (triggered by AdapTable scheduled reports)
  • Save each download with a timestamp to ./downloads/
  • Run until you press Ctrl+C

CLI Reference

download-report

Option Default Description
--url <url> required URL of the page with an AdapTable instance
--report <name> All Data Report name to export
--format <format> CSV Export format: CSV, Excel, JSON
--output <dir> ./downloads Directory to save the file
--headless / --no-headless headless Whether to show the browser

watch-reports

Option Default Description
--url <url> required URL of the page with an AdapTable instance
--output <dir> ./downloads Directory to save files
--headless / --no-headless headed Whether to show the browser

Using with your own AdapTable page

The CLI works with any AdapTable page. When the Adaptable API is exposed on the window object, it uses that.

onAdaptableReady={(readyInfo) => {
  (window as any).__adaptableApi = readyInfo.adaptableApi;
}}

When the API is not available, the CLI automatically falls back to UI automation (clicking the toolbar buttons) to trigger exports.

Then point the CLI at your page URL:

npx tsx src/index.ts download-report --url http://localhost:5137 --report "My Report" --format Excel


```bash
npx tsx src/index.ts download-report --url http://localhost:5173 --report "Popular Frameworks" --format JSON
npx tsx src/index.ts download-report --url http://localhost:5173 --report "Popular Frameworks" --format Excel

Demo page reports

The demo page comes pre-configured with:

  • System reports: "All Data", "Current Layout"
  • Custom report: "Popular Frameworks" (frameworks with > 50k GitHub stars)
  • Scheduled export: "All Data" as CSV, configured to fire periodically (you can adjust the schedule in the AdapTable UI)

Project structure

report-automation-demo/
  README.md
  demo-page/
    package.json          # Vite + React + AG Grid + AdapTable
    index.html
    vite.config.ts
    tsconfig.json
    src/
      main.tsx            # React entry point
      App.tsx             # AdapTable grid with reports config
      data.ts             # WebFramework sample data (25 rows)
      columns.ts          # AG Grid column definitions
  cli/
    package.json          # Playwright + Commander
    tsconfig.json
    src/
      index.ts            # CLI entry point with subcommands
      download-report.ts  # One-shot report download
      watch-reports.ts    # Long-running download watcher

About

Use node & playwright to automate downloading Adaptable Reports

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors