From 695d2512a767ef5417174d46eb030d69bf2451fe Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 26 Mar 2025 16:57:51 +0100 Subject: [PATCH] Fixed persisted version to work with ngax --- .../ngax/scripts/controllers/AppController.js | 5 +++- .../scripts/controllers/HomeController.js | 8 +++-- .../ngax/scripts/services/BackupList.js | 10 +++++++ .../ngax/scripts/services/ServerStatus.js | 2 +- .../Server/webroot/ngax/templates/home.html | 29 ++++++++++++------- .../WebserverCore/Endpoints/V1/Backups.cs | 2 +- 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/AppController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/AppController.js index 919c1f741..a9e18fb2a 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/AppController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/AppController.js @@ -1,4 +1,4 @@ -backupApp.controller('AppController', function($scope, $cookies, $location, AppService, BrandingService, ServerStatus, SystemInfo, AppUtils, DialogService, gettextCatalog) { +backupApp.controller('AppController', function($rootScope, $scope, $cookies, $location, AppService, BrandingService, ServerStatus, SystemInfo, AppUtils, DialogService, gettextCatalog) { $scope.brandingService = BrandingService.watch($scope); $scope.state = ServerStatus.watch($scope); $scope.systemInfo = SystemInfo.watch($scope); @@ -177,6 +177,9 @@ backupApp.controller('AppController', function($scope, $cookies, $location, AppS var dt = data.data['max-download-speed']; $scope.throttle_active = (ut != null && ut.trim().length != 0) || (dt != null && dt.trim().length != 0); + ServerStatus.state.orderBy = data.data['backup-list-sort-order'] || 'id'; + $rootScope.$broadcast('sortorder_changed', { orderBy: ServerStatus.state.orderBy } ); + var has_asked = AppUtils.parseBoolString(data.data['has-asked-for-password-change']); var autogen_passphrase = AppUtils.parseBoolString(data.data['autogenerated-passphrase']); if (!has_asked && autogen_passphrase) { diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/HomeController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/HomeController.js index d75b32fe0..a8e9c8f71 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/HomeController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/HomeController.js @@ -8,7 +8,7 @@ backupApp.controller('HomeController', function ($scope, $location, ServerStatus return ServerStatus.state.orderBy; } - $scope.orderBy = $scope.orderByFromState(); + $scope.orderBy = null; $scope.openFolderContext = function(path) { BackupList.getFolderContext(path).then(function(context) { @@ -74,10 +74,14 @@ backupApp.controller('HomeController', function ($scope, $location, ServerStatus $scope.doApplyOrder = function (orderby) { - console.log('doapplyorder'); ServerStatus.state.orderBy = orderby; + AppService.patch('/serversettings', { 'backup-list-sort-order': orderby }); BackupList.reload(); }; + $scope.$on('sortorder_changed', function() { + $scope.orderBy = $scope.orderByFromState(); + }); + $scope.formatDuration = AppUtils.formatDuration; }); diff --git a/Duplicati/Server/webroot/ngax/scripts/services/BackupList.js b/Duplicati/Server/webroot/ngax/scripts/services/BackupList.js index 20ac788a5..8a82f95fc 100644 --- a/Duplicati/Server/webroot/ngax/scripts/services/BackupList.js +++ b/Duplicati/Server/webroot/ngax/scripts/services/BackupList.js @@ -1,6 +1,7 @@ backupApp.service('BackupList', function($rootScope, $timeout, AppService, AppUtils, ServerStatus, $http) { var list = []; var lookup = {}; + var activeLoad = false; this.list = list; this.lookup = lookup; @@ -35,6 +36,12 @@ backupApp.service('BackupList', function($rootScope, $timeout, AppService, AppUt }; this.reload = function() { + // Wait until we know the sort order + if (ServerStatus.state.orderBy == null || activeLoad) + return; + + // Prevent flickering + activeLoad = true; AppService.get('/backups?orderby='+ (ServerStatus.state.orderBy || '')).then(function(data) { list.length = 0; @@ -48,6 +55,8 @@ backupApp.service('BackupList', function($rootScope, $timeout, AppService, AppUt } updateNextRunStamp(); + }).finally(function() { + activeLoad = false; }); }; @@ -63,4 +72,5 @@ backupApp.service('BackupList', function($rootScope, $timeout, AppService, AppUt $rootScope.$on('serverstatechanged.lastDataUpdateId', this.reload); $rootScope.$on('serverstatechanged.proposedSchedule', updateNextRunStamp); + $rootScope.$on('sortorder_changed', this.reload); }); diff --git a/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js b/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js index 50ed4fcc7..e55fc2a5d 100644 --- a/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js +++ b/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js @@ -25,7 +25,7 @@ backupApp.service('ServerStatus', function ($rootScope, $timeout, AppService, Ap updateDownloadProgress: 0, proposedSchedule: [], schedulerQueueIds: [], - orderBy: 'id' + orderBy: null }; this.state = state; diff --git a/Duplicati/Server/webroot/ngax/templates/home.html b/Duplicati/Server/webroot/ngax/templates/home.html index 28b4474e8..58fe8bc99 100644 --- a/Duplicati/Server/webroot/ngax/templates/home.html +++ b/Duplicati/Server/webroot/ngax/templates/home.html @@ -3,16 +3,25 @@
-
- - +
+ +
diff --git a/Duplicati/WebserverCore/Endpoints/V1/Backups.cs b/Duplicati/WebserverCore/Endpoints/V1/Backups.cs index 72c2c2bb0..f5dcd58a8 100644 --- a/Duplicati/WebserverCore/Endpoints/V1/Backups.cs +++ b/Duplicati/WebserverCore/Endpoints/V1/Backups.cs @@ -82,7 +82,7 @@ public class Backups : IEndpointV1 , "nextrun" => x => x.Schedule?.Time, "schedule" => x => string.IsNullOrWhiteSpace(x.Schedule?.Repeat), - "destination" => x => Library.Utility.Utility.GuessScheme(x.Backup.TargetURL), + "backend" => x => Library.Utility.Utility.GuessScheme(x.Backup.TargetURL), _ => null };