diff --git a/app.js b/app.js index 8e28cca..aecd8db 100755 --- a/app.js +++ b/app.js @@ -234,9 +234,9 @@ process.on('SIGTERM', function() { app.listen(app.get('port'), app.get('host'), function() { console.log("Node version:", process.versions.node); - fs.access(__dirname + "/crontabs/", fs.W_OK, function(err) { + fs.access(crontab.db_folder, fs.W_OK, function(err) { if(err){ - console.error("Write access to", __dirname + "/crontabs/", "DENIED."); + console.error("Write access to", crontab.db_folder, "DENIED."); process.exit(1); } }); diff --git a/crontab.js b/crontab.js index 6e588b1..49b5e78 100644 --- a/crontab.js +++ b/crontab.js @@ -45,11 +45,14 @@ crontab = function(name, command, schedule, stopped, logging, mailing){ exports.create_new = function(name, command, schedule, logging, mailing){ var tab = crontab(name, command, schedule, false, logging, mailing); tab.created = new Date().valueOf(); + tab.saved = false; db.insert(tab); }; exports.update = function(data){ - db.update({_id: data._id}, crontab(data.name, data.command, data.schedule, null, data.logging, data.mailing)); + var tab = crontab(data.name, data.command, data.schedule, null, data.logging, data.mailing); + tab.saved = false; + db.update({_id: data._id}, tab); }; exports.status = function(_id, stopped){ @@ -156,7 +159,10 @@ exports.set_crontab = function(env_vars, callback){ console.error(err); return callback(err); } - else callback(); + else { + db.update({},{$set: {saved: true}}, {multi: true}); + callback(); + } }); }); }); diff --git a/public/js/script.js b/public/js/script.js index 9421f03..8b4791b 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -69,6 +69,7 @@ function setCrontab(){ $.get(routes.crontab, { "env_vars": $("#env_vars").val() }, function(){ // TODO show only if success infoMessageBox("Successfuly set crontab file!","Information"); + location.reload(); }).fail(function(response) { errorMessageBox(response.statusText,"Error"); }); diff --git a/views/index.ejs b/views/index.ejs index 52b1f0b..804b4ba 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -70,8 +70,15 @@ <% if (crontab.name) { %> <%= crontab.name %> + <% if (crontab.saved) { %> + <% } else { %> - <%= crontab._id %> + + + + <% } %> + <% } else { %> + <%= crontab._id %> <% } %>