233 lines
6.7 KiB
PHTML
233 lines
6.7 KiB
PHTML
<%inherit file="dashboard.phtml"/>
|
|
<%block name="extra_css">
|
|
<link href="${make_media_url('css/jquery-ui.min.css', 'pastafari2')}" rel="stylesheet">
|
|
<link href="${make_media_url('css/jquery-ui-theme.min.css', 'pastafari2')}" rel="stylesheet">
|
|
<style>
|
|
.ui-progressbar {
|
|
position: relative;
|
|
}
|
|
.progress-label {
|
|
position: absolute;
|
|
left: 50%;
|
|
top: 4px;
|
|
font-weight: bold;
|
|
color: #fff;
|
|
text-shadow: 1px 1px 0 #000;
|
|
}
|
|
|
|
.return_block {
|
|
|
|
display: none;
|
|
|
|
}
|
|
</style>
|
|
</%block>
|
|
<%block name="content">
|
|
<h3>${hostname}</h3>
|
|
<h2>${lang('pastafari2', 'task progress', 'Task progress')} - ${name_task}</h2>
|
|
<div class="return_block"></div>
|
|
<p>${description_task}</p>
|
|
<hr />
|
|
<i class="fa fa-cog fa-spin fa-5x fa-fw margin-bottom" id="gear"></i>
|
|
<div id="progressbar"><div class="progress-label">${lang('pastafari2', 'processing_task', 'Processing task...')}</div></div>
|
|
<div id="no_progress" style="border: solid #cbcbcb 1px;height:150px;overflow:scroll;padding:2px;"></div>
|
|
<div id="return_block"></div>
|
|
</%block>
|
|
<%block name="jscript_block">
|
|
<script language="Javascript" src="${make_media_url('js/jquery-ui.min.js', 'pastafari2')}"></script>
|
|
<script>
|
|
|
|
position=${position};
|
|
yes_progress=1;
|
|
yes_position=0;
|
|
last_status=0;
|
|
|
|
text_complete="Complete!";
|
|
|
|
var progressbar = $( "#progressbar" ),
|
|
progressLabel = $( ".progress-label" );
|
|
|
|
progressbar.progressbar({
|
|
value: false,
|
|
change: function() {
|
|
|
|
if(progressbar.progressbar( "value" )>0)
|
|
{
|
|
|
|
progressLabel.text( progressbar.progressbar( "value" ) + "%" );
|
|
console.log('Progress '+progressbar.progressbar( "value" ) + "%");
|
|
|
|
}
|
|
else
|
|
{
|
|
progressbar.progressbar( "value", false);
|
|
progressLabel.text( "Processing task..." );
|
|
console.log('Processing task...');
|
|
|
|
}
|
|
},
|
|
complete: function() {
|
|
progressLabel.text( text_complete );
|
|
}
|
|
});
|
|
|
|
objDiv = document.getElementById("no_progress");
|
|
|
|
function update_messages_queue(message)
|
|
{
|
|
|
|
//timeout=setTimeout(function () {
|
|
|
|
progressbar.progressbar( "value", false );
|
|
|
|
$('#no_progress').append(message);
|
|
objDiv.scrollTop = objDiv.scrollHeight;
|
|
|
|
//}, 600);
|
|
|
|
//return timeout;
|
|
|
|
}
|
|
|
|
function update_progress_messages_queue(message, progress)
|
|
{
|
|
|
|
console.log('Getting progress...');
|
|
|
|
//timeout=setTimeout(function () {
|
|
|
|
progress=parseInt(progress);
|
|
|
|
progressbar.progressbar( "value", progress );
|
|
|
|
$('#no_progress').append(message+'<br />');
|
|
|
|
objDiv.scrollTop = objDiv.scrollHeight;
|
|
|
|
//}, 600);
|
|
|
|
//return timeout;
|
|
|
|
}
|
|
|
|
function finish_progress_error(progress)
|
|
{
|
|
|
|
progressbar.progressbar( "value", progress );
|
|
progressLabel.text( "ERROR, please see the log" );
|
|
|
|
}
|
|
|
|
|
|
function update_progress()
|
|
{
|
|
|
|
//pastafari/showprogress/tasks
|
|
|
|
$.ajax({
|
|
url: "${url_for('.pastafari2_getprogress')}?task_id=${task_id}&server=${server}&position="+position,
|
|
method: "POST",
|
|
dataType: "json",
|
|
data: {}
|
|
}).done(function(data) {
|
|
|
|
if(!data.hasOwnProperty("wait"))
|
|
{
|
|
|
|
x=data.length;
|
|
|
|
for(k=0;k<x;k++)
|
|
{
|
|
|
|
if(data[k].no_progress==1)
|
|
{
|
|
//yes_progress=0;
|
|
//$('#no_progress').append(data[k].message+'<br />');
|
|
update_messages_queue(data[k].message+'<br />');
|
|
|
|
//Scroll
|
|
|
|
}
|
|
else
|
|
if(data[k].no_progress==0)
|
|
{
|
|
|
|
update_progress_messages_queue(data[k].message, data[k].progress);
|
|
|
|
}
|
|
|
|
if(data[k].status!=1)
|
|
{
|
|
position+=1;
|
|
last_status=0;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
position+=1;
|
|
last_status=1;
|
|
|
|
if(data[k].error==1)
|
|
{
|
|
text_complete='ERROR, please view the log';
|
|
finish_progress_error(data[k].progress);
|
|
console.log('ERROR, please view the log');
|
|
console.log('Error, finishing progress...');
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//progressLabel.text( "Complete!" );
|
|
|
|
}
|
|
|
|
//clearTimeout(update_interval);
|
|
|
|
$('#gear').removeClass('fa-spin');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if(last_status==0)
|
|
{
|
|
|
|
update_interval = setTimeout(update_progress, 1000);
|
|
console.log('Updating progress...');
|
|
|
|
}
|
|
else {
|
|
|
|
console.log('Finishing progress...');
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
console.log('Updating waiting progress...');
|
|
update_interval = setTimeout(update_progress, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
}).fail(function (data) {
|
|
|
|
alert('Error: '+data.status+' '+data.statusText);
|
|
/*clearInterval(update_interval);*/
|
|
text_complete='ERROR, please view the log';
|
|
finish_progress_error(100);
|
|
$('#gear').removeClass('fa-spin');
|
|
});
|
|
}
|
|
|
|
update_progress();
|
|
|
|
</script>
|
|
</%block>
|