get_my/server/methods.js
Brian McGonagill c70f9bd74e 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.
2024-08-21 07:01:36 -05:00

63 lines
2.2 KiB
JavaScript

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) {
let countOfUsers = Meteor.users.find().count();
// if users = 1 - set to role passed in function call
if (countOfUsers > 1) {
console.log("User id for role: " + Meteor.userId() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, role);
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
} else if (countOfUsers == 1) {
console.log("Creating first system admin user: " + Meteor.userId() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, "systemadmin");
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
}
},
'edit.userPass' (userId, newPassword) {
check(userId, String);
check(newPassword, String);
return Accounts.setPassword(userId, newPassword);
},
'delete.userFromSys' (userId) {
check(userId, String);
return Meteor.users.remove({ _id: userId });
},
'update.userEmail' (userId, email) {
check(userId, String);
check(email, String);
return Meteor.users.update({ _id: userId }, {
$set: {
'emails.0.address': email,
}
});
},
'edit.userRole' (userId, role) {
check(userId, String);
check(role, String);
return Roles.setUserRoles(userId, role);
},
});