Show a different alert message if the user has never synchronized.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-15 01:20:31 +01:00
parent cda79820b3
commit 046476cd6e
3 changed files with 31 additions and 9 deletions

View File

@ -40,7 +40,7 @@ namespace XenAdmin.Alerts
{
public class OutOfSyncWithCdnAlert : Alert
{
private readonly TimeSpan _outOfSyncSpan;
private readonly TimeSpan _outOfSyncSpan = TimeSpan.Zero;
private readonly Pool _pool;
private OutOfSyncWithCdnAlert(Pool pool, DateTime timestamp)
@ -49,6 +49,8 @@ namespace XenAdmin.Alerts
_pool = pool;
Connection = _pool.Connection;
if (pool.last_update_sync > Util.GetUnixMinDateTime())
{
_outOfSyncSpan = _timestamp - _pool.last_update_sync;
if (_outOfSyncSpan >= TimeSpan.FromDays(180))
@ -56,6 +58,11 @@ namespace XenAdmin.Alerts
else if (_outOfSyncSpan >= TimeSpan.FromDays(90))
Priority = AlertPriority.Priority2;
}
else
{
Priority = AlertPriority.Priority3;
}
}
public static bool TryCreate(IXenConnection connection, out Alert alert)
{
@ -79,8 +86,9 @@ namespace XenAdmin.Alerts
public override string AppliesTo => Helpers.GetName(_pool);
public override string Description => string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_DESCRIPTION,
AlertExtensions.GetGuiDate(_pool.last_update_sync));
public override string Description => _outOfSyncSpan == TimeSpan.Zero
? Messages.ALERT_CDN_NEVER_SYNC_TITLE
: string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_DESCRIPTION, AlertExtensions.GetGuiDate(_pool.last_update_sync));
public override Action FixLinkAction
{
@ -99,7 +107,9 @@ namespace XenAdmin.Alerts
public override string HelpID => "TODO";
public override string Title => string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_TITLE, _outOfSyncSpan.Days);
public override string Title => _outOfSyncSpan == TimeSpan.Zero
? Messages.ALERT_CDN_NEVER_SYNC_TITLE
: string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_TITLE, _outOfSyncSpan.Days);
}

View File

@ -4993,6 +4993,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to You have never synchronized with the update channel..
/// </summary>
public static string ALERT_CDN_NEVER_SYNC_TITLE {
get {
return ResourceManager.GetString("ALERT_CDN_NEVER_SYNC_TITLE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The last synchronization with the update channel took place on {0}..
/// </summary>

View File

@ -1834,6 +1834,9 @@ This alarm is set to be triggered when the total throughput exceeds {4}.</value>
<data name="ALERT_CAP_LABEL" xml:space="preserve">
<value>(Showing first {0} entries)</value>
</data>
<data name="ALERT_CDN_NEVER_SYNC_TITLE" xml:space="preserve">
<value>You have never synchronized with the update channel.</value>
</data>
<data name="ALERT_CDN_OUT_OF_SYNC_DESCRIPTION" xml:space="preserve">
<value>The last synchronization with the update channel took place on {0}.</value>
</data>