open-health/client/AdminMgmt/SysConfig/systemAdmin.js
2025-12-06 15:44:43 -06:00

62 lines
1.9 KiB
JavaScript

import { SysConfig } from "../../../imports/api/systemConfig";
Template.systemAdmin.onCreated(function() {
this.subscribe("SystemConfig");
this.subscribe("rolesAvailable");
});
Template.systemAdmin.onRendered(function() {
this.autorun (() => {
const curr = SysConfig.findOne({});
if (curr) {
$("#allowGenReg").prop('checked', curr.allowReg);
$("#allowAdmReg").prop('checked', curr.SysAdminReg);
$("#recvUpdateMsgs").prop('checked', curr.allowUpdates);
} else {
console.log(" ---- unable to find current system configuration.");
}
});
});
Template.systemAdmin.helpers({
currConfigs: function() {
},
});
Template.systemAdmin.events({
'change #allowGenReg, change #allowAdmReg' (evnnt) {
let genReg = $("#allowGenReg").prop('checked');
let admReg = $("#allowAdmReg").prop('checked');
console.log("General Reg set to: " + genReg);
const setNoSysAdminReg = async() => {
try {
const result = await Meteor.callAsync("add.noSysAdminReg", admReg, genReg);
if (result) {
console.log("Successfully added reg settings.");
showSnackbar("Updated Registration Settings.", "green");
}
} catch(error) {
console.log(" ERROR setting registration: " + error);
}
}
setNoSysAdminReg();
},
'change #recvUpdateMsgs' (event) {
let updSet = $("#recvUpdateMsgs").prop('checked');
const updateInfo = async() => {
try {
const result = Meteor.callAsync('allow.updateInfo', updSet);
showSnackbar("Update Setting Changed Successfully!", "green");
} catch(error) {
console.log(" ERROR changing update setting: " + err);
}
}
updateInfo();
},
});