<com:TActiveCustomValidator ID="PriorityValidator" ValidationGroup="JobGroup" ControlToValidate="Priority" ErrorMessage="<%[ Priority value must be integer greather than 0. ]%>" ControlCssClass="validation-error" Display="None" OnServerValidate="priorityValidator" />
</div>
</div>
- <com:TCallback ID="ReloadJobs" OnCallback="Page.JobWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobWindow').setLoadRequest();" />
+ <com:TCallback ID="ReloadJobs" OnCallback="Page.JobWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobWindow').setLoadRequest(); job_callback_duration = new Date().getTime();" />
<script type="text/javascript">
+ var job_callback_duration;
var job_callback_func = function() {
/*
* Check if Job list window is open and if any checkbox from actions is not checked.
<com:TActiveLabel ID="CancelButton"><com:BActiveButton ID="Cancel" Text="<%[ Cancel job ]%>" CausesValidation="false" OnClick="cancel" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" CssClass="bbutton" /> </com:TActiveLabel>
<com:BActiveButton ID="Run" Text="<%[ Run job again ]%>" ValidationGroup="JobGroup" CausesValidation="true" OnClick="run_again" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();oMonitor();"/>
</div>
- <com:TCallback ID="RefreshStatus" OnCallback="status" ClientSide.OnComplete="status_callback_timeout = setTimeout('status_callback_func()', 10000);" />
+ <com:TCallback ID="RefreshStatus" OnCallback="status" ClientSide.OnComplete="job_callback_duration = new Date().getTime();" />
<script type="text/javascript">
- var status_callback_timeout;
var status_prev = false;
var status_callback_func = function() {
- if(status_callback_timeout) {
- clearTimeout(status_callback_timeout);
- }
if($('<%=$this->getID()%>configuration').visible() && ($('<%=$this->RefreshStart->ClientID%>').value === 'true' || status_prev === true)) {
status_prev = ($('<%=$this->RefreshStart->ClientID%>').value === 'true');
var callback = <%=$this->RefreshStatus->ActiveControl->Javascript%>;
- oMonitor();
callback.dispatch();
} else {
status_prev = false;
var default_refresh_interval = 60000;
var default_fast_refresh_interval = 10000;
var timeout_handler;
+ var last_callback_time = 0;
+ var callback_time_offset = 0;
document.observe("dom:loaded", function() {
oMonitor = function() {
return new Ajax.Request('<%=$this->Service->constructUrl("Monitor")%>', {
+ onCreate: function() {
+ if (job_callback_duration) {
+ callback_time_offset = job_callback_duration - last_callback_time;
+ }
+ last_callback_time = new Date().getTime();
+ },
onSuccess: function(response) {
if (timeout_handler) {
clearTimeout(timeout_handler);
}
var jobs = (response.responseText).evalJSON();
if (jobs.running_jobs.length > 0) {
- refreshInterval = default_fast_refresh_interval;
+ refreshInterval = callback_time_offset + default_fast_refresh_interval;
} else {
refreshInterval = default_refresh_interval;
}
job_callback_func();
+ status_callback_func();
$('running_jobs').update(jobs.running_jobs.length);
$('finished_jobs').update(jobs.terminated_jobs.length);
timeout_handler = setTimeout("oMonitor()", refreshInterval);