Skip to content

Commit

Permalink
More code update to support new sid system. Addresses #633
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsielicki committed Sep 1, 2016
1 parent cfa76a3 commit 738a1a9
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 88 deletions.
44 changes: 27 additions & 17 deletions web-server/js/slycat-remote-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ define('slycat-remote-interface', ['knockout', 'knockout-mapping', 'slycat-serve
var vm = this;
vm.disabled = params.disabled === undefined ? false : params.disabled;
vm.nnodes_disabled = params.disabled === undefined ? false : params.disabled;
vm.remote = mapping.fromJS({ hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null });
vm.remote = mapping.fromJS({ hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null, session_exists: false });
vm.remote.sid = params.sid;
vm.remote.hostname = params.hostname;
vm.remote.username = params.username;
vm.remote.password = params.password;
vm.remote.session_exists = params.session_exists;
vm.remote.focus.extend({ notify: 'always' });
vm.radio = ko.observable('batch-file');
vm.command = ko.observable('');
Expand Down Expand Up @@ -66,22 +67,31 @@ define('slycat-remote-interface', ['knockout', 'knockout-mapping', 'slycat-serve
vm.remote.status_type('info');
vm.remote.status('Connecting...');

client.post_remotes({
hostname: vm.remote.hostname(),
username: vm.remote.username(),
password: vm.remote.password(),
success: function(sid) {
vm.remote.sid(sid);
$('#' + modal_id).modal('hide');
callback_map[vm.radio()]();
},
error: function(request, status, reason_phrase) {
vm.remote.enable(true);
vm.remote.status_type('danger');
vm.remote.status(reason_phrase);
vm.remote.focus('password');
}
});
if(component.remote.session_exists())
{
$('#' + modal_id).modal('hide');
callback_map[vm.radio()]();
}
else
{
client.post_remotes({
hostname: vm.remote.hostname(),
username: vm.remote.username(),
password: vm.remote.password(),
success: function(sid) {
vm.remote.session_exists(true);
vm.remote.sid(sid);
$('#' + modal_id).modal('hide');
callback_map[vm.radio()]();
},
error: function(request, status, reason_phrase) {
vm.remote.enable(true);
vm.remote.status_type('danger');
vm.remote.status(reason_phrase);
vm.remote.focus('password');
}
});
}
};

vm.cancel = function() {
Expand Down
53 changes: 31 additions & 22 deletions web-server/plugins/slycat-cca/js/new-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 CCA 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 @@ -45,9 +45,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 @@ -135,24 +132,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-cca/new-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ <h3 class="modal-title">New CCA 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
103 changes: 62 additions & 41 deletions web-server/plugins/slycat-parameter-image-plus-model/js/wizard-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ define(["slycat-server-root", "slycat-web-client", "slycat-dialog", "slycat-mark
component.ps_type = ko.observable("remote"); // local is selected by default...
component.matrix_type = ko.observable("remote"); // remote is selected by default...
component.model = mapping.fromJS({_id: null, name: "New Parameter Image Model", description: "", marking: markings.preselected()});
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: ko.computed(function(){return component.ps_type() == 'remote' ? true : false;}), focus: false, sid: null});
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: ko.computed(function(){return component.ps_type() == 'remote' ? true : false;}), focus: false, sid: null, session_exists: false});
component.remote.focus.extend({notify: "always"});
component.remote_matrix = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: ko.computed(function(){return component.matrix_type() == 'remote' ? true : false;}), focus: false, sid: null});
component.remote_matrix = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: ko.computed(function(){return component.matrix_type() == 'remote' ? true : false;}), focus: false, sid: null, session_exists: false});
component.remote_matrix.focus.extend({notify: "always"});
component.browser = mapping.fromJS({path:null, selection: []});
component.parser = ko.observable(null);
Expand Down Expand Up @@ -64,9 +64,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 @@ -246,47 +243,71 @@ define(["slycat-server-root", "slycat-web-client", "slycat-dialog", "slycat-mark
component.connect = function() {
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(1);
$('.browser-continue').toggleClass("disabled", false);
component.remote.status_type(null);
component.remote.status(null);
},
error: function(request, status, reason_phrase) {
component.remote.status_type("danger");
component.remote.status(reason_phrase);
component.remote.focus("password");
$('.browser-continue').toggleClass("disabled", false);
}
});

if(component.remote.session_exists())
{
component.tab(1);
$('.browser-continue').toggleClass("disabled", false);
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(1);
$('.browser-continue').toggleClass("disabled", false);
component.remote.status_type(null);
component.remote.status(null);
},
error: function(request, status, reason_phrase) {
component.remote.status_type("danger");
component.remote.status(reason_phrase);
component.remote.focus("password");
$('.browser-continue').toggleClass("disabled", false);
}
});
}
};

component.connect_matrix = function() {
component.remote_matrix.status_type("info");
component.remote_matrix.status("Connecting ...");
client.post_remotes({
hostname: component.remote_matrix.hostname(),
username: component.remote_matrix.username(),
password: component.remote_matrix.password(),
success: function(sid) {
component.remote_matrix.sid(sid);
component.tab(6);
$('.browser-continue').toggleClass("disabled", false);
component.remote_matrix.status_type(null);
component.remote_matrix.status(null);
},
error: function(request, status, reason_phrase) {
component.remote_matrix.status_type("danger");
component.remote_matrix.status(reason_phrase);
component.remote_matrix.focus("password");
$('.browser-continue').toggleClass("disabled", false);
}
});

if(component.remote.session_exists())
{
component.tab(6);
$('.browser-continue').toggleClass("disabled", false);
component.remote_matrix.status_type(null);
component.remote_matrix.status(null);
}
else
{
client.post_remotes({
hostname: component.remote_matrix.hostname(),
username: component.remote_matrix.username(),
password: component.remote_matrix.password(),
success: function(sid) {
component.remote_matrix.session_exists(true);
component.remote_matrix.sid(sid);
component.tab(6);
$('.browser-continue').toggleClass("disabled", false);
component.remote_matrix.status_type(null);
component.remote_matrix.status(null);
},
error: function(request, status, reason_phrase) {
component.remote_matrix.status_type("danger");
component.remote_matrix.status(reason_phrase);
component.remote_matrix.focus("password");
$('.browser-continue').toggleClass("disabled", false);
}
});
}
};

component.load_table = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ <h3 class="modal-title">New Parameter Image Model</h3>
</div>
<div class="remote-controls">
<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>

<div data-bind="visible:tab() == 1" 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 Expand Up @@ -95,7 +95,7 @@ <h3 class="modal-title">New Parameter Image Model</h3>
</div>
<div class="remote-controls">
<form class="form-horizontal" role="form">
<slycat-remote-controls params="hostname:remote_matrix.hostname,username:remote_matrix.username,password:remote_matrix.password,status:remote_matrix.status,status_type:remote_matrix.status_type,enable:remote_matrix.enable,focus:remote_matrix.focus,activate:connect_matrix"></slycat-remote-controls>
<slycat-remote-controls params="hostname:remote_matrix.hostname,username:remote_matrix.username,password:remote_matrix.password,status:remote_matrix.status,status_type:remote_matrix.status_type,enable:remote_matrix.enable,focus:remote_matrix.focus,activate:connect_matrix,session_exists:remote_matrix.session_exists"></slycat-remote-controls>
</form>
</div>
</div>
Expand All @@ -114,13 +114,13 @@ <h3 class="modal-title">New Parameter Image Model</h3>
<div data-bind="visible:tab() == 5">
<div class="compute-interface">
<form class="compute form-horizontal" role="form">
<slycat-remote-interface params="agent_function: distance_measure, agent_function_params: { 'image_columns_names': image_columns_names(), 'input': browser.selection()[0] }, model_type: 'parameter-image-plus', mid: model._id(), suggestions: [{'ntasks_per_node': 1, 'nnodes': 4, 'time_hours': 1, 'time_minutes': 0}], sid: remote.sid, hostname: remote.hostname, username: remote.username, password: remote.password, on_submit_callback: to_last_step"></slycat-remote-interface>
<slycat-remote-interface params="agent_function: distance_measure, agent_function_params: { 'image_columns_names': image_columns_names(), 'input': browser.selection()[0] }, model_type: 'parameter-image-plus', mid: model._id(), suggestions: [{'ntasks_per_node': 1, 'nnodes': 4, 'time_hours': 1, 'time_minutes': 0}], sid: remote.sid, hostname: remote.hostname, username: remote.username, password: remote.password, session_exists: remote.session_exists, on_submit_callback: to_last_step"></slycat-remote-interface>
</form>
</div>
</div>

<div data-bind="visible:tab() == 6" style="height: 400px">
<slycat-remote-browser params="type:'remote',sid:remote_matrix.sid,hostname:remote_matrix.hostname,selection:browser.selection,path:browser.path,open_file_callback:load_distance_matrix"></slycat-remote-browser>
<slycat-remote-browser params="type:'remote',sid:remote_matrix.sid,hostname:remote_matrix.hostname,selection:browser.selection,path:browser.path,open_file_callback:load_distance_matrix,session_exists:remote_matrix.session_exists"></slycat-remote-browser>
</div>

<div data-bind="visible:tab() == 7">
Expand Down
2 changes: 1 addition & 1 deletion web-server/templates/slycat-remote-interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h4 class="modal-title">Connect to host...</h4>
</div>
<div class="modal-body">
<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 class="modal-footer">
Expand Down

0 comments on commit 738a1a9

Please sign in to comment.