2017-09-02 16:59:36 +02:00
|
|
|
/**
|
|
|
|
* 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-02 16:59:36 +02:00
|
|
|
|
2017-09-06 11:42:05 +02:00
|
|
|
router.post('/', authorize.auth, function(req, res, next) {
|
2017-09-02 16:59:36 +02:00
|
|
|
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;
|
2017-09-02 16:59:36 +02:00
|
|
|
glass_config.slack_webhook_url = request.slack_webhook_url;
|
|
|
|
glass_config.slack_alert_channel = request.slack_alert_channel;
|
2017-10-04 22:11:19 +02:00
|
|
|
glass_config.email_alert_to = request.email_alert_to;
|
|
|
|
glass_config.sms_alert_to = request.sms_alert_to;
|
2017-09-02 16:59:36 +02:00
|
|
|
|
|
|
|
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;
|