-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gui: Add dropdown menu to choose discovered devices to device modal (fixes #4157) #4186
Conversation
@@ -1807,4 +1811,6 @@ angular.module('syncthing.core') | |||
window.localStorage["metricRates"] = $scope.metricRates; | |||
} catch (exception) { } | |||
} | |||
|
|||
$scope.isEmptyObject = isEmptyObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this, empty object is already false'ish.
@@ -1226,6 +1227,9 @@ angular.module('syncthing.core') | |||
|
|||
$scope.saveDevice = function () { | |||
$('#editDevice').modal('hide'); | |||
if ($scope.currentDevice.deviceID === '') { | |||
$scope.currentDevice.deviceID = $scope.manualDeviceID; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if something like this works instead, removing the need for a scope variable
<select ng-if="!editingExisting && discovery" class="form-control" ng-model="currentDevice.deviceID">
<option ng-repeat="(id, data) in discovery" value="{{id}}">{{id}}</option>
<option ng-value='currentDevice.deviceID' translate>Enter manually below</option>
</select>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you base the ng-if of the text input field on then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why you need that to be honest. What's the exact problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to display a text input field unless "Enter manually below" is selected. its ugly(er) and then the user could theoretically both choose an ID from the list and enter one below.
<div ng-if="editingExisting" class="well well-sm text-monospace" select-on-click>{{currentDevice.deviceID}}</div> | ||
<p class="help-block"> | ||
<span translate ng-if="deviceEditor.deviceID.$valid || deviceEditor.deviceID.$pristine">The device ID to enter here can be found in the "Actions > Show ID" dialog on the other device. Spaces and dashes are optional (ignored).</span> | ||
<span translate ng-if="!currentDevice.deviceID && !isEmptyObject(discovery) && deviceEditor.deviceID.$pristine">Choose a discovered device ID or enter one manually.</span> | ||
<span translate ng-if="!currentDevice.deviceID && deviceEditor.deviceID.$pristine">The device ID can be found in the "Actions > Show ID" dialog on the other device. Spaces and dashes are optional (ignored).</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removal of the $valid and the false'ish check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point of telling the user where to find the device ID when a valid one has already been entered or selected -> removal of $valid and checking whether an ID has been selected in from the list.
So this is a nice feature an all, but UX/UI wise it's a car crash. I think it might be better to make some sort of expandable thing "Devices nearby" like advanced settings in folder editor that lists the devices. We should also improve local discovery to put friendly name in the local discovery packet and display that if available along the ID. Another alternative would be CSS HAX such as https://stackoverflow.com/a/31734324 |
Agreed, could be much nicer, I just wanted a compact and quick solution because I really think that feature helps a lot for usability and I really totally missed it before. I would be happy if someone with actual frontend skills did something nice. |
Don't we all? like to the whole UI perhaps maybe? |
How about something more HTMLy? Maybe not the most beautiful, but quite clear? <p class="help-block" ng-if="!editingExisting && discovery">
<span translate>You can also select one of these nearby devices:</span>
<ul>
<li ng-repeat="(id, data) in discovery"><a ng-click="currentDevice.deviceID = id">{{id}}</a>
<span class="text-muted">{{data.addresses.join(", ")}}</span></li>
</ul>
</p> |
I wonder how that looks on the fossdem wifi |
Similar to the wifi network dropdown in the middle of a busy city, if we are successful. I don't think it matters. |
Fine. I still think we should ramp it up a notch by adding friendly name to local discovery packets. |
My vote is against friendly names unless it is clear to the user that friendly name is broadcast. "local discovery" means "in the same network", e.g. public wifi, hotel wifi - correct? |
Usually these sort of networks block multicast. Furthermore, on Windows, as you connect to a network it asks you what type of network it is, if you select public (like you should) local discovery would be blocked. I also think you can probe the hostname of a machine on the local network without needing syncthing anyway, so omitting the name is more of a nuisance oppose to a privacy measure. I recall doing that using using a piece of software. |
Ok, thanks for info. I just wanted to make sure that privacy is kept since most users only have 3 devices and adding a new device is a rare action. |
I suggest doing something with what we have now, and potentially adding info to the discovery packets as a separate stage. |
That's why I chose a dropdown menu. What about combining @calmh's version with @AudriusButkevicius proposal, to make it somewhat "scalable":
|
Another way to do this would be to have a separate item in the settings dropdown menu (with a bootstrap badge listing the count of devices found and also only visible if the count is non zero) which shows a modal dialog with devices nearby. As you click on one of them, it shows you the add device dialog. Another question, does this hide devices that are already added? |
You could also add a blue link (like "help" on other settings) next to "Device ID" which shows a (default hidden) div with the list once you click it. But I suggest to keep it simple. It would be great success for Syncthing to see a long list of Syncthing devices around them but at the moment I expect max. 5 devices to show up in this list. And only if the user has configured network, etc. correctly |
Any collective decision here or 🖌🚲🏡 ? |
What you suggested is better than whats in the PR if we don't want to go for something more advanced. |
I think @calmh's idea is simple and fast: click/tap and done. |
Done. I am still concerned that users from the top 5% in the usage statistics may have to do quite some scrolling on adding a device, but maybe that's not really an issue. |
We should not show devices here that are already added, which mitigates that to a certain extent. |
I don't think we should show addresses, and cap at max 5 unadded devices. |
Works for me. Extra points for a |
I forgot it in the commit message: Already connected devices are filtered out as well. |
so looks good to me, someone who actually runs more than one syncthing should test. |
@st-review lgtm |
@AudriusButkevicius: Noted! Need another LGTM or explicit merge command. |
@st-review lgtm |
For me, the list shows an already connected device. v0.14.32-rc.1, Linux (64 bit). |
…ixes syncthing#4157) GitHub-Pull-Request: syncthing#4186 LGTM: AudriusButkevicius, calmh
GitHub-Pull-Request: syncthing#4239
Purpose
#4157
Testing
Manual poking around.
Screenshots
http://i.imgur.com/8TjO0Q8.png
http://i.imgur.com/iEIPV0w.png
Implementation
I needed the isEmptyObject function within the modal view. I don't know what the "correct" way of doing this in JS/Angular is, I just assigned it to $scope.isEmptyObject.