Skip to content

Commit

Permalink
Updating Parameter Space wizard to use new session api. Addresses #633
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsielicki committed Aug 31, 2016
1 parent 1d5d415 commit dbc7eaf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
53 changes: 31 additions & 22 deletions web-server/plugins/slycat-parameter-image/js/wizard-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define(["slycat-server-root", "slycat-web-client", "slycat-dialog", "slycat-mark
component.tab = ko.observable(0);
component.project = params.projects()[0];
component.model = mapping.fromJS({_id: null, name: "New Parameter Space Model", description: "", marking: markings.preselected()});
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null});
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null, session_exists: false});
component.remote.focus.extend({notify: "always"});
component.browser = mapping.fromJS({path:null, selection: []});
component.parser = ko.observable(null);
Expand Down Expand Up @@ -44,9 +44,6 @@ define(["slycat-server-root", "slycat-web-client", "slycat-dialog", "slycat-mark
component.create_model();

component.cancel = function() {
if(component.remote.sid())
client.delete_remote({ sid: component.remote.sid() });

if(component.model._id())
client.delete_model({ mid: component.model._id() });
};
Expand Down Expand Up @@ -124,24 +121,36 @@ define(["slycat-server-root", "slycat-web-client", "slycat-dialog", "slycat-mark
component.remote.enable(false);
component.remote.status_type("info");
component.remote.status("Connecting ...");
client.post_remotes({
hostname: component.remote.hostname(),
username: component.remote.username(),
password: component.remote.password(),
success: function(sid) {
component.remote.sid(sid);
component.tab(3);
component.remote.enable(true);
component.remote.status_type(null);
component.remote.status(null);
},
error: function(request, status, reason_phrase) {
component.remote.enable(true);
component.remote.status_type("danger");
component.remote.status(reason_phrase);
component.remote.focus("password");
}
});

if(component.remote.session_exists())
{
component.tab(3);
component.remote.enable(true);
component.remote.status_type(null);
component.remote.status(null);
}
else
{
client.post_remotes({
hostname: component.remote.hostname(),
username: component.remote.username(),
password: component.remote.password(),
success: function(sid) {
component.remote.session_exists(true);
component.remote.sid(sid);
component.tab(3);
component.remote.enable(true);
component.remote.status_type(null);
component.remote.status(null);
},
error: function(request, status, reason_phrase) {
component.remote.enable(true);
component.remote.status_type("danger");
component.remote.status(reason_phrase);
component.remote.focus("password");
}
});
}
};

component.load_table = function() {
Expand Down
4 changes: 2 additions & 2 deletions web-server/plugins/slycat-parameter-image/wizard-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ <h3 class="modal-title">New Parameter Space Model</h3>

<div data-bind="visible:tab() == 2">
<form class="form-horizontal" role="form">
<slycat-remote-controls params="hostname:remote.hostname,username:remote.username,password:remote.password,status:remote.status,status_type:remote.status_type,enable:remote.enable,focus:remote.focus,activate:connect"></slycat-remote-controls>
<slycat-remote-controls params="hostname:remote.hostname,username:remote.username,password:remote.password,status:remote.status,status_type:remote.status_type,enable:remote.enable,focus:remote.focus,activate:connect,session_exists:remote.session_exists"></slycat-remote-controls>
</form>
</div>

<div data-bind="visible:tab() == 3" style="height: 400px">
<slycat-remote-browser params="type:'remote',sid:remote.sid,hostname:remote.hostname,selection:browser.selection,path:browser.path,open_file_callback:load_table"></slycat-remote-browser>
<slycat-remote-browser params="type:'remote',sid:remote.sid,hostname:remote.hostname,selection:browser.selection,path:browser.path,open_file_callback:load_table,session_exists:remote.session_exists"></slycat-remote-browser>
<slycat-parser-controls params="parser:parser,category:'table'"></slycat-parser-controls>
</div>

Expand Down

0 comments on commit dbc7eaf

Please sign in to comment.