Skip to content

Commit

Permalink
Merge pull request cronicle-edge#58 from cronicle-edge/v172
Browse files Browse the repository at this point in the history
V172
  • Loading branch information
mikeTWC1984 authored Sep 29, 2023
2 parents a697f28 + 6fe9fd0 commit 16a00b6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 44 deletions.
9 changes: 4 additions & 5 deletions bin/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,18 @@ stream.on('json', function (job) {
var table = {
title: "Workflow Events",
header: [
"#", "title", "arg", "job", "status", "view log", "started at", "elapsed", "description"
"#", "title", "arg", "job", "started at", "elapsed", "status", "view log", "description"
],
rows: Object.keys(jobStatus).map(key => [
jobStatus[key].seq,

`<span style="${jobStatus[key].code % 255 ? 'color:red' : ''}"><b>${he.encode(jobStatus[key].title) || '[Unknown]'}</b></span>`, //title
(jobStatus[key].arg ? he.encode(jobStatus[key].arg) : ''), // arg

(jobStatus[key].arg ? he.encode(jobStatus[key].arg) : ''), // arg
key === jobStatus[key].event ? '' : `<a href="/#JobDetails?id=${key}" target="_blank">${key}</a>`, // joblink
getNiceStatus(jobStatus[key]), // status
key === jobStatus[key].event ? '' : `<i id="view_${key}" onclick="this.className = this.className == 'fa fa-eye' ? 'fa fa-eye-slash' : 'fa fa-eye'; $P().get_log_to_grid('${getNiceTitle(jobStatus[key], key)}', '${key}')" style="cursor:pointer" class="fa fa-eye"></i>`,
jobStatus[key].start,
niceInterval(jobStatus[key].elapsed),
getNiceStatus(jobStatus[key]), // status
key === jobStatus[key].event ? '' : `<i id="view_${key}" onclick="this.className = this.className == 'fa fa-eye' ? 'fa fa-eye-slash' : 'fa fa-eye'; $P().get_log_to_grid('${getNiceTitle(jobStatus[key], key)}', '${key}')" style="cursor:pointer" class="fa fa-eye"></i>`,
//jobStatus[key].code ? `${he.encode(jobStatus[key].description)}`.substring(0,120) : ''
`${he.encode(jobStatus[key].description)}`.substring(0, 120)

Expand Down
98 changes: 59 additions & 39 deletions htdocs/js/pages/Schedule.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,16 @@ toggle_token: function () {
}

// allow delete event by pressing del key
$(document).keyup(function (e) {
if (e.keyCode == 46) { // delete button pressed
var eventId = net.getSelectedNodes()[0]
if(! eventId) return;
var idx = $P().events.findIndex(i => i.id === eventId)
if (eventId) $P().delete_event(idx)
}
})

// $(document).keyup(function (e) {
// if (e.keyCode == 46) { // delete button pressed
// var eventId = net.getSelectedNodes()[0]
// if (!eventId) return;
// var idx = $P().events.findIndex(i => i.id === eventId)
// if (eventId) $P().delete_event(idx)
// }
// })


// open event edit page on double click
net.on("doubleClick", function (params) {
Expand Down Expand Up @@ -749,15 +751,15 @@ toggle_token: function () {

// Scheduled Event page:

let miniButtons = '<div style="float:right;" class="subtitle_widget"><i style="width:20px;cursor:pointer;margin-right: 20px" class="fa fa-pie-chart" title="Show Event Graph" onMouseUp="$P().show_graph()"></i></div>'
let miniButtons = '<div style="float:right;" class="subtitle_widget"><a><i style="width:20px;cursor:pointer;margin-right: 20px" class="fa fa-pie-chart" title="Show Event Graph" onMouseUp="$P().show_graph()"></i></a></div>'

if (app.isAdmin()) {
miniButtons += '<div style="float:right;" class="subtitle_widget"><i style="width:20px;cursor:pointer;" class="fa fa-download" title="Backup" onMouseUp="$P().export_schedule()"></i></div>'
miniButtons += '<div style="float:right;" class="subtitle_widget"><a><i style="width:20px;cursor:pointer;" class="fa fa-download" title="Backup" onMouseUp="$P().export_schedule()"></i></a></div>'
}

if (app.hasPrivilege('create_events')) {
miniButtons += '<div style="float:right;" class="subtitle_widget"><i style="width:20px;cursor:pointer;" class="fa fa-random" title="Random Event" onMouseUp="$P().do_random_event()"></i></div>'
miniButtons += '<div style="float:right;" class="subtitle_widget"><i style="width:20px;cursor:pointer;" class="fa fa fa-plus-circle" title="Add Event" onMouseUp="$P().edit_event(-1)"></i></div>'
miniButtons += '<div style="float:right;" class="subtitle_widget"><a><i style="width:20px;cursor:pointer;" class="fa fa-random" title="Random Event" onMouseUp="$P().do_random_event()"></i><a/></div>'
miniButtons += '<div style="float:right;" class="subtitle_widget"><a><i style="width:20px;cursor:pointer;" class="fa fa fa-plus-circle" title="Add Event" onMouseUp="$P().edit_event(-1)"></i></a></div>'
}

html += `
Expand Down Expand Up @@ -995,37 +997,55 @@ toggle_token: function () {
change_event_enabled: function (idx, box) {
// toggle event on / off
var event = this.events[idx];

if (this.isAdmin()) { // for admins - toggle state right away (old way)
event.enabled = event.enabled ? 0 : 1;
var stub = {
id: event.id,
title: event.title,
enabled: event.enabled,
catch_up: event.catch_up || false
};

let action = event.enabled ? 'Disable' : 'Enable'
let msg = `Are you sure you want to ${action} <b>${event.title}</b> event?`

app.confirm(`<span style="color:red">${action} Event</span>`, msg, action, function (result) {
if (result) {

event.enabled = event.enabled ? 0 : 1;
app.api.post('app/update_event', stub, function (resp) {
$('#' + event.id).toggleClass('disabled')
app.showMessage('success', "Event '" + event.title + "' has been " + (event.enabled ? 'enabled' : 'disabled') + ".");
});

var stub = {
id: event.id,
title: event.title,
enabled: event.enabled,
catch_up: event.catch_up || false
};
}
else { // for non-admin ask to confirm first
let action = event.enabled ? 'Disable' : 'Enable'
let msg = `Are you sure you want to ${action} <b>${event.title}</b> event?`

app.confirm(`<span style="color:red">${action} Event</span>`, msg, action, function (result) {
if (result) {

event.enabled = event.enabled ? 0 : 1;

var stub = {
id: event.id,
title: event.title,
enabled: event.enabled,
catch_up: event.catch_up || false
};

app.showProgress(1.0, "Updating Event...");

app.api.post('app/update_event', stub, function (resp) {
app.hideProgress();
app.showMessage('success', "Event '" + event.title + "' has been " + action + "d.");
$('#' + event.id).toggleClass('disabled');
});

}
else {
if(box) box.checked = !box.checked
}

app.showProgress(1.0, "Updating Event...");
});

}

app.api.post('app/update_event', stub, function (resp) {
app.hideProgress();
app.showMessage('success', "Event '" + event.title + "' has been " + action + "d.");
$('#' + event.id).toggleClass('disabled');
});

}
else {
if(box) box.checked = !box.checked
}

});

},

run_event: function (event_idx, e) {
Expand Down

0 comments on commit 16a00b6

Please sign in to comment.