1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-21 23:33:13 +00:00

Show trigger (user/scheduled) in Archive tab. By @diivi (#1732)

This commit is contained in:
Divyansh Singh 2023-06-23 18:51:54 +05:30 committed by GitHub
parent 210a968f91
commit c56c6700ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 5 deletions

View file

@ -142,9 +142,6 @@
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
@ -173,6 +170,11 @@
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Trigger</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">

View file

@ -0,0 +1 @@
<svg fill="#000000" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="m224 256c70.7 0 128-57.3 128-128s-57.3-128-128-128-128 57.3-128 128 57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7c-74.2 0-134.4 60.2-134.4 134.4v41.6c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"/></svg>

After

Width:  |  Height:  |  Size: 365 B

View file

@ -28,6 +28,7 @@ def process_result(self, result):
'repo': result['params']['repo_id'],
'duration': result['data']['archive']['duration'],
'size': result['data']['archive']['stats']['deduplicated_size'],
'trigger': result['params'].get('category', 'user'),
},
)
new_archive.save()

View file

@ -21,7 +21,7 @@
)
from .settings import get_misc_settings
SCHEMA_VERSION = 20
SCHEMA_VERSION = 21
@signals.post_save(sender=SettingsModel)

View file

@ -228,6 +228,17 @@ def run_migrations(current_schema, db_connection):
migrator.add_column(SettingsModel._meta.table_name, 'tooltip', pw.CharField(default='')),
)
if current_schema.version < 21:
_apply_schema_update(
current_schema,
21,
migrator.add_column(
ArchiveModel._meta.table_name,
'trigger',
pw.CharField(null=True),
),
)
def _apply_schema_update(current_schema, version_after, *operations):
with DB.atomic():

View file

@ -132,6 +132,7 @@ class ArchiveModel(BaseModel):
time = pw.DateTimeField()
duration = pw.FloatField(null=True)
size = pw.IntegerField(null=True)
trigger = pw.CharField(null=True)
def formatted_time(self):
return

View file

@ -14,6 +14,7 @@
QLayout,
QMenu,
QMessageBox,
QStyledItemDelegate,
QTableView,
QTableWidgetItem,
QWidget,
@ -57,6 +58,13 @@
SIZE_DECIMAL_DIGITS = 1
# from https://stackoverflow.com/questions/63177587/pyqt-tableview-align-icons-to-center
class IconDelegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
super().initStyleOption(option, index)
option.decorationSize = option.rect.size() - QtCore.QSize(0, 10)
class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
prune_intervals = ['hour', 'day', 'week', 'month', 'year']
@ -83,7 +91,10 @@ def __init__(self, parent=None, app=None):
header.setSectionResizeMode(2, QHeaderView.ResizeMode.ResizeToContents)
header.setSectionResizeMode(3, QHeaderView.ResizeMode.Interactive)
header.setSectionResizeMode(4, QHeaderView.ResizeMode.Stretch)
header.setStretchLastSection(True)
header.setSectionResizeMode(5, QHeaderView.ResizeMode.ResizeToContents)
delegate = IconDelegate(self.archiveTable)
self.archiveTable.setItemDelegateForColumn(5, delegate)
if sys.platform != 'darwin':
self._set_status('') # Set platform-specific hints.
@ -255,6 +266,12 @@ def populate_from_profile(self):
self.toolBox.setItemText(0, self.tr('Archives for %s') % profile.repo.url)
archives = [s for s in profile.repo.archives.select().order_by(ArchiveModel.time.desc())]
# if no archive's name can be found in self.mount_points, then hide the mount point column
if not any(a.name in self.mount_points for a in archives):
self.archiveTable.hideColumn(3)
else:
self.archiveTable.showColumn(3)
sorting = self.archiveTable.isSortingEnabled()
self.archiveTable.setSortingEnabled(False)
best_unit = find_best_unit_for_sizes((a.size for a in archives), precision=SIZE_DECIMAL_DIGITS)
@ -280,6 +297,16 @@ def populate_from_profile(self):
self.archiveTable.setItem(row, 4, QTableWidgetItem(archive.name))
if archive.trigger == 'scheduled':
item = QTableWidgetItem(get_colored_icon('clock-o'), '')
item.setToolTip(self.tr('Scheduled'))
self.archiveTable.setItem(row, 5, item)
elif archive.trigger == 'user':
item = QTableWidgetItem(get_colored_icon('user'), '')
item.setToolTip(self.tr('User initiated'))
item.setTextAlignment(Qt.AlignmentFlag.AlignRight)
self.archiveTable.setItem(row, 5, item)
self.archiveTable.setRowCount(len(archives))
self.archiveTable.setSortingEnabled(sorting)
item = self.archiveTable.item(0, 0)