Skip to content

Add dispatcher dashboard, simulated DispatchState and simple admin JSON APIs - #4

Open
Peter220101 wants to merge 1 commit into
mainfrom
codex/complete-dispatcher-ui-for-sertaej-gx4fhp
Open

Add dispatcher dashboard, simulated DispatchState and simple admin JSON APIs#4
Peter220101 wants to merge 1 commit into
mainfrom
codex/complete-dispatcher-ui-for-sertaej-gx4fhp

Conversation

@Peter220101

Copy link
Copy Markdown
Owner

Motivation

  • Provide a self-contained dispatcher UI with a simulated backend state for development and demos.
  • Expose a lightweight admin API to manage demo users, vehicles and reports via session storage.
  • Enable configurable Google Maps integration and polling via a new dispatcher config.

Description

  • Added a full dispatcher frontend dispatcher.php that renders a responsive UI, polls api/state.php, renders drivers/services/queues, and exposes an admin modal that interacts with api/admin.php.
  • Implemented app/DispatchState.php which seeds, simulates and persists an in-memory dispatch state in the session and exposes metrics, drivers, services and zone queues.
  • Added api/state.php to return the current dispatch state and aggregated stats, and api/admin.php to provide simple GET/create/update/delete operations against per-session demo data for users, vehicles, and reports.
  • Added configuration config/dispatcher_config.php with options such as enable_google_maps, google_maps_api_key, polling_ms, max_drivers, and simulate_live_data.

Testing

  • Ran PHP syntax checks on new PHP files with php -l and verified there were no parse errors.
  • Performed automated HTTP sanity checks using curl --silent --fail against api/state.php and api/admin.php?module=users to confirm responses are 200 and valid JSON, and both checks succeeded.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa9d26aa7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/DispatchState.php
$names = ['Carlos Mite', 'Ana Solis', 'Ricardo Cedeño', 'Marlon Vera', 'Jessica Ortiz', 'Luis Falconi', 'Pedro Villao', 'Diana Mendoza'];
$zones = ['Kennedy Norte', 'Urdesa', 'Ceibos', 'Centro', 'Mapasingue', 'Samanes', 'Alborada', 'Sauces'];

$maxId = max(array_column($state['drivers'], 'id'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard empty driver list before computing next driver ID

In maybeAddDriver, calling max(array_column($state['drivers'], 'id')) crashes with a ValueError when the session starts with zero drivers (the seeded default). As soon as simulate_live_data is enabled and the 50% add-driver path is hit, api/state.php will return 500 and the dashboard polling breaks. Handle the empty-array case (e.g., seed from 0) before calling max().

Useful? React with 👍 / 👎.

Comment thread api/admin.php
exit;
}

$action = $payload['action'] ?? 'create';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject missing action instead of defaulting to create

For any non-GET request, the API defaults $action to 'create' when the client omits action. That means a malformed or empty write request (for example POST {}) silently inserts a new blank record, which mutates admin data unexpectedly. Mutating endpoints should require an explicit supported action and otherwise return a client error.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant