First files to the project
This commit is contained in:
commit
cda8eb1232
26 changed files with 2657 additions and 0 deletions
104
templates/admin/multiprogress.phtml
Normal file
104
templates/admin/multiprogress.phtml
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<%inherit file="dashboard.phtml"/>
|
||||
<%block name="content">
|
||||
<h2>${name_task}</h2>
|
||||
<p>${description_task}</p>
|
||||
<hr />
|
||||
<p>${lang('pastafari2', 'num_servers', 'Number of servers')}: <span id="num_servers">${num_servers}</span></p>
|
||||
<p>${lang('pastafari2', 'completed_tasks', 'Completed tasks')}: <span id="num_completed">0</span></p>
|
||||
<p id="detecting_servers" style="display:none;">${lang('pastafari2', 'loading_servers', 'Loading servers...')} <i class="fa fa-cog fa-spin fa-fw"></i></p>
|
||||
<table class="table_servers" style="width:100%;">
|
||||
<tr class="row_server" id="father_server" style="display:none;">
|
||||
<td class="hostname">Hostname</td>
|
||||
<td class="progress"><span class="progress_text">In progress</span> <i class="fa fa-cog fa-spin fa-fw"></i></td>
|
||||
<td><a href="#" class="server_log">${lang('pastafari2', 'server_log', 'Server log')}</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="finished" style="display:none;">
|
||||
<p><strong>All tasks were finished.</strong></p>
|
||||
</div>
|
||||
</%block>
|
||||
<%block name="jscript_block">
|
||||
<script>
|
||||
|
||||
ids=[];
|
||||
|
||||
//Get all tasks, next process 50 next progress.
|
||||
$.ajax({
|
||||
url: "${url_for('.pastafari2_get_servers_task')}",
|
||||
data: {task_id: ${task_id}},
|
||||
success: function (data) {
|
||||
|
||||
for(i in data) {
|
||||
|
||||
//console.log(data[i]);
|
||||
new_row=$(father_server).clone().appendTo('.table_servers');
|
||||
new_row.prop('id', 'task_'+data[i].id);
|
||||
//console.log(data[i]);
|
||||
new_row.children('.hostname').html(data[i].hostname);
|
||||
|
||||
new_row.find('.server_log').attr('href', "${url_for('.pastafari2_progress')}?task_id="+data[i].id);
|
||||
|
||||
new_row.show();
|
||||
|
||||
ids.push(data[i].id);
|
||||
//console.log($('#father_server').attr('id'));
|
||||
|
||||
}
|
||||
|
||||
get_log();
|
||||
|
||||
setInterval(get_log, 1000);
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
function get_log() {
|
||||
|
||||
$.ajax({
|
||||
url: "${url_for('.pastafari2_get_multiprogress')}",
|
||||
data: {ids: JSON.stringify(ids)},
|
||||
success: function (data) {
|
||||
|
||||
/*$('.row_server').each(function () {
|
||||
|
||||
console.log($(this).attr('id'));
|
||||
|
||||
});*/
|
||||
|
||||
for(i in data) {
|
||||
|
||||
//console.log(data[i]);
|
||||
|
||||
//If is no_progress then show message.
|
||||
|
||||
if(!data[i].no_progress) {
|
||||
//console.log('#server_'+data[i].server);
|
||||
$('#task_'+data[i].task_id).find('.progress_text').html(data[i].message);
|
||||
|
||||
if(data[i].status==1) {
|
||||
|
||||
if(data[i].error==0) {
|
||||
|
||||
$('#task_'+data[i].task_id).find('i').removeClass('fa-cog fa-spin fa-fw').addClass('fa-check');
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$('#task_'+data[i].task_id).find('i').removeClass('fa-cog fa-spin fa-fw').addClass('fa-times');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</%block>
|
||||
Loading…
Add table
Add a link
Reference in a new issue