Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
3e43e4b6
Commit
3e43e4b6
authored
Jul 12, 2013
by
Marcel
Browse files
Prepare the execute button in the code editor extension.
parent
f9e828b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
vispa/extensions/codeeditor/__init__.py
View file @
3e43e4b6
...
...
@@ -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
):
...
...
vispa/extensions/codeeditor/static/js/editor.js
View file @
3e43e4b6
...
...
@@ -127,7 +127,7 @@ var CodeEditor = Class.extend({
});
}
});
return
th
is
;
return
prom
is
e
;
},
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
vispa/extensions/codeeditor/static/js/extension.js
View file @
3e43e4b6
...
...
@@ -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
();
}
}
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment