mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-06-04 06:30:47 +00:00
Add a progress bar to the fetch modal
This commit is contained in:
parent
4ca3a38cf2
commit
6d28777d1f
|
@ -85,8 +85,6 @@ class FetchController extends AbstractController
|
||||||
{
|
{
|
||||||
$message = \JText::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', $status['page']);
|
$message = \JText::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', $status['page']);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($status['page']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new \JResponseJson($status, $message, false, true);
|
$response = new \JResponseJson($status, $message, false, true);
|
||||||
|
|
|
@ -17,5 +17,8 @@
|
||||||
<div id="patchtester-container">
|
<div id="patchtester-container">
|
||||||
<h1 id="patchtester-progress-header"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
|
<h1 id="patchtester-progress-header"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
|
||||||
<p id="patchtester-progress-message"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
|
<p id="patchtester-progress-message"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
|
||||||
|
<div id="progress" class="progress progress-striped active">
|
||||||
|
<div id="progress-bar" class="bar bar-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
<input id="patchtester-token" type="hidden" name="<?php echo \JFactory::getSession()->getFormToken(); ?>" value="1" />
|
<input id="patchtester-token" type="hidden" name="<?php echo \JFactory::getSession()->getFormToken(); ?>" value="1" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,7 +24,9 @@ if (typeof Joomla === 'undefined') {
|
||||||
var PatchFetcher = function () {
|
var PatchFetcher = function () {
|
||||||
var offset = null,
|
var offset = null,
|
||||||
progress = null,
|
progress = null,
|
||||||
path = 'index.php?option=com_patchtester&tmpl=component&format=json';
|
path = 'index.php?option=com_patchtester&tmpl=component&format=json',
|
||||||
|
lastPage = null,
|
||||||
|
progressBar = jQuery('#progress-bar');
|
||||||
|
|
||||||
var initialize = function () {
|
var initialize = function () {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
@ -45,10 +47,28 @@ if (typeof Joomla === 'undefined') {
|
||||||
if (response === null) {
|
if (response === null) {
|
||||||
throw textStatus;
|
throw textStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
throw response;
|
throw response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store the last page if it is part of this request and not a boolean false
|
||||||
|
if (typeof response.data.lastPage !== 'undefined' && response.data.lastPage !== false) {
|
||||||
|
lastPage = response.data.lastPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the progress bar if we have the data to do so
|
||||||
|
if (typeof response.data.page !== 'undefined') {
|
||||||
|
progress = (response.data.page / lastPage) * 100;
|
||||||
|
|
||||||
|
if (progress < 100) {
|
||||||
|
progressBar.css('width', progress + '%').attr('aria-valuenow', progress);
|
||||||
|
} else {
|
||||||
|
progressBar.removeClass('bar-success').addClass('bar-warning').attr('aria-valuemin', 100).attr('aria-valuemax', 200);
|
||||||
|
progressBar.css('width', progress + '%').attr('aria-valuenow', progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jQuery('#patchtester-progress-message').html(response.message);
|
jQuery('#patchtester-progress-message').html(response.message);
|
||||||
|
|
||||||
if (response.data.header) {
|
if (response.data.header) {
|
||||||
|
@ -58,6 +78,8 @@ if (typeof Joomla === 'undefined') {
|
||||||
if (!response.data.complete) {
|
if (!response.data.complete) {
|
||||||
// Send another request
|
// Send another request
|
||||||
getRequest('fetch');
|
getRequest('fetch');
|
||||||
|
} else {
|
||||||
|
jQuery('#progress').remove();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
try {
|
try {
|
||||||
|
@ -72,14 +94,16 @@ if (typeof Joomla === 'undefined') {
|
||||||
|
|
||||||
jQuery('#patchtester-progress-header').text(Joomla.JText._('COM_PATCHTESTER_FETCH_AN_ERROR_HAS_OCCURRED'));
|
jQuery('#patchtester-progress-header').text(Joomla.JText._('COM_PATCHTESTER_FETCH_AN_ERROR_HAS_OCCURRED'));
|
||||||
jQuery('#patchtester-progress-message').html(error);
|
jQuery('#patchtester-progress-message').html(error);
|
||||||
|
jQuery('#progress').remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
var json = (typeof jqXHR == 'object' && jqXHR.responseText) ? jqXHR.responseText : null;
|
var json = (typeof jqXHR === 'object' && jqXHR.responseText) ? jqXHR.responseText : null;
|
||||||
jQuery('#patchtester-progress-header').text(Joomla.JText._('COM_PATCHTESTER_FETCH_AN_ERROR_HAS_OCCURRED'));
|
jQuery('#patchtester-progress-header').text(Joomla.JText._('COM_PATCHTESTER_FETCH_AN_ERROR_HAS_OCCURRED'));
|
||||||
jQuery('#patchtester-progress-message').html(json);
|
jQuery('#patchtester-progress-message').html(json);
|
||||||
|
jQuery('#progress').remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -90,7 +114,7 @@ if (typeof Joomla === 'undefined') {
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
new PatchFetcher();
|
new PatchFetcher();
|
||||||
|
|
||||||
if (typeof window.parent.SqueezeBox == 'object') {
|
if (typeof window.parent.SqueezeBox === 'object') {
|
||||||
jQuery(window.parent.SqueezeBox).on('close', function () {
|
jQuery(window.parent.SqueezeBox).on('close', function () {
|
||||||
window.parent.location.reload(true);
|
window.parent.location.reload(true);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user