You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce automated email reporting with SMTP support and server-side PNG exports.
- Add email configuration and scheduling (simple_org_chart/email_config.py) and sender logic (simple_org_chart/email_sender.py).
- Add Playwright-based screenshot exporter (simple_org_chart/screenshot.py) and wire PNG generation into report flows.
- Trigger scheduled/`Send Now` emails after successful syncs (data_update.py) and add API endpoints to manage/test email config (app_main.py).
- Update scheduler to mark runs as 'scheduled' so reports are only sent for scheduled syncs.
- Include Playwright dependency and adjust Dockerfile to use Ubuntu 22.04, install Python 3.10, and install Playwright browsers; add playwright to requirements.txt.
- Make runtime/config tweaks: expose APP_BASE_URL and GUNICORN_TIMEOUT in .env.template and use env timeout in gunicorn config.
- Frontend: add email report UI/README docs, add search highlight duration setting, and implement timed fading highlight behavior in static JS/CSS and configure UI.
This change enables configurable, scheduled email reports (XLSX and optional PNG attachments) and ensures server-side PNG generation works reliably in Docker.
|`GRAPH_API_ENDPOINT`|`https://graph.microsoft.com/v1.0`| Microsoft Graph API v1.0 endpoint. |
100
100
|`GRAPH_API_BETA_ENDPOINT`|`https://graph.microsoft.com/beta`| Microsoft Graph API beta endpoint. |
101
101
102
+
**SMTP Email Configuration (optional, for automated reports)**
103
+
104
+
| Variable | Default | Description |
105
+
| --- | --- | --- |
106
+
|`SMTP_SERVER`|*(none)*| SMTP server hostname (e.g., `smtp.gmail.com`, `smtp.office365.com`). |
107
+
|`SMTP_PORT`|`587`| SMTP server port (587 for STARTTLS, 465 for SSL/TLS, 25 for plain). |
108
+
|`SMTP_USERNAME`|*(none)*| SMTP username (often your email address). |
109
+
|`SMTP_PASSWORD`|*(none)*| SMTP password or app-specific password. |
110
+
|`SMTP_FROM_ADDRESS`|*(none)*| From address for sent emails (must be authorized by SMTP server). |
111
+
|`SMTP_ENCRYPTION`|`TLS`| Encryption protocol: `TLS` (STARTTLS for port 587), `SSL` (SSL/TLS for port 465), or `None`. |
112
+
|`APP_BASE_URL`|`http://localhost:5000`| Base URL for generating PNG screenshots (required for PNG email attachments). |
113
+
102
114
## Running the Application
103
115
104
116
### Docker (recommended)
@@ -116,17 +128,86 @@ docker compose up -d
116
128
117
129
-**Interactive D3 Org Chart**: Pan, zoom, and expand/collapse hierarchies with persistent hidden subtrees.
118
130
-**Search & Discovery**: Real-time directory search, quick navigation helpers, and configurable filters for guests/disabled users.
119
-
-**Configuration UI** (`/configure`): Adjust styling, filtering, export columns, and scheduling without editing files.
131
+
-**Configuration UI** (`/configure`): Adjust styling, filtering, export columns, scheduling, and email reports without editing files.
120
132
-**Admin Reports** (`/reports`):
121
133
- Missing managers
122
-
- Users by last sign-in activity
123
-
- Employees hired in the last 365 days
124
-
- Users hidden by filters
134
+
- Users by last sign-in activity
135
+
- Employees hired in the last 365 days
136
+
- Users hidden by filters
137
+
-**Automated Email Reports**: Schedule daily, weekly, or monthly reports sent via SMTP after data synchronization.
125
138
-**Export Options**: SVG/PNG/PDF snapshots and XLSX exports for reports and chart data.
126
139
-**MicroSIP Directory Feed**: Serve a MicroSIP contacts JSON at /contacts.json using cached employee data.
127
140
-**Desk Phone Directory**: Yealink-compatible XML phonebook at /contacts.xml for T31P, T33G, T46U, and similar models.
128
141
-**Caching & Scheduling**: JSON caches regenerate nightly; manual refresh endpoints keep data current on demand.
129
142
143
+
## Automated Email Reports
144
+
145
+
SimpleOrgChart can send scheduled email reports with organization chart data as attachments after each successful data synchronization. **Disabled by default.**
146
+
147
+
### Prerequisites
148
+
149
+
1. Configure SMTP environment variables in `.env` (see SMTP Email Configuration section above)
150
+
2. Ensure all required SMTP settings are provided: server, port, username, password, and from address
151
+
3. Set `APP_BASE_URL` in `.env` to the **internal** URL where the app listens:
152
+
-**Docker**: `http://localhost` (port 80 inside container, regardless of external port mapping)
153
+
-**Non-Docker**: `http://localhost:5000` (or whatever port you configured)
154
+
4.**(Docker users)** PNG screenshots are automatically supported - Playwright is included in the Docker image
155
+
5.**(Non-Docker users)** For PNG chart screenshots, install Playwright:
156
+
```bash
157
+
pip install playwright
158
+
playwright install --with-deps chromium
159
+
```
160
+
161
+
### Configuration
162
+
163
+
1. Navigate to `/configure` and locate the **📧 Email Reports** section
164
+
2. Enable **Automated Email Reports** toggle
165
+
3. Configure the following options:
166
+
-**Recipient Email**: Email address(es) to receive reports (comma-separated for multiple recipients)
167
+
-**Report Frequency**: Choose daily, weekly, or monthly
168
+
-**Day of Week**: For weekly schedules, select which day to send
169
+
-**Day of Month**: For monthly schedules, select first or last day
170
+
-**Attachment Types**: Select which file formats to include:
171
+
-**XLSX (Excel)**: Employee data spreadsheet (always available)
> **Note**: SVG and PDF exports require client-side rendering and are not available for automated email reports. These formats can still be generated manually from the web interface.
198
+
199
+
### Test Email
200
+
201
+
Use the **Send Test Email** button to verify your SMTP configuration before enabling automated reports. Use **Manual Send Now** to immediately send a report with XLSX and/or PNG attachments based on your configuration.
202
+
203
+
### SMTP Status
204
+
205
+
The email reports section displays the current SMTP configuration status:
206
+
- ✓ **SMTP configured**: Shows the server, port, and from address
207
+
- ⚠ **SMTP not configured**: Indicates missing SMTP environment variables
208
+
209
+
If SMTP is not configured, ensure all required variables are set in your `.env` file and restart the application.
210
+
130
211
## MicroSIP Directory
131
212
132
213
SimpleOrgChart can publish a MicroSIP-compatible directory export. **Disabled by default.**
0 commit comments