mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 02:48:59 +00:00
Making short deviceID length consistent and referencing to protocol file for future-proof edits. Closes #9313.
This commit is contained in:
parent
86a08eb87d
commit
2abfefc18c
@ -910,7 +910,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="deviceCfg.introducedBy">
|
<tr ng-if="deviceCfg.introducedBy">
|
||||||
<th><span class="far fa-fw fa-handshake-o"></span> <span translate>Introduced By</span></th>
|
<th><span class="far fa-fw fa-handshake-o"></span> <span translate>Introduced By</span></th>
|
||||||
<td class="text-right">{{ deviceName(devices[deviceCfg.introducedBy]) || deviceCfg.introducedBy.substring(0, 5) }}</td>
|
<td class="text-right">{{ deviceName(devices[deviceCfg.introducedBy]) || deviceShortID(deviceCfg.introducedBy) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="deviceCfg.autoAcceptFolders">
|
<tr ng-if="deviceCfg.autoAcceptFolders">
|
||||||
<th><span class="fa fa-fw fa-level-down"></span> <span translate>Auto Accept</span></th>
|
<th><span class="fa fa-fw fa-level-down"></span> <span translate>Auto Accept</span></th>
|
||||||
|
@ -18,6 +18,9 @@ var syncthing = angular.module('syncthing', [
|
|||||||
var urlbase = 'rest';
|
var urlbase = 'rest';
|
||||||
var authUrlbase = urlbase + '/noauth/auth';
|
var authUrlbase = urlbase + '/noauth/auth';
|
||||||
|
|
||||||
|
// keep consistent with ShortIDStringLength in lib/protocol/deviceid.go
|
||||||
|
var shortIDStringLength = 7;
|
||||||
|
|
||||||
syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvider) {
|
syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvider) {
|
||||||
// language and localisation
|
// language and localisation
|
||||||
|
|
||||||
|
@ -1460,7 +1460,7 @@ angular.module('syncthing.core')
|
|||||||
|
|
||||||
$scope.friendlyNameFromShort = function (shortID) {
|
$scope.friendlyNameFromShort = function (shortID) {
|
||||||
var matches = Object.keys($scope.devices).filter(function (id) {
|
var matches = Object.keys($scope.devices).filter(function (id) {
|
||||||
return id.substr(0, 7) === shortID;
|
return id.substr(0, shortIDStringLength) === shortID;
|
||||||
});
|
});
|
||||||
if (matches.length !== 1) {
|
if (matches.length !== 1) {
|
||||||
return shortID;
|
return shortID;
|
||||||
@ -1473,7 +1473,7 @@ angular.module('syncthing.core')
|
|||||||
if (match) {
|
if (match) {
|
||||||
return $scope.deviceName(match);
|
return $scope.deviceName(match);
|
||||||
}
|
}
|
||||||
return deviceID.substr(0, 6);
|
return deviceID.substr(0, shortIDStringLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.deviceName = function (deviceCfg) {
|
$scope.deviceName = function (deviceCfg) {
|
||||||
@ -1490,7 +1490,7 @@ angular.module('syncthing.core')
|
|||||||
if (typeof deviceID === 'undefined') {
|
if (typeof deviceID === 'undefined') {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return deviceID.substr(0, 6);
|
return deviceID.substr(0, shortIDStringLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.thisDeviceName = function () {
|
$scope.thisDeviceName = function () {
|
||||||
@ -1501,7 +1501,7 @@ angular.module('syncthing.core')
|
|||||||
if (device.name) {
|
if (device.name) {
|
||||||
return device.name;
|
return device.name;
|
||||||
}
|
}
|
||||||
return device.deviceID.substr(0, 6);
|
return device.deviceID.substr(0, shortIDStringLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showDeviceIdentification = function (deviceCfg) {
|
$scope.showDeviceIdentification = function (deviceCfg) {
|
||||||
|
@ -14,7 +14,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DeviceIDLength = 32
|
DeviceIDLength = 32
|
||||||
|
// keep consistent with shortIDStringLength in gui/default/syncthing/app.js
|
||||||
ShortIDStringLength = 7
|
ShortIDStringLength = 7
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ func TestShortIDString(t *testing.T) {
|
|||||||
id, _ := DeviceIDFromString(formatted)
|
id, _ := DeviceIDFromString(formatted)
|
||||||
|
|
||||||
sid := id.Short().String()
|
sid := id.Short().String()
|
||||||
|
// keep consistent with ShortIDStringLength in lib/protocol/deviceid.go
|
||||||
if len(sid) != 7 {
|
if len(sid) != 7 {
|
||||||
t.Errorf("Wrong length for short ID: got %d, want 7", len(sid))
|
t.Errorf("Wrong length for short ID: got %d, want 7", len(sid))
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { environment } from '../environments/environment'
|
import { environment } from '../environments/environment'
|
||||||
|
|
||||||
export const deviceID = (): String => {
|
export const deviceID = (): String => {
|
||||||
|
// keep consistent with ShortIDStringLength in lib/protocol/deviceid.go
|
||||||
return environment.production ? globalThis.metadata['deviceIDShort'] : '1234567';
|
return environment.production ? globalThis.metadata['deviceIDShort'] : '1234567';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user