mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
gui, lib/config: Add default path for new folders (fixes #2157)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4192
This commit is contained in:
parent
0ad10b0fee
commit
a04b92332f
@ -74,7 +74,8 @@ angular.module('syncthing.core')
|
||||
staggeredCleanInterval: 3600,
|
||||
staggeredVersionsPath: "",
|
||||
externalCommand: "",
|
||||
autoNormalize: true
|
||||
autoNormalize: true,
|
||||
path: ""
|
||||
};
|
||||
|
||||
$scope.localStateTotal = {
|
||||
@ -606,6 +607,21 @@ angular.module('syncthing.core')
|
||||
$scope.neededTotal = data.total;
|
||||
}
|
||||
|
||||
function pathJoin(base, name) {
|
||||
base = expandTilde(base);
|
||||
if (base[base.length - 1] !== $scope.system.pathSeparator) {
|
||||
return base + $scope.system.pathSeparator + name;
|
||||
}
|
||||
return base + name;
|
||||
}
|
||||
|
||||
function expandTilde(path) {
|
||||
if (path && path.trim().charAt(0) === '~') {
|
||||
return $scope.system.tilde + path.trim().substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
$scope.neededPageChanged = function (page) {
|
||||
$scope.neededCurrentPage = page;
|
||||
refreshNeed($scope.neededFolder);
|
||||
@ -1360,9 +1376,10 @@ angular.module('syncthing.core')
|
||||
$scope.directoryList = [];
|
||||
|
||||
$scope.$watch('currentFolder.path', function (newvalue) {
|
||||
if (newvalue && newvalue.trim().charAt(0) === '~') {
|
||||
$scope.currentFolder.path = $scope.system.tilde + newvalue.trim().substring(1);
|
||||
if (!newvalue) {
|
||||
return;
|
||||
}
|
||||
$scope.currentFolder.path = expandTilde(newvalue);
|
||||
$http.get(urlbase + '/system/browse', {
|
||||
params: { current: newvalue }
|
||||
}).success(function (data) {
|
||||
@ -1370,6 +1387,20 @@ angular.module('syncthing.core')
|
||||
}).error($scope.emitHTTPError);
|
||||
});
|
||||
|
||||
$scope.$watch('currentFolder.label', function (newvalue) {
|
||||
if (!$scope.config.options || !$scope.config.options.defaultFolderPath || $scope.editingExisting || !$scope.folderEditor.folderPath.$pristine || !newvalue) {
|
||||
return;
|
||||
}
|
||||
$scope.currentFolder.path = pathJoin($scope.config.options.defaultFolderPath, newvalue);
|
||||
});
|
||||
|
||||
$scope.$watch('currentFolder.id', function (newvalue) {
|
||||
if (!$scope.config.options || !$scope.config.options.defaultFolderPath || !$scope.folderEditor.folderPath.$pristine || !newvalue || $scope.currentFolder.label) {
|
||||
return;
|
||||
}
|
||||
$scope.currentFolder.path = pathJoin($scope.config.options.defaultFolderPath, newvalue);
|
||||
});
|
||||
|
||||
$scope.loadFormIntoScope = function (form) {
|
||||
console.log('loadFormIntoScope',form.$name);
|
||||
switch (form.$name) {
|
||||
@ -1394,6 +1425,7 @@ angular.module('syncthing.core')
|
||||
};
|
||||
|
||||
$scope.editFolder = function (folderCfg) {
|
||||
$scope.editingExisting = true;
|
||||
$scope.currentFolder = angular.copy(folderCfg);
|
||||
if ($scope.currentFolder.path.slice(-1) === $scope.system.pathSeparator) {
|
||||
$scope.currentFolder.path = $scope.currentFolder.path.slice(0, -1);
|
||||
@ -1436,21 +1468,21 @@ angular.module('syncthing.core')
|
||||
}
|
||||
$scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || "";
|
||||
|
||||
$scope.editingExisting = true;
|
||||
$scope.editFolderModal();
|
||||
};
|
||||
|
||||
$scope.addFolder = function () {
|
||||
$http.get(urlbase + '/svc/random/string?length=10').success(function (data) {
|
||||
$scope.editingExisting = false;
|
||||
$scope.currentFolder = angular.copy($scope.folderDefaults);
|
||||
$scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase();
|
||||
$scope.editingExisting = false;
|
||||
$scope.editFolderModal();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addFolderAndShare = function (folder, folderLabel, device) {
|
||||
$scope.dismissFolderRejection(folder, device);
|
||||
$scope.editingExisting = false;
|
||||
$scope.currentFolder = angular.copy($scope.folderDefaults);
|
||||
$scope.currentFolder.id = folder;
|
||||
$scope.currentFolder.label = folderLabel;
|
||||
@ -1459,7 +1491,6 @@ angular.module('syncthing.core')
|
||||
};
|
||||
$scope.currentFolder.selectedDevices[device] = true;
|
||||
|
||||
$scope.editingExisting = false;
|
||||
$scope.editFolderModal();
|
||||
};
|
||||
|
||||
|
@ -73,6 +73,7 @@ func TestDefaultValues(t *testing.T) {
|
||||
KCPSendWindowSize: 128,
|
||||
KCPUpdateIntervalMs: 25,
|
||||
KCPFastResend: false,
|
||||
DefaultFolderPath: "~",
|
||||
}
|
||||
|
||||
cfg := New(device1)
|
||||
@ -221,6 +222,7 @@ func TestOverriddenValues(t *testing.T) {
|
||||
KCPSendWindowSize: 1280,
|
||||
KCPUpdateIntervalMs: 1000,
|
||||
KCPFastResend: true,
|
||||
DefaultFolderPath: "/media/syncthing",
|
||||
}
|
||||
|
||||
os.Unsetenv("STNOUPGRADE")
|
||||
|
@ -140,6 +140,7 @@ type OptionsConfiguration struct {
|
||||
KCPCongestionControl bool `xml:"kcpCongestionControl" json:"kcpCongestionControl" default:"true"`
|
||||
KCPSendWindowSize int `xml:"kcpSendWindowSize" json:"kcpSendWindowSize" default:"128"`
|
||||
KCPReceiveWindowSize int `xml:"kcpReceiveWindowSize" json:"kcpReceiveWindowSize" default:"128"`
|
||||
DefaultFolderPath string `xml:"defaultFolderPath" json:"defaultFolderPath" default:"~"`
|
||||
|
||||
DeprecatedUPnPEnabled bool `xml:"upnpEnabled,omitempty" json:"-"`
|
||||
DeprecatedUPnPLeaseM int `xml:"upnpLeaseMinutes,omitempty" json:"-"`
|
||||
|
13
lib/config/testdata/overridenvalues.xml
vendored
13
lib/config/testdata/overridenvalues.xml
vendored
@ -38,11 +38,12 @@
|
||||
<stunKeepaliveSeconds>10</stunKeepaliveSeconds>
|
||||
<stunServer>a.stun.com</stunServer>
|
||||
<stunServer>b.stun.com</stunServer>
|
||||
<defaultKCPEnabled>true</defaultKCPEnabled>
|
||||
<kcpCongestionControl>false</kcpCongestionControl>
|
||||
<kcpReceiveWindowSize>1280</kcpReceiveWindowSize>
|
||||
<kcpSendWindowSize>1280</kcpSendWindowSize>
|
||||
<kcpUpdateIntervalMs>1000</kcpUpdateIntervalMs>
|
||||
<kcpFastResend>true</kcpFastResend>
|
||||
<defaultKCPEnabled>true</defaultKCPEnabled>
|
||||
<kcpCongestionControl>false</kcpCongestionControl>
|
||||
<kcpReceiveWindowSize>1280</kcpReceiveWindowSize>
|
||||
<kcpSendWindowSize>1280</kcpSendWindowSize>
|
||||
<kcpUpdateIntervalMs>1000</kcpUpdateIntervalMs>
|
||||
<kcpFastResend>true</kcpFastResend>
|
||||
<defaultFolderPath>/media/syncthing</defaultFolderPath>
|
||||
</options>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user