Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Jan 11, 2022
1 parent b10a20e commit 5b67b9d
Show file tree
Hide file tree
Showing 21 changed files with 1,569 additions and 1,429 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Changelog
All notable changes to this project will be documented in this file.

# [1.0.4] - 2022-01-11

## Other Changes
- Interface:
- Limit max page size to 6 (pagination)
- Refactored Lightbox
- Bump dependencies

## Bugfixes
- Fixed an issue with pagination middleware, where the nextPage and prevPage attribute showed wrong path
- Fixed an isue where opening a recording or a notification (with recording) loaded all recordings in the background and caused the interface to crash
- Fixed an issue where the notification banner could not display a video
- Fixed an issue where utilization could not show process cpu load / memory usage
- Minor bugfixes

# [1.0.3] - 2022-01-11

## Bugfixes
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camera.ui",
"version": "1.0.3",
"version": "1.0.4",
"description": "User Interface for RTSP capable cameras.",
"author": "SeydX (https://github.com/SeydX/camera.ui)",
"scripts": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"morgan": "^1.10.0",
"mqtt": "^4.3.4",
"multer": "^1.4.4",
"nanoid": "^3.1.30",
"nanoid": "^3.1.31",
"os": "^0.1.2",
"pam-diff": "^1.1.0",
"piexifjs": "^1.0.6",
Expand Down
3 changes: 2 additions & 1 deletion src/api/components/notifications/notifications.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ exports.createNotification = async (data) => {
title: cameraName,
message: `${data.trigger} - ${time}`,
subtxt: room,
mediaSource: storing
mediaSource: storing ? `/files/${fileName}.${extension}` : false,
tumbnail: storing
? data.type === 'Video'
? `/files/${fileName}@2.jpeg`
: `/files/${fileName}.${extension}`
Expand Down
8 changes: 4 additions & 4 deletions src/api/middlewares/pagination.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
exports.pages = (req, res) => {
let start = Number.parseInt(req.query.start); //for infinite scroll
let page = Number.parseInt(req.query.page) || 1;
let pageSize = Number.parseInt(req.query.pageSize) || 25;
let pageSize = Number.parseInt(req.query.pageSize) || 6;

// eslint-disable-next-line unicorn/prefer-number-properties
start = !isNaN(start) ? start : null;
const items = res.locals.items || [];

let maxPageSize = 50;
let maxPageSize = 6;
let minPage = 1;
let maxPage = Math.ceil(items.length / pageSize);

Expand Down Expand Up @@ -43,8 +43,8 @@ exports.pages = (req, res) => {
startIndex: startIndex,
endIndex: endIndex,
totalItems: totalItems,
nextPage: page < items.length / pageSize ? `/api/recordings?page=${page + 1}` : null,
prevPage: page > 1 ? `/api/recordings?page=${page - 1}` : null,
nextPage: page < items.length / pageSize ? `${req.path}?page=${page + 1}` : null,
prevPage: page > 1 ? `${req.path}?page=${page - 1}` : null,
};

const result = items.slice(pagination.startIndex, pagination.endIndex + 1);
Expand Down
32 changes: 30 additions & 2 deletions src/api/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,21 @@ class Socket {
static async handleCpuLoad() {
try {
const cpuLoad = await systeminformation.currentLoad();
const processLoad = await systeminformation.processLoad(process.title);
let processLoad = await systeminformation.processLoad(process.title);

if (processLoad?.length && !processLoad[0].pid && !processLoad[0].cpu && !processLoad[0].mem) {
// can not find through process.title, try again with process.pid
const processes = await systeminformation.processes();
const processByPID = processes.list.find((p) => p.pid === process.pid);

if (processByPID) {
processLoad = [
{
cpu: processByPID.cpu,
},
];
}
}

Socket.#cpuLoadHistory = Socket.#cpuLoadHistory.slice(-60);
Socket.#cpuLoadHistory.push({
Expand Down Expand Up @@ -356,7 +370,21 @@ class Socket {
try {
const mem = await systeminformation.mem();
const memoryFreePercent = mem ? ((mem.total - mem.available) / mem.total) * 100 : 50;
const processLoad = await systeminformation.processLoad(process.title);
let processLoad = await systeminformation.processLoad(process.title);

if (!processLoad.pid && !processLoad.cpu && !processLoad.mem) {
// can not find through process.title, try again with process.pid
const processes = await systeminformation.processes();
const processByPID = processes.list.find((p) => p.pid === process.pid);

if (processByPID) {
processLoad = [
{
mem: processByPID.mem,
},
];
}
}

Socket.#memoryUsageHistory = Socket.#memoryUsageHistory.slice(-60);
Socket.#memoryUsageHistory.push({
Expand Down
Loading

0 comments on commit 5b67b9d

Please sign in to comment.