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
deda5a37
Commit
deda5a37
authored
Jul 10, 2013
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remoteMaster'
parents
84cc414c
87e7ab07
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
186 additions
and
384 deletions
+186
-384
dream/platform/__init__.py
dream/platform/__init__.py
+2
-2
dream/platform/static/index.html
dream/platform/static/index.html
+3
-5
dream/platform/static/lib/underscore-min.js
dream/platform/static/lib/underscore-min.js
+0
-1
dream/platform/static/src/dream.js
dream/platform/static/src/dream.js
+77
-180
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+27
-28
dream/platform/static/src/jsonPlumb.js
dream/platform/static/src/jsonPlumb.js
+77
-168
No files found.
dream/platform/__init__.py
View file @
deda5a37
...
...
@@ -2,7 +2,6 @@ import json
import
traceback
import
multiprocessing
from
pprint
import
pformat
from
flask
import
Flask
,
jsonify
,
redirect
,
url_for
from
flask
import
request
...
...
@@ -17,7 +16,8 @@ def front_page():
@
app
.
route
(
"/runSimulation"
,
methods
=
[
"POST"
,
"OPTIONS"
])
def
runSimulation
():
parameter_dict
=
request
.
json
[
'json'
]
app
.
logger
.
debug
(
"running with:
\
n
%s"
%
(
pformat
(
parameter_dict
,)))
app
.
logger
.
debug
(
"running with:
\
n
%s"
%
(
json
.
dumps
(
parameter_dict
,
sort_keys
=
True
,
indent
=
2
)))
try
:
timeout
=
int
(
parameter_dict
[
'general'
][
'processTimeout'
])
...
...
dream/platform/static/index.html
View file @
deda5a37
...
...
@@ -19,7 +19,6 @@
<form>
<fieldset
id=
"general-fieldset"
>
</fieldset>
<!-- <button id="run_simulation">Run Simulation</button> -->
<a
id=
"run_simulation"
>
Run Simulation
</a>
</form>
</div>
...
...
@@ -55,10 +54,9 @@
</div>
-->
</div>
<!-- DEP -->
<script
type=
"text/javascript"
src=
"lib/underscore-min.js"
></script>
<script
type=
"text/javascript"
src=
"lib/jquery-1.8.1-min.js"
></script>
<script
type=
"text/javascript"
src=
"lib/jquery-ui-1.8.23-min.js"
></script>
<!-- DEP -->
<script
type=
"text/javascript"
src=
"lib/jquery-1.8.1-min.js"
></script>
<script
type=
"text/javascript"
src=
"lib/jquery-ui-1.8.23-min.js"
></script>
<script
type=
"text/javascript"
src=
"lib/jquery.ui.touch-punch.min.js"
></script>
<script
type=
"text/javascript"
src=
"lib/md5.js"
></script>
<script
type=
"text/javascript"
src=
"lib/jio.js"
></script>
...
...
dream/platform/static/lib/underscore-min.js
deleted
100644 → 0
View file @
84cc414c
This diff is collapsed.
Click to expand it.
dream/platform/static/src/dream.js
View file @
deda5a37
This diff is collapsed.
Click to expand it.
dream/platform/static/src/dream_launcher.js
View file @
deda5a37
...
...
@@ -17,14 +17,13 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* =========================================================================== */
(
function
(
$
,
_
)
{
(
function
(
$
)
{
"
use strict
"
;
jsPlumb
.
bind
(
"
ready
"
,
function
()
{
var
dream_instance
,
available_people
=
{},
people_list
,
i
,
i_length
,
updateWorkerCount
,
json_plumb_configuration
=
{},
jio
;
var
dream_instance
,
jio
;
jio
=
new
jIO
.
newJio
({
type
:
"
local
"
,
username
:
"
dream
"
,
applicationname
:
"
dream
"
});
var
window_id
=
1
;
var
element_id
;
var
id_container
=
{};
// to allow generating next ids, like Machine_1, Machine_2, etc
var
property_container
=
{
entity
:
{
id
:
"
entity
"
,
type
:
"
string
"
,
_class
:
"
Dream.Property
"
,
default
:
"
Part
"
},
// XXX is it possible not to repeat id ?
...
...
@@ -84,18 +83,19 @@
_class
:
'
Dream.Repairman
'
,
},
}
dream_instance
=
D
REAM
.
newD
ream
(
configuration
)
dream_instance
=
Dream
(
configuration
)
dream_instance
.
start
();
$
(
"
.tool
"
).
draggable
({
opacity
:
0.7
,
helper
:
"
clone
"
,
stop
:
function
(
tool
)
{
var
box_top
,
box_left
,
_class
;
box_top
=
tool
.
clientY
;
box_left
=
tool
.
clientX
;
var
offset
=
$
(
"
[id=render]
"
).
offset
();
box_top
=
tool
.
clientY
-
offset
.
top
+
"
px
"
;
box_left
=
tool
.
clientX
-
offset
.
left
+
"
px
"
;
id_container
[
tool
.
target
.
id
]
=
(
id_container
[
tool
.
target
.
id
]
||
0
)
+
1
;
_class
=
tool
.
target
.
id
.
replace
(
'
-
'
,
'
.
'
);
// XXX - vs .
dream_instance
.
newElement
({
id
:
tool
.
target
.
id
+
"
_
"
+
id_container
[
tool
.
target
.
id
],
coordinate
:
{
y
:
box_top
,
x
:
box_left
},
_class
:
_class
,
coordinate
:
{
top
:
box_top
,
left
:
box_left
},
_class
:
_class
,
});
window_id
+=
1
;
},
...
...
@@ -103,31 +103,28 @@
// Check if there is already data when we first load the page, if yes, then build graph from it
jio
.
get
({
_id
:
"
dream_demo
"
},
function
(
err
,
response
)
{
console
.
log
(
"
jio get:
"
,
response
);
if
(
response
!==
undefined
&&
response
.
data
!==
undefined
)
{
// Add all elements
_
.
each
(
response
.
data
.
element
,
function
(
value
,
key
,
list
)
{
var
element_id
=
value
.
id
;
var
preference_data
=
response
.
data
.
preference
!==
undefined
?
response
.
data
.
preference
[
element_id
]
:
{};
_
.
each
(
_
.
pairs
(
preference_data
),
function
(
preference_value
,
preference_key
,
preference_list
)
{
value
[
preference_value
[
0
]]
=
preference_value
[
1
];
$
.
each
(
response
.
data
.
element
,
function
(
key
,
value
)
{
var
preference_data
=
response
.
data
.
preference
!==
undefined
?
response
.
data
.
preference
[
value
.
id
]
:
{};
$
.
each
(
preference_data
,
function
(
preference_key
,
preference_value
){
value
[
preference_key
]
=
preference_value
;
});
dream_instance
.
newElement
(
value
);
dream_instance
.
updateElementData
(
element_
id
,
{
data
:
value
.
data
||
{}});
dream_instance
.
updateElementData
(
value
.
id
,
{
data
:
value
.
data
||
{}});
});
// Now link elements between them and update id_container
_
.
each
(
response
.
data
.
element
,
function
(
value
,
key
,
list
)
{
$
.
each
(
response
.
data
.
element
,
function
(
key
,
value
)
{
var
element_id
=
value
.
id
,
prefix
,
suffix
,
splitted_element_id
,
successor_list
=
value
.
successorList
||
[];
splitted_element_id
=
element_id
.
split
(
"
_
"
);
prefix
=
splitted_element_id
[
0
];
suffix
=
splitted_element_id
[
1
];
id_container
[
prefix
]
=
Math
.
max
((
id_container
[
prefix
]
||
0
),
parseInt
(
suffix
,
10
));
if
(
successor_list
.
length
>
0
)
{
_
.
each
(
successor_list
,
function
(
successor_value
,
successor_key
,
list
)
{
dream_instance
.
connect
(
value
.
id
,
successor_value
);
});
}
$
.
each
(
successor_list
,
function
(
idx
,
successor_value
)
{
dream_instance
.
connect
(
value
.
id
,
successor_value
);
});
});
dream_instance
.
setGeneralProperties
(
response
.
data
.
general
);
dream_instance
.
initGeneralProperties
();
// XXX
...
...
@@ -144,13 +141,16 @@
});
});
// Enable "Run Simulation" button
$
(
"
#run_simulation
"
).
button
().
click
(
function
(
e
){
dream_instance
.
runSimulation
(
function
(
data
)
{
if
(
data
[
'
success
'
])
{
$
(
"
#json_result
"
).
text
(
JSON
.
stringify
(
data
[
'
success
'
],
undefined
,
"
"
));
$
.
each
(
data
.
coreObject
,
function
(
idx
,
obj
){
$
.
each
(
data
[
'
success
'
]
.
coreObject
,
function
(
idx
,
obj
){
var
e
=
$
(
"
#
"
+
obj
.
id
);
/* attach something to each corresponding core object */
// e.tooltip(JSON.stringify(obj['results'], undefined, " "));
...
...
@@ -162,15 +162,14 @@
e
.
preventDefault
();
return
false
;
});
// Enable "Clear All" button
$
(
"
#clear_all
"
).
button
().
click
(
function
(
e
){
dream_instance
.
clearAll
(
function
()
{
dream_instance
.
clearAll
();
});
dream_instance
.
clearAll
();
e
.
preventDefault
();
return
false
;
});
})
})(
jQuery
,
_
);
})(
jQuery
);
dream/platform/static/src/jsonPlumb.js
View file @
deda5a37
...
...
@@ -17,15 +17,11 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* =========================================================================== */
(
function
(
scope
,
$
,
jsPlumb
,
console
,
_
)
{
(
function
(
scope
,
$
,
jsPlumb
,
console
)
{
"
use strict
"
;
var
jsonPlumb
=
function
(
model
)
{
scope
.
jsonPlumb
=
function
(
model
)
{
var
that
=
{},
priv
=
{};
priv
.
onError
=
function
(
error
)
{
console
.
log
(
"
Error
"
,
error
);
};
priv
.
initJsPlumb
=
function
()
{
jsPlumb
.
setRenderMode
(
jsPlumb
.
SVG
);
var
color
=
"
#00f
"
;
...
...
@@ -101,11 +97,14 @@
priv
.
draggable
();
};
priv
.
updateElementCoordinate
=
function
(
element_id
,
x
,
y
)
{
var
preference
=
priv
.
preference_container
[
element_id
]
||
{};
var
coordinate
=
preference
.
coordinate
||
{};
coordinate
.
x
=
x
;
coordinate
.
y
=
y
;
priv
.
updateElementCoordinate
=
function
(
element_id
,
coordinate
)
{
var
preference
=
priv
.
preference_container
[
element_id
]
||
{},
element
;
if
(
coordinate
===
undefined
)
{
coordinate
=
{};
element
=
$
(
"
#
"
+
element_id
);
coordinate
.
top
=
element
.
css
(
"
top
"
);
coordinate
.
left
=
element
.
css
(
"
left
"
);
}
preference
[
"
coordinate
"
]
=
coordinate
;
priv
.
preference_container
[
element_id
]
=
preference
;
priv
.
onDataChange
();
...
...
@@ -116,7 +115,7 @@
// make all the window divs draggable
var
stop
=
function
(
el
)
{
var
element_id
=
el
.
target
.
id
;
priv
.
updateElementCoordinate
(
element_id
,
el
.
clientX
,
el
.
clientY
);
priv
.
updateElementCoordinate
(
element_id
);
}
jsPlumb
.
draggable
(
jsPlumb
.
getSelector
(
"
.window
"
),
{
grid
:
[
20
,
20
]
,
stop
:
stop
,
...
...
@@ -150,172 +149,82 @@
priv
.
onDataChange
();
};
Object
.
defineProperty
(
that
,
"
updateElementData
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
element_id
,
data
)
{
_
.
extend
(
priv
.
element_container
[
element_id
],
data
);
priv
.
onDataChange
();
}
});
Object
.
defineProperty
(
that
,
"
start
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
priv
.
element_container
=
{};
priv
.
preference_container
=
{};
priv
.
general_container
=
{};
priv
.
initJsPlumb
();
}
});
that
.
updateElementData
=
function
(
element_id
,
data
)
{
$
.
extend
(
priv
.
element_container
[
element_id
],
data
);
priv
.
onDataChange
();
};
Object
.
defineProperty
(
that
,
"
removeElement
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
element_id
)
{
console
.
log
(
"
going to remove element
"
,
element_id
);
priv
.
removeElement
(
element_id
);
}
});
that
.
start
=
function
()
{
priv
.
element_container
=
{};
priv
.
preference_container
=
{};
priv
.
general_container
=
{};
priv
.
initJsPlumb
();
};
Object
.
defineProperty
(
that
,
"
getData
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
priv
.
getData
();
}
});
that
.
removeElement
=
function
(
element_id
)
{
console
.
log
(
"
going to remove element
"
,
element_id
);
priv
.
removeElement
(
element_id
);
};
Object
.
defineProperty
(
that
,
"
clearAll
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
$
(
"
[id=render]
"
).
children
().
remove
()
_
.
each
(
_
.
pairs
(
priv
.
element_container
),
function
(
element
,
index
)
{
priv
.
removeElement
(
element
[
0
]);
});
}
});
that
.
getData
=
function
()
{
return
priv
.
getData
();
};
Object
.
defineProperty
(
that
,
"
connect
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
source_id
,
target_id
)
{
jsPlumb
.
connect
({
source
:
source_id
,
target
:
target_id
});
}
});
that
.
clearAll
=
function
()
{
$
(
"
[id=render]
"
).
children
().
remove
()
$
.
each
(
priv
.
element_container
,
function
(
idx
,
element
)
{
priv
.
removeElement
(
element
);
});
};
Object
.
defineProperty
(
that
,
"
setGeneralProperties
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
properties
)
{
// XXX or k, v ?
priv
.
general_container
=
properties
;
priv
.
onDataChange
();
},
});
that
.
connect
=
function
(
source_id
,
target_id
)
{
jsPlumb
.
connect
({
source
:
source_id
,
target
:
target_id
});
};
Object
.
defineProperty
(
that
,
"
newElement
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
element
,
option
)
{
var
render_element
,
style_string
=
""
,
coordinate
=
{};
render_element
=
$
(
"
[id=render]
"
);
if
(
element
.
coordinate
!==
undefined
)
{
priv
.
updateElementCoordinate
(
element
.
id
,
element
.
coordinate
.
x
,
element
.
coordinate
.
y
)
var
main_div_offset
=
$
(
"
#main
"
).
offset
();
coordinate
.
x
=
element
.
coordinate
.
x
-
main_div_offset
.
left
;
coordinate
.
y
=
element
.
coordinate
.
y
-
main_div_offset
.
top
;
that
.
setGeneralProperties
=
function
(
properties
)
{
priv
.
general_container
=
properties
;
priv
.
onDataChange
();
};
_
.
each
(
coordinate
,
function
(
value
,
key
,
list
)
{
if
(
key
===
"
x
"
)
{
key
=
"
left
"
;
}
else
{
key
=
"
top
"
;
}
style_string
=
style_string
+
key
+
'
:
'
+
value
+
'
px;
'
;
})
}
if
(
style_string
.
length
>
0
)
{
style_string
=
'
style="
'
+
style_string
+
'
"
'
;
}
render_element
.
append
(
'
<div class="window" id="
'
+
element
.
id
+
'
"
'
+
style_string
+
'
">
'
+
element
.
id
+
'
</div>
'
);
// Initial DEMO code : make all the window divs draggable
priv
.
draggable
();
// Add endPoint to allow drawing connections
var
color
=
"
#00f
"
;
var
gradient_color
=
"
#09098e
"
;
// Different endpoint color for Repairman
if
(
element
.
_class
===
"
Dream.Repairman
"
)
{
color
=
"
rgb(189,11,11)
"
;
gradient_color
=
"
rgb(255,0,0)
"
;
};
var
endpoint
=
{
endpoint
:
"
Rectangle
"
,
paintStyle
:{
width
:
25
,
height
:
21
,
fillStyle
:
color
},
isSource
:
true
,
scope
:
"
blue rectangle
"
,
/*connectorStyle : {
gradient:{stops:[[0, color], [0.5, gradient_color], [1, color]]},
lineWidth:5,
strokeStyle:color,
dashstyle:"2 2"
},*/
//connector: ["Bezier", { curviness:63 } ],
maxConnections
:
3
,
isTarget
:
true
,
//dropOptions : exampleDropOptions
};
_
.
each
(
_
.
pairs
(
option
.
anchor
),
function
(
value
,
key
,
list
)
{
var
anchor
=
value
[
0
],
endpoint_configuration
=
value
[
1
];
jsPlumb
.
addEndpoint
(
element
.
id
,
{
anchor
:
anchor
},
endpoint
);
})
priv
.
addElementToContainer
(
element
);
that
.
newElement
=
function
(
element
,
option
)
{
var
render_element
,
style_string
=
""
,
coordinate
=
element
.
coordinate
,
box
;
render_element
=
$
(
"
[id=render]
"
);
if
(
coordinate
!==
undefined
)
{
coordinate
=
priv
.
updateElementCoordinate
(
element
.
id
,
coordinate
)
}
});
return
that
;
};
render_element
.
append
(
'
<div class="window" id="
'
+
element
.
id
+
'
">
'
+
element
.
id
+
'
</div>
'
);
box
=
$
(
"
#
"
+
element
.
id
);
box
.
css
(
"
top
"
,
coordinate
.
top
);
box
.
css
(
"
left
"
,
coordinate
.
left
);
var
JsonPlumbNamespace
=
(
function
()
{
var
that
=
{}
;
// Initial DEMO code : make all the window divs draggable
priv
.
draggable
()
;
/**
* Creates a new dream instance.
* @method newDream
* @param {object} model The model definition
* @return {object} The new Dream instance.
*/
Object
.
defineProperty
(
that
,
"
newJsonPlumb
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
model
)
{
var
instance
=
jsonPlumb
(
model
);
return
instance
;
}
});
// Add endPoint to allow drawing connections
var
color
=
"
#00f
"
;
var
gradient_color
=
"
#09098e
"
;
// Different endpoint color for Repairman
if
(
element
.
_class
===
"
Dream.Repairman
"
)
{
color
=
"
rgb(189,11,11)
"
;
gradient_color
=
"
rgb(255,0,0)
"
;
};
var
endpoint
=
{
endpoint
:
"
Rectangle
"
,
paintStyle
:{
width
:
25
,
height
:
21
,
fillStyle
:
color
},
isSource
:
true
,
scope
:
"
blue rectangle
"
,
maxConnections
:
3
,
isTarget
:
true
,
};
for
(
var
key
in
option
.
anchor
)
{
jsPlumb
.
addEndpoint
(
element
.
id
,
{
anchor
:
key
},
endpoint
);
};
priv
.
addElementToContainer
(
element
);
};
return
that
;
})();
Object
.
defineProperty
(
scope
,
"
jsonPlumb
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
JsonPlumbNamespace
});
};
}(
window
,
jQuery
,
jsPlumb
,
console
,
_
));
}(
window
,
jQuery
,
jsPlumb
,
console
));
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