Skip to content

Commit

Permalink
Merge pull request #58 from KSJaay/v0.6.5
Browse files Browse the repository at this point in the history
V0.6.5: Removes caching system
  • Loading branch information
KSJaay authored Dec 9, 2024
2 parents ec6f5b3 + 79f2a75 commit 511bb04
Show file tree
Hide file tree
Showing 47 changed files with 548 additions and 820 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

## 🚀 Getting Started

> [!CAUTION]
>
> This project is under active development, things may randomly break. But I'll do my best to fix them as soon as possible.
#### Requirements

Make sure you have the following applications installed before starting:
Expand Down Expand Up @@ -77,7 +81,7 @@ pm2 monit
## 🎯 Roadmap

- [ ] Custom status pages
- [ ] Better design for compact mode
- [x] Better design for compact mode
- [ ] API keys for users
- [ ] Move to Oauth2 for authentication
- [ ] Allow session management (Track/logout from sessions)
Expand Down
35 changes: 21 additions & 14 deletions app/components/monitor/menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ const MonitorMenu = ({ name = 'Unknown', monitorId }) => {
const {
modalStore: { openModal, closeModal },
globalStore: { getMonitor, editMonitor, removeMonitor },
userStore: { user },
} = useContextStore();
const navigate = useNavigate();

const isEditor = user.permission <= 3;

const handleConfirm = async () => {
await createGetRequest('/api/monitor/delete', {
monitorId,
Expand Down Expand Up @@ -65,20 +68,24 @@ const MonitorMenu = ({ name = 'Unknown', monitorId }) => {
</div>
{/* <Button iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}>Pause</Button> */}
{/* <Button iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}>Duplicate</Button> */}
<Button
id="monitor-edit-button"
iconLeft={<MdEdit style={{ width: '20px', height: '20px' }} />}
onClick={handleEdit}
>
Edit
</Button>
<Button
id="monitor-delete-button"
iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}
onClick={handleDelete}
>
Delete
</Button>
{isEditor && (
<>
<Button
id="monitor-edit-button"
iconLeft={<MdEdit style={{ width: '20px', height: '20px' }} />}
onClick={handleEdit}
>
Edit
</Button>
<Button
id="monitor-delete-button"
iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}
onClick={handleDelete}
>
Delete
</Button>
</>
)}
</div>
);
};
Expand Down
22 changes: 2 additions & 20 deletions app/context/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ class GlobalStore {

this.monitors.set(data.monitorId, data);

const nextTimeout = data.nextCheck - Date.now() + 5000;

if (nextTimeout > 0) {
this.timeouts.set(
data.monitorId,
setTimeout(() => func(data.monitorId, this.setMonitor), nextTimeout)
);
return true;
}

this.timeouts.set(
data.monitorId,
setTimeout(
Expand All @@ -54,15 +44,11 @@ class GlobalStore {
setTimeouts = (monitors, func) => {
for (const monitor of monitors) {
if (!this.timeouts.has(monitor.monitorId)) {
const nextTimeout = monitor.nextCheck - Date.now() + 5000;
const timeoutInterval =
nextTimeout > 0 ? nextTimeout : monitor.interval * 1000;

this.timeouts.set(
monitor.monitorId,
setTimeout(
() => func(monitor.monitorId, this.setMonitor),
timeoutInterval
monitor.interval * 1000
)
);
}
Expand All @@ -72,15 +58,11 @@ class GlobalStore {
addMonitor = (monitor) => {
this.monitors.set(monitor.monitorId, monitor);

const nextTimeout = monitor.nextCheck - Date.now() + 5000;
const timeoutInterval =
nextTimeout > 0 ? nextTimeout : monitor.interval * 1000;

this.timeouts.set(
monitor.monitorId,
setTimeout(
() => fetchMonitorById(monitor.monitorId, this.setMonitor),
timeoutInterval
monitor.interval * 1000
)
);
};
Expand Down
9 changes: 0 additions & 9 deletions docs/api/monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ There are various restrictions applied to the monitor data. The following are so
| port | number | Port for the TCP monitor |
| uptimePercentage | number | Uptime percentage for the monitor over the last 24 hours |
| averageHeartbeatLatency | number | Average latency for the monitor over the last 24 hours |
| lastCheck | number | Time of last time monitor was checked (in ms) |
| nextCheck | number | Time of next time monitor should be checked (in ms) |
| heartbeats | Array<[Heartbeat](#heartbeat-structure)> | Array of monitor heartbeats |
| cert | [Certificate](#certificate-structure) | Information about the certificate |

Expand All @@ -152,8 +150,6 @@ There are various restrictions applied to the monitor data. The following are so
"port": null,
"uptimePercentage": 83,
"averageHeartbeatLatency": 38,
"lastCheck": 1708092690225,
"nextCheck": 1708095536463,
"heartbeats": [
{
"id": 38,
Expand All @@ -180,7 +176,6 @@ There are various restrictions applied to the monitor data. The following are so
"validTill": "Jul 10 03:50:39 2024 GMT",
"validOn": ["lunalytics.xyz", "www.lunalytics.xyz"],
"daysRemaining": "72",
"lastCheck": 1708092690225,
"nextCheck": 1714178279326
}
}
Expand All @@ -203,8 +198,6 @@ There are various restrictions applied to the monitor data. The following are so
"port": 2308,
"uptimePercentage": 83,
"averageHeartbeatLatency": 38,
"lastCheck": 1708092690225,
"nextCheck": 1708095536463,
"heartbeats": [
{
"id": 38,
Expand Down Expand Up @@ -242,7 +235,6 @@ There are various restrictions applied to the monitor data. The following are so
| validTill | date | Date the certificate expires |
| validOn | array | Array of urls the certificate is valid for |
| daysRemaining | number | Number of days the certificate is valid |
| lastCheck | number | Time of last time certificate was checked (in ms) |
| nextCheck | number | Time of next time certificate should be checked (in ms) |

### Example Certificate
Expand All @@ -255,7 +247,6 @@ There are various restrictions applied to the monitor data. The following are so
"validTill": "Jul 10 03:50:39 2024 GMT",
"validOn": ["lunalytics.xyz", "www.lunalytics.xyz"],
"daysRemaining": "72",
"lastCheck": 1708092690225,
"nextCheck": 1714178279326
}
```
Expand Down
71 changes: 71 additions & 0 deletions docs/internals/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
# Previous updates

## 0.6.5

### Removes caching system

### Summary

Removes caching system, and adds column to certificate table for the next check time. I was testing the caching system, and realised it was pretty useless, so for now it's been removed. The difference between response time for caching and non-caching was barely noticeable. There are some calls that have a higher latency, so they may be cached in the future at somepoint.

## 0.6.4

### Moves from chart.js to recharts

## 0.6.3

### Adds new compact mode

### Summary

Adds a new compact mode that shows both the list of monitors and information about the selected monitor on the same page. This is to make it easier to filter/look through larger list of monitors. This is only available for PC/laptops and for mobile/tablet it'll still be the previous view, where the user is taken to another page.

### Updates

- Adds new compact mode
- Updates setting page to remove transfer ownership if you don't have the permission
- Moved scss for pages to /styles/pages directory

## 0.6.2

### New config and filtering system

### Summary

It's a pretty small update, wanted to rework the config system because the old one was a pain to use. Also, wanted to make some more adjustments for mobile users as filtering on the monitor list page was pretty annoying.

### New Features

- Adds new config system
- Changes to `npm run setup` to no longer require user input (Making setup a bit easier)
- Adds `npm run setup:advance` that uses the old config setup system
- Adds a new filtering system for mobile devices, old one was uhh.. rough...
- Adds some guides for notifications

## 0.6.1

### Updates package-lock.json and adds roadmap to readme

### Summary

Updates package-lock.json and adds roadmap to readme

## 0.6.0

### Adds ability to create different notifications

### Summary

This PR introduces notifications for when services are down/recovered. This is the first of two parts for PRs, the second PR will be out later this month. And needs to be merged at the same time!

### New Features

- Allows users to create notifications
- New page to show currently available notifications
- Adds notification support for Discord, Slack, Telegram, and Webhooks
- Adds Collection which extends Map with a few extra functions
- Adds schemas for notifications (To be used in the future)

### Updates

- Reworks folder structure to better share code
- Reworks context store to add computed methods

## v0.5.4

### Cleaning up and moving to canvasjs
Expand Down
15 changes: 9 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lunalytics",
"version": "0.6.4",
"version": "0.6.5",
"description": "Open source Node.js server/website monitoring tool",
"private": true,
"author": "KSJaay <ksjaay@gmail.com>",
Expand All @@ -27,8 +27,8 @@
"preview": "vite preview",
"reset:password": "node ./scripts/reset.js",
"server:watch": "nodemon --delay 2 --watch server --watch shared ./server/index.js",
"setup": "npm install && node ./scripts/basic_setup.js && npm run build",
"setup:advance": "npm install && node ./scripts/setup.js && npm run build",
"setup": "npm install && node ./scripts/basic_setup.js && npm run build && npm run start",
"setup:advance": "npm install && node ./scripts/setup.js && npm run build && npm run start",
"start": "cross-env NODE_ENV=production node server/index.js",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
Expand Down Expand Up @@ -78,7 +78,7 @@
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.79.5",
"vite": "^5.0.10",
"vite-plugin-compression2": "^1.0.0",
"vite-plugin-compression2": "^1.3.3",
"vitepress": "^1.1.3",
"vitest": "^1.5.3"
}
Expand Down
4 changes: 0 additions & 4 deletions renovate.json

This file was deleted.

12 changes: 9 additions & 3 deletions scripts/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ const migrateDatabase = async () => {

const migrationListKeys = Object.keys(migrationList);

const [version, patch] = config.version.split('.');
const [version, patch, minor] = config.version.split('.');

const validMigrations = migrationListKeys.filter((migration) => {
const [migrationVersion, migrationPatch] = migration.split('.');
const [migrationVersion, migrationPatch, migrationMinor] =
migration.split('.');
return (
migrationVersion > version ||
(migrationVersion === version && migrationPatch > patch)
(migrationVersion === version && migrationPatch > patch) ||
(migrationVersion === version &&
migrationPatch === patch &&
migrationMinor > minor)
);
});

Expand All @@ -48,6 +52,8 @@ const migrateDatabase = async () => {

logger.info('MIGRATION', { message: 'Automatic migration complete' });
}

return;
};

export default migrateDatabase;
23 changes: 23 additions & 0 deletions scripts/migrations/cache-0-6-5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// import local files
import SQLite from '../../server/database/sqlite/setup.js';
import logger from '../../server/utils/logger.js';

const infomation = {
title: 'Removes caching system',
description:
'Removes caching system, and adds column to certificate table for the next check time.',
version: '0.6.5',
breaking: true,
};

const migrate = async () => {
const client = await SQLite.connect();

await client.schema.alterTable('certificate', (table) => {
table.timestamp('nextCheck').defaultTo(Date.now());
});

logger.info('Migrations', { message: '0.6.5 has been applied' });
};

export { infomation, migrate };
2 changes: 2 additions & 0 deletions scripts/migrations/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// import local files
import { migrate as migrateTcpUpdate } from './tcpUpdate-0-4-0.js';
import { migrate as migrateNotifications } from './notifications-0-6-0.js';
import { migrate as migrateCache } from './cache-0-6-5.js';

const migrationList = {
'0.4.0': migrateTcpUpdate,
'0.6.0': migrateNotifications,
'0.6.5': migrateCache,
};

export default migrationList;
Loading

0 comments on commit 511bb04

Please sign in to comment.