Skip to content
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

Version feature #388

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e30eed4
Create PULL_REQUEST_TEMPLATE.md
adbharadwaj Mar 4, 2018
6521955
Added GET Api for Graph Versions
jahandaniyal Jun 9, 2018
240fd20
Added POST Api for graph_version
jahandaniyal Jun 10, 2018
64921a3
Added DELETE API for graph_version
jahandaniyal Jun 10, 2018
4d307e3
Added Version selector dropdown
jahandaniyal Jun 10, 2018
321a432
Added API Specifications for Graph Version
jahandaniyal Jun 11, 2018
f99e668
Changes in model for version feature
jahandaniyal Jun 18, 2018
76b4acc
Added changes for upload, add graph
jahandaniyal Jun 18, 2018
50b9c7e
Update models - migrate json from graph to graph_version table
jahandaniyal Jun 23, 2018
1cdcb57
Added migration files for model changes
jahandaniyal Jun 23, 2018
e6b59cf
Added graph_version specific code to views
jahandaniyal Jun 23, 2018
9bd1573
Added graph_version specific code to controllers
jahandaniyal Jun 23, 2018
aed358b
dal changes - moved json from graph to graph_version
jahandaniyal Jun 23, 2018
9141f57
UI changes for graph_version feature
jahandaniyal Jun 23, 2018
5ba4276
Added Python Documentation for Version Feature
jahandaniyal Jun 30, 2018
3e1dffc
Fix indentations and remove unnecessary commented code
jahandaniyal Jun 30, 2018
5f7e224
Added Tests for GraphSpace models
jahandaniyal Jul 1, 2018
c2ed1d8
Fix indentation
jahandaniyal Jul 1, 2018
4135efe
Graph Version minor UI Fixes
jahandaniyal Jul 2, 2018
c2b90c8
Merge branch 'version_feature' of https://github.com/jahandaniyal/Gra…
jahandaniyal Jul 2, 2018
c4465e3
Fix Graph Fit and Layout issues for Graph Versions
jahandaniyal Jul 15, 2018
19e319d
Set correct z-index for Export button & version dropdown
jahandaniyal Jul 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Purpose
_Describe the problem or feature in addition to a link to the issues._

Example:
Fixes # .

## Approach
_How does this change address the problem?_

#### Open Questions and Pre-Merge TODOs
- [ ] Use github checklists. When solved, check the box and explain the answer.

## Learning
_Describe the research stage_

_Links to blog posts, patterns, libraries or addons used to solve this problem_

#### Blog Posts
- [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template.

261 changes: 261 additions & 0 deletions api_specifications/api.raml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,156 @@ types:
graph_id: number
positions_json: string
style_json: string
GraphVersion:
description: Graph Version object
example: |
{
"name": "Graph Version 1.0",
"owner_email": "user1@example.com",
"description": "This is Version 1.0 of Sample Graph",
"graph_id": 1,
"graph_json": {
"elements": {
"nodes": [
{
"position": {
"y": 277.5,
"x": 297.5
},
"data": {
"k": 0,
"id": "P4314611",
"name": "P4314611",
"label": ""
}
},
{
"position": {
"y": 277.5,
"x": 892.5
},
"data": {
"k": 0,
"id": "P0810711",
"name": "P0810711",
"label": ""
}
}
],
"edges": [
{
"data": {
"target": "P0810711",
"k": 0,
"source": "P4314611",
"is_directed": 1,
"id": "P4314611-P0810711",
"name": "P4314611-P0810711"
},
"style": {
"line-color": "blue",
"target-arrow-shape": "triangle",
"source-arrow-color": "yellow",
"width": "12px",
"curve-style": "bezier",
"line-style": "dotted"
}
}
]
},
"data": {
"description": "Description of graph.. can also point to an image hosted elsewhere",
"name": "My first graph",
"tags": [
"tutorial", "sample"
]
}
}
}
properties:
name: string
owner_email: string
description: string
graph_id: number
graph_json: GraphJSON
GraphVersionResponse:
description: Graph Version Response object
example: |
{
"name": "Graph Version 1.0",
"updated_at": "2017-03-25T15:37:20.728954",
"graph_id": 25,
"created_at": "2017-03-25T15:37:20.728954",
"owner_email": "user1@example.com",
"description": "This is Version 1.0 of Sample Graph",
"id": 21384,
"graph_json": {
"elements": {
"nodes": [
{
"position": {
"y": 277.5,
"x": 297.5
},
"data": {
"k": 0,
"id": "P4314611",
"name": "P4314611",
"label": ""
}
},
{
"position": {
"y": 277.5,
"x": 892.5
},
"data": {
"k": 0,
"id": "P0810711",
"name": "P0810711",
"label": ""
}
}
],
"edges": [
{
"data": {
"target": "P0810711",
"k": 0,
"source": "P4314611",
"is_directed": 1,
"id": "P4314611-P0810711",
"name": "P4314611-P0810711"
},
"style": {
"line-color": "blue",
"target-arrow-shape": "triangle",
"source-arrow-color": "yellow",
"width": "12px",
"curve-style": "bezier",
"line-style": "dotted"
}
}
]
},
"data": {
"description": "Description of graph.. can also point to an image hosted elsewhere",
"name": "My first graph",
"tags": [
"tutorial", "sample"
]
}
}
}
properties:
id: number
name: string
owner_email: string
graph_id: number
graph_json: GraphJSON
created_at: string
updated_at: string
description: string
Member:
description: Member Response object
example: |
Expand Down Expand Up @@ -808,6 +958,117 @@ types:
body:
application/json:
type: Error
/versions:
description: APIs to access versions of a specific graph on GraphSpace.
displayName: Graph Versions
get:
description: List all Graph Versions matching query criteria, if provided; otherwise list all Graph Versions.
queryParameters:
owner_email?: string
name?:
description: Search for Graph Versions with given name. In order to search for versions with given name as a substring, wrap the name with percentage symbol. For example, %xyz% will search for all versions with xyz in their name.
type: string
limit?:
description: Number of entities to return.
default: 20
type: number
offset?:
description: Offset the list of returned entities by this number.
default: 0
type: number
order?:
description: Defines the column sort order, can only be 'asc' or 'desc'.
type: string
sort?:
description: Defines which column will be sorted.
type: string
example: "name"
responses:
200:
description: SUCCESS
body:
application/json:
type: object
properties:
total: number
versions: GraphVersionResponse[]
400:
description: BAD REQUEST
body:
application/json:
type: Error
403:
description: FORBIDDEN
body:
application/json:
type: Error
post:
description: Create a new Graph Version.
body:
application/json:
type: GraphVersion
responses:
201:
description: SUCCESS
body:
application/json:
type: GraphVersionResponse
400:
description: BAD REQUEST
body:
application/json:
type: Error
/{version_id}:
description: APIs to access a specific graph version on GraphSpace.
displayName: Graph Version
get:
description: Get a Graph Version by id
responses:
200:
description: SUCCESS
body:
application/json:
type: GraphVersionResponse
403:
description: FORBIDDEN
body:
application/json:
type: Error
put:
description: Update a Graph Version by id
body:
application/json:
type: GraphVersion
responses:
200:
description: SUCCESS
body:
application/json:
type: GraphVersionResponse
403:
description: FORBIDDEN
body:
application/json:
type: Error
delete:
description: Delete a Graph Version by id
responses:
200:
description: SUCCESS
body:
application/json:
type: object
properties:
message: string
example: |
{
"message": "Successfully deleted graph version with id=21341"
}
403:
description: FORBIDDEN
body:
application/json:
type: Error

/groups:
description: APIs to access groups on GraphSpace.
Expand Down
77 changes: 76 additions & 1 deletion applications/graphs/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,18 @@ def add_graph(request, name=None, tags=None, is_public=None, graph_json=None, st

# Construct new graph to add to database
new_graph = db.add_graph(request.db_session, name=name, owner_email=owner_email,
graph_json=json.dumps(G.get_graph_json()), style_json=json.dumps(G.get_style_json()),
is_public=is_public, default_layout_id=default_layout_id)
default_version = db.add_graph_version(request.db_session, name=name, description='Default Version',
owner_email=owner_email, graph_json=json.dumps(G.get_graph_json()),
style_json=json.dumps(G.get_style_json()), graph_id=new_graph.id, is_default = True)

# Add default_version to new_graph
new_graph.__setattr__('default_version', default_version)
# Add graph_json to new_graph
new_graph.__setattr__('graph_json', default_version.graph_json)
# Add style_json to new_graph
new_graph.__setattr__('style_json', default_version.style_json)

# Add graph tags
for tag in G.get_tags():
add_graph_tag(request, new_graph.id, tag)
Expand Down Expand Up @@ -586,3 +596,68 @@ def add_edge(request, name=None, head_node_id=None, tail_node_id=None, is_direct
def delete_edge_by_id(request, edge_id):
db.delete_edge(request.db_session, id=edge_id)
return

def search_graph_versions(request, graph_id=None, names=None, limit=20, offset=0, order='desc', sort='name'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add python documentation. Document cases where an exception will be raised.

"""
Parameters
----------
request : object
HTTP GET Request.
graph_id : string
Unique ID of the graph.
names : list of strings
Search for graphs with given list of names. In order to search for graphs with given name as a substring, wrap the name with percentage symbol. For example, %xyz% will search for all graphs with xyz in their name.
limit : integer
Number of entities to return. Default value is 20.
offset : integer
Offset the list of returned entities by this number. Default value is 0.
order : string
Defines the column sort order, can only be 'asc' or 'desc'.
sort : string
Defines which column will be sorted.

Returns
-------
total : integer
Number of groups matching the request.
graph_versions : List of Graph Versions.
List of Graph Version Objects with given limit and offset.

Raises
------

Notes
------
"""
if sort == 'name':
sort_attr = db.GraphVersion.name
elif sort == 'update_at':
sort_attr = db.GraphVersion.updated_at
else:
sort_attr = db.GraphVersion.name

if order == 'desc':
orber_by = db.desc(sort_attr)
else:
orber_by = db.asc(sort_attr)

total, graph_versions = db.find_graph_versions(request.db_session,
names=names,
graph_id=graph_id,
limit=limit,
offset=offset,
order_by=orber_by)

return total, graph_versions

def get_graph_version_by_id(request, version_id):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

return db.get_graph_version_by_id(request.db_session, version_id)

def add_graph_version(request, name=None, description=None, owner_email=None, graph_json=None, graph_id=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

if name is None or graph_id is None or graph_json is None:
raise Exception("Required Parameter is missing!")
return db.add_graph_version(request.db_session, name=name, description=description, owner_email=owner_email, graph_json=graph_json, graph_id=graph_id)

def delete_graph_version_by_id(request, graph_version_id):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

db.delete_graph_version(request.db_session, id=graph_version_id)
return
Loading