Saved to crontab indicator
parent
d43ffa5814
commit
c9a3ab099c
4
app.js
4
app.js
|
@ -234,9 +234,9 @@ process.on('SIGTERM', function() {
|
||||||
|
|
||||||
app.listen(app.get('port'), app.get('host'), function() {
|
app.listen(app.get('port'), app.get('host'), function() {
|
||||||
console.log("Node version:", process.versions.node);
|
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){
|
if(err){
|
||||||
console.error("Write access to", __dirname + "/crontabs/", "DENIED.");
|
console.error("Write access to", crontab.db_folder, "DENIED.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
10
crontab.js
10
crontab.js
|
@ -45,11 +45,14 @@ crontab = function(name, command, schedule, stopped, logging, mailing){
|
||||||
exports.create_new = function(name, command, schedule, logging, mailing){
|
exports.create_new = function(name, command, schedule, logging, mailing){
|
||||||
var tab = crontab(name, command, schedule, false, logging, mailing);
|
var tab = crontab(name, command, schedule, false, logging, mailing);
|
||||||
tab.created = new Date().valueOf();
|
tab.created = new Date().valueOf();
|
||||||
|
tab.saved = false;
|
||||||
db.insert(tab);
|
db.insert(tab);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.update = function(data){
|
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){
|
exports.status = function(_id, stopped){
|
||||||
|
@ -156,7 +159,10 @@ exports.set_crontab = function(env_vars, callback){
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
else callback();
|
else {
|
||||||
|
db.update({},{$set: {saved: true}}, {multi: true});
|
||||||
|
callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,6 +69,7 @@ function setCrontab(){
|
||||||
$.get(routes.crontab, { "env_vars": $("#env_vars").val() }, function(){
|
$.get(routes.crontab, { "env_vars": $("#env_vars").val() }, function(){
|
||||||
// TODO show only if success
|
// TODO show only if success
|
||||||
infoMessageBox("Successfuly set crontab file!","Information");
|
infoMessageBox("Successfuly set crontab file!","Information");
|
||||||
|
location.reload();
|
||||||
}).fail(function(response) {
|
}).fail(function(response) {
|
||||||
errorMessageBox(response.statusText,"Error");
|
errorMessageBox(response.statusText,"Error");
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,8 +70,15 @@
|
||||||
<% if (crontab.name) { %>
|
<% if (crontab.name) { %>
|
||||||
<%= crontab.name %>
|
<%= crontab.name %>
|
||||||
<a class="btn" data-toggle="tooltip" data-placement="right" title="<%= crontab._id %>"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> </a>
|
<a class="btn" data-toggle="tooltip" data-placement="right" title="<%= crontab._id %>"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> </a>
|
||||||
|
<% if (crontab.saved) { %>
|
||||||
|
<span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<%= crontab._id %>
|
<a data-toggle="tooltip" data-placement="right" title="'Save to crontab' to deploy">
|
||||||
|
<span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
|
<% } %>
|
||||||
|
<% } else { %>
|
||||||
|
<%= crontab._id %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= crontab.command %></td>
|
<td><%= crontab.command %></td>
|
||||||
|
@ -85,11 +92,11 @@
|
||||||
<a class="btn btn-primary btn-danger" data-toggle="tooltip" data-placement="left" title="stderr" href="<%= JSON.parse(routes).logger + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
<a class="btn btn-primary btn-danger" data-toggle="tooltip" data-placement="left" title="stderr" href="<%= JSON.parse(routes).logger + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
||||||
<a class="btn btn-primary" data-toggle="tooltip" data-placement="left" title="stdout" href="<%= JSON.parse(routes).stdout + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
<a class="btn btn-primary" data-toggle="tooltip" data-placement="left" title="stdout" href="<%= JSON.parse(routes).stdout + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
||||||
<% } %>
|
<% } %>
|
||||||
<a class="btn btn-info" onclick="runJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Run</a>
|
<a class="btn btn-info" onclick="runJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Run now</a>
|
||||||
<a class="btn btn-primary" onclick="editJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit</a>
|
<a class="btn btn-primary" onclick="editJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit</a>
|
||||||
<a class="btn btn-info" onclick="stopJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Stop</a>
|
<a class="btn btn-info" onclick="stopJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Disable</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<a class="btn btn-info" onclick="startJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Start</a>
|
<a class="btn btn-info" onclick="startJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Enable</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
<a class="btn btn-danger" onclick="deleteJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
<a class="btn btn-danger" onclick="deleteJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue