Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
3c163f1b
Commit
3c163f1b
authored
Jun 18, 2014
by
Romain Courteaud
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save simulation parameters before triggering calculations.
parent
f2646b4a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
61 deletions
+122
-61
dream/platform/src2/dream/Input_viewSimulation.html
dream/platform/src2/dream/Input_viewSimulation.html
+1
-3
dream/platform/src2/dream/Input_viewSimulation.js
dream/platform/src2/dream/Input_viewSimulation.js
+121
-58
No files found.
dream/platform/src2/dream/Input_viewSimulation.html
View file @
3c163f1b
...
...
@@ -19,11 +19,9 @@
<script
src=
"Input_viewSimulation.js"
type=
"text/javascript"
></script>
</head>
<body>
<form>
<form
class=
"save_form"
>
<fieldset
class=
"simulation_parameters"
>
</fieldset>
</form>
<form
class=
"run_form"
>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right"
>
Run Simulation
</button>
</form>
...
...
dream/platform/src2/dream/Input_viewSimulation.js
View file @
3c163f1b
...
...
@@ -5,6 +5,124 @@
promiseEventListener
,
initGadgetMixin
)
{
"
use strict
"
;
function
saveForm
(
gadget
)
{
var
general
=
{};
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
gadget
.
props
.
gadget_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
gadget
.
props
.
gadget_list
[
i
].
getContent
());
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
result_list
)
{
var
i
,
result
,
key
;
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
result
=
result_list
[
i
];
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
// Drop empty
if
(
result
[
key
])
{
general
[
key
]
=
result
[
key
];
}
}
}
}
// Always get a fresh version, to prevent deleting spreadsheet & co
return
gadget
.
aq_getAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
});
})
.
push
(
function
(
body
)
{
var
data
=
JSON
.
parse
(
body
);
data
.
general
=
general
;
return
gadget
.
aq_putAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
,
"
_data
"
:
JSON
.
stringify
(
data
,
null
,
2
),
"
_mimetype
"
:
"
application/json
"
});
});
}
function
runSimulation
(
gadget
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
aq_getAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
});
})
.
push
(
function
(
body_json
)
{
// XXX Hardcoded relative URL
return
gadget
.
aq_ajax
({
url
:
"
../../runSimulation
"
,
type
:
"
POST
"
,
data
:
body_json
,
headers
:
{
"
Content-Type
"
:
'
application/json
'
}
});
})
.
push
(
function
(
evt
)
{
var
json_data
=
JSON
.
parse
(
evt
.
target
.
responseText
);
if
(
json_data
.
success
!==
true
)
{
throw
new
Error
(
json_data
.
error
);
}
return
gadget
.
aq_putAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
simulation.json
"
,
"
_data
"
:
JSON
.
stringify
(
json_data
.
data
,
null
,
2
),
"
_mimetype
"
:
"
application/json
"
});
})
.
push
(
function
()
{
return
gadget
.
whoWantToDisplayThisDocument
(
gadget
.
props
.
jio_key
,
"
view_result
"
);
})
.
push
(
function
(
url
)
{
return
gadget
.
pleaseRedirectMyHash
(
url
);
});
}
function
waitForRunSimulation
(
gadget
)
{
var
submit_evt
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
save_form
"
)[
0
],
'
submit
'
,
false
);
})
.
push
(
function
(
evt
)
{
submit_evt
=
evt
;
// Prevent double click
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
$
.
mobile
.
loading
(
'
show
'
);
return
saveForm
(
gadget
);
})
.
push
(
function
()
{
return
runSimulation
(
gadget
);
})
.
push
(
undefined
,
function
(
error
)
{
// Always drop the loader
$
.
mobile
.
loading
(
'
hide
'
);
throw
error
;
})
.
push
(
function
()
{
submit_evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
false
;
$
.
mobile
.
loading
(
'
hide
'
);
});
}
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
...
...
@@ -70,6 +188,7 @@
})
.
push
(
function
(
sub_element
)
{
parent_element
.
appendChild
(
sub_element
);
gadget
.
props
.
gadget_list
.
push
(
sub_gadget
);
});
}
...
...
@@ -84,6 +203,7 @@
.
push
(
function
(
configuration_dict
)
{
var
property_list
=
configuration_dict
[
'
Dream-Configuration
'
].
property_list
;
gadget
.
props
.
gadget_list
=
[];
for
(
i
=
0
;
i
<
property_list
.
length
;
i
+=
1
)
{
property
=
property_list
[
i
];
if
(
property
.
_class
===
"
Dream.Property
"
)
{
...
...
@@ -97,64 +217,7 @@
})
.
declareMethod
(
"
startService
"
,
function
()
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
run_form
"
)[
0
],
'
submit
'
,
false
);
})
.
push
(
function
()
{
// Prevent double click
gadget
.
props
.
element
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
return
gadget
.
aq_getAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
});
})
.
push
(
function
(
body_json
)
{
$
.
mobile
.
loading
(
'
show
'
);
// XXX Hardcoded relative URL
return
gadget
.
aq_ajax
({
url
:
"
../../runSimulation
"
,
type
:
"
POST
"
,
data
:
body_json
,
headers
:
{
"
Content-Type
"
:
'
application/json
'
}
});
})
.
push
(
undefined
,
function
(
error
)
{
// Always drop the loader
$
.
mobile
.
loading
(
'
hide
'
);
throw
error
;
})
.
push
(
function
(
evt
)
{
$
.
mobile
.
loading
(
'
hide
'
);
var
json_data
=
JSON
.
parse
(
evt
.
target
.
responseText
);
if
(
json_data
.
success
!==
true
)
{
throw
new
Error
(
json_data
.
error
);
}
return
gadget
.
aq_putAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
simulation.json
"
,
"
_data
"
:
JSON
.
stringify
(
json_data
.
data
,
null
,
2
),
"
_mimetype
"
:
"
application/json
"
});
})
.
push
(
function
()
{
return
gadget
.
whoWantToDisplayThisDocument
(
gadget
.
props
.
jio_key
,
"
view_result
"
);
})
.
push
(
function
(
url
)
{
return
gadget
.
pleaseRedirectMyHash
(
url
);
});
return
waitForRunSimulation
(
this
);
});
}(
window
,
rJS
,
RSVP
,
jQuery
,
Handlebars
,
promiseEventListener
,
initGadgetMixin
));
Write
Preview
Markdown
is supported
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