improve display of 'next run' for sync jobs
if the last sync job is too far in the past (or there was none at all for now) we run it at the next iteration, so we want to show that we now calculate the next_run by using either the real last endtime as time or 0 then in the frontend, we check if the next_run is < now and show 'pending' (we do it this way also for replication on pve) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
eed8a5ad79
commit
8d78589969
@ -1,6 +1,5 @@
|
|||||||
use anyhow::{Error};
|
use anyhow::{Error};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use proxmox::api::{api, ApiMethod, Router, RpcEnvironment};
|
use proxmox::api::{api, ApiMethod, Router, RpcEnvironment};
|
||||||
@ -51,25 +50,22 @@ pub fn list_sync_jobs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
|
||||||
Ok(epoch_now) => epoch_now.as_secs() as i64,
|
|
||||||
_ => 0i64,
|
|
||||||
};
|
|
||||||
|
|
||||||
for job in &mut list {
|
for job in &mut list {
|
||||||
|
let mut last = 0;
|
||||||
|
if let Some(task) = last_tasks.get(&job.id) {
|
||||||
|
job.last_run_upid = Some(task.upid_str.clone());
|
||||||
|
if let Some((endtime, status)) = &task.state {
|
||||||
|
job.last_run_state = Some(String::from(status));
|
||||||
|
job.last_run_endtime = Some(*endtime);
|
||||||
|
last = *endtime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
job.next_run = (|| -> Option<i64> {
|
job.next_run = (|| -> Option<i64> {
|
||||||
let schedule = job.schedule.as_ref()?;
|
let schedule = job.schedule.as_ref()?;
|
||||||
let event = parse_calendar_event(&schedule).ok()?;
|
let event = parse_calendar_event(&schedule).ok()?;
|
||||||
compute_next_event(&event, now, false).ok()
|
compute_next_event(&event, last, false).ok()
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if let Some(task) = last_tasks.get(&job.id) {
|
|
||||||
job.last_run_upid = Some(task.upid_str.clone());
|
|
||||||
if let Some((endttime, status)) = &task.state {
|
|
||||||
job.last_run_state = Some(String::from(status));
|
|
||||||
job.last_run_endtime = Some(*endttime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||||
|
@ -114,7 +114,19 @@ Ext.define('PBS.config.SyncJobView', {
|
|||||||
return `<i class="fa fa-times critical"></i> ${gettext("Error")}:${value}`;
|
return `<i class="fa fa-times critical"></i> ${gettext("Error")}:${value}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
render_optional_timestamp: function(value) {
|
render_next_run: function(value, metadat, record) {
|
||||||
|
if (!value) return '-';
|
||||||
|
|
||||||
|
let now = new Date();
|
||||||
|
let next = new Date(value*1000);
|
||||||
|
|
||||||
|
if (next < now) {
|
||||||
|
return gettext('pending');
|
||||||
|
}
|
||||||
|
return Proxmox.Utils.render_timestamp(value);
|
||||||
|
},
|
||||||
|
|
||||||
|
render_optional_timestamp: function(value, metadata, record) {
|
||||||
if (!value) return '-';
|
if (!value) return '-';
|
||||||
return Proxmox.Utils.render_timestamp(value);
|
return Proxmox.Utils.render_timestamp(value);
|
||||||
},
|
},
|
||||||
@ -237,7 +249,7 @@ Ext.define('PBS.config.SyncJobView', {
|
|||||||
header: gettext('Next Run'),
|
header: gettext('Next Run'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
renderer: 'render_optional_timestamp',
|
renderer: 'render_next_run',
|
||||||
dataIndex: 'next-run',
|
dataIndex: 'next-run',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user