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
fe2282a1
Commit
fe2282a1
authored
Nov 20, 2013
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make loadData() function.
parent
afee6b20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
38 deletions
+40
-38
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+40
-38
No files found.
dream/platform/static/src/dream_launcher.js
View file @
fe2282a1
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
applicationname
:
"
dream
"
applicationname
:
"
dream
"
});
});
var
window_id
=
1
;
var
id_container
=
{};
// to allow generating next ids, like Machine_1, Machine_2, etc
var
id_container
=
{};
// to allow generating next ids, like Machine_1, Machine_2, etc
var
property_container
=
{
var
property_container
=
{
entity
:
{
entity
:
{
...
@@ -231,52 +230,55 @@
...
@@ -231,52 +230,55 @@
},
},
_class
:
_class
_class
:
_class
});
});
window_id
+=
1
;
}
}
});
});
// Check if there is already data when we first load the page, if yes, then build graph from it
var
loadData
=
function
(
data
)
{
jio
.
get
({
var
preference
=
data
.
preference
!==
undefined
?
_id
:
"
dream_demo
"
data
.
preference
:
{};
},
function
(
err
,
response
)
{
dream_instance
.
setPreferences
(
preference
);
if
(
response
!==
undefined
&&
response
.
data
!==
undefined
)
{
var
preference
=
response
.
data
.
preference
!==
undefined
?
response
.
data
.
preference
:
{};
dream_instance
.
setPreferences
(
preference
);
// Add all elements
// Add all elements
$
.
each
(
response
.
data
.
nodes
,
function
(
key
,
value
)
{
$
.
each
(
data
.
nodes
,
function
(
key
,
value
)
{
var
coordinates
=
preference
[
'
coordinates
'
]
||
{};
var
coordinates
=
preference
[
'
coordinates
'
]
||
{};
var
coordinate
=
coordinates
[
key
]
||
{};
var
coordinate
=
coordinates
[
key
]
||
{};
value
[
'
coordinate
'
]
=
{};
value
[
'
coordinate
'
]
=
{};
$
.
each
(
coordinate
||
{},
function
(
k
,
v
)
{
$
.
each
(
coordinate
||
{},
function
(
k
,
v
)
{
value
[
'
coordinate
'
][
k
]
=
v
;
value
[
'
coordinate
'
][
k
]
=
v
;
});
dream_instance
.
newElement
(
value
);
dream_instance
.
updateElementData
(
key
,
{
data
:
value
.
data
||
{}
});
});
});
$
.
each
(
response
.
data
.
edges
,
function
(
key
,
value
)
{
dream_instance
.
newElement
(
value
);
dream_instance
.
connect
(
value
[
0
],
value
[
1
]);
dream_instance
.
updateElementData
(
key
,
{
data
:
value
.
data
||
{}
});
});
});
$
.
each
(
data
.
edges
,
function
(
key
,
value
)
{
dream_instance
.
connect
(
value
[
0
],
value
[
1
]);
});
// Now update id_container
// Now update id_container
$
.
each
(
response
.
data
.
nodes
,
function
(
key
,
value
)
{
$
.
each
(
data
.
nodes
,
function
(
key
,
value
)
{
var
element_id
=
value
.
id
,
var
element_id
=
value
.
id
,
prefix
,
suffix
,
splitted_element_id
;
prefix
,
suffix
,
splitted_element_id
;
splitted_element_id
=
element_id
.
split
(
"
_
"
);
splitted_element_id
=
element_id
.
split
(
"
_
"
);
prefix
=
splitted_element_id
[
0
];
prefix
=
splitted_element_id
[
0
];
suffix
=
splitted_element_id
[
1
];
suffix
=
splitted_element_id
[
1
];
id_container
[
prefix
]
=
Math
.
max
((
id_container
[
prefix
]
||
0
),
id_container
[
prefix
]
=
Math
.
max
((
id_container
[
prefix
]
||
0
),
parseInt
(
suffix
,
10
));
parseInt
(
suffix
,
10
));
});
});
dream_instance
.
setGeneralProperties
(
response
.
data
.
general
);
dream_instance
.
setGeneralProperties
(
data
.
general
);
dream_instance
.
initGeneralProperties
();
// XXX
dream_instance
.
initGeneralProperties
();
// XXX
$
(
"
#json_output
"
).
text
(
JSON
.
stringify
(
dream_instance
.
getData
(),
dream_instance
.
redraw
()
undefined
,
"
"
));
$
(
"
#json_output
"
).
text
(
JSON
.
stringify
(
dream_instance
.
getData
(),
}
undefined
,
"
"
));
};
// 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
)
{
if
(
response
!==
undefined
&&
response
.
data
!==
undefined
)
{
loadData
(
response
.
data
);
}
// once the data is read, we can subscribe to every changes
// once the data is read, we can subscribe to every changes
$
.
subscribe
(
"
Dream.Gui.onDataChange
"
,
function
(
event
,
data
)
{
$
.
subscribe
(
"
Dream.Gui.onDataChange
"
,
function
(
event
,
data
)
{
$
(
"
#json_output
"
).
text
(
JSON
.
stringify
(
data
,
undefined
,
"
"
));
$
(
"
#json_output
"
).
text
(
JSON
.
stringify
(
data
,
undefined
,
"
"
));
...
...
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