Skip to content

Commit

Permalink
v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Jan 24, 2022
1 parent ac1c9ed commit 74958b4
Show file tree
Hide file tree
Showing 22 changed files with 959 additions and 777 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Changelog
All notable changes to this project will be documented in this file.

# v1.1.4 - 2022-01-24

## Other Changes
- Improved adding of cameras within the interface
- Added a new "Reports" page (atm its only placeholder)
- Redesigned the "save" button in camera settings page
- Reduced system payload
- Added more translations

## Bugfixes
- Fixed an issue where filtering of recordings and/or notifications did not work if end date was before start date
- Fixed an issue where it was possible to add multiple cameras with the same name through the interface
- Fixed an issue where a maximum of only 6 cameras could be displayed on Dashboard and Camview
- Fixed an issue where the config generator failed
- Minor bugfixes

# v1.1.3 - 2022-01-23

## Other Changes
Expand Down Expand Up @@ -40,7 +56,7 @@ All notable changes to this project will be documented in this file.
- The database has been completely updated and will not be read/written again when the data is changed. Instead, any changes are cached and saved when logging out/restarting/closing camera.ui

## Other Changes
- Database: Changed to `@seydx/lowdb`
- Database: Changed to `lowdb`
- Videoanalysis: It is now possible to set the internal "forceClose" timer for video analysis via the interface
- Videoanalysis: A "reset" button has been added (interface) to reset the values for video analytics to default values
- SMTP: The SMTP server can now also search the content of an email if no camera could be assigned to the email addresse(s)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camera.ui",
"version": "1.1.3",
"version": "1.1.4",
"description": "NVR like user interface for RTSP capable cameras.",
"author": "SeydX (https://github.com/SeydX/camera.ui)",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions src/api/components/notifications/notifications.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ export const list = async (query) => {
const date = moment.unix(notification.timestamp).format('YYYY-MM-DD');
const dateMoment = moment(date).set({ hour: 0, minute: 0, second: 1 });

const fromDate = query.from;
const toDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();
let fromDate = query.from;
let toDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();

if (moment(toDate).isBefore(fromDate)) {
toDate = query.from;
fromDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();
}

const fromDateMoment = moment(fromDate).set({ hour: 0, minute: 0, second: 0 });
const toDateMoment = moment(toDate).set({ hour: 23, minute: 59, second: 59 });
Expand Down
9 changes: 7 additions & 2 deletions src/api/components/recordings/recordings.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ export const list = (query) => {
const date = moment.unix(recording.timestamp).format('YYYY-MM-DD');
const dateMoment = moment(date).set({ hour: 0, minute: 0, second: 1 });

const fromDate = query.from;
const toDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();
let fromDate = query.from;
let toDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();

if (moment(toDate).isBefore(fromDate)) {
toDate = query.from;
fromDate = moment(query.to, 'YYYY-MM-DD').isValid() ? query.to : moment();
}

const fromDateMoment = moment(fromDate).set({ hour: 0, minute: 0, second: 0 });
const toDateMoment = moment(toDate).set({ hour: 23, minute: 59, second: 59 });
Expand Down
15 changes: 8 additions & 7 deletions src/api/components/settings/settings.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ export const patchByTarget = async (all, target, settingsData) => {

if (target === 'cameras') {
for (const cameraSettings of settingsData) {
cameraSettings.rekognition.confidence = Number.parseInt(cameraSettings.rekognition.confidence);

cameraSettings.rekognition.labels = cameraSettings.rekognition.labels.toString();
cameraSettings.rekognition.labels = cameraSettings.rekognition.labels
.split(',')
.map((value) => value.trim())
.filter((value) => value);
if (cameraSettings.rekognition) {
cameraSettings.rekognition.confidence = Number.parseInt(cameraSettings.rekognition.confidence);
cameraSettings.rekognition.labels = cameraSettings.rekognition.labels.toString();
cameraSettings.rekognition.labels = cameraSettings.rekognition.labels
.split(',')
.map((value) => value.trim())
.filter((value) => value);
}

cameraSettings.pingTimeout =
(Number.parseInt(cameraSettings.pingTimeout) || 0) < 1 ? 1 : Number.parseInt(cameraSettings.pingTimeout);
Expand Down
13 changes: 6 additions & 7 deletions src/api/middlewares/pagination.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
'use-strict';

export const pages = (req, res) => {
const maxPageSize = req.path === '/api/cameras' ? 50 : 6;
const minPage = 1;

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) || 6;
let page = Number.parseInt(req.query.page) || minPage;
let pageSize = Number.parseInt(req.query.pageSize) || maxPageSize;

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

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

pageSize = pageSize > maxPageSize ? maxPageSize : pageSize;

page = page < minPage ? minPage : page;

/*if(page > maxPage && items.length){
Expand Down
48 changes: 20 additions & 28 deletions src/api/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ export default class Socket {
}
});

Socket.handleUptime();
Socket.handleCpuLoad();
Socket.handleCpuTemperature();
Socket.handleMemoryUsage();
Socket.watchSystem();

return Socket.io;
}
Expand All @@ -278,6 +275,17 @@ export default class Socket {
}
}

static async watchSystem() {
await Socket.handleUptime();
await Socket.handleCpuLoad();
await Socket.handleCpuTemperature();
await Socket.handleMemoryUsage();

setTimeout(() => {
Socket.watchSystem();
}, 30000);
}

static async handleUptime() {
try {
const humaniseDuration = (seconds) => {
Expand All @@ -302,13 +310,9 @@ export default class Socket {
};
} catch (error) {
log.error(error, 'Socket');
} finally {
Socket.io.emit('uptime', Socket.#uptime);

setTimeout(() => {
Socket.handleUptime();
}, 30000);
}

Socket.io.emit('uptime', Socket.#uptime);
}

static async handleCpuLoad() {
Expand Down Expand Up @@ -338,13 +342,9 @@ export default class Socket {
});
} catch (error) {
log.error(error, 'Socket');
} finally {
Socket.io.emit('cpuLoad', Socket.#cpuLoadHistory);

setTimeout(() => {
Socket.handleCpuLoad();
}, 20000);
}

Socket.io.emit('cpuLoad', Socket.#cpuLoadHistory);
}

static async handleCpuTemperature() {
Expand All @@ -358,13 +358,9 @@ export default class Socket {
});
} catch (error) {
log.error(error, 'Socket');
} finally {
Socket.io.emit('cpuTemp', Socket.#cpuTempHistory);

setTimeout(() => {
Socket.handleCpuTemperature();
}, 20000);
}

Socket.io.emit('cpuTemp', Socket.#cpuTempHistory);
}

static async handleMemoryUsage() {
Expand Down Expand Up @@ -397,12 +393,8 @@ export default class Socket {
});
} catch (error) {
log.error(error, 'Socket');
} finally {
Socket.io.emit('memory', Socket.#memoryUsageHistory);

setTimeout(() => {
Socket.handleMemoryUsage();
}, 20000);
}

Socket.io.emit('memory', Socket.#memoryUsageHistory);
}
}
8 changes: 4 additions & 4 deletions src/common/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const storeFrameFromVideoBuffer = (camera, fileBuffer, outputPath) => {

ffmpeg.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

ffmpeg.on('error', (error) => reject(error));
Expand Down Expand Up @@ -202,7 +202,7 @@ export const getAndStoreSnapshot = (

ffmpeg.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

let imageBuffer = Buffer.alloc(0);
Expand Down Expand Up @@ -271,7 +271,7 @@ export const storeSnapshotFromVideo = async (camera, recordingPath, fileName) =>

ffmpeg.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

ffmpeg.on('error', (error) => reject(error));
Expand Down Expand Up @@ -358,7 +358,7 @@ export const storeVideo = (camera, recordingPath, fileName, recordingTimer) => {

ffmpeg.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

ffmpeg.on('error', (error) => reject(error));
Expand Down
2 changes: 1 addition & 1 deletion src/controller/camera/services/prebuffer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ export default class PrebufferService {

cp.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

cp.on('exit', (code, signal) => {
Expand Down
2 changes: 1 addition & 1 deletion src/controller/camera/services/stream.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class StreamService {

this.streamSession.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

this.streamSession.on('exit', (code, signal) => {
Expand Down
2 changes: 1 addition & 1 deletion src/controller/camera/services/videoanalysis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default class VideoAnalysisService {

cp.stderr.on('data', (data) => {
errors = errors.slice(-5);
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ''));
errors.push(data.toString().replace(/(\r\n|\n|\r)/gm, ' - '));
});

cp.on('exit', (code, signal) => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/config/config.defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ConfigSetup {
...ConfigSetup.setupUi(config),
options: ConfigSetup.setupOptions(config?.options),
ssl: ConfigSetup.setupSsl(config?.ssl),
http: ConfigSetup.setupMqtt(config?.http),
http: ConfigSetup.setupHttp(config?.http),
smtp: ConfigSetup.setupSmtp(config?.smtp),
ftp: ConfigSetup.setupFtp(config?.ftp),
mqtt: ConfigSetup.setupMqtt(config?.mqtt),
Expand Down
20 changes: 12 additions & 8 deletions src/services/config/config.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export default class ConfigService {
ConfigService.ui.version = process.env.CUI_MODULE_VERSION;

const config = new ConfigSetup(configJson);
ConfigService.configJson = new ConfigSetup(configJson);

ConfigService.configJson = JSON.parse(JSON.stringify(config));
ConfigService.parseConfig(config);

fs.ensureFileSync(ConfigService.configPath);
Expand All @@ -107,7 +107,7 @@ export default class ConfigService {
};
}

static parseConfig(config) {
static parseConfig(config = {}) {
ConfigService.#config(config);
ConfigService.#configInterface();

Expand Down Expand Up @@ -141,21 +141,25 @@ export default class ConfigService {
}

static writeToConfig(target, configJson) {
let config = ConfigService.configJson;

if (configJson) {
if (ConfigService.configJson[target]) {
ConfigService.configJson[target] = configJson;
fs.writeJSONSync(ConfigService.configPath, ConfigService.configJson, { spaces: 2 });
if (config[target]) {
config[target] = configJson;
} else if (!target) {
ConfigService.configJson = configJson;
fs.writeJSONSync(ConfigService.configPath, ConfigService.configJson, { spaces: 2 });
config = configJson;
} else {
throw new Error(`Can not save config, "${target}" not found in config!`, 'Config', 'system');
}
} else {
throw new Error('Can not save config, no config defined!', 'Config', 'system');
}

const config = JSON.parse(JSON.stringify(ConfigService.configJson));
config = new ConfigSetup(config);
ConfigService.configJson = new ConfigSetup(config);

fs.writeJSONSync(ConfigService.configPath, config, { spaces: 2 });

ConfigService.parseConfig(config);
}

Expand Down
Loading

0 comments on commit 74958b4

Please sign in to comment.