Set repo background colour based on backup status
This commit is contained in:
parent
395e03803f
commit
cb5ab6fdb8
|
@ -11,6 +11,26 @@ class Repo(models.Model):
|
||||||
last_modified = models.DateTimeField()
|
last_modified = models.DateTimeField()
|
||||||
label = models.OneToOneField(Label, on_delete=models.CASCADE, unique=True)
|
label = models.OneToOneField(Label, on_delete=models.CASCADE, unique=True)
|
||||||
|
|
||||||
|
def warning(self):
|
||||||
|
if self.error():
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
latest_archive = self.latest_archive()
|
||||||
|
if latest_archive.start > datetime.utcnow() - timedelta(hours=2):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def error(self):
|
||||||
|
latest_archive = self.latest_archive()
|
||||||
|
if latest_archive is None or not self.archive_after_latest_error():
|
||||||
|
return True
|
||||||
|
|
||||||
|
if latest_archive.start > datetime.utcnow() - timedelta(hours=4):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def archive_after_latest_error(self):
|
def archive_after_latest_error(self):
|
||||||
latest_archive = self.latest_archive()
|
latest_archive = self.latest_archive()
|
||||||
latest_error = self.latest_error()
|
latest_error = self.latest_error()
|
||||||
|
@ -100,7 +120,7 @@ class Repo(models.Model):
|
||||||
return ''.join(['H' if archive is not None else '-' for archive in archives])
|
return ''.join(['H' if archive is not None else '-' for archive in archives])
|
||||||
|
|
||||||
def hourly_archive_string(self):
|
def hourly_archive_string(self):
|
||||||
return ''.join(['H' if archive is not None else '-' for archive in self.hourly_archives(24)])
|
return ''.join(['H' if archive is not None else '-' for archive in self.hourly_archives(48)])
|
||||||
|
|
||||||
def monthly_archives(self, n_months: int = 12):
|
def monthly_archives(self, n_months: int = 12):
|
||||||
archives = []
|
archives = []
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
{% if repo_list %}
|
{% if repo_list %}
|
||||||
<div class="grid mx-auto d-flex justify-content-center flex-wrap">
|
<div class="grid mx-auto d-flex justify-content-center flex-wrap">
|
||||||
{% for repo in repo_list %}
|
{% for repo in repo_list %}
|
||||||
<div style="width: 600px;" class="repo-container shadow rounded bg-primary overflow-hidden
|
<div style="width: 600px;" class="repo-container shadow rounded overflow-hidden
|
||||||
{% if not repo.archive_after_latest_error %}bg-danger{% endif %}">
|
{% if repo.error %}bg-danger{% elif repo.warning %}bg-warning{% else %}bg-primary{% endif %}">
|
||||||
<div class="row me-1 overflow-hidden text-truncate">
|
<div class="row me-1 overflow-hidden text-truncate">
|
||||||
<h2 class="h2">{{ repo.label }}
|
<h2 class="h2">{{ repo.label }}
|
||||||
<small class="text-muted"> {{ repo.location }}</small>
|
<small class="text-muted"> {{ repo.location }}</small>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user