-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from samply/develop
Revised the style of the page and made it dynamic
- Loading branch information
Showing
5 changed files
with
179 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
from os import environ | ||
from flask import Flask, render_template, url_for | ||
from os import environ | ||
from importlib import import_module | ||
from common import ServiceType | ||
|
||
app = Flask(__name__) | ||
|
||
def prepare_vars(vars): | ||
missingvars = [] | ||
for var in vars: | ||
env = environ.get(var) | ||
if env == None: | ||
missingvars.append(var) | ||
|
||
def prepare_vars(required_vars): | ||
missing_vars = [var for var in required_vars if not environ.get(var)] | ||
if missing_vars: | ||
raise Exception(f"Please define variables: {', '.join(missing_vars)}") | ||
|
||
for var in required_vars: | ||
globals()[var] = environ.get(var) | ||
|
||
if(len(missingvars) > 0): | ||
raise Exception("Please define variables: %s" % (", ".join(missingvars)) ) | ||
|
||
prepare_vars(["PROJECT", "SITE_NAME", "HOST", "ENVIRONMENT"]) | ||
project = import_module(f"projects.{PROJECT.lower()}") | ||
|
||
|
||
@app.route("/") | ||
def page(): | ||
return render_template('page.template', | ||
site_name=SITE_NAME, | ||
thishostname=HOST, | ||
project=PROJECT, | ||
projectname=project.projectname_friendly, | ||
logo=url_for("static", filename="%s.svg" % (PROJECT)), | ||
centralservices=[service for service in project.services if service.type==ServiceType.CENTRAL], | ||
localservices=[service for service in project.services if service.type==ServiceType.BRIDGEHEAD]) | ||
|
||
prepare_vars(["PROJECT", "SITE_NAME", "HOST"]) | ||
site_name=SITE_NAME, | ||
ENVIRONMENT=environ.get("ENVIRONMENT"), | ||
thishostname=HOST, | ||
project=PROJECT, | ||
projectname=project.projectname_friendly, | ||
logo=url_for("static", filename="%s.svg" % (PROJECT)), | ||
centralservices=[service for service in project.services if | ||
service.type == ServiceType.CENTRAL], | ||
localservices=[service for service in project.services if | ||
service.type == ServiceType.BRIDGEHEAD]) | ||
|
||
project = import_module("projects.%s" % (PROJECT.lower()) ) | ||
|
||
if __name__ == '__main__': | ||
app.run() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
from enum import Enum | ||
|
||
|
||
class ServiceType(Enum): | ||
CENTRAL = 1 | ||
BRIDGEHEAD = 2 | ||
|
||
|
||
class ServiceGroup(Enum): | ||
PSEUDONYMIZATION = 1 | ||
SEARCH = 2 | ||
PERSISTENCE = 3 | ||
OPERATIONS = 4 | ||
NEGOTIATION = 5 | ||
|
||
|
||
class Service: | ||
def __init__(self, group, name, url, type): | ||
self.group = group | ||
self.name = name | ||
self.url = url | ||
self.type = type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import os | ||
from common import Service, ServiceGroup, ServiceType | ||
|
||
projectname_friendly = "BBMRI-ERIC/GBN" | ||
|
||
services = [ | ||
Service(ServiceGroup.SEARCH, "Sample Locator (bbmri.de)", "https://samplelocator.bbmri.de", ServiceType.CENTRAL), | ||
Service(ServiceGroup.SEARCH, "Sample Locator (BBMRI-ERIC)", "https://locator.bbmri-eric.eu", ServiceType.CENTRAL), | ||
services = [] | ||
|
||
if os.environ.get("FLASK_ENV") == "production": | ||
services.append(Service(ServiceGroup.SEARCH, "Sample Locator (bbmri.de)", "https://samplelocator.bbmri.de", ServiceType.CENTRAL)) | ||
services.append(Service(ServiceGroup.SEARCH, "Sample Locator (BBMRI-ERIC)", "https://locator.bbmri-eric.eu", ServiceType.CENTRAL)) | ||
else: | ||
services.append(Service(ServiceGroup.SEARCH, "Sample Locator (bbmri.de)", "https://samplelocator.test.bbmri.de", ServiceType.CENTRAL)) | ||
services.append(Service(ServiceGroup.SEARCH, "Sample Locator (BBMRI-ERIC)", "https://locator-dev.bbmri-eric.eu", ServiceType.CENTRAL)) | ||
|
||
services.extend([ | ||
Service(ServiceGroup.NEGOTIATION, "Negotiator", "https://negotiator.bbmri-eric.eu", ServiceType.CENTRAL), | ||
Service(ServiceGroup.OPERATIONS, "Zentrales Monitoring", "https://monitoring.verbis.dkfz.de/icingaweb2/dashboard", ServiceType.CENTRAL), | ||
Service(ServiceGroup.OPERATIONS, "Reverse Proxy (Traefik)", "https://<THISHOST>/dashboard/", ServiceType.BRIDGEHEAD), | ||
Service(ServiceGroup.PERSISTENCE, "FHIR-Server (Blaze)", "https://<THISHOST>/bbmri-localdatamanagement/fhir", ServiceType.BRIDGEHEAD), | ||
] | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters