cmd/syncthing: Add more stats to usage reports (ref #3628)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4347
This commit is contained in:
committed by
Jakob Borg
parent
813e6ddf83
commit
2760d032ca
@@ -1,6 +1,8 @@
|
||||
angular.module('syncthing.core')
|
||||
.directive('modal', function () {
|
||||
return {
|
||||
// If you ever change any of the petroglyphs below, please search for $parent.$parent,
|
||||
// as some templates rely on the way scope is composed in this case.
|
||||
restrict: 'E',
|
||||
templateUrl: 'modal.html',
|
||||
replace: true,
|
||||
|
||||
@@ -33,6 +33,8 @@ angular.module('syncthing.core')
|
||||
$scope.folderRejections = {};
|
||||
$scope.protocolChanged = false;
|
||||
$scope.reportData = {};
|
||||
$scope.reportDataPreview = {};
|
||||
$scope.reportDataPreviewVersion = '';
|
||||
$scope.reportPreview = false;
|
||||
$scope.folders = {};
|
||||
$scope.seenError = '';
|
||||
@@ -133,7 +135,11 @@ angular.module('syncthing.core')
|
||||
}).error($scope.emitHTTPError);
|
||||
|
||||
$http.get(urlbase + '/svc/report').success(function (data) {
|
||||
$scope.reportData = data;
|
||||
$scope.reportDataPreview = $scope.reportData = data;
|
||||
if ($scope.system && $scope.config.options.urSeen < $scope.system.urVersionMax) {
|
||||
// Usage reporting format has changed, prompt the user to re-accept.
|
||||
$('#ur').modal();
|
||||
}
|
||||
}).error($scope.emitHTTPError);
|
||||
|
||||
$http.get(urlbase + '/system/upgrade').success(function (data) {
|
||||
@@ -376,6 +382,7 @@ angular.module('syncthing.core')
|
||||
$scope.config = config;
|
||||
$scope.config.options._listenAddressesStr = $scope.config.options.listenAddresses.join(', ');
|
||||
$scope.config.options._globalAnnounceServersStr = $scope.config.options.globalAnnounceServers.join(', ');
|
||||
$scope.config.options._urAcceptedStr = "" + $scope.config.options.urAccepted;
|
||||
|
||||
$scope.devices = $scope.config.devices;
|
||||
$scope.devices.forEach(function (deviceCfg) {
|
||||
@@ -412,6 +419,10 @@ angular.module('syncthing.core')
|
||||
$scope.myID = data.myID;
|
||||
$scope.system = data;
|
||||
|
||||
if ($scope.reportDataPreviewVersion === '') {
|
||||
$scope.reportDataPreviewVersion = $scope.system.urVersionMax;
|
||||
}
|
||||
|
||||
var listenersFailed = [];
|
||||
for (var address in data.connectionServiceStatus) {
|
||||
if (data.connectionServiceStatus[address].error) {
|
||||
@@ -1058,7 +1069,6 @@ angular.module('syncthing.core')
|
||||
$scope.editSettings = function () {
|
||||
// Make a working copy
|
||||
$scope.tmpOptions = angular.copy($scope.config.options);
|
||||
$scope.tmpOptions.urEnabled = ($scope.tmpOptions.urAccepted > 0);
|
||||
$scope.tmpOptions.deviceName = $scope.thisDevice().name;
|
||||
$scope.tmpOptions.upgrades = "none";
|
||||
if ($scope.tmpOptions.autoUpgradeIntervalH > 0) {
|
||||
@@ -1088,18 +1098,31 @@ angular.module('syncthing.core')
|
||||
}).error($scope.emitHTTPError);
|
||||
};
|
||||
|
||||
$scope.urVersions = function() {
|
||||
var result = [];
|
||||
if ($scope.system) {
|
||||
for (var i = $scope.system.urVersionMax; i >= 2; i--) {
|
||||
result.push("" + i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
$scope.saveSettings = function () {
|
||||
// Make sure something changed
|
||||
var changed = !angular.equals($scope.config.options, $scope.tmpOptions) || !angular.equals($scope.config.gui, $scope.tmpGUI);
|
||||
var themeChanged = $scope.config.gui.theme !== $scope.tmpGUI.theme;
|
||||
if (changed) {
|
||||
// Angular has issues with selects with numeric values, so we handle strings here.
|
||||
$scope.tmpOptions.urAccepted = parseInt($scope.tmpOptions._urAcceptedStr);
|
||||
// Check if auto-upgrade has been enabled or disabled. This
|
||||
// also has an effect on usage reporting, so do the check
|
||||
// for that later.
|
||||
if ($scope.tmpOptions.upgrades == "candidate") {
|
||||
$scope.tmpOptions.autoUpgradeIntervalH = $scope.tmpOptions.autoUpgradeIntervalH || 12;
|
||||
$scope.tmpOptions.upgradeToPreReleases = true;
|
||||
$scope.tmpOptions.urEnabled = true;
|
||||
$scope.tmpOptions.urAccepted = $scope.system.urVersionMax;
|
||||
$scope.tmpOptions.urSeen = $scope.system.urVersionMax;
|
||||
} else if ($scope.tmpOptions.upgrades == "stable") {
|
||||
$scope.tmpOptions.autoUpgradeIntervalH = $scope.tmpOptions.autoUpgradeIntervalH || 12;
|
||||
$scope.tmpOptions.upgradeToPreReleases = false;
|
||||
@@ -1107,13 +1130,6 @@ angular.module('syncthing.core')
|
||||
$scope.tmpOptions.autoUpgradeIntervalH = 0;
|
||||
}
|
||||
|
||||
// Check if usage reporting has been enabled or disabled
|
||||
if ($scope.tmpOptions.urEnabled && $scope.tmpOptions.urAccepted <= 0) {
|
||||
$scope.tmpOptions.urAccepted = 1000;
|
||||
} else if (!$scope.tmpOptions.urEnabled && $scope.tmpOptions.urAccepted > 0) {
|
||||
$scope.tmpOptions.urAccepted = -1;
|
||||
}
|
||||
|
||||
// Check if protocol will need to be changed on restart
|
||||
if ($scope.config.gui.useTLS !== $scope.tmpGUI.useTLS) {
|
||||
$scope.protocolChanged = true;
|
||||
@@ -1691,13 +1707,17 @@ angular.module('syncthing.core')
|
||||
};
|
||||
|
||||
$scope.acceptUR = function () {
|
||||
$scope.config.options.urAccepted = 1000; // Larger than the largest existing report version
|
||||
$scope.config.options.urAccepted = $scope.system.urVersionMax;
|
||||
$scope.config.options.urSeen = $scope.system.urVersionMax;
|
||||
$scope.saveConfig();
|
||||
$('#ur').modal('hide');
|
||||
};
|
||||
|
||||
$scope.declineUR = function () {
|
||||
$scope.config.options.urAccepted = -1;
|
||||
if ($scope.config.options.urAccepted === 0) {
|
||||
$scope.config.options.urAccepted = -1;
|
||||
}
|
||||
$scope.config.options.urSeen = $scope.system.urVersionMax;
|
||||
$scope.saveConfig();
|
||||
$('#ur').modal('hide');
|
||||
};
|
||||
@@ -1747,6 +1767,13 @@ angular.module('syncthing.core')
|
||||
$scope.reportPreview = true;
|
||||
};
|
||||
|
||||
$scope.refreshReportDataPreview = function () {
|
||||
$scope.reportDataPreview = '';
|
||||
$http.get(urlbase + '/svc/report?version=' + $scope.reportDataPreviewVersion).success(function (data) {
|
||||
$scope.reportDataPreview = data;
|
||||
}).error($scope.emitHTTPError);
|
||||
};
|
||||
|
||||
$scope.rescanAllFolders = function () {
|
||||
$http.post(urlbase + "/db/scan");
|
||||
};
|
||||
|
||||
@@ -139,10 +139,14 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox" ng-if="tmpOptions.upgrades != 'candidate'">
|
||||
<label>
|
||||
<input id="UREnabled" type="checkbox" ng-model="tmpOptions.urEnabled"/> <span translate>Anonymous Usage Reporting</span> (<a href="" translate data-toggle="modal" data-target="#urPreview">Preview</a>)
|
||||
</label>
|
||||
<div ng-if="tmpOptions.upgrades != 'candidate'">
|
||||
<label translate for="urVersion">Anonymous Usage Reporting</label> (<a href="" translate data-toggle="modal" data-target="#urPreview">Preview</a>)
|
||||
<select class="form-control" id="urVersion" ng-model="tmpOptions._urAcceptedStr">
|
||||
<option ng-repeat="n in urVersions()" value="{{n}}">Version {{n}}</option>
|
||||
<!-- 1 does not exist, as we did not support incremental formats back then. -->
|
||||
<option value="0" translate>Undecided (will prompt)</option>
|
||||
<option value="-1" translate>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-block" ng-if="tmpOptions.upgrades == 'candidate'">
|
||||
<span translate>Usage reporting is always enabled for candidate releases.</span> (<a href="" translate data-toggle="modal" data-target="#urPreview">Preview</a>)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<modal id="ur" status="info" icon="bar-chart" heading="{{'Allow Anonymous Usage Reporting?' | translate}}" large="yes" closeable="no">
|
||||
<div class="modal-body">
|
||||
<p translate>The encrypted usage report is sent daily. It is used to track common platforms, folder sizes and app versions. If the reported data set is changed you will be prompted with this dialog again.</p>
|
||||
<p translate>The aggregated statistics are publicly available at the URL below.</p>
|
||||
<p><a href="https://data.syncthing.net/" target="_blank">https://data.syncthing.net/</a></p>
|
||||
<div ng-if="config.options.urAccepted > 0 && config.options.urAccepted < system.urVersionMax">
|
||||
<p>Anonymous Usage report format has changed. Would you like to move to the new format?</p>
|
||||
</div>
|
||||
<div ng-if="!(config.options.urAccepted > 0 && config.options.urAccepted < system.urVersionMax)">
|
||||
<p translate>The encrypted usage report is sent daily. It is used to track common platforms, folder sizes and app versions. If the reported data set is changed you will be prompted with this dialog again.</p>
|
||||
<p translate>The aggregated statistics are publicly available at the URL below.</p>
|
||||
<p><a href="https://data.syncthing.net/" target="_blank">https://data.syncthing.net/</a></p>
|
||||
</div>
|
||||
<button type="button" class="btn btn-default btn-sm" ng-click="showReportPreview()" ng-show="!reportPreview">
|
||||
<span class="fa fa-file-text-o"></span> <span translate>Preview Usage Report</span>
|
||||
</button>
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
</p>
|
||||
<p translate>The aggregated statistics are publicly available at the URL below.</p>
|
||||
<p><a href="https://data.syncthing.net/" target="_blank">https://data.syncthing.net/</a></p>
|
||||
<label translate>Version</label>
|
||||
<select id="urPreviewVersion" class="form-control" ng-model="$parent.$parent.reportDataPreviewVersion" ng-change="refreshReportDataPreview()" >
|
||||
<option ng-repeat="n in urVersions()" value="{{n}}">Version {{n}}</option>
|
||||
</select>
|
||||
<hr>
|
||||
<form>
|
||||
<textarea class="form-control" rows="20">{{reportData | json}}</textarea>
|
||||
<textarea class="form-control" rows="20" ng-if="reportDataPreview">{{reportDataPreview | json}}</textarea>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
Reference in New Issue
Block a user