-
Notifications
You must be signed in to change notification settings - Fork 40
Added functionality for modifing graph metadata using UI #364
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
Changes from all commits
0611da0
77de6e9
71ece32
0ff1dca
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 |
|---|---|---|
|
|
@@ -290,6 +290,9 @@ def add_tag(db_session, name): | |
| db_session.add(tag) | ||
| return tag | ||
|
|
||
| @with_session | ||
| def remove_tags_by_graph_id(db_session, graph_id): | ||
|
Collaborator
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. @bruce-wayne99 Why was this method introduced? |
||
| db_session.query(GraphToTag).filter(GraphToTag.graph_id == graph_id).delete() | ||
|
|
||
| @with_session | ||
| def get_layout(db_session, owner_email, name, graph_id): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Editing Graph Data Attributes | ||
|
|
||
| GraphSpace includes a user interface to modify the [Graph Data Attributes](https://github.com/Murali-group/GraphSpace/blob/master/docs/GraphSpace_Network_Model.md#graph-data-attributes). | ||
| Through this interface a [GraphSpace](http://www.graphspace.org) user will be able to: | ||
|
|
||
| - [Modify graph title](#edit-graph-title) | ||
| - [Modify graph name](#edit-graph-name) | ||
| - [Modify graph information/legend](#edit-graph-description) | ||
| - [Add/remove tags](#edit-graph-tags) | ||
|
|
||
| The user can activate this functionality by clicking the `Edit` button on the page for an individual network. | ||
|
|
||
| ## Edit graph title | ||
|
|
||
| A [Graphspace](http://www.graphspace.org) user can edit the graph title by following the given steps: | ||
|
|
||
| 1. Click on the `Edit` button present on the right top corner of the page given for an individual network. | ||
| 2. Enter the **new title** in the space provided under the `Title` heading. | ||
| 3. Click on `Save` if you want to save the changes else click on the `Cancel` button to discard the changes. | ||
| 4. On clicking the `Save` button you will be notified with a success or error message based on whether **title** of the graph has been updated or not. | ||
|
|
||
|  | ||
|
|
||
| ## Edit graph name | ||
|
|
||
| A [Graphspace](http://www.graphspace.org) user can edit the graph name by following the given steps: | ||
|
|
||
| 1. Click on the `Edit` button present on the right top corner of the page given for an individual network. | ||
| 2. Enter the **new name** in the space provided under the `Name` heading. | ||
| 3. Click on `Save` if you want to save the changes else click on the `Cancel` button to discard the changes. | ||
| 4. On clicking the `Save` button you will be notified with a success or error message based on whether **name** of the graph has been updated or not. | ||
|
|
||
|  | ||
|
|
||
| ## Edit graph description | ||
|
|
||
| A [Graphspace](http://www.graphspace.org) user can edit the graph description/legend by following the given steps: | ||
|
|
||
| 1. Click on the `Edit` button present on the right top corner of the page given for an individual network. | ||
| 2. Navigate to the `Graph Information` Page. | ||
| 3. Enter the **new description** in the space provided under the `Description` heading. | ||
| 3. Click on `Save` if you want to save the changes else click on the `Cancel` button to discard the changes. | ||
| 4. On clicking the `Save` button you will be notified with a success or error message based on whether **description** of the graph has been updated or not. | ||
|
|
||
|  | ||
|
|
||
| ## Edit graph tags | ||
|
|
||
| A [Graphspace](http://www.graphspace.org) user can add/remove tags by following the given steps: | ||
|
|
||
| 1. Click on the `Edit` button present on the right top corner of the page given for an individual network. | ||
| 2. Enter the **new tags** in the space provided under the `Add/Remove tags` heading with space separation. | ||
| 3. You can remove the **old tags** by clicking on the `x` symbol provided for each tag. | ||
| 4. Click on `Save` if you want to save the changes else click on the `Cancel` button to discard the changes. | ||
| 5. On clicking the `Save` button you will be notified with a success or error message based on whether **tags** of the graph have been updated or not. | ||
|
|
||
|  |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -430,6 +430,7 @@ var uploadGraphPage = { | |
| var graphPage = { | ||
| cyGraph: undefined, | ||
| timeout: null, | ||
| tagsBar: null, | ||
|
Collaborator
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. Rename it to |
||
| init: function () { | ||
| /** | ||
| * This function is called to setup the graph page. | ||
|
|
@@ -513,6 +514,19 @@ var graphPage = { | |
| $('#inputSearchEdgesAndNodes').val(searchquery).trigger('onkeyup'); | ||
| } | ||
|
|
||
| graphPage.tagsBar = $(".add-remove-tags").select2({ | ||
| tags: true, | ||
| tokenSeparators: [',', ' '], | ||
| width: '99%' | ||
| }); | ||
|
|
||
| //adding on click event handlers to buttons used for editing graphs. | ||
| $('#cancel-edit-btn').click(function () { | ||
| $('#edit-tab').css('display','none'); | ||
| $('#view-tab').css('display',''); | ||
| $('#edit-desc').css('display','none'); | ||
| $('#view-desc').css('display',''); | ||
| }); | ||
|
|
||
| graphPage.defaultLayoutWidget.init(); | ||
| }, | ||
|
|
@@ -686,6 +700,56 @@ var graphPage = { | |
| ) | ||
| ); | ||
| }, | ||
| updateGraphAttributesBtn: function (e, graph_id) { | ||
|
|
||
| //takes name,title, description and tags and updates them by sending an ajax request to server. | ||
| apis.graphs.update(graph_id, { | ||
| 'name': $('#new_name').val(), | ||
| 'title': $('#new_title').val(), | ||
| 'description': $('#new_description').val(), | ||
| 'tags': graphPage.tagsBar.val() | ||
| }, | ||
| successCallback = function (response) { | ||
| // This method is called when attributes of the graph(name, title, tags...etc) have been successfully updated. | ||
| $.notify({message: 'Successfully updated the graph with id=' + graph_id.toString()}, {type: 'success'}); | ||
| location.reload(); | ||
| }, | ||
| errorCallback = function (xhr, status, errorThrown) { | ||
| // This method is called when error occurs while trying to update the graph attributes. | ||
| $.notify({ | ||
| message: xhr.responseJSON.error_message | ||
| }, { | ||
| type: 'danger' | ||
| }); | ||
|
|
||
| }); | ||
| }, | ||
| graphEditFormatter: function(e, title, name, description) { | ||
|
|
||
| //populating input tags with appropriate values before showing the edit panel. | ||
| $('#new_name').val(name); | ||
| $('#new_title').val(title); | ||
| $('#new_description').val(description); | ||
|
|
||
| //fetching all the tags and populating them in the tag bar. | ||
| console.log(title, name, description); | ||
|
Collaborator
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. Remove logs from final pull request. |
||
| var hyper_links = $('#Tags').children(); | ||
| graphPage.tagsBar.find('option').remove().end(); | ||
| $.each(hyper_links, function(idx) { | ||
| var tag = $.trim(hyper_links[idx].text); | ||
| graphPage.tagsBar.append(new Option(tag, tag, true, true)); | ||
| } | ||
| ); | ||
| graphPage.tagsBar.trigger('change'); | ||
|
|
||
| //hides view tab and displays edit tab. | ||
| $('#view-tab').css('display','none'); | ||
| $('#edit-tab').css('display',''); | ||
|
|
||
| //hides view description tab and displays edit description tab. | ||
| $('#view-desc').css('display','none'); | ||
| $('#edit-desc').css('display',''); | ||
| }, | ||
| onShareGraphWithPublicBtn: function (e, graph_id) { | ||
|
|
||
| apis.graphs.update(graph_id, { | ||
|
|
||
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.
@bruce-wayne99 Why was this method introduced?
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.
Editing tags involves adding new tags and removing old tags simultaneously,
For example:
Let a user removed a tag named x from the graph G and added a tag y to the graph. So, there is a need to delete a row from
GraphToTagcontaining thegraph_idequal to the graph id of G andtag_idequal to tag id of tag x and also addition of a row withgraph_idequal to the graph id of G andtag_idequal to tag id of tag y.Now both these operations can be carried out at once if we remove all the entries of graph G in
GraphToTagtable and after that adding the final list of tags the user wants to the graph.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.
@adbharadwaj I have provided an explanation for the usage of
db.remove_tags_by_graph_id. Please review.