Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 2.6 KB

README_LOCAL.md

File metadata and controls

78 lines (57 loc) · 2.6 KB

Civil Protection Plans Dashboard - Local Setup Guide

This guide explains how to run the dashboard locally on your Mac.

Prerequisites

  1. Node.js: Required to run the frontend. Download from nodejs.org.
  2. Python 3: Required to run the data update scripts. (Usually pre-installed on macOS).

Installation

  1. Unzip the project: Extract the prociv_plans_dashboard.zip file to a location of your choice.

  2. Open Terminal: Open the Terminal app and navigate to the project folder:

    cd path/to/prociv_plans_dashboard
  3. Install Dependencies: Run the following command to install the required Node.js packages:

    npm install

    (Note: If you don't have pnpm installed, npm works fine. If you prefer pnpm, run npm install -g pnpm first, then pnpm install).

  4. Install Python Dependencies: The data update scripts require a few Python libraries. Install them using pip:

    pip3 install requests beautifulsoup4 python-dateutil

Running the Dashboard

  1. Start the Development Server:
    npm run dev
    This will start the local server, usually at http://localhost:5173. Open this URL in your browser to view the dashboard.

Updating the Data

The dashboard data is static, meaning it doesn't fetch from the official website in real-time (to avoid overloading their server). Instead, you run a script to update the data locally.

To update the data:

  1. Run the Update Script:

    ./scripts/update_data.sh

    This script will:

    • Scrape the latest data from planos.prociv.pt.
    • Categorize the plans.
    • Update the historical data (for the chart).
    • Update the client/src/lib/plans-data-pt.ts file which the dashboard uses.

    Once the script finishes, the dashboard (if running) will automatically reload with the new data.

Automating Updates (Optional)

You can set up a "cron job" to run the update script automatically every day.

  1. Type crontab -e in Terminal.
  2. Add a line like this (replace /path/to/... with the actual path):
    0 9 * * * /path/to/prociv_plans_dashboard/scripts/update_data.sh >> /path/to/prociv_plans_dashboard/update.log 2>&1
    This runs the update every day at 9:00 AM.

Troubleshooting

  • Permission Denied: If ./scripts/update_data.sh fails with permission denied, run:
    chmod +x scripts/update_data.sh
  • Python Errors: Ensure you installed the dependencies (requests, beautifulsoup4, python-dateutil).