Skip to content

Commit

Permalink
Hiding username and password fields when a session already exists. Ad…
Browse files Browse the repository at this point in the history
…dresses #633
  • Loading branch information
alexsielicki committed Aug 31, 2016
1 parent 9146cef commit b55f252
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions web-server/js/slycat-remote-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define("slycat-remote-controls", ["slycat-server-root", "slycat-web-client", "kn
component.status = params.status || ko.observable(null);
component.status_type = params.status_type || ko.observable(null);
component.remote_hosts = mapping.fromJS([]);
component.session_exists = ko.observable(false);

component.status_classes = ko.pureComputed(function()
{
Expand All @@ -46,6 +47,25 @@ define("slycat-remote-controls", ["slycat-server-root", "slycat-web-client", "kn
{
localStorage.setItem("slycat-remote-controls-hostname", value);
component.status(null);

client.get_remotes({
hostname: value,
success: function(result)
{
if(component.hostname() == value)
{
if(result.status)
component.session_exists(true);
else
component.session_exists(false);
}
},
error: function(request, status, reason_phrase)
{
if(component.hostname() == value)
component.session_exists(false);
}
});
});

component.username.subscribe(function(value)
Expand Down
4 changes: 2 additions & 2 deletions web-server/templates/slycat-remote-controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
</div>
</div>
</div>
<div class="form-group">
<div class="form-group" data-bind="visible: !session_exists()">
<label for="slycat-remote-username" class="col-sm-2 control-label" data-bind="css: {'disabled' : !enable()}">Username</label>
<div class="col-sm-10">
<input id="slycat-remote-username" class="form-control" type="text" data-bind="enable:enable, textInput:username"></input>
</div>
</div>
<div class="form-group">
<div class="form-group" data-bind="visible: !session_exists()">
<label for="slycat-remote-password" class="col-sm-2 control-label" data-bind="css: {'disabled' : !enable()}">Password</label>
<div class="col-sm-10">
<input id="slycat-remote-password" class="form-control" type="password" data-bind="enable:enable, textInput:password"></input>
Expand Down

0 comments on commit b55f252

Please sign in to comment.