Commit 3e43e4b6 authored by Marcel's avatar Marcel
Browse files

Prepare the execute button in the code editor extension.

parent f9e828b5
......@@ -39,6 +39,14 @@ class CodeEditorController(AbstractController):
except Exception, e:
return self.fail(msg="Couldn\"t check the mtime: %s" % str(e), encode_json=True)
@cherrypy.expose
def execute(self, path):
try:
# TODO: plan the job submission structure
return self.success("blaaa", encode_json=True)
except Exception, e:
return self.fail(msg="Couldn\"t execute the script: %s" % str(e), encode_json=True)
class CodeEditorExtension(AbstractExtension):
def get_name(self):
......
......@@ -127,7 +127,7 @@ var CodeEditor = Class.extend({
});
}
});
return this;
return promise;
},
checkMTime: function() {
......@@ -245,5 +245,45 @@ var CodeEditor = Class.extend({
default:
return 'python';
}
},
execute: function() {
var self = this;
var promise = null;
if (this.workflow.modified) {
promise = this.save();
}
var dfd = $.Deferred();
$.when(promise).then(function() {
var promise2 = $.ajax({
type: 'POST',
url: self.instance._getPath('execute'),
data: {
_wid: self.instance._wid,
path: self.workflow.path
}
});
var msgObject = $.Topic('msg.log').publishBack('info', {
text: 'Executing ...',
icon: 'ui-icon-refresh'
})[0];
$.when(promise2).then(function(response) {
if (response.success) {
// TODO: start a polling when the job submission structure is done
} else {
$.Topic('msg.error').publish(response.msg);
msgObject.update({
text: 'Execution failed',
icon: 'ui-icon-alert'
});
}
});
});
return dfd;
}
});
\ No newline at end of file
......@@ -72,14 +72,20 @@ var CodeEditorFullContent = ExtensionContentFull.extend({
init: function(config, path) {
this._super(config);
var _this = this;
var self = this;
this.menuEntries = [
{
label: 'Save',
icon: 'ui-icon-disk',
callback: function() {
_this.editor.save();
self.editor.save();
}
}, {
label: 'Execute',
icon: 'ui-icon-play',
callback: function() {
self.editor.execute();
}
}
];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment