-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Proof of concept Fork functionality #353
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,6 +441,13 @@ var graphPage = { | |
|
||
utils.initializeTabs(); | ||
|
||
$("#ForkGraph").click(function (e) { | ||
e.preventDefault(); | ||
if (!$(this).hasClass('disabled')){ | ||
graphPage.fork($(this).data()); // Passing data about parent graph to fork() as argument | ||
} | ||
}); | ||
|
||
$('#saveOnExitLayoutBtn').click(function () { | ||
graphPage.cyGraph.contextMenus('get').destroy(); // Destroys the cytocscape context menu extension instance. | ||
|
||
|
@@ -516,6 +523,34 @@ var graphPage = { | |
|
||
graphPage.defaultLayoutWidget.init(); | ||
}, | ||
fork: function (data) { | ||
//Read the meta_data object and add 'parent_id' & 'parent_email' to the data field. | ||
graph_meta_data = cytoscapeGraph.getNetworkAndViewJSON(graphPage.cyGraph); | ||
graph_meta_data.data['parent_id'] = data.graph_id; | ||
graph_meta_data.data['parent_email'] = data.owner_email; | ||
var graphData = { | ||
'name':data.graph_name, | ||
'is_public':0, | ||
'owner_email':data.uid, | ||
'graph_json':JSON.stringify(graph_meta_data, null, 4), | ||
'style_json':JSON.stringify(cytoscapeGraph.getStyleJSON(graphPage.cyGraph), null, 4) | ||
} | ||
$.ajax({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of making an ajax call here. Can you add an API function at the top of the file (checkout Line 5)- just like - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review. I will make the changes you have requested and send another pull request. |
||
"type": "POST", | ||
"dataType": "json", | ||
"url": "/fork_graph", | ||
"data": graphData, | ||
"success": function (data) { | ||
if(data.result=='Success'){ | ||
$("#ForkGraph span").text('Forked Successfully'); | ||
$("#ForkGraph").addClass('disabled'); | ||
} | ||
else{ | ||
alert('Could not fork the Graph due to the following error : ' + data.result); | ||
} | ||
}, | ||
}); | ||
}, | ||
export: function (format) { | ||
cytoscapeGraph.export(graphPage.cyGraph, format, $('#GraphName').val()); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ <h4 class="modal-title" id="myModalLabel">Save Layout</h4> | |
<!--- Modals end here---> | ||
<div class="container-fluid zero-margin zero-padding"> | ||
<div class="row zero-margin zero-padding padding-top-2 padding-bottom-2"> | ||
<div class="col-md-10"> | ||
<div class="col-md-9"> | ||
<p class="lead"> | ||
{{ title }} | ||
</p> | ||
|
@@ -169,16 +169,40 @@ <h4 class="zero-margin d-inline-block"> | |
{% endfor %} | ||
</div> | ||
{% endif %} | ||
{% if 'data' in graph.graph_json and 'parent_email' in graph.graph_json.data%} | ||
<p class="small"> | ||
<small> forked from {{ graph.graph_json.data.parent_email }}/ <a class="text-center" | ||
href="{% url 'graphs' %}{{ graph.graph_json.data.parent_id }} "> {{ graph.name }} </a> </small> | ||
</p> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="col-md-2"> | ||
<div class="col-md-3"> | ||
{% if isForked %} | ||
<div class="btn-group" style=": 1em !important; z-index: 20000"> | ||
<button type="button" class="btn btn-sm btn-default disabled" | ||
aria-haspopup="true" aria-expanded="false"> | ||
<i class="fa fa-code-fork" aria-hidden="true"></i> Forked Successfully | ||
</button> | ||
|
||
</div> | ||
{% elif uid != graph.owner_email %} | ||
<div class="btn-group pull-right" style=": 1em !important; z-index: 20000"> | ||
<button type="button" id='ForkGraph' class="btn btn-sm btn-default" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ID should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I will make the changes. |
||
aria-haspopup="true" aria-expanded="false" data-uid={{ uid }} data-graph_name="{{ title }}" | ||
data-graph_id={{ graph.id }} data-owner_email={{ graph.owner_email }}> | ||
<i class="fa fa-code-fork" aria-hidden="true"></i> <span>Fork</span> | ||
</button> | ||
|
||
</div> | ||
{% endif %} | ||
{% if uid and uid == graph.owner_email %} | ||
<a class="btn btn-default pull-right btn-sm" href="#" data-toggle="modal" | ||
data-target="#shareGraphModal"> | ||
<i class="fa fa-share-alt fa-lg"></i> Share | ||
</a> | ||
{% endif %} | ||
<div class="btn-group pull-right" style="margin-right: 1em !important; z-index: 20000"> | ||
<div class="btn-group pull-right" style="margin-right: 1em !important; z-index: 1001"> | ||
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" | ||
aria-haspopup="true" aria-expanded="false"> | ||
<i class="fa fa-download fa-lg"></i> Export <span class="caret"></span> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cna you fix the indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely, I will fix it.