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

New Dashboard #30

Merged
merged 24 commits into from
Feb 18, 2019
Merged
Prev Previous commit
Next Next commit
cleanup config
Andrej Berg committed Feb 3, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a766870e3ab125362e7d8a1a1172e6b35af15939
4 changes: 2 additions & 2 deletions simdb/dashboard/app/base/templates/site_template/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="footer_status">
{% if config.selected_database.id == None %}
{% if config.SELECTED_DATABASE.id == None %}
<i class="fa fa-unlink"></i> <span class="db_name">No database selected</span> <span class="db_path"></span>
{% else %}
<i class="fa fa-link"></i> <span class="db_name">{{ config.selected_database.name }}</span> <span class="db_path">( {{ config.selected_database.path }} )</span>
<i class="fa fa-link"></i> <span class="db_name">{{ config.SELECTED_DATABASE.name }}</span> <span class="db_path">( {{ config.SELECTED_DATABASE.path }} )</span>
{% endif %}
</div>

6 changes: 3 additions & 3 deletions simdb/dashboard/app/preferences/routes.py
Original file line number Diff line number Diff line change
@@ -75,16 +75,16 @@ def select_db():

if id:
id = int(id)
if id == current_app.config['selected_database']['id']:
current_app.config['selected_database'] = { "id" : None,
if id == current_app.config['SELECTED_DATABASE']['id']:
current_app.config['SELECTED_DATABASE'] = { "id" : None,
"name" : None,
"path" : None,
"comment" : None}
return "deselected"

else:
sim_db = db.session.query(Database).filter_by(id = id).first()
current_app.config['selected_database'] = sim_db.__dict__
current_app.config['SELECTED_DATABASE'] = sim_db.__dict__
return "selected"
else:
return "No database ID given."
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ <h2>Databases</h2>
<tbody>
{%- for db in databases %}

{% if db.id == config.selected_database.id %}
{% if db.id == config.SELECTED_DATABASE.id %}
<tr class="entry selected-db">
{% else %}
<tr class="entry">
@@ -56,7 +56,7 @@ <h2>Databases</h2>
<td class="db_table_toolbox">
<ul class='nav navbar-right panel_toolbox'>
<li><a class='select-link'><i class="fa fa-circle"></i></a></li>
{% if db.id == config.selected_database.id %}
{% if db.id == config.SELECTED_DATABASE.id %}
<li><a class='edit-link disabled'><i class='fa fa-edit'></i></a></li>
<li><a class='delete-link disabled'><i class='fa fa-close'></i></a></li>
{% else %}
20 changes: 13 additions & 7 deletions simdb/dashboard/config.py
Original file line number Diff line number Diff line change
@@ -13,18 +13,24 @@ class Config(object):
# DEFAULT_THEME = "themes/dark"
DEFAULT_THEME = None

SELECTED_DATABASE = {"id": None,
"name": None,
"path": None,
"comment": None}


class ProductionConfig(Config):
DEBUG = False

# AB: We can use this if we want to use a real DB server
# PostgreSQL database
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
environ.get('GENTELELLA_DATABASE_USER', 'gentelella'),
environ.get('GENTELELLA_DATABASE_PASSWORD', 'gentelella'),
environ.get('GENTELELLA_DATABASE_HOST', 'db'),
environ.get('GENTELELLA_DATABASE_PORT', 5432),
environ.get('GENTELELLA_DATABASE_NAME', 'gentelella')
)
# SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
# environ.get('GENTELELLA_DATABASE_USER', 'gentelella'),
# environ.get('GENTELELLA_DATABASE_PASSWORD', 'gentelella'),
# environ.get('GENTELELLA_DATABASE_HOST', 'db'),
# environ.get('GENTELELLA_DATABASE_PORT', 5432),
# environ.get('GENTELELLA_DATABASE_NAME', 'gentelella')
# )


class DebugConfig(Config):
9 changes: 3 additions & 6 deletions simdb/dashboard/run_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
from __future__ import print_function
from flask_migrate import Migrate
from os import environ
from sys import exit

from config import config_dict
from app import create_app, db

get_config_mode = environ.get('GENTELELLA_CONFIG_MODE', 'Debug')
get_config_mode = environ.get('SIMDB_CONFIG_MODE', 'Debug')

try:
config_mode = config_dict[get_config_mode.capitalize()]
except KeyError:
exit('Error: Invalid GENTELELLA_CONFIG_MODE environment variable entry.')
exit('Error: Invalid SIMDB_CONFIG_MODE environment variable entry.')

app = create_app(config_mode)

app.config["selected_database"] = { "id" : None,
"name" : None,
"path" : None,
"comment" : None}

Migrate(app, db)