diff --git a/DAILY_VIEW_FEATURE.md b/DAILY_VIEW_FEATURE.md
new file mode 100644
index 000000000..594995feb
--- /dev/null
+++ b/DAILY_VIEW_FEATURE.md
@@ -0,0 +1,162 @@
+# Daily View Feature for Status Pages
+
+## Overview
+
+This feature adds the ability to show 3-month history on Uptime Kuma status pages with daily aggregation instead of the standard 100 recent heartbeats. Each monitor can be individually configured to use either the regular heartbeat view or the new daily view.
+
+## Features
+
+### ✅ **Per-Monitor Configuration**
+- Each monitor on a status page can individually be set to use daily view or regular view
+- Settings are stored in the database and persist across restarts
+- Easy toggle in the monitor settings dialog
+- **Fixed**: Daily view checkbox now properly saves and persists between page reloads
+
+### ✅ **Daily Aggregation**
+- Fetches 3 months of heartbeat data and aggregates by day
+- Each day shows the overall status based on the majority of heartbeats
+- Maintenance status takes priority over other statuses
+- Average ping time is calculated for each day
+- Daily uptime percentage is displayed
+
+### ✅ **Missing Data Visualization**
+- **New**: Days with missing data are displayed as grey bars instead of empty space
+- Ensures visual consistency across all monitors
+- New monitors show complete 3-month timeline with grey bars for days before monitoring started
+- Maintains consistent width and alignment with older monitors
+
+### ✅ **Smart Data Routing**
+- Mixed mode: Some monitors can use daily view while others use regular view on the same status page
+- Backend automatically determines data type needed per monitor
+- Frontend components dynamically render appropriate visualization
+
+### ✅ **Enhanced Tooltips**
+- Daily view shows date, status, uptime percentage, and average ping
+- Missing days show "No data" with the date
+- Special handling for "Today" and "Yesterday"
+
+## Technical Implementation
+
+### Backend Changes
+
+1. **Database Migration**: Added `daily_view` boolean column to `monitor_group` table
+2. **API Endpoint**: `/api/status-page/heartbeat-daily/:slug` returns mixed data based on monitor settings
+3. **Data Aggregation**: SQL queries group by date and calculate daily statistics
+4. **Monitor Model**: Updated to include `dailyView` property in public JSON
+
+### Frontend Changes
+
+1. **DailyHeartbeatBar Component**: New component for 3-month daily timeline visualization
+2. **Missing Data Generation**: Generates complete 3-month timeline with grey placeholders
+3. **Conditional Rendering**: PublicGroupList dynamically chooses between components
+4. **Settings Dialog**: Added toggle for daily view in monitor settings
+5. **Persistence Fix**: Proper boolean conversion for database values
+
+## Usage
+
+### For Administrators
+
+1. **Enable Daily View for a Monitor**:
+ - Open the status page in edit mode
+ - Click the settings icon next to any monitor
+ - Toggle "Daily View" checkbox
+ - Save the status page
+
+2. **Visual Differences**:
+ - **Regular View**: Shows last 100 individual heartbeats as small dots
+ - **Daily View**: Shows up to 90 days as wider bars representing daily aggregates
+ - **Missing Days**: Grey bars maintain visual consistency
+
+### For Users
+
+- Status pages automatically display the appropriate view for each monitor
+- Daily view shows broader trends over months rather than minute-by-minute detail
+- Hover over any day to see detailed statistics
+- Grey bars indicate days when the monitor wasn't active or data is missing
+
+## API Examples
+
+### Daily Data Response
+```json
+{
+ "heartbeatList": {
+ "1": [
+ {
+ "status": 1,
+ "time": "2025-06-10 09:40:26.626",
+ "ping": 177,
+ "uptime": 1.0,
+ "date": "2025-06-10",
+ "dailyStats": {
+ "total": 19,
+ "up": 19,
+ "down": 0,
+ "pending": 0,
+ "maintenance": 0
+ }
+ }
+ ]
+ },
+ "uptimeList": { "1": 1.0 },
+ "dailyViewSettings": { "1": 1 },
+ "hasMixedData": true
+}
+```
+
+### Missing Day Placeholder
+```json
+{
+ "status": -1,
+ "time": null,
+ "ping": null,
+ "uptime": null,
+ "date": "2025-06-09",
+ "missing": true
+}
+```
+
+## Configuration
+
+- **Database**: Migration adds `daily_view` column with default `false`
+- **Performance**: Daily data is cached for 5 minutes vs 1 minute for regular heartbeats
+- **Timeline**: Fixed 3-month window (90 days) regardless of monitor check frequency
+- **Compatibility**: Fully backward compatible - existing monitors continue to use regular view
+
+## Benefits
+
+1. **Better Long-term Visibility**: See patterns and trends over months
+2. **Performance**: Fewer data points to load and render for long time periods
+3. **Consistency**: All monitors show same time scale regardless of check frequency
+4. **Flexibility**: Per-monitor configuration allows mixed usage
+5. **Complete Timeline**: Missing data visualization prevents confusing gaps
+
+## Database Schema
+
+```sql
+-- Migration: 2025-06-10-0000-add-daily-view.js
+ALTER TABLE monitor_group ADD COLUMN daily_view BOOLEAN DEFAULT FALSE;
+```
+
+## Files Modified
+
+### Backend
+- `db/knex_migrations/2025-06-10-0000-add-daily-view.js` - Database migration
+- `server/routers/status-page-router.js` - Mixed data API endpoint
+- `server/socket-handlers/status-page-socket-handler.js` - Save daily view setting
+- `server/model/group.js` - Include daily_view in SQL queries
+- `server/model/monitor.js` - Add dailyView to public JSON
+
+### Frontend
+- `src/components/DailyHeartbeatBar.vue` - New daily timeline component
+- `src/components/PublicGroupList.vue` - Conditional component rendering
+- `src/components/MonitorSettingDialog.vue` - Daily view toggle UI
+- `src/pages/StatusPage.vue` - Mixed data handling
+- `src/mixins/socket.js` - Additional data properties
+- `src/lang/en.json` - New translation keys
+
+## Troubleshooting
+
+1. **Daily view not persisting**: Ensure the database migration has run successfully
+2. **Missing grey bars**: Check that the monitor has `dailyView: true` in the API response
+3. **Timeline not showing**: Verify the `/api/status-page/heartbeat-daily/:slug` endpoint returns data
+4. **Performance issues**: Daily data is cached, but initial load may be slower for large datasets
\ No newline at end of file
diff --git a/db/knex_migrations/2025-06-10-0000-add-daily-view.js b/db/knex_migrations/2025-06-10-0000-add-daily-view.js
new file mode 100644
index 000000000..48e67f6ea
--- /dev/null
+++ b/db/knex_migrations/2025-06-10-0000-add-daily-view.js
@@ -0,0 +1,13 @@
+// Add column daily_view to monitor_group table
+exports.up = function (knex) {
+ return knex.schema
+ .alterTable("monitor_group", function (table) {
+ table.boolean("daily_view").defaultTo(false);
+ });
+};
+
+exports.down = function (knex) {
+ return knex.schema.alterTable("monitor_group", function (table) {
+ table.dropColumn("daily_view");
+ });
+};
\ No newline at end of file
diff --git a/server/model/group.js b/server/model/group.js
index 16c482759..cfde6867c 100644
--- a/server/model/group.js
+++ b/server/model/group.js
@@ -33,7 +33,7 @@ class Group extends BeanModel {
*/
async getMonitorList() {
return R.convertToBeans("monitor", await R.getAll(`
- SELECT monitor.*, monitor_group.send_url, monitor_group.custom_url FROM monitor, monitor_group
+ SELECT monitor.*, monitor_group.send_url, monitor_group.custom_url, monitor_group.daily_view FROM monitor, monitor_group
WHERE monitor.id = monitor_group.monitor_id
AND group_id = ?
ORDER BY monitor_group.weight
diff --git a/server/model/monitor.js b/server/model/monitor.js
index 741fb940e..d1a8b4b84 100644
--- a/server/model/monitor.js
+++ b/server/model/monitor.js
@@ -60,6 +60,11 @@ class Monitor extends BeanModel {
obj.url = this.customUrl ?? this.url;
}
+ // Add daily_view field from monitor_group table
+ if (this.daily_view !== undefined) {
+ obj.dailyView = this.daily_view;
+ }
+
if (showTags) {
obj.tags = await this.getTags();
}
diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js
index 6e57451f1..930e99a26 100644
--- a/server/routers/status-page-router.js
+++ b/server/routers/status-page-router.js
@@ -111,6 +111,126 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
}
});
+// Status Page Daily Aggregated Heartbeat Data (3 months)
+// Can fetch only if published
+router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (request, response) => {
+ allowDevAllOrigin(response);
+
+ try {
+ let heartbeatList = {};
+ let uptimeList = {};
+ let dailyViewSettings = {};
+
+ let slug = request.params.slug;
+ slug = slug.toLowerCase();
+ let statusPageID = await StatusPage.slugToID(slug);
+
+ // Get monitor data with daily view settings
+ let monitorData = await R.getAll(`
+ SELECT monitor_group.monitor_id, monitor_group.daily_view FROM monitor_group, \`group\`
+ WHERE monitor_group.group_id = \`group\`.id
+ AND public = 1
+ AND \`group\`.status_page_id = ?
+ `, [
+ statusPageID
+ ]);
+
+ // Get 3 months of daily aggregated data
+ const threeMonthsAgo = new Date();
+ threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
+
+ for (let monitor of monitorData) {
+ const monitorID = monitor.monitor_id;
+ const useDailyView = monitor.daily_view;
+
+ dailyViewSettings[monitorID] = useDailyView;
+
+ if (useDailyView) {
+ // Aggregate heartbeats by day over the last 3 months
+ let dailyData = await R.getAll(`
+ SELECT
+ DATE(time) as date,
+ COUNT(*) as total_beats,
+ SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as up_beats,
+ SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) as down_beats,
+ SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as pending_beats,
+ SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as maintenance_beats,
+ AVG(CASE WHEN ping IS NOT NULL THEN ping END) as avg_ping,
+ MAX(time) as latest_time
+ FROM heartbeat
+ WHERE monitor_id = ?
+ AND time >= ?
+ GROUP BY DATE(time)
+ ORDER BY date ASC
+ `, [
+ monitorID,
+ threeMonthsAgo.toISOString()
+ ]);
+
+ // Convert to daily heartbeat format
+ let processedData = dailyData.map(row => {
+ let status;
+ // Determine overall status for the day based on majority
+ if (row.maintenance_beats > 0) {
+ status = 3; // Maintenance
+ } else if (row.down_beats > row.up_beats / 2) {
+ status = 0; // Down if more than 50% down
+ } else if (row.up_beats > 0) {
+ status = 1; // Up
+ } else {
+ status = 2; // Pending
+ }
+
+ return {
+ status: status,
+ time: row.latest_time,
+ ping: row.avg_ping ? Math.round(row.avg_ping) : null,
+ msg: null,
+ uptime: row.total_beats > 0 ? (row.up_beats / row.total_beats) : 0,
+ date: row.date,
+ // Additional daily stats
+ dailyStats: {
+ total: row.total_beats,
+ up: row.up_beats,
+ down: row.down_beats,
+ pending: row.pending_beats,
+ maintenance: row.maintenance_beats
+ }
+ };
+ });
+
+ heartbeatList[monitorID] = processedData;
+ } else {
+ // Use regular heartbeat data (last 100 beats)
+ let list = await R.getAll(`
+ SELECT * FROM heartbeat
+ WHERE monitor_id = ?
+ ORDER BY time DESC
+ LIMIT 100
+ `, [
+ monitorID,
+ ]);
+
+ list = R.convertToBeans("heartbeat", list);
+ heartbeatList[monitorID] = list.reverse().map(row => row.toPublicJSON());
+ }
+
+ const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID);
+ uptimeList[`${monitorID}_24`] = uptimeCalculator.get24Hour().uptime;
+ }
+
+ response.json({
+ heartbeatList,
+ uptimeList,
+ dailyViewSettings,
+ hasMixedData: true
+ });
+
+ } catch (error) {
+ sendHttpError(response, error.message);
+ }
+});
+
// Status page's manifest.json
router.get("/api/status-page/:slug/manifest.json", cache("1440 minutes"), async (request, response) => {
allowDevAllOrigin(response);
diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js
index 952ec2fa7..2a0c97f32 100644
--- a/server/socket-handlers/status-page-socket-handler.js
+++ b/server/socket-handlers/status-page-socket-handler.js
@@ -215,6 +215,10 @@ module.exports.statusPageSocketHandler = (socket) => {
relationBean.custom_url = monitor.url;
}
+ if (monitor.dailyView !== undefined) {
+ relationBean.daily_view = monitor.dailyView;
+ }
+
await R.store(relationBean);
}
diff --git a/src/components/DailyHeartbeatBar.vue b/src/components/DailyHeartbeatBar.vue
new file mode 100644
index 000000000..0152ade21
--- /dev/null
+++ b/src/components/DailyHeartbeatBar.vue
@@ -0,0 +1,509 @@
+
+