Multiple updates and additions

- Added a permission to show or hide update version information on that dashboard as a card that will only show when new update info is available and not yet dismissed.
- Updated Lists so list items added will have their fist letter auto-capitalized
- Updated Lists so list items are searched against the products before being added to the list, so we have store info more commonly in lists
- Updated Products so new products will have their first letter capitalized automatically
- Updated the dashboard to show the Update Available card if this is enbaled in permissions.
    - The dashboard card only shows for System Admin roles.
    - The dashboard card is enabled by default
    - The dashboard card is pulled from the GitLab releases RSS feed.
    - The RSS Feed is only checked every 30 minutes using node-cron
- Updated System Configuration to have a toggle for the update available card
- Added a bell icon to the top and slide out navigation, shown when a new update is available, if update available is enabled in system configuration.
This commit is contained in:
Brian McGonagill 2024-08-21 07:01:36 -05:00
parent f02ea7d549
commit c70f9bd74e
14 changed files with 410 additions and 29 deletions

View file

@ -4,6 +4,7 @@ import { MenuItems } from '../imports/api/menuItems';
import { Products } from '../imports/api/products.js';
import { Menus } from '../imports/api/menu.js';
import { MScripts } from '../imports/api/mScripts.js';
import { UpdateInfo } from '../imports/api/updateInfo.js';
Meteor.startup(() => {
// code to run on server at startup
@ -21,6 +22,7 @@ Meteor.startup(() => {
SysAdminReg: false,
dateAdded: new Date(),
allowReg: true,
allowUpdates: true,
});
} else {
// console.log("Registration policy already set.");
@ -128,8 +130,28 @@ Meteor.startup(() => {
}
}
// get update available information if enabled in system confiuration
let currConfig = SysConfig.findOne({});
let feedurl = "https://gitlab.com/bmcgonag/get_my/-/releases.atom"
if (currConfig.allowUpdates == true) {
// console.log("Allow Updates is true");
startCronForUpdates(feedurl);
} else if (typeof currConfig.allowUpdates == 'undefined' || currConfig.allowUpdates == null) {
SysConfig.update({ _id: currConfig._id }, { $set: {
allowUpdates: true,
}});
startCronForUpdates(feedurl);
}
});
var startCronForUpdates = function(feedurl) {
var cron = require('node-cron');
cron.schedule('*/30 * * * *', () => {
getUpdateInfoNow(feedurl);
});
}
var markScriptRun = function(scriptName) {
// check if this is already set
let scriptRun = MScripts.findOne({ scriptName: scriptName });
@ -144,3 +166,25 @@ var markScriptRun = function(scriptName) {
});
}
}
var getUpdateInfoNow = async function(feedurl) {
const parser = require('rss-url-parser')
const data = await parser(feedurl)
let dataLength = data.length;
// console.dir(data[0].title);
// check if this title already exists in db
let updatesExist = UpdateInfo.findOne({ title: data[0].title });
if (!updatesExist) {
UpdateInfo.insert({
title: data[0].title,
description: data[0].description,
dateRelease: data[0].date,
releaseLink: data[0].link,
viewed: false
});
} else {
console.log("No new updates available at this time.");
}
}