mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 17:05:44 +02:00
BUG Indicator stuck on 0% until you refresh the page.
admin/externallinks/start is called, but asynchronously, so the poll() call is never called immediately on start, you have to refresh the page to get it to show.
This commit is contained in:
parent
606c801513
commit
65117b2599
@ -1,13 +1,14 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
$.entwine('ss', function($) {
|
$.entwine('ss', function($) {
|
||||||
$('#externalLinksReport').entwine({
|
$('#externalLinksReport').entwine({
|
||||||
|
PollTimeout: null,
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
$(this).start();
|
this.start();
|
||||||
},
|
},
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
// poll the current job and update the front end status
|
// poll the current job and update the front end status
|
||||||
$('#externalLinksReport').hide();
|
$('#externalLinksReport').hide();
|
||||||
$(this).poll(0);
|
this.poll();
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
// initiate a new job
|
// initiate a new job
|
||||||
@ -15,10 +16,12 @@
|
|||||||
$('#ReportHolder').text('Running report 0%');
|
$('#ReportHolder').text('Running report 0%');
|
||||||
$('#ReportHolder').append('<span class="ss-ui-loading-icon"></span>');
|
$('#ReportHolder').append('<span class="ss-ui-loading-icon"></span>');
|
||||||
$('#externalLinksReport').hide();
|
$('#externalLinksReport').hide();
|
||||||
$.ajax({url: "admin/externallinks/start", async: true, timeout: 3000 });
|
$.ajax({url: "admin/externallinks/start", async: false, timeout: 3000 });
|
||||||
$(this).poll(1);
|
this.poll();
|
||||||
},
|
},
|
||||||
poll: function(start) {
|
poll: function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "admin/externallinks/getJobStatus",
|
url: "admin/externallinks/getJobStatus",
|
||||||
async: true,
|
async: true,
|
||||||
@ -47,11 +50,14 @@
|
|||||||
.text('Running report ' + completed + '/' + total + ' (' + percent.toFixed(2) + '%)')
|
.text('Running report ' + completed + '/' + total + ' (' + percent.toFixed(2) + '%)')
|
||||||
.append('<span class="ss-ui-loading-icon"></span>');
|
.append('<span class="ss-ui-loading-icon"></span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the regular poll method is run
|
// Ensure the regular poll method is run
|
||||||
if(!start) {
|
// kill any existing timeout
|
||||||
setTimeout(function() { $('#externalLinksReport').poll(0); }, 1000);
|
if(self.getPollTimeout() !== null) {
|
||||||
|
clearTimeout(self.getPollTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setPollTimeout(setTimeout(function() { $('#externalLinksReport').poll(); }, 1000));
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
if(typeof console !== 'undefined') console.log(e);
|
if(typeof console !== 'undefined') console.log(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user