feat(dashboard): add real metrics to manager dashboard#35
Open
edilsonoliveirama wants to merge 2 commits intoEvolutionAPI:mainfrom
Open
feat(dashboard): add real metrics to manager dashboard#35edilsonoliveirama wants to merge 2 commits intoEvolutionAPI:mainfrom
edilsonoliveirama wants to merge 2 commits intoEvolutionAPI:mainfrom
Conversation
The /manager dashboard previously showed only a static placeholder
("Dashboard content will be implemented here..."). This replaces it
with a standalone HTML page that fetches live data from the API and
displays real metrics:
- Total instances count
- Connected instances count and percentage
- Disconnected instances count
- Server health status (GET /server/ok)
- AlwaysOnline count
- Instance table with name, status badge, phone number, client and
AlwaysOnline indicator
- Auto-refresh every 30 seconds with manual refresh button
Implementation uses a standalone HTML file (Tailwind CDN + vanilla JS
fetch) served at GET /manager, keeping the existing compiled bundle
intact for all other routes (/manager/instances, /manager/login, etc.).
Changes:
- manager/dashboard/index.html: new self-contained dashboard page
- pkg/routes/routes.go: serve dashboard/index.html for GET /manager
(exact), keep dist/index.html for GET /manager/*any (wildcard)
- Dockerfile: copy manager/dashboard/ into the final image
- .gitignore: exclude manager build artifacts from version control
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer's GuideImplements a new standalone HTML/JS manager dashboard served at /manager that fetches live metrics from existing API endpoints, while preserving the existing React manager bundle under /manager/*any and wiring the new assets into the Docker image and gitignore configuration. Sequence diagram for manager dashboard data loadingsequenceDiagram
actor ManagerUser
participant Browser
participant GinRouter
participant DashboardHTML
participant API_Instance
participant API_Server
ManagerUser->>Browser: Open /manager
Browser->>GinRouter: GET /manager
GinRouter-->>Browser: manager/dashboard/index.html
Browser->>DashboardHTML: Parse and execute JS
DashboardHTML->>Browser: Read apikey from localStorage
DashboardHTML->>API_Instance: GET /instance/all with header apikey
DashboardHTML->>API_Server: GET /server/ok with header apikey
API_Instance-->>DashboardHTML: JSON instances list
API_Server-->>DashboardHTML: JSON server status
DashboardHTML->>Browser: Compute metrics (total, connected, disconnected, alwaysOnline)
DashboardHTML->>Browser: Update metric cards and instance table
loop every 30s
DashboardHTML->>API_Instance: GET /instance/all with header apikey
DashboardHTML->>API_Server: GET /server/ok with header apikey
API_Instance-->>DashboardHTML: Updated JSON
API_Server-->>DashboardHTML: Updated JSON
DashboardHTML->>Browser: Update metrics and table
end
ManagerUser->>DashboardHTML: Click Atualizar button
DashboardHTML->>API_Instance: Manual refresh GET /instance/all
DashboardHTML->>API_Server: Manual refresh GET /server/ok
API_Instance-->>DashboardHTML: JSON
API_Server-->>DashboardHTML: JSON
DashboardHTML->>Browser: Update metrics and table
Flow diagram for updated manager routing and assetsflowchart LR
subgraph Client
U[Manager user browser]
end
subgraph Server
R[Gin_router]
DHTML[manager/dashboard/index.html]
DBundle[manager/dist/index.html]
end
subgraph ImageBuild[Docker image build]
BDist[build output manager/dist]
BDash[build output manager/dashboard]
FinalImage[Final container image]
end
U -->|GET /manager| R
U -->|GET /manager/instances etc| R
R -->|serve file| DHTML
R -->|serve file| DBundle
BDist -->|COPY /build/manager/dist| FinalImage
BDash -->|COPY /build/manager/dashboard| FinalImage
style DHTML fill:#e0ffe0,stroke:#16a34a
style DBundle fill:#e0f2ff,stroke:#2563eb
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- When rendering the instances table, values like
inst.name,inst.clientName, andinst.jidare interpolated directly intoinnerHTML, which can allow XSS if those fields ever contain untrusted data; consider building the table withcreateElement/textContentor sanitizing these fields before insertion. apiKeyis read fromlocalStorageand used unconditionally inapiFetch, but the UI only shows a generic error when calls fail; it would be helpful to explicitly detect a missing/empty API key and present a clearer state/message to the user in that case.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When rendering the instances table, values like `inst.name`, `inst.clientName`, and `inst.jid` are interpolated directly into `innerHTML`, which can allow XSS if those fields ever contain untrusted data; consider building the table with `createElement`/`textContent` or sanitizing these fields before insertion.
- `apiKey` is read from `localStorage` and used unconditionally in `apiFetch`, but the UI only shows a generic error when calls fail; it would be helpful to explicitly detect a missing/empty API key and present a clearer state/message to the user in that case.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
9d30f36 to
f8c7d23
Compare
Replaces innerHTML interpolation of server-supplied fields (name, clientName, jid) with DOM createElement/textContent to eliminate potential XSS. Also detects a missing or empty API key before making any requests and renders an actionable message explaining how to set it, instead of showing a generic fetch error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Problema
EN: The
/managerdashboard showed only a static placeholder text ("Dashboard content will be implemented here...") with no real data.PT: O dashboard em
/managerexibia apenas um texto placeholder estático, sem nenhum dado real.Solution / Solução
EN: Created a standalone dashboard page that fetches live data from the existing API endpoints and displays real metrics, without touching the compiled bundle that powers the rest of the manager (instances, login, etc.).
PT: Criada uma página de dashboard standalone que busca dados em tempo real dos endpoints existentes da API e exibe métricas reais, sem tocar no bundle compilado que alimenta o restante do manager (instâncias, login, etc.).
Metrics / Métricas
GET /instance/allconnected === truecountconnected === falsecountGET /server/ok+ AlwaysOnline countapikeyfrom localStorage (set by the existing login flow)Changes / Alterações
manager/dashboard/index.html— standalone page (Tailwind CDN + vanilla JS fetch)pkg/routes/routes.go—GET /manager(exact) serves new dashboard;GET /manager/*any(wildcard) keeps original bundle intactDockerfile— copiesmanager/dashboard/into final image.gitignore— excludes manager build artifactsSummary by Sourcery
Introduce a standalone manager dashboard at /manager that shows live metrics from existing API endpoints while keeping the original React manager bundle for other routes.
New Features:
Build:
Chores: