glass-isc-dhcp/routes/glass_alert_settings_save.js

29 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Created by cmiles on 8/9/2017.
*/
var express = require('express');
var router = express.Router();
2018-08-14 10:45:48 +02:00
var authorize = require('../core/authorize.js');
2017-09-06 11:42:05 +02:00
router.post('/', authorize.auth, function(req, res, next) {
var request = req.body;
var json_file = require('jsonfile');
var glass_config = json_file.readFileSync('config/glass_config.json');
glass_config.shared_network_critical_threshold = request.shared_network_critical_threshold;
glass_config.shared_network_warning_threshold = request.shared_network_warning_threshold;
2017-09-06 10:14:39 +02:00
glass_config.leases_per_minute_threshold = request.leases_per_minute_threshold;
glass_config.slack_webhook_url = request.slack_webhook_url;
glass_config.slack_alert_channel = request.slack_alert_channel;
glass_config.email_alert_to = request.email_alert_to;
glass_config.sms_alert_to = request.sms_alert_to;
json_file.writeFile('./config/glass_config.json', glass_config, {spaces: 2}, function(err) {
console.error(err);
});
res.send('<script type="text/javascript">notification(\'Saved Alert Settings!\')</script>');
});
module.exports = router;