Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Dec 30, 2024
1 parent f12f10e commit 6796085
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 119 deletions.
12 changes: 6 additions & 6 deletions www/models/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,9 @@ private function generateTaskLogTables()
Identifier VARCHAR(255),
Title VARCHAR(255),
Status CHAR(9), /* running, completed, error */
Start VARCHAR(255),
End VARCHAR(255),
Duration VARCHAR(255),
Start REAL,
End REAL,
Duration REAL,
Message VARCHAR(255),
Task_id INTEGER)");

Expand All @@ -999,9 +999,9 @@ private function generateTaskLogTables()
Title VARCHAR(255),
Note VARCHAR(255),
Status CHAR(9), /* new, running, completed, error */
Start VARCHAR(255),
End VARCHAR(255),
Duration VARCHAR(255),
Start REAL,
End REAL,
Duration REAL,
Output TEXT,
Step_id INTEGER)");

Expand Down
7 changes: 5 additions & 2 deletions www/public/resources/js/events/task/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ $(document).on('click','.show-task-btn',function () {
// Change URL without reloading the page
history.pushState(null, null, '/run/' + taskId);

// Reload task container
reloadContainer('tasks/log');
// Reload task container to print the new task log
reloadContainer('tasks/log').then(function () {
// Restart log scroll event listener
scrollEvent();
});
});

/**
Expand Down
104 changes: 56 additions & 48 deletions www/public/resources/js/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,54 +249,62 @@ function reloadPanel(name, params = [''])
*/
function reloadContainer(container)
{
/**
* If the container to reload does not exist, return
*/
if (!$('.reloadable-container[container="' + container + '"]').length) {
return;
}

/**
* Print a loading icon on the bottom of the page
*/
printLoading();

/**
* Check if container has children with class .veil-on-reload
* If so print a veil on them
*/
printLoadingVeilByParentClass('reloadable-container[container="' + container + '"]');

ajaxRequest(
// Controller:
'general',
// Action:
'getContainer',
// Data:
{
sourceUrl: window.location.href,
sourceUri: window.location.pathname,
container: container
},
// Print success alert:
false,
// Print error alert:
true,
// Reload container:
[],
// Execute functions on success:
[
// Replace container with itself, with new content
"$('.reloadable-container[container=\"" + container + "\"]').replaceWith(jsonValue.message)",
// Reload opened or closed elements that were opened/closed before reloading
"reloadOpenedClosedElements()"
]
);

/**
* Hide loading icon
*/
hideLoading();
return new Promise((resolve, reject) => {
try {
/**
* If the container to reload does not exist, reject promise
*/
if (!$('.reloadable-container[container="' + container + '"]').length) {
reject('Container not found');
}

/**
* Print a loading icon on the bottom of the page
*/
printLoading();

/**
* Check if container has children with class .veil-on-reload
* If so print a veil on them
*/
printLoadingVeilByParentClass('reloadable-container[container="' + container + '"]');

ajaxRequest(
// Controller:
'general',
// Action:
'getContainer',
// Data:
{
sourceUrl: window.location.href,
sourceUri: window.location.pathname,
container: container
},
// Print success alert:
false,
// Print error alert:
true,
// Reload container:
[],
// Execute functions on success:
[
// Replace container with itself, with new content
"$('.reloadable-container[container=\"" + container + "\"]').replaceWith(jsonValue.message)",
// Reload opened or closed elements that were opened/closed before reloading
"reloadOpenedClosedElements()"
]
).then(() => {
// Hide loading icon
hideLoading();

// Resolve promise
resolve('Container reloaded');
});
} catch (error) {
// Reject promise
reject('Failed to reload container');
}
});
}

/**
Expand Down
133 changes: 70 additions & 63 deletions www/public/resources/js/pre/functions/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,77 +29,84 @@ function ajaxRequest(controller, action, additionalData = null, printSuccessAler
*/
// console.log(data);

/**
* Ajax request
*/
$.ajax({
type: "POST",
url: "/ajax/controller.php",
data: data,
dataType: "json",
success: function (data, textStatus, jqXHR) {
/**
* Retrieve and print success message
*/
jsonValue = jQuery.parseJSON(jqXHR.responseText);
return new Promise((resolve, reject) => {
/**
* Ajax request
*/
$.ajax({
type: "POST",
url: "/ajax/controller.php",
data: data,
dataType: "json",
success: function (data, textStatus, jqXHR) {
/**
* Retrieve and print success message
*/
jsonValue = jQuery.parseJSON(jqXHR.responseText);

/**
* Print success message
*/
// Print alert
if (printSuccessAlert === true) {
printAlert(jsonValue.message, 'success');
}
// Print to console
if (printSuccessAlert == 'console') {
console.log(jsonValue.message);
}
/**
* Print success message
*/
// Print alert
if (printSuccessAlert === true) {
printAlert(jsonValue.message, 'success');
}
// Print to console
if (printSuccessAlert == 'console') {
console.log(jsonValue.message);
}

/**
* Reload containers if specified
*/
if (reloadContainers != null) {
for (let i = 0; i < reloadContainers.length; i++) {
reloadContainer(reloadContainers[i]);
/**
* Reload containers if specified
*/
if (reloadContainers != null) {
for (let i = 0; i < reloadContainers.length; i++) {
reloadContainer(reloadContainers[i]);
}
}
}

/**
* Execute function(s) if specified
*/
if (execOnSuccess != null) {
for (let i = 0; i < execOnSuccess.length; i++) {
eval(execOnSuccess[i]);
/**
* Execute function(s) if specified
*/
if (execOnSuccess != null) {
for (let i = 0; i < execOnSuccess.length; i++) {
eval(execOnSuccess[i]);
}
}
}
},
error: function (jqXHR, textStatus, thrownError) {
/**
* Retrieve and print error message
*/
jsonValue = jQuery.parseJSON(jqXHR.responseText);

/**
* Print error message
*/
// Print alert
if (printErrorAlert === true) {
printAlert(jsonValue.message, 'error');
}
// Print to console
if (printErrorAlert == 'console') {
console.log(jsonValue.message);
}
resolve('Ajax request executed successfully');
},

/**
* Execute function(s) if specified
*/
if (execOnError != null) {
for (let i = 0; i < execOnError.length; i++) {
eval(execOnError[i]);
error: function (jqXHR, textStatus, thrownError) {
/**
* Retrieve and print error message
*/
jsonValue = jQuery.parseJSON(jqXHR.responseText);

/**
* Print error message
*/
// Print alert
if (printErrorAlert === true) {
printAlert(jsonValue.message, 'error');
}
// Print to console
if (printErrorAlert == 'console') {
console.log(jsonValue.message);
}
}
},

/**
* Execute function(s) if specified
*/
if (execOnError != null) {
for (let i = 0; i < execOnError.length; i++) {
eval(execOnError[i]);
}
}

reject('Failed to execute ajax request');
},
});
});
}

Expand Down

0 comments on commit 6796085

Please sign in to comment.