diff --git a/.gitignore b/.gitignore index d95d47655ab9bacaa5a937d05998f0783285d419..4433965e4ceaee4a5242d0d66a1fc00c2ca69366 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **__pycache__/ # contains data for local tests -app/ \ No newline at end of file +app/ +site/ \ No newline at end of file diff --git a/frontend/createStatic.py b/frontend/createStatic.py new file mode 100644 index 0000000000000000000000000000000000000000..f997f3a8ac6f756606aec51784522d23b51c4620 --- /dev/null +++ b/frontend/createStatic.py @@ -0,0 +1,46 @@ +from jinja2 import Environment, FileSystemLoader +import os +import shutil + +def main(): + ## copy javascript files to site folder + src_files = os.listdir('frontend/js') + dest = 'site/js' + os.makedirs(dest, exist_ok=True) + #os.mkdir(dest) + + for file_name in src_files: + full_name = os.path.join('frontend/js', file_name) + if os.path.isfile(full_name): + shutil.copy(full_name, dest) + + ## render templates to site folder + file_loader = FileSystemLoader('frontend/templates') + env = Environment(loader=file_loader) + + files = { + 'index' : 'index_content.html.jinja', + 'storage' : 'storage_content.html.jinja', + 'impressum' : 'impressum_content.html.jinja', + 'login' : 'login_content.html.jinja' + } + + templates = {} + + for file in files.keys(): + templates[file] = env.get_template(files[file]) + + html = {} + + + html['index'] = templates['index'].render(home=True) + html['storage'] = templates['storage'].render(storage=True) + html['impressum'] = templates['impressum'].render(impressum=True) + html['login'] = templates['login'].render(login=True) + + for file in files.keys(): + with open('site/'+file+'.html', 'w') as f: + f.write(html[file]) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/frontend/js/apicalls.js b/frontend/js/apicalls.js new file mode 100644 index 0000000000000000000000000000000000000000..ab016175b185de17438b783ac9c6d9a5ba84517f --- /dev/null +++ b/frontend/js/apicalls.js @@ -0,0 +1 @@ +// This file will contain the api calls, as well as transform the data into html-text (via a template) \ No newline at end of file diff --git a/frontend/js/auth.js b/frontend/js/auth.js new file mode 100644 index 0000000000000000000000000000000000000000..48f89d356329ce4b6a180693b89401a1d3cac51d --- /dev/null +++ b/frontend/js/auth.js @@ -0,0 +1 @@ +// This file will contain functions to manage authentication (including the token storage and access) diff --git a/frontend/js/choose_storage.js b/frontend/js/choose_storage.js new file mode 100644 index 0000000000000000000000000000000000000000..8b71c9a3dc3be275c9439a365ea5cfef9f120ba3 --- /dev/null +++ b/frontend/js/choose_storage.js @@ -0,0 +1,27 @@ +// get data from url query variables +function getUrlVars() +{ + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; +} + +// return the storage type +function getType() { + var type = getUrlVars()["type"] + console.log("Type: " + type) + return type +} + +// set the text of the typetext element +function setTypeText() { + $('#typetext').text(getType()) +} + +setTypeText() \ No newline at end of file diff --git a/frontend/templates/base.html.jinja b/frontend/templates/base.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..782e5009e676ce1f736de12fde1c9b625b51a249 --- /dev/null +++ b/frontend/templates/base.html.jinja @@ -0,0 +1,60 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>eFlows4HPC Data Catalog - {% block title %}{% endblock %}</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> + <style> + .fakeimg { + height: 200px; + background: #aaa; + } + </style> +</head> +<body> + <!--BIG TITLE WITH LOGO--> + <div class="jumbotron text-center" style="margin-bottom:0"> + <h1><a href="https://www.eFlows4HPC.eu">eFlows4HPC Data Catalog</a></h1> + </div> + + <!--NAVBAR--> + <nav class="navbar navbar-inverse"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="#">Data Catalog</a> + </div> + <div class="collapse navbar-collapse" id="myNavbar"> + <ul class="nav navbar-nav"> + <li {% if home is true %} class="active"{% endif %}><a href="./index.html">Home</a></li> + <li {% if storage is true %} class="active"{% endif %}><a href="./storage.html?type=dataset">Storage</a></li> + <li {% if impressum is true %} class="active"{% endif %}><a href="./impressum.html">Impressum</a></li> + <li {% if login is true %} class="active"{% endif %}><a href="./login.html" id="loginText">Log In</a></li> <!--If token is found in local storage, replace with logged in username and log-out option (i.e. delete local token)--> + </ul> + </div> + </div> + </nav> + + <!--SPECIFIC PAGE CONTENT--> + {% block content%} + {% endblock %} + + <!--FOOTER--> + <div class="jumbotron text-center" style="margin-bottom:0"> + <p>Information about server admin and impressum</p> + </div> + + <!--EXTRA JAVASCRIPT--> + {% block scripts %} + {% endblock %} + + <!--SHARED JAVASCRIPT--> + <script src="js/auth.js"></script> +</body> \ No newline at end of file diff --git a/frontend/templates/impressum_content.html.jinja b/frontend/templates/impressum_content.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..a0a1793bfbcb6ac9787017346322deb5092d8651 --- /dev/null +++ b/frontend/templates/impressum_content.html.jinja @@ -0,0 +1,9 @@ +{% extends "base.html.jinja"%} + +{% block title %}Impressum{% endblock %} +{% block content %} +<p>INSERT IMPRESSUM HERE!!</p> +{% endblock %} + +{% block scripts %} +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/index_content.html.jinja b/frontend/templates/index_content.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..1a6698d9d2ea4d973ea5fdda429503d7ef912367 --- /dev/null +++ b/frontend/templates/index_content.html.jinja @@ -0,0 +1,18 @@ +{% extends "base.html.jinja"%} + +{% block title %}Home{% endblock %} +{% block content %} +<div class="container"> + <div class="row"> + <div class="col-sm-8"> + <h2>Basic information about this service</h2> + <h5>Documentation of the data format</h5> + <div class="fakeimg">Maybe the Logo again</div> + <hr class="hidden-sm hidden-md hidden-lg"> + </div> + </div> +</div> +{% endblock %} + +{% block scripts %} +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/login_content.html.jinja b/frontend/templates/login_content.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..1d044e9b051842ad459992aecd5f78b1776dbc22 --- /dev/null +++ b/frontend/templates/login_content.html.jinja @@ -0,0 +1,9 @@ +{% extends "base.html.jinja"%} + +{% block title %}Login{% endblock %} +{% block content %} +<p>INSERT Login Stuff HERE!!</p> +{% endblock %} + +{% block scripts %} +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/storage_content.html.jinja b/frontend/templates/storage_content.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..e5aebece1e41c6132ebd3eecc46ae11af45885ec --- /dev/null +++ b/frontend/templates/storage_content.html.jinja @@ -0,0 +1,28 @@ +{% extends "base.html.jinja"%} + +{% block title %}Storage{% endblock %} +{% block content %} +<div class="container"> + <div class="row"> + <div class="col-sm-8"> + <div class="dropdown"> + <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuType" data-bs-toggle="dropdown" aria-expanded="false"> + Select Storage Type + </button> <label id="typetext">TYPENAME</label> + <ul class="dropdown-menu" aria-labelledby="dropdownMenuType"> + <li><a class="dropdown-item" href="?type=dataset">Dataset</a></li> + <li><a class="dropdown-item" href="?type=storagetarget">Storage Target</a></li> + </ul> + </div> + <h2>Basic information about this service</h2> + <h5>Documentation of the data format</h5> + <div class="fakeimg">Maybe the Logo again</div> + <hr class="hidden-sm hidden-md hidden-lg"> + </div> + </div> +</div> +{% endblock %} + +{% block scripts %} + <script src="js/choose_storage.js"></script> +{% endblock %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 01cc3bcf5c0698441a411d1b07cf6ea7c79a3ac0..b736477610ba4c32f55d0ff4d4d50e226824e77c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ uvicorn==0.13.4 python-dotenv==0.17.1 python-multipart==0.0.5 python-jose[cryptography]==3.2.0 -passlib[bcrypt]==1.7.4 \ No newline at end of file +passlib[bcrypt]==1.7.4 +jinja2==3.0.1 \ No newline at end of file