From faacd986b3924ccc092801a58e79b63f8fe9563f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Feb 2018 10:37:15 -0800 Subject: [PATCH] remove deleted backups from content archives tables --- .../resources/web/content/js/content.js | 46 +++++++++++++------ .../src/DomainServerSettingsManager.cpp | 3 +- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/domain-server/resources/web/content/js/content.js b/domain-server/resources/web/content/js/content.js index 69a8c93f82..5c2e134102 100644 --- a/domain-server/resources/web/content/js/content.js +++ b/domain-server/resources/web/content/js/content.js @@ -78,6 +78,8 @@ $(document).ready(function(){ }); var GENERATE_ARCHIVE_BUTTON_ID = 'generate-archive-button'; + var CONTENT_ARCHIVES_NORMAL_ID = 'content-archives-success'; + var CONTENT_ARCHIVES_ERROR_ID = 'content-archives-error'; var AUTOMATIC_ARCHIVES_TABLE_ID = 'automatic-archives-table'; var AUTOMATIC_ARCHIVES_TBODY_ID = 'automatic-archives-tbody'; var MANUAL_ARCHIVES_TABLE_ID = 'manual-archives-table'; @@ -90,10 +92,10 @@ $(document).ready(function(){ function setupContentArchives() { // construct the HTML needed for the content archives panel - var html = "
"; + var html = "
"; html += ""; html += "Your domain server makes regular archives of the content in your domain. In the list below, you can see and download all of your domain content and settings backups. " - html += "Click here to manage automatic content archive intervals."; + html += "Click here to manage automatic content archive intervals."; html += "
"; html += ""; @@ -110,7 +112,11 @@ $(document).ready(function(){ html += ""; html += "
"; html += backups_table_head; - html += "
"; + html += "
"; + + html += ""; // put the base HTML in the content archives panel $('#' + Settings.CONTENT_ARCHIVES_PANEL_ID + ' .panel-body').html(html); @@ -119,7 +125,8 @@ $(document).ready(function(){ var BACKUP_RESTORE_LINK_CLASS = 'restore-backup'; var BACKUP_DOWNLOAD_LINK_CLASS = 'download-backup'; var BACKUP_DELETE_LINK_CLASS = 'delete-backup'; - + var ACTIVE_BACKUP_ROW_CLASS = 'active-backup'; + function reloadBackupInformation() { // make a GET request to get backup information to populate the table $.ajax({ @@ -153,6 +160,10 @@ $(document).ready(function(){ $progressBar.find('.sr-only').html(data.status.recoveryProgress + "% Complete"); } + // before we add any new rows and update existing ones + // remove our flag for active rows + $('.' + ACTIVE_BACKUP_ROW_CLASS).removeClass(ACTIVE_BACKUP_ROW_CLASS); + function updateOrAddTableRow(backup, tableBodyID) { // check for a backup with this ID var $backupRow = $("tr[data-backup-id='" + backup.id + "']"); @@ -169,7 +180,7 @@ $(document).ready(function(){ $backupRow.find('td.backup-status').html(progressBarHTML('availability', 'Archiving')); // set the value of the progress bar based on availability progress - updateProgressBars($backupRow.find('.progress-bar'), backup.availabilityProgress); + updateProgressBars($backupRow.find('.progress-bar'), backup.availabilityProgress * 100); } else if (backup.id == data.status.recoveringBackupId) { // add a progress bar to the status row for recovery $backupRow.find('td.backup-status').html(progressBarHTML('recovery', 'Restoring')); @@ -179,22 +190,29 @@ $(document).ready(function(){ } $backupRow.find('td.' + ACTION_MENU_CLASS + ' .dropdown').toggle(backup.isAvailable); + + $backupRow.addClass(ACTIVE_BACKUP_ROW_CLASS); } var automaticRows = ""; if (automaticBackups.length > 0) { for (var backupIndex in automaticBackups) { - updateOrAddTableRow(automaticBackups[backupIndex], AUTOMATIC_ARCHIVES_TBODY_ID) + updateOrAddTableRow(automaticBackups[backupIndex], AUTOMATIC_ARCHIVES_TBODY_ID); + } } if (manualBackups.length > 0) { for (var backupIndex in manualBackups) { - updateOrAddTableRow(manualBackups[backupIndex], MANUAL_ARCHIVES_TBODY_ID) + updateOrAddTableRow(manualBackups[backupIndex], MANUAL_ARCHIVES_TBODY_ID); } } + // at this point, any rows that no longer have the ACTIVE_BACKUP_ROW_CLASS + // are deleted backups, so we remove them from the table + $('tbody tr:not(.' + ACTIVE_BACKUP_ROW_CLASS + ')').remove(); + // check if the restore action on all rows should be enabled or disabled $('.' + BACKUP_RESTORE_LINK_CLASS).parent().toggleClass('disabled', data.status.isRecovering); @@ -204,12 +222,15 @@ $(document).ready(function(){ // update the progress bars for current restore status if (data.status.isRecovering) { - updateProgressBars($('.recovery.progress-bar'), data.status.recoveryProgress); + updateProgressBars($('.recovery.progress-bar'), data.status.recoveryProgress * 100); } // tell bootstrap sortable to update for the new rows $.bootstrapSortable({ applyLast: true }); + $('#' + CONTENT_ARCHIVES_NORMAL_ID).toggle(true); + $('#' + CONTENT_ARCHIVES_ERROR_ID).toggle(false); + }).fail(function(){ // we've hit the very rare case where we couldn't load the list of backups from the domain server @@ -219,11 +240,8 @@ $(document).ready(function(){ // replace the content archives panel with a simple error message // stating that the user should reload the page - $('#' + Settings.CONTENT_ARCHIVES_PANEL_ID + ' .panel-body').html( - "
" + - "There was a problem loading your list of automatic and manual content archives. Please reload the page to try again." + - "
" - ); + $('#' + CONTENT_ARCHIVES_NORMAL_ID).toggle(false); + $('#' + CONTENT_ARCHIVES_ERROR_ID).toggle(true); }).always(function(){ // toggle showing or hiding the tables depending on if they have entries @@ -377,6 +395,6 @@ $(document).ready(function(){ reloadBackupInformation(); // setup a timer to reload them every 5 seconds - setTimeout(reloadBackupInformation(), 5000); + setInterval(reloadBackupInformation, 5000); }; }); diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index a3f99facea..cd7155d9da 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -1356,7 +1356,7 @@ QJsonObject DomainServerSettingsManager::settingsResponseObjectForType(const QSt BLOCKING_INVOKE_METHOD(this, "settingsResponseObjectForType", Q_RETURN_ARG(QJsonObject, responseObject), - Q_ARG(const QString&, typeValue), + Q_ARG(QString, typeValue), Q_ARG(bool, isAuthenticated), Q_ARG(bool, includeDomainSettings), Q_ARG(bool, includeContentSettings), @@ -1374,6 +1374,7 @@ QJsonObject DomainServerSettingsManager::settingsResponseObjectForType(const QSt // only enumerate the requested settings type (domain setting or content setting) QJsonArray* filteredDescriptionArray = &_descriptionArray; + if (includeDomainSettings && !includeContentSettings) { filteredDescriptionArray = &_domainSettingsDescription; } else if (includeContentSettings && !includeDomainSettings) {