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({