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

update endpoints section and change connect to disconnect #17

Merged
merged 2 commits into from
Sep 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

@app.route('/', methods= ['GET','POST'])
def enter_url():
global history
history = []
if request.method == 'GET':
# print(render_template("index.html"))
return render_template("index.html")
Expand All @@ -34,7 +36,7 @@ def enter_url():
check_url = str.encode(url)
querying_mechanism.check_url_exist(check_url,facades)
print(url,endpoints)
return render_template("index.html", apidoc = endpoints, history=history)
return render_template("query.html", apidoc = endpoints, history=history)
# elif 'query' in request.form:
# query = request.form['query']
# print(query)
Expand All @@ -46,7 +48,7 @@ def enter_url():
def enter_query():
global history
if request.method == 'GET':
return render_template("index.html")
return render_template("query.html")
if request.method == 'POST':
if 'query' in request.form:
print("here")
Expand All @@ -58,7 +60,7 @@ def enter_query():
history_rev.pop()
history = history_rev[::-1]
output = facades.user_query(query)
return render_template("index.html", apidoc = endpoints, query_output = output, history=history_rev)
return render_template("query.html", apidoc = endpoints, query_output = output, history=history_rev)


if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions static/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
margin-right: 12px;
margin-top: 10px;
}
.row {
margin-right: 0px;
}
48 changes: 31 additions & 17 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,31 @@
<h1 align="center">Hydra Astrodemo</h1>
<h3 align="center">Satellite Assemblying with Smart Clients</h3>
<div class="container">
<div class="row">
<div class="row" style="margin-right: 0px;">
<form method="post">
<div id="url" class="input-group mb-3 col-sm">
<div id="url" class="input-group mb-3 col-sm" style="margin-left:240px;">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-default">URL</span>
</div>
<input id="url-input" name="url" type="text" placeholder="Enter Server URL" class="form-control" aria-label="Default" />
<input type="submit" style="margin-left: 6px" class="btn btn-success" value="Connect" />
</div>
</form>

<form action="http://localhost:5000/query" method="post">
<div id="url" class="input-group mb-3 col-sm">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-default">Query</span>
</div>
<input id="url-input" name="query" placeholder="Enter Query Here" type="text" class="form-control" aria-label="Default" />
<input type="submit" value="Send Query" style="margin-left: 6px" class="btn btn-success" />
</div>
</form>


<!-- <form action="http://localhost:5000/query" method="post">-->
<!-- <div id="url" class="input-group mb-3 col-sm">-->
<!-- <div class="input-group-prepend">-->
<!-- <span class="input-group-text" id="inputGroup-sizing-default">Query</span>-->
<!-- </div>-->
<!-- <input id="url-input1" name="query" placeholder="Enter Query Here" type="text" class="form-control" aria-label="Default" />-->
<!-- <input id="submit_query" type="submit" value="Send Query" style="margin-left: 6px" class="btn btn-success" />-->
<!-- </div>-->
<!-- </form>-->
</div>

</div>
<div class="row">
<div class="row" style="margin-right: 0px; margin-left:50px;">
<div class="col-sm-4" id="endpoints-header">Endpoints</div>
<div class="col-sm-7" id="output-header">OutPut</div>
</div>
Expand Down Expand Up @@ -132,14 +133,27 @@ <h4 class="panel-title">
</div>
</div>
</div>-->
<div class = "row">
<!-- <script>-->
<!-- function put_input(name){-->
<!-- var input = document.getElementById('url-input1');-->
<!-- if (name.match("Collection")) {-->
<!-- name = name + " members"-->
<!-- }-->
<!-- else{-->
<!-- name = name+" properties"-->
<!-- }-->
<!-- input.value = name-->
<!-- }-->
<!-- </script>-->
<div class = "row" style="margin-right: 0px; margin-left:50px;">
<div class="col-sm-4" id="entrypoint-body" style="height:80%;">
{% for element in apidoc %}
{% if element != "@type" and element != "@id" and element != "@context" %}
<a href = ''><p>{{ element }} </p></a>

<p onClick = "put_input('{{element}}')" style="color: #0000FF;">{{element}}</p>
{% endif %}
{% endfor %}</div>
<div class="col-sm-7" id="entrypoint-body">
<div class="col-sm-7" id="entrypoint-body"style="margin-left:16px">
{% if query_output %}
{% for element in query_output %}
<p>{{element}}</p>
Expand All @@ -150,7 +164,7 @@ <h4 class="panel-title">
</div>
</div>
<br><br>
<div class="col-sm-4" style="background-color: bisque; text-align: center; font-size: x-large; margin-right: 12px; height: 40px;">History</div>
<div class="col-12" style="background-color: bisque; text-align: center; font-size: x-large; margin-right: 40px; height: 30px;">History</div>
<div class="col-sm-4" id="output-body">{{history}}</div>


Expand Down
93 changes: 93 additions & 0 deletions templates/query.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<html>

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">

<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='styles/index.css') }}">
<title>
AstroDemo
</title>


</head>


<body>
<h1 align="center">Hydra Astrodemo</h1>
<h3 align="center">Satellite Assemblying with Smart Clients</h3>
<div class="container">
<div class="row" style="margin-right: 0px;">
<form method="post" action="http://localhost:5000">
<div id="url" class="input-group mb-3 col-sm" style="margin-left:75px;">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-default">URL</span>
</div>

<input onclick="window.location.href='http://localhost:5000';" style="margin-left: 6px" class="btn btn-success" value="DisConnect" />
</div>
</form>

<form name = "query_submit" action="http://localhost:5000/query" method="post">
<div id="url" class="input-group mb-3 col-sm" style="margin-left:0px">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-default">Query</span>
</div>
<input id="url-input1" name="query" placeholder="Enter Query Here" type="text" class="form-control" aria-label="Default" />
<input id="submit_query" type="submit" value="Send Query" style="margin-left: 6px" class="btn btn-success" />
</div>
</form>

</div>

</div>
<div class="row" style="margin-right:0px; margin-left:50px;">
<div class="col-sm-4" id="endpoints-header">Endpoints</div>
<div class="col-sm-7" id="output-header">OutPut</div>
</div>


<script>
function put_input(name,type){
var input = document.getElementById('url-input1');
if (type == 'endpoint'){
if (name.match("Collection")) {
name = name + " members"
}
else{
name = "class"+name+" properties"
}
}
input.value = name
document.query_submit.submit();

}
</script>
<div class = "row" style="margin-right: 0px; margin-left:50px;">
<div class="col-sm-4" id="entrypoint-body" style="height:80%;">
{% for element in apidoc %}
{% if element != "@type" and element != "@id" and element != "@context" %}

<p title = "@id: '{{element}} members'" onClick = "put_input('{{element}}','endpoint')" style="color: #0000FF;cursor: pointer;">{{element}}</p>
{% endif %}
{% endfor %}</div>
<div class="col-sm-7" id="entrypoint-body" style="margin-left: 16px">
{% if query_output %}
{% for element in query_output %}
<p>{{element}}</p>
{% endfor %}
{% else %}
<p>{{query_output}}</p>
{% endif %}
</div>
</div>
<br><br>
<div class="col-12" style="background-color: bisque; text-align: center; font-size: x-large; margin-right: 40px; height: 30px;">History</div>
<div class="col-12" id="output-body">
{% for elt in history %}
<p title="@id:'{{elt}}'" onClick = "put_input('{{elt}}','history')" style="color: #0000FF;cursor: pointer;">{{elt}}</p>

{% endfor %}
</div>

</body>