diff --git a/gui/default/index.html b/gui/default/index.html index fb7d644b3..e49d8ffc4 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -750,7 +750,6 @@ - diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 3bbc9cf4a..22e239e2b 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -637,6 +637,16 @@ angular.module('syncthing.core') $scope.remoteNeedDevice = undefined; } + function saveIgnores(ignores, cb) { + $http.post(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id), { + ignore: ignores + }).success(function () { + if (cb) { + cb(); + } + }); + }; + $scope.neededPageChanged = function (page) { $scope.neededCurrentPage = page; refreshNeed($scope.neededFolder); @@ -1150,7 +1160,9 @@ angular.module('syncthing.core') $scope.tmpOptions.upgrades = "candidate"; } $scope.tmpGUI = angular.copy($scope.config.gui); - $('#settings').modal(); + $('#settings').modal().on('hidden.bs.modal', function () { + window.location.hash = ""; + }); }; $scope.saveConfig = function (cb) { @@ -1512,8 +1524,16 @@ angular.module('syncthing.core') $scope.editFolderModal = function () { $scope.folderPathErrors = {}; $scope.folderEditor.$setPristine(); - $('#editIgnores textarea').val(""); - $('#editFolder').modal(); + $('#editFolder').modal().on({ + 'shown.bs.tab': function (e) { + if (e.target.attributes.href.value === "#folder-ignores") { + $('#folder-ignores textarea').focus(); + } + }, + 'hidden.bs.modal': function () { + window.location.hash = ""; + } + }); }; $scope.editFolder = function (folderCfg) { @@ -1560,6 +1580,17 @@ angular.module('syncthing.core') } $scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || ""; + $('#folder-ignores textarea').val(""); + $('#folder-ignores textarea').attr('disabled', 'disabled'); + $http.get(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id)) + .success(function (data) { + $scope.currentFolder.ignores = data.ignore || []; + $('#folder-ignores textarea').val($scope.currentFolder.ignores.join('\n')); + }) + .then(function () { + $('#folder-ignores textarea').removeAttr('disabled'); + }); + $scope.editFolderModal(); }; @@ -1568,6 +1599,8 @@ angular.module('syncthing.core') $scope.editingExisting = false; $scope.currentFolder = angular.copy($scope.folderDefaults); $scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase(); + $('#folder-ignores textarea').val(""); + $('#folder-ignores textarea').removeAttr('disabled'); $scope.editFolderModal(); }); }; @@ -1582,7 +1615,8 @@ angular.module('syncthing.core') importFromOtherDevice: true }; $scope.currentFolder.selectedDevices[device] = true; - + $('#folder-ignores textarea').val(""); + $('#folder-ignores textarea').removeAttr('disabled'); $scope.editFolderModal(); }; @@ -1654,21 +1688,30 @@ angular.module('syncthing.core') delete folderCfg.versioning; } - var ignores = $('#editIgnores textarea').val().trim(); - if (!$scope.editingExisting && ignores) { + var ignores = $('#folder-ignores textarea').val().split('\n'); + // Split always returns a minimum 1-length array even for no patterns + if (ignores.length === 1 && ignores[0] === "") { + ignores = []; + } + if (!$scope.editingExisting && ignores.length) { folderCfg.paused = true; }; $scope.folders[folderCfg.id] = folderCfg; $scope.config.folders = folderList($scope.folders); + if ($scope.editingExisting && ignores !== folderCfg.ignores) { + saveIgnores(ignores); + }; + $scope.saveConfig(function () { - if (!$scope.editingExisting && ignores) { - $scope.saveIgnores(function () { + if (!$scope.editingExisting && ignores.length) { + saveIgnores(ignores, function () { $scope.setFolderPause(folderCfg.id, false); }); } }); + }; $scope.dismissFolderRejection = function (folder, device) { @@ -1724,27 +1767,6 @@ angular.module('syncthing.core') $scope.saveConfig(); }; - $scope.editIgnores = function () { - if (!$scope.editingExisting) { - return; - } - - $('#editIgnoresButton').attr('disabled', 'disabled'); - $http.get(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id)) - .success(function (data) { - data.ignore = data.ignore || []; - var textArea = $('#editIgnores textarea'); - textArea.val(data.ignore.join('\n')); - $('#editIgnores').modal() - .one('shown.bs.modal', function () { - textArea.focus(); - }); - }) - .then(function () { - $('#editIgnoresButton').removeAttr('disabled'); - }); - }; - function resetRestoreVersions() { $scope.restoreVersions = { folder: null, @@ -1972,30 +1994,6 @@ angular.module('syncthing.core') }); }); - $scope.editIgnoresOnAddingFolder = function () { - if ($scope.editingExisting) { - return; - } - - if ($scope.currentFolder.path.endsWith($scope.system.pathSeparator)) { - $scope.currentFolder.path = $scope.currentFolder.path.slice(0, -1); - }; - $('#editIgnores').modal().one('shown.bs.modal', function () { - textArea.focus(); - }); - }; - - - $scope.saveIgnores = function (cb) { - $http.post(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id), { - ignore: $('#editIgnores textarea').val().split('\n') - }).success(function () { - if (cb) { - cb(); - } - }); - }; - $scope.setAPIKey = function (cfg) { $http.get(urlbase + '/svc/random/string?length=32').success(function (data) { cfg.apiKey = data.random; diff --git a/gui/default/syncthing/folder/editFolderModalView.html b/gui/default/syncthing/folder/editFolderModalView.html index cc2aab45e..3e559bafa 100644 --- a/gui/default/syncthing/folder/editFolderModalView.html +++ b/gui/default/syncthing/folder/editFolderModalView.html @@ -1,8 +1,14 @@