mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-03 07:12:36 +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']);
|
||||
}
|
||||
|
||||
unset($status['page']);
|
||||
}
|
||||
|
||||
$response = new \JResponseJson($status, $message, false, true);
|
||||
|
@ -17,5 +17,8 @@
|
||||
<div id="patchtester-container">
|
||||
<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>
|
||||
<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" />
|
||||
</div>
|
||||
|
@ -24,7 +24,9 @@ if (typeof Joomla === 'undefined') {
|
||||
var PatchFetcher = function () {
|
||||
var offset = 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 () {
|
||||
offset = 0;
|
||||
@ -45,10 +47,28 @@ if (typeof Joomla === 'undefined') {
|
||||
if (response === null) {
|
||||
throw textStatus;
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
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);
|
||||
|
||||
if (response.data.header) {
|
||||
@ -58,6 +78,8 @@ if (typeof Joomla === 'undefined') {
|
||||
if (!response.data.complete) {
|
||||
// Send another request
|
||||
getRequest('fetch');
|
||||
} else {
|
||||
jQuery('#progress').remove();
|
||||
}
|
||||
} catch (error) {
|
||||
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-message').html(error);
|
||||
jQuery('#progress').remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
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-message').html(json);
|
||||
jQuery('#progress').remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -90,7 +114,7 @@ if (typeof Joomla === 'undefined') {
|
||||
jQuery(function () {
|
||||
new PatchFetcher();
|
||||
|
||||
if (typeof window.parent.SqueezeBox == 'object') {
|
||||
if (typeof window.parent.SqueezeBox === 'object') {
|
||||
jQuery(window.parent.SqueezeBox).on('close', function () {
|
||||
window.parent.location.reload(true);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user