Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

imsodin
Copy link
Member

@imsodin imsodin commented May 31, 2017

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.

@@ -1807,4 +1811,6 @@ angular.module('syncthing.core')
window.localStorage["metricRates"] = $scope.metricRates;
} catch (exception) { }
}

$scope.isEmptyObject = isEmptyObject;
Copy link
Member

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;
}
Copy link
Member

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>

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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>
Copy link
Member

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?

Copy link
Member Author

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.

@AudriusButkevicius
Copy link
Member

AudriusButkevicius commented May 31, 2017

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
We should check how that looks on the mobile though.

@imsodin
Copy link
Member Author

imsodin commented May 31, 2017

So this is a nice feature an all, but UX/UI wise it's a car crash.

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.

@AudriusButkevicius
Copy link
Member

if someone with actual frontend skills did something nice.

Don't we all? like to the whole UI perhaps maybe?

@calmh
Copy link
Member

calmh commented Jun 1, 2017

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>

jun-01-2017 07-46-36

@AudriusButkevicius
Copy link
Member

I wonder how that looks on the fossdem wifi

@calmh
Copy link
Member

calmh commented Jun 1, 2017

Similar to the wifi network dropdown in the middle of a busy city, if we are successful. I don't think it matters.

@AudriusButkevicius
Copy link
Member

AudriusButkevicius commented Jun 1, 2017

Fine. I still think we should ramp it up a notch by adding friendly name to local discovery packets.

@uok
Copy link
Contributor

uok commented Jun 1, 2017

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?

@AudriusButkevicius
Copy link
Member

AudriusButkevicius commented Jun 1, 2017

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.

@uok
Copy link
Contributor

uok commented Jun 1, 2017

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.

@calmh
Copy link
Member

calmh commented Jun 1, 2017

I suggest doing something with what we have now, and potentially adding info to the discovery packets as a separate stage.

@imsodin
Copy link
Member Author

imsodin commented Jun 1, 2017

I wonder how that looks on the fossdem wifi

That's why I chose a dropdown menu. What about combining @calmh's version with @AudriusButkevicius proposal, to make it somewhat "scalable":

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.

@AudriusButkevicius
Copy link
Member

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?

@uok
Copy link
Contributor

uok commented Jun 1, 2017

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

@calmh
Copy link
Member

calmh commented Jun 9, 2017

Any collective decision here or 🖌🚲🏡 ?

@AudriusButkevicius
Copy link
Member

What you suggested is better than whats in the PR if we don't want to go for something more advanced.

@uok
Copy link
Contributor

uok commented Jun 9, 2017

I think @calmh's idea is simple and fast: click/tap and done.

@imsodin
Copy link
Member Author

imsodin commented Jun 9, 2017

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.

@calmh
Copy link
Member

calmh commented Jun 9, 2017

We should not show devices here that are already added, which mitigates that to a certain extent.

@calmh
Copy link
Member

calmh commented Jun 9, 2017

Also I think my idea to show the addresses needs to be somewhat restrained, at the least to not show relay addresses...

screen shot 2017-06-09 at 11 58 43

@AudriusButkevicius
Copy link
Member

AudriusButkevicius commented Jun 9, 2017

I don't think we should show addresses, and cap at max 5 unadded devices.

@calmh
Copy link
Member

calmh commented Jun 9, 2017

Works for me. Extra points for a ... and {{items.length - 5}} other devices or something under the list if it overflows. But really, we're almost never going to need it.

@imsodin
Copy link
Member Author

imsodin commented Jun 9, 2017

I forgot it in the commit message: Already connected devices are filtered out as well.

@AudriusButkevicius
Copy link
Member

so looks good to me, someone who actually runs more than one syncthing should test.

@AudriusButkevicius
Copy link
Member

@st-review lgtm

@st-review
Copy link

@AudriusButkevicius: Noted! Need another LGTM or explicit merge command.

@calmh
Copy link
Member

calmh commented Jun 16, 2017

@st-review lgtm

@st-review
Copy link

👌 Merged as 98cfc20. Thanks, @imsodin!

@st-review st-review closed this Jun 16, 2017
st-review pushed a commit that referenced this pull request Jun 16, 2017
…ixes #4157)

GitHub-Pull-Request: #4186
LGTM: AudriusButkevicius, calmh
@dinosore
Copy link
Contributor

For me, the list shows an already connected device. v0.14.32-rc.1, Linux (64 bit).

imsodin added a commit to imsodin/syncthing that referenced this pull request Jun 29, 2017
st-review pushed a commit that referenced this pull request Jun 29, 2017
viable-hartman pushed a commit to viable-hartman/syncthing that referenced this pull request Aug 25, 2017
viable-hartman pushed a commit to viable-hartman/syncthing that referenced this pull request Aug 25, 2017
@imsodin imsodin deleted the fix-4157 branch October 5, 2017 18:24
@st-review st-review added the pr-merged Legacy label used in the past for pull requests merged to the main tree label Jan 15, 2018
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jul 15, 2018
@syncthing syncthing locked and limited conversation to collaborators Jul 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion pr-merged Legacy label used in the past for pull requests merged to the main tree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants