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

@ -1,7 +1,7 @@
<template name="systemAdmin">
<h2>System Administration</h2>
<div class="row">
<div class="col s12 m12 l6">
<div class="col s12">
<div class="card">
<div class="card-content">
<h4>Registration Settings</h4>
@ -18,11 +18,31 @@
<div class="col s12 m6 l6">
<div class="switch">
<label>
<input type="checkbox" class="currConfigs" id="allowGenReg">
<span class="lever"></span>
Allow Registration
<input type="checkbox" class="currConfigs" id="allowGenReg">
<span class="lever"></span>
Allow Registration
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col s12">
<div class="card">
<div class="card-content">
<h4>Update Notifications</h4>
<p>This option requires the seerver to have an internet connection.</p>
<br>
<div class="row">
<div class="col s12 m12 l6">
<div class="switch">
<label>
<input type="checkbox" class="currConfigs" id="recvUpdateMsgs">
<span class="lever"></span>
System Admin will receive information on updates and new featres
</label>
</div>
</div>
</div>
</div>
@ -30,4 +50,4 @@
</div>
</div>
{{> snackbar}}
</template>
</template>

View file

@ -1,7 +1,9 @@
import { SysConfig } from '../../../imports/api/systemConfig.js';
import { M } from '../../lib/assets/materialize.js';
Template.systemAdmin.onCreated(function() {
this.subscribe("SystemConfig");
this.subscribe("rolesAvailable");
});
Template.systemAdmin.onRendered(function() {
@ -10,16 +12,24 @@ Template.systemAdmin.onRendered(function() {
if (typeof curr != 'undefined') {
$("#allowGenReg").prop('checked', curr.allowReg);
$("#allAdmReg").prop('checked', curr.SysAdminReg);
$("#recvUpdateMsgs").prop('checked', curr.allowUpdates);
} else {
console.log(" ---- unable to find current system configuration.");
}
});
var elems = document.querySelectorAll('select');
setTimeout(function() {
var instances = M.FormSelect.init(elems, {});
}, 300);
});
Template.systemAdmin.helpers({
currConfigs: function() {
}
},
});
Template.systemAdmin.events({
@ -29,12 +39,22 @@ Template.systemAdmin.events({
// console.log("General Reg set to: " + genReg);
Meteor.call("add.noSysAdminReg", admReg, genReg, function(err, result) {
if (err) {
console.log(" ERROR updating permission to allow general registration: " + err);
showSnackbar("Registration Permission Change Failed.", "red");
// console.log(" ERROR updating permission to allow general registration: " + err);
// showSnackbar("Registration Permission Change Failed.", "red");
} else {
console.log(" Successfully updated permission to allow general registration.");
// console.log(" Successfully updated permission to allow general registration.");
showSnackbar("Registration Permission Successfully Changed.", "green")
}
});
}
});
},
'change #recvUpdateMsgs' (event) {
let updSet = $("#recvUpdateMsgs").prop('checked');
Meteor.call('allow.updateInfo', updSet, function(err, result) {
if (err) {
console.log(" ERROR changing update setting: " + err);
} else {
showSnackbar("Update Setting Changed Successfully!", "green");
}
});
},
});

View file

@ -1,6 +1,43 @@
<template name="dashboard">
<h4>My Dashboard</h4>
<div class="row">
{{#if $eq currConfig.allowUpdates true}}
{{#if updatesExist}}
<div class="col s12">
<div class="card green darken-3" id="updateInfoCard">
<div class="card-content white-text">
<div class="card-title">Update Available</div>
<div class="row">
{{#each updates}}
<div class="col s12">
<div class="row">
<div class="col s12">
<h4>{{title}}</h4>
</div>
<div class="col s12">
Release Notes:
<p class="flow-text">{{descriptionSinHTML}}</p>
</div>
<div class="col s12">
Release Date:
<p class="flow-text">{{niceDate}}</p>
</div>
<div class="col s12">
<a href="{{releaseLink}}" target=”_blank”>Visit Release on Gitlab</a>
</div>
</div>
</div>
<div class="col s12">
<a class="btn waves-effect waves-light blue white-text readLink" id="{{_id}}">Mark Read</a>
</div>
<hr />
{{/each}}
</div>
</div>
</div>
</div>
{{/if}}
{{/if}}
<div class="col s12 m6 l4">
<div class="card blue darken-3" id="taskInfoCard">
<div class="card-content white-text">

View file

@ -5,7 +5,8 @@ import { Menus } from '../../imports/api/menu.js';
import { MenuItems } from '../../imports/api/menuItems.js';
import moment from 'moment';
import { TaskItems } from "../../imports/api/tasks";
import { UpdateInfo } from '../../imports/api/updateInfo.js';
import { SysConfig } from '../../imports/api/systemConfig.js';
Template.dashboard.onCreated(function() {
this.subscribe("userList");
@ -17,6 +18,8 @@ Template.dashboard.onCreated(function() {
// this.subscribe("myMenus");
this.subscribe("todayMenuItems");
this.subscribe("myTasks");
this.subscribe("UpdateVersion");
this.subscribe("SystemConfig");
});
Template.dashboard.onRendered(function() {
@ -56,11 +59,34 @@ Template.dashboard.helpers({
let todayDate = moment(now).format("MMM DD, YYYY");
return todayDate;
},
updates: function() {
return UpdateInfo.find({});
},
updatesExist: function() {
let updateExists = UpdateInfo.find({ viewed: false }).fetch();
if (updateExists.length > 0) {
return true;
} else {
return false;
}
},
currConfig: function() {
return SysConfig.findOne({});
},
descriptionSinHTML: function() {
let desc = this.description;
let sinH = $(desc).text();
return sinH;
},
niceDate: function() {
let rDateNorm = this.date;
let rDate = moment(rDateNorm).format('LL');
return rDate;
}
});
Template.dashboard.events({
"click .cardLink" (event) {
event.preventDefault();
let link = event.currentTarget.id;
switch(link) {
case "userMgmtLink":
@ -86,7 +112,6 @@ Template.dashboard.events({
}
},
'click .card' (event) {
event.preventDefault();
let cardId = event.currentTarget.id;
switch(cardId) {
@ -111,5 +136,16 @@ Template.dashboard.events({
default:
break;
}
},
'click .readLink' (event) {
let eventId = event.currentTarget.id;
Meteor.call('markUpdate.read', eventId, function(err, result) {
if (err) {
console.log(" ERROR marking update as 'read': " + err);
} else {
console.log("marked read successfully!");
}
});
}
});

View file

@ -16,6 +16,9 @@
<li><a href="#" id="manage" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Manage</a></li>
{{/if}}
<li class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}"><a href="#" class="signOut">Log Out</a></li>
{{#if $eq updateExists true}}
<li><a href="#!"><i class="material-icons white-text navBtn" id='dashboard'>notifications</i></a></li>
{{/if}}
{{else}}
<li><a href="#!" id="login" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Login</a></li>
{{/if}}
@ -30,6 +33,7 @@
<li><a href="#!" class="navBtn" id="mySettings {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Settings</a></li>
{{#if isInRole 'systemadmin'}}
<li><a href="#!" id="manage" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Manage</a></li>
<li><a href="#!"><i class="material-icons">notifications</i></a></li>
{{/if}}
<li><a href="#!" class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}">Sign Out</a></li>
{{else}}

View file

@ -1,7 +1,8 @@
import { M } from '../lib/assets/materialize';
import { UpdateInfo } from '../../imports/api/updateInfo.js';
Template.headerBar.onCreated(function() {
this.subscribe("UpdateVersion");
});
Template.headerBar.onRendered(function() {
@ -17,7 +18,15 @@ Template.headerBar.helpers({
},
myTheme: function() {
return Session.get("myTheme");
}
},
updateExists: function() {
let update = UpdateInfo.find({ viewed: false }).fetch();
if (update.length > 0) {
return true;
} else {
return false;
}
},
});
Template.headerBar.events({

View file

@ -22,16 +22,19 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
}
let iname = itemName.charAt(0).toUpperCase() + itemName.slice(1);
// look up the item from the Products collection
let prodInfo = Products.findOne({ prodName: itemName });
if (typeof prodInfo == "undefined") {
Meteor.call("add.product", itemName, "", "", "", function(err, result) {
let prodInfo = Products.findOne({ prodName: iname });
if (!prodInfo) {
Meteor.call("add.product", itemName, [""], function(err, result) {
if (err) {
console.log(" ERROR adding item to products: " + err);
} else {
// console.log(" SUCCESS adding item to Products.");
return ListItems.insert({
itemName: itemName,
itemName: iname,
listId: listId,
prodId: result,
addedBy: this.userId,
@ -44,7 +47,7 @@ Meteor.methods({
});
} else {
return ListItems.insert({
itemName: itemName,
itemName: iname,
listId: listId,
prodId: prodInfo._id,
addedBy: this.userId,
@ -176,4 +179,4 @@ Meteor.methods({
return ListItems.remove({ _id: itemId });
}
});
});

View file

@ -22,11 +22,19 @@ Meteor.methods({
let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1);
return Products.insert({
prodName: pname,
prodOwner: this.userId,
prodStore: prodStore,
});
// first does this product already exist?
let prodExists = Products.findOne({ prodName: pname });
if (!prodExists) {
return Products.insert({
prodName: pname,
prodOwner: this.userId,
prodStore: prodStore,
});
} else {
console.log(" ---- Product exsits in database already.");
}
},
'edit.product' (prodId, prodName, prodStore) {
check(prodId, String);

View file

@ -55,4 +55,21 @@ Meteor.methods({
}
});
},
});
'allow.updateInfo' (allowUpdate) {
check(allowUpdate, Boolean);
if (!this.userId) {
throw new Meteor.Error('Not able to change system update notification settings. Make sure you are logged in with valid system administrator credentials.');
}
let curr = SysConfig.findOne({});
let configId = curr._id;
return SysConfig.update({ _id: configId }, {
$set: {
allowUpdates: allowUpdate,
}
});
},
});

157
package-lock.json generated
View file

@ -11,11 +11,72 @@
"regenerator-runtime": "^0.13.4"
}
},
"addressparser": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz",
"integrity": "sha512-aQX7AISOMM7HFE0iZ3+YnD07oIeJqWGVnJ+ZIKaBZAk03ftmVYVqsGas/rbXKR21n4D/hKCSHypvcyOkds/xzg=="
},
"array-indexofobject": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/array-indexofobject/-/array-indexofobject-0.0.1.tgz",
"integrity": "sha512-tpdPBIBm4TMNxSp8O3pZgC7mF4+wn9SmJlhE+7bi5so6x39PvzUqChQMbv93R5ilYGZ1HV+Neki4IH/i+87AoQ=="
},
"core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"feedparser": {
"version": "2.2.10",
"resolved": "https://registry.npmjs.org/feedparser/-/feedparser-2.2.10.tgz",
"integrity": "sha512-WoAOooa61V8/xuKMi2pEtK86qQ3ZH/M72EEGdqlOTxxb3m6ve1NPvZcmPFs3wEDfcBbFLId2GqZ4YjsYi+h1xA==",
"requires": {
"addressparser": "^1.0.1",
"array-indexofobject": "~0.0.1",
"lodash.assign": "^4.2.0",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.uniq": "^4.5.0",
"mri": "^1.1.5",
"readable-stream": "^2.3.7",
"sax": "^1.2.4"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
},
"jquery": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
"integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw=="
},
"lodash.assign": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
"integrity": "sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw=="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
},
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
},
"lodash.uniq": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ=="
},
"meteor-node-stubs": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.2.5.tgz",
@ -798,15 +859,111 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
},
"mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="
},
"node-cron": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz",
"integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==",
"requires": {
"uuid": "8.3.2"
}
},
"node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"requires": {
"whatwg-url": "^5.0.0"
}
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"readable-stream": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"regenerator-runtime": {
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA=="
},
"rss-url-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/rss-url-parser/-/rss-url-parser-3.0.0.tgz",
"integrity": "sha512-x39bDQDe1BwpiVwPrjg52ILbTMZc5h7oDPE7FRLa/sgYar7BrNRBTU/msxgokacPZN1rawXmK1rtBU5N7Gsn4A==",
"requires": {
"feedparser": "^2.2.10",
"node-fetch": "^2.6.7"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"sax": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz",
"integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg=="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"typeahead-standalone": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/typeahead-standalone/-/typeahead-standalone-5.2.0.tgz",
"integrity": "sha512-9GTbCO7XhwimgolmxzuPklftoIa2NEGXBI30n9f5kQZOptvTeJ9ublhNYy4W00RN1D5gSHM5n4dI5vOojr51hg=="
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
}
}
}

View file

@ -12,6 +12,8 @@
"jquery": "^3.6.0",
"meteor-node-stubs": "^1.2.5",
"moment": "^2.29.4",
"node-cron": "^3.0.3",
"rss-url-parser": "^3.0.0",
"typeahead-standalone": "^5.2.0"
}
}

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.");
}
}

View file

@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
import { TaskItems } from '../imports/api/tasks';
import { SysConfig } from '../imports/api/systemConfig';
Meteor.methods({
'addToRole' (role) {

View file

@ -11,6 +11,7 @@ import { TaskItems } from '../imports/api/tasks.js';
import { UserConfig } from '../imports/api/userConfig.js';
import { MenuProdLinks } from '../imports/api/menuProdLinks.js';
import { UserLast } from '../imports/api/userLast.js';
import { UpdateInfo } from '../imports/api/updateInfo.js';
Meteor.publish("SystemConfig", function() {
try {
@ -28,6 +29,14 @@ Meteor.publish("UserConfigPrefs", function() {
}
});
Meteor.publish("UpdateVersion", function() {
try {
return UpdateInfo.find({ viewed: false });
} catch(error) {
console.log(" ERROR pulling updated version info: " + error);
}
})
Meteor.publish('userList', function() {
return Meteor.users.find({});
});
@ -80,6 +89,20 @@ Meteor.publish("myListItems", function(listId) {
}
});
Meteor.publish("myStoreListItems", function(listId) {
try {
let stores = Store.find({});
if (stores) {
for (i=0; i<stores.length; i++) {
let items = ListItems.find({ prodStore: store[i], listId: listId }).fetch();
}
}
} catch (error) {
console.log(" ERROR pulling items or stores: " + error);
}
});
Meteor.publish("myMenus", function() {
try {
return Menus.find({ menuComplete: false });