add simple task manager in js

This commit is contained in:
Uwe Steinmann 2020-09-24 16:50:50 +02:00
parent 656cc5843f
commit 05a6917102
2 changed files with 44 additions and 27 deletions

View File

@ -1227,8 +1227,13 @@ $(document).ready(function() { /* {{{ */
});
}); /* }}} */
(function( SeedDMSTask, $, undefined ) { /* {{{ */
var approval_count, review_count, workflow_count;
var checkTasks = function() {
var timeout = 1000;
var counter = 0;
var tasks = Array(
{name: 'checktasks', interval: 15, func:
checkTasks = function() {
$.ajax({url: '../out/out.Tasks.php',
type: 'GET',
dataType: "json",
@ -1248,11 +1253,23 @@ $(document).ready(function() { /* {{{ */
},
timeout: 3000
});
timeOutId = setTimeout(checkTasks, 30000);
}
}
);
SeedDMSTask.add = function(task) {
tasks.push(task);
}
var updateDropFolder = function() {
$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder});
timeOutId = setTimeout(updateDropFolder, 60000);
SeedDMSTask.run = function() {
for(let task of tasks) {
if(counter % task.interval == 0) {
// console.log("Running task '" + task.name + "'");
task.func();
}
}
//console.log(counter);
counter++;
timeOutId = setTimeout(SeedDMSTask.run, timeout);
}
}( window.SeedDMSTask = window.SeedDMSTask || {}, jQuery )); /* }}} */

View File

@ -182,10 +182,10 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo '<script src="'.$this->params['absbaseprefix'].'out/out.'.$this->params['class'].'.php?'.http_build_query($tmp).'"></script>'."\n";
echo '<script src="../styles/'.$this->theme.'/application.js"></script>'."\n";
if($this->params['enablemenutasks'] && isset($this->params['user']) && $this->params['user']) {
$this->addFooterJS('checkTasks();');
$this->addFooterJS('SeedDMSTask.run();');
}
if($this->params['enabledropfolderlist'] && isset($this->params['user']) && $this->params['user']) {
$this->addFooterJS('updateDropFolder();');
$this->addFooterJS("SeedDMSTask.add({name: 'dropfolder', interval: 15, func: function(){\$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder});}});");
}
if($this->footerjs) {
$jscode = "$(document).ready(function () {\n";