Squashed commit of pull request #1981

Conflicts:
	gui/scripts/syncthing/core/controllers/syncthingController.js
	internal/auto/gui.files.go
This commit is contained in:
Jakob Borg 2015-07-20 14:48:03 +02:00
parent 43d6322d0f
commit 1836ef2884
3 changed files with 53 additions and 59 deletions

View File

@ -49,7 +49,7 @@
</a> </a>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog" aria-label="Edit"></span>&nbsp;<span translate>Actions</span><span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span>&nbsp;<span translate>Actions</span> <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="" ng-click="editSettings()"><span class="glyphicon glyphicon-cog"></span>&nbsp;<span translate>Settings</span></a></li> <li><a href="" ng-click="editSettings()"><span class="glyphicon glyphicon-cog"></span>&nbsp;<span translate>Settings</span></a></li>
<li><a href="" ng-click="idDevice()"><span class="glyphicon glyphicon-qrcode"></span>&nbsp;<span translate>Show ID</span></a></li> <li><a href="" ng-click="idDevice()"><span class="glyphicon glyphicon-qrcode"></span>&nbsp;<span translate>Show ID</span></a></li>
@ -343,7 +343,7 @@
</tr> </tr>
<tr> <tr>
<th><span class="glyphicon glyphicon-home"></span>&nbsp;<span translate>Local State (Total)</span></th> <th><span class="glyphicon glyphicon-home"></span>&nbsp;<span translate>Local State (Total)</span></th>
<td class="text-right">{{foldersTotalLocalFiles | alwaysNumber}} <span translate>items</span>, ~{{ foldersTotalLocalBytes | binary}}B</td> <td class="text-right">{{localStateTotal.files | alwaysNumber}} <span translate>items</span>, ~{{localStateTotal.bytes | binary}}B</td>
</tr> </tr>
<tr> <tr>
<th><span class="glyphicon glyphicon-th"></span>&nbsp;<span translate>RAM Utilization</span></th> <th><span class="glyphicon glyphicon-th"></span>&nbsp;<span translate>RAM Utilization</span></th>
@ -579,7 +579,7 @@
<input ng-disabled="currentDevice.deviceID == myID" id="addresses" class="form-control" type="text" ng-model="currentDevice._addressesStr"></input> <input ng-disabled="currentDevice.deviceID == myID" id="addresses" class="form-control" type="text" ng-model="currentDevice._addressesStr"></input>
<p translate class="help-block">Enter comma separated addresses ("ip:port", "host:port") or "dynamic" to perform automatic discovery of the address.</p> <p translate class="help-block">Enter comma separated addresses ("ip:port", "host:port") or "dynamic" to perform automatic discovery of the address.</p>
</div> </div>
<div ng-if="!editingSelf" class="form-group"> <div class="form-group">
<label translate>Compression</label> <label translate>Compression</label>
<select class="form-control" ng-model="currentDevice.compression"> <select class="form-control" ng-model="currentDevice.compression">
<option value="always" translate>All Data</option> <option value="always" translate>All Data</option>
@ -587,7 +587,7 @@
<option value="never" translate>Off</option> <option value="never" translate>Off</option>
</select> </select>
</div> </div>
<div ng-if="!editingSelf" class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
<label> <label>
<input type="checkbox" ng-model="currentDevice.introducer"> <span translate>Introducer</span> <input type="checkbox" ng-model="currentDevice.introducer"> <span translate>Introducer</span>
@ -596,7 +596,7 @@
</div> </div>
</div> </div>
<div class="row" ng-if="!editingSelf"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label translate for="folders">Share Folders With Device</label> <label translate for="folders">Share Folders With Device</label>
@ -619,7 +619,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary btn-sm" ng-click="saveDevice()" ng-disabled="deviceEditor.$invalid"><span class="glyphicon glyphicon-ok"></span>&nbsp;<span translate>Save</span></button> <button type="button" class="btn btn-primary btn-sm" ng-click="saveDevice()" ng-disabled="deviceEditor.$invalid"><span class="glyphicon glyphicon-ok"></span>&nbsp;<span translate>Save</span></button>
<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>&nbsp;<span translate>Close</span></button> <button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>&nbsp;<span translate>Close</span></button>
<button ng-if="editingExisting && !editingSelf" type="button" class="btn btn-danger pull-left btn-sm" ng-click="deleteDevice()"><span class="glyphicon glyphicon-minus"></span>&nbsp;<span translate>Delete</span></button> <button ng-if="editingExisting" type="button" class="btn btn-danger pull-left btn-sm" ng-click="deleteDevice()"><span class="glyphicon glyphicon-minus"></span>&nbsp;<span translate>Delete</span></button>
</div> </div>
</div> </div>
</div> </div>
@ -787,7 +787,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary btn-sm" ng-click="saveFolder()" ng-disabled="folderEditor.$invalid"><span class="glyphicon glyphicon-ok"></span>&nbsp;<span translate>Save</span></button> <button type="button" class="btn btn-primary btn-sm" ng-click="saveFolder()" ng-disabled="folderEditor.$invalid"><span class="glyphicon glyphicon-ok"></span>&nbsp;<span translate>Save</span></button>
<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>&nbsp;<span translate>Close</span></button> <button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>&nbsp;<span translate>Close</span></button>
<button ng-if="editingExisting" type="button" class="btn btn-danger pull-left btn-sm" ng-click="deleteFolder()"><span class="glyphicon glyphicon-minus"></span>&nbsp;<span translate>Delete</span></button> <button ng-if="editingExisting" type="button" class="btn btn-danger pull-left btn-sm" ng-click="deleteFolder(currentFolder.id)"><span class="glyphicon glyphicon-minus"></span>&nbsp;<span translate>Delete</span></button>
<button id="editIgnoresButton" ng-if="editingExisting" type="button" class="btn btn-default pull-left btn-sm" ng-click="editIgnores()"><span class="glyphicon glyphicon-eye-close"></span>&nbsp;<span translate>Ignore Patterns</span></button> <button id="editIgnoresButton" ng-if="editingExisting" type="button" class="btn btn-default pull-left btn-sm" ng-click="editIgnores()"><span class="glyphicon glyphicon-eye-close"></span>&nbsp;<span translate>Ignore Patterns</span></button>
</div> </div>
</div> </div>

View File

@ -44,13 +44,16 @@ angular.module('syncthing.core')
$scope.neededTotal = 0; $scope.neededTotal = 0;
$scope.neededCurrentPage = 1; $scope.neededCurrentPage = 1;
$scope.neededPageSize = 10; $scope.neededPageSize = 10;
$scope.foldersTotalLocalBytes = 0;
$scope.foldersTotalLocalFiles = 0;
$scope.failed = {}; $scope.failed = {};
$scope.failedCurrentPage = 1; $scope.failedCurrentPage = 1;
$scope.failedCurrentFolder = undefined; $scope.failedCurrentFolder = undefined;
$scope.failedPageSize = 10; $scope.failedPageSize = 10;
$scope.localStateTotal = {
bytes: 0,
files: 0
};
$(window).bind('beforeunload', function () { $(window).bind('beforeunload', function () {
navigatingAway = true; navigatingAway = true;
}); });
@ -265,6 +268,7 @@ angular.module('syncthing.core')
$scope.$on(Events.FOLDER_SUMMARY, function (event, arg) { $scope.$on(Events.FOLDER_SUMMARY, function (event, arg) {
var data = arg.data; var data = arg.data;
$scope.model[data.folder] = data.summary; $scope.model[data.folder] = data.summary;
recalcLocalStateTotal();
}); });
$scope.$on(Events.FOLDER_COMPLETION, function (event, arg) { $scope.$on(Events.FOLDER_COMPLETION, function (event, arg) {
@ -303,6 +307,7 @@ angular.module('syncthing.core')
debouncedFuncs[key] = debounce(function () { debouncedFuncs[key] = debounce(function () {
$http.get(urlbase + '/db/status?folder=' + encodeURIComponent(folder)).success(function (data) { $http.get(urlbase + '/db/status?folder=' + encodeURIComponent(folder)).success(function (data) {
$scope.model[folder] = data; $scope.model[folder] = data;
recalcLocalStateTotal();
console.log("refreshFolder", folder, data); console.log("refreshFolder", folder, data);
}).error($scope.emitHTTPError); }).error($scope.emitHTTPError);
}, 1000, true); }, 1000, true);
@ -350,18 +355,23 @@ angular.module('syncthing.core')
} }
$scope.announceServersFailed = failed; $scope.announceServersFailed = failed;
$scope.foldersTotalLocalBytes = 0;
$scope.foldersTotalLocalFiles = 0;
for (var f in $scope.model) {
$scope.foldersTotalLocalBytes += $scope.model[f].localBytes;
$scope.foldersTotalLocalFiles += $scope.model[f].localFiles;
};
console.log("refreshSystem", data); console.log("refreshSystem", data);
}).error($scope.emitHTTPError); }).error($scope.emitHTTPError);
} }
function recalcLocalStateTotal () {
$scope.localStateTotal = {
bytes: 0,
files: 0
};
for (var f in $scope.model) {
$scope.localStateTotal.bytes += $scope.model[f].localBytes;
$scope.localStateTotal.files += $scope.model[f].localFiles;
}
}
function refreshCompletion(device, folder) { function refreshCompletion(device, folder) {
if (device === $scope.myID) { if (device === $scope.myID) {
return; return;
@ -599,18 +609,6 @@ angular.module('syncthing.core')
return Math.floor(pct); return Math.floor(pct);
}; };
$scope.deviceIcon = function (deviceCfg) {
if ($scope.connections[deviceCfg.deviceID]) {
if ($scope.completion[deviceCfg.deviceID] && $scope.completion[deviceCfg.deviceID]._total === 100) {
return 'ok';
} else {
return 'refresh';
}
}
return 'minus';
};
$scope.deviceStatus = function (deviceCfg) { $scope.deviceStatus = function (deviceCfg) {
if ($scope.deviceFolders(deviceCfg).length === 0) { if ($scope.deviceFolders(deviceCfg).length === 0) {
return 'unused'; return 'unused';
@ -812,14 +810,11 @@ angular.module('syncthing.core')
$scope.editDevice = function (deviceCfg) { $scope.editDevice = function (deviceCfg) {
$scope.currentDevice = $.extend({}, deviceCfg); $scope.currentDevice = $.extend({}, deviceCfg);
$scope.editingExisting = true; $scope.editingExisting = true;
$scope.editingSelf = (deviceCfg.deviceID == $scope.myID);
$scope.currentDevice._addressesStr = deviceCfg.addresses.join(', '); $scope.currentDevice._addressesStr = deviceCfg.addresses.join(', ');
if (!$scope.editingSelf) {
$scope.currentDevice.selectedFolders = {}; $scope.currentDevice.selectedFolders = {};
$scope.deviceFolders($scope.currentDevice).forEach(function (folder) { $scope.deviceFolders($scope.currentDevice).forEach(function (folder) {
$scope.currentDevice.selectedFolders[folder] = true; $scope.currentDevice.selectedFolders[folder] = true;
}); });
}
$scope.deviceEditor.$setPristine(); $scope.deviceEditor.$setPristine();
$('#editDevice').modal(); $('#editDevice').modal();
}; };
@ -841,7 +836,6 @@ angular.module('syncthing.core')
selectedFolders: {} selectedFolders: {}
}; };
$scope.editingExisting = false; $scope.editingExisting = false;
$scope.editingSelf = false;
$scope.deviceEditor.$setPristine(); $scope.deviceEditor.$setPristine();
$('#editDevice').modal(); $('#editDevice').modal();
}); });
@ -916,7 +910,6 @@ angular.module('syncthing.core')
return id !== deviceCfg.deviceID; return id !== deviceCfg.deviceID;
}); });
if (!$scope.editingSelf) {
for (var id in deviceCfg.selectedFolders) { for (var id in deviceCfg.selectedFolders) {
if (deviceCfg.selectedFolders[id]) { if (deviceCfg.selectedFolders[id]) {
var found = false; var found = false;
@ -938,7 +931,6 @@ angular.module('syncthing.core')
}); });
} }
} }
}
$scope.saveConfig(); $scope.saveConfig();
}; };
@ -1208,14 +1200,16 @@ angular.module('syncthing.core')
return folders; return folders;
}; };
$scope.deleteFolder = function () { $scope.deleteFolder = function (id) {
$('#editFolder').modal('hide'); $('#editFolder').modal('hide');
if (!$scope.editingExisting) { if (!$scope.editingExisting) {
return; return;
} }
delete $scope.folders[$scope.currentFolder.id]; delete $scope.folders[id];
delete $scope.model[id];
$scope.config.folders = folderList($scope.folders); $scope.config.folders = folderList($scope.folders);
recalcLocalStateTotal();
$scope.saveConfig(); $scope.saveConfig();
}; };

File diff suppressed because one or more lines are too long