mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 23:24:57 +00:00
add code for saving and redrawing layout
This commit is contained in:
parent
4d6ce5114a
commit
d64747ddef
|
@ -96,6 +96,8 @@ var cy = cytoscape({
|
||||||
{
|
{
|
||||||
selector: 'edge',
|
selector: 'edge',
|
||||||
style: {
|
style: {
|
||||||
|
'content': 'data(name)',
|
||||||
|
'text-wrap': 'wrap',
|
||||||
'width': 4,
|
'width': 4,
|
||||||
'curve-style': 'bezier',
|
'curve-style': 'bezier',
|
||||||
'target-arrow-shape': 'triangle',
|
'target-arrow-shape': 'triangle',
|
||||||
|
@ -109,6 +111,30 @@ var cy = cytoscape({
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function save_handler(evt) {
|
||||||
|
// console.log(JSON.stringify(cy.json().elements));
|
||||||
|
$.ajax('../op/op.WorkflowMgr.php', {
|
||||||
|
type:"POST",
|
||||||
|
async:true,
|
||||||
|
dataType:"json",
|
||||||
|
data: {
|
||||||
|
action: 'setrenderdata',
|
||||||
|
workflowid: <?php echo $this->workflow->getID(); ?>,
|
||||||
|
data: JSON.stringify(cy.json().elements)
|
||||||
|
},
|
||||||
|
success: function(data, textStatus) {
|
||||||
|
noty({
|
||||||
|
text: data.message,
|
||||||
|
type: data.success ? 'success' : 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
cy.on('free', 'node', function(evt) {
|
cy.on('free', 'node', function(evt) {
|
||||||
$('#png').attr('src', cy.png({'full': true}));
|
$('#png').attr('src', cy.png({'full': true}));
|
||||||
});
|
});
|
||||||
|
@ -116,8 +142,20 @@ cy.on('free', 'node', function(evt) {
|
||||||
if(!$renderdata)
|
if(!$renderdata)
|
||||||
$this->printGraph();
|
$this->printGraph();
|
||||||
?>
|
?>
|
||||||
cy.layout({ name: '<?php echo $renderdata ? 'preset' : 'grid'; ?>', condense: true });
|
cy.layout({ name: '<?php echo $renderdata ? 'preset' : 'cose'; ?>', condense: true, ready: function() {$('#png').attr('src', cy.png({'full': true}))} });
|
||||||
$('#png').attr('src', cy.png({'full': true}));
|
// $('#png').attr('src', cy.png({'full': true}));
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('body').on('click', '#savelayout', function(ev){
|
||||||
|
ev.preventDefault();
|
||||||
|
save_handler();
|
||||||
|
});
|
||||||
|
$('body').on('click', '#setlayout', function(ev){
|
||||||
|
ev.preventDefault();
|
||||||
|
var element = $(this);
|
||||||
|
cy.layout({name: element.data('layout'), ready: function() {$('#png').attr('src', cy.png({'full': true}))}});
|
||||||
|
});
|
||||||
|
});
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -244,6 +282,8 @@ $('#png').attr('src', cy.png({'full': true}));
|
||||||
$this->htmlAddHeader('
|
$this->htmlAddHeader('
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {padding: 0px;}
|
body {padding: 0px;}
|
||||||
|
div.buttons {float: right; padding-left: 4px; height: 100px; width: 120px; margin-right: 5px;}
|
||||||
|
div.buttons button {margin: 3px; float: right;}
|
||||||
</style>
|
</style>
|
||||||
', 'css');
|
', 'css');
|
||||||
$this->htmlStartPage(getMLText("admin_tools"));
|
$this->htmlStartPage(getMLText("admin_tools"));
|
||||||
|
@ -252,6 +292,10 @@ body {padding: 0px;}
|
||||||
?>
|
?>
|
||||||
<div id="canvas" style="width: 100%; height:546px; _border: 1px solid #bbb;"></div>
|
<div id="canvas" style="width: 100%; height:546px; _border: 1px solid #bbb;"></div>
|
||||||
<img id="png" style="float: left; border: 1px solid #bbb; min-height: 100px; min-width: 100px; height: 100px; _width: 100px; padding: 3px;" />
|
<img id="png" style="float: left; border: 1px solid #bbb; min-height: 100px; min-width: 100px; height: 100px; _width: 100px; padding: 3px;" />
|
||||||
|
<div class="buttons">
|
||||||
|
<button class="btn btn-mini" id="savelayout">Save layout</button>
|
||||||
|
<button class="btn btn-mini" id="setlayout" data-layout="cose">Redraw</button>
|
||||||
|
</div>
|
||||||
<?php
|
<?php
|
||||||
// $this->contentContainerEnd();
|
// $this->contentContainerEnd();
|
||||||
if(method_exists($this, 'js'))
|
if(method_exists($this, 'js'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user