Skip to content

Commit

Permalink
Merge branch 'master' of https://[email protected]/toddbirchard…
Browse files Browse the repository at this point in the history
…/pythonmyadmin
  • Loading branch information
toddbirchard committed Jun 24, 2024
2 parents 8bbbcef + 35aa3ad commit 580d411
Show file tree
Hide file tree
Showing 19 changed files with 552 additions and 141 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ lint: env
--show-source \
--statistics


.PHONY: clean
clean:
find . -name 'poetry.lock' -delete && \
find . -name '.coverage' -delete && \
find . -wholename './**/*.pyc' -delete && \
find . -type d -wholename '__pycache__' -exec rm -rf {} +
find . -type d -wholename '**/__pycache__' -exec rm -rf {} +
find . -type d -wholename '.pytest_cache' -exec rm -rf {} +
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} +
find . -type d -wholename './logs/*' -exec rm -rf {} +
find . -type d -wholename './.reports/*' -exec rm -rf {} +
find . -type d -wholename '**/webassets-cache/' -exec rm -rf {} +
find . -type d -wholename '**/.webassets-cache/' -exec rm -rf {} +
rm -rf './pythonmyadmin/static/.webassets-cache/'
9 changes: 6 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

from dotenv import load_dotenv

basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, ".env"))
BASE_DIR = path.abspath(path.dirname(__file__))
load_dotenv(path.join(BASE_DIR, ".env"))


class Config:
"""Global configuration variables."""

# General Config
APP_NAME = "pythonmyadmin"
ENVIRONMENT = environ.get("ENVIRONMENT")
SECRET_KEY = environ.get("SECRET_KEY")

# Flask Config
FLASK_APP = environ.get("FLASK_APP")
SECRET_KEY = environ.get("SECRET_KEY")
FLASK_DEBUG = environ.get("FLASK_DEBUG")

# Database
Expand Down
15 changes: 8 additions & 7 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from dotenv import load_dotenv

# Read environment variables from ".env" file.
basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, ".env"))
BASE_DIR = path.abspath(path.dirname(__file__))
load_dotenv(path.join(BASE_DIR, ".env"))

# Fetch deployment environment from environment variables.
ENVIRONMENT = environ.get("ENVIRONMENT")

proc_name = "pythonmyadmin"
wsgi_app = "wsgi:app"
bind = "unix:flask.sock"
wsgi_app = "main:app"
bind = "unix:pythonmyadmin.sock"
threads = 4
workers = 2

Expand All @@ -23,10 +23,11 @@
threads = 1
bind = ["127.0.0.1:8000"]
elif ENVIRONMENT == "production":
access_log_format = "%(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"
daemon = True
accesslog = "/var/log/pythonmyadmin/access.log"
errorlog = "/var/log/pythonmyadmin/error.log"
accesslog = "/var/log/pythonmyadmin/access.json"
errorlog = "/var/log/pythonmyadmin/error.json"
loglevel = "trace"
dogstatsd_tags = "env:prod,service:pythonmyadmin,language:python"
dogstatsd_tags = "env:production,service:pythonmyadmin,language:python"
else:
raise ValueError(f"Unknown environment provided: `{ENVIRONMENT}`. Must be `development` or `production`.")
File renamed without changes.
507 changes: 433 additions & 74 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ flake8 = "*"
cryptography = "*"
gunicorn = "*"
poetry-plugin-export = "*"
ddtrace = "^2.9.1"
loguru = "^0.7.2"

[tool.poetry.scripts]
run = "wsgi:app"
run = "main:app"

[tool.poetry.urls]
issues = "https://github.com/toddbirchard/pythonmyadmin/issues"
Expand Down
14 changes: 6 additions & 8 deletions pythonmyadmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ def create_app() -> Flask:
db.init_app(app)

with app.app_context():
# Create tables for our models
db.create_all()

# Import parts of our application
from table import tableview

from . import routes
from .assets import compile_js_assets, compile_style_assets
from .tables import table_view

# Register App Blueprint
app.register_blueprint(routes.main_bp)
# Create tables for our models
db.create_all()

# Compile static assets
if app.config["ENVIRONMENT"] == "development":
compile_js_assets(app)
compile_style_assets(app)

app = tableview.create_dash_view(app)
# Register App Blueprint
app.register_blueprint(routes.main_bp)
app = table_view.create_dash_view(app)

return app
7 changes: 3 additions & 4 deletions pythonmyadmin/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def compile_js_assets(app: Flask):
Environment.debug = False
js_bundle = Bundle("js/*.js", filters="jsmin", output="dist/js/main.js")
assets.register("js_all", js_bundle)
if app.config["ENVIRONMENT"] != "production":
js_bundle.build()
js_bundle.build()


def compile_style_assets(app: Flask):
"""Build CSS style bundle."""
# shutil.rmtree(f"{BASE_DIR}/pythonmyadmin/static/.webassets-cache", ignore_errors=False)
assets = Environment(app)
Environment.auto_build = True
Environment.debug = False
Expand All @@ -26,5 +26,4 @@ def compile_style_assets(app: Flask):
extra={"rel": "stylesheet/less"},
)
assets.register("less_all", less_bundle)
if app.config["ENVIRONMENT"] != "production":
less_bundle.build(force=True)
less_bundle.build(force=True)
2 changes: 1 addition & 1 deletion pythonmyadmin/static/dist/css/style.css

Large diffs are not rendered by default.

File renamed without changes.
24 changes: 18 additions & 6 deletions pythonmyadmin/static/less/main.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import './variables.less';
@import './nav.less';
@import './table.less';
@import './home.less';
@import './index.less';

body,
html {
Expand All @@ -10,6 +10,8 @@ html {
padding: 0;
background: @background-color !important;
font-family: @body-font;
max-width: 100%;
overflow: hidden;
@media(max-width: @mobile-breakpoint) {
margin: 0;
}
Expand Down Expand Up @@ -39,10 +41,13 @@ html {
box-shadow: 0 0 4px #cdd3e2;
padding: 30px;
background: white;
@media(max-width: @tablet-breakpoint) {
max-width: 96vw;
}
@media(max-width: 600px) {
margin: 0;
max-width: unset;
width: 100%;

padding: 5vw;
}

Expand Down Expand Up @@ -84,21 +89,28 @@ html {

.dash-spreadsheet-container {
max-width: 100%;
margin: 40px auto !important;
margin: 40px auto;
overflow: hidden;
border: 1px solid #d3d8e0;
box-shadow: none;
font-family: @body-font;

@media(max-width: @tablet-breakpoint) {
margin: 2vw auto;
}
}

.layout-container {
width: 1000px;
max-width: 90%;
max-width: 96vw;
margin: 20px auto;
@media(max-width: @tablet-breakpoint) {
width: unset;
max-width: 96vw;;
margin: 2vw auto 0px auto;
}
@media(max-width: @mobile-breakpoint) {
width: 100%;
max-width: 95%;
margin: 20px auto;
}
}
}
13 changes: 9 additions & 4 deletions pythonmyadmin/static/less/nav.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
header {
position: relative;
width: 100%;
margin-bottom: 50px !important;
margin-bottom: 2vw;
padding: 40px 0 !important;
background: white !important;
box-shadow: 0 0 5px #bec6cf;
font-family: 'Lato', sans-serif;
max-width: 100%;
overflow: hidden;
@media(max-width: 800px) {
margin: 0 auto;
box-shadow: 0 0 2px #707985;
}
@media(max-width: 600px) {
margin: 0 !important;
padding: 30px 0 !important;
}

Expand Down Expand Up @@ -58,7 +63,7 @@ header {

.nav-link,
a {
margin-left: 30px;
margin-left: 25px;
color: #70829d;
font-size: 1.1em;
text-decoration: none;
Expand All @@ -70,7 +75,7 @@ header {
}

i {
margin-right: 5px;
margin-right: 3px;
}
}
}
Expand Down
39 changes: 27 additions & 12 deletions pythonmyadmin/static/less/table.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@
margin: 0;

header {
margin-bottom: 25px !important;
margin-bottom: 25px;

@media(max-width: @tablet-breakpoint) {
margin: 0 auto 2vw;
}
}

.dash-spreadsheet-container {
max-width: 100%;
margin: 25px auto !important;
margin: 25px auto;
overflow: hidden;
border: 0;
border-radius: 4px;
box-shadow: 0 0 4px #cdd3e2;
font-family: @body-font;

@media(max-width: @tablet-breakpoint) {
margin: 2vw auto;
}

* {
box-shadow: none !important;
font-family: @body-font;
Expand Down Expand Up @@ -57,6 +65,7 @@

svg {
width: 0.5em;
font-size: 1.6em;
}
}

Expand All @@ -78,7 +87,7 @@
width: fit-content;

span:last-of-type {
font-size: 0.85em;
font-size: 0.95em;
text-transform: uppercase;
}
}
Expand All @@ -94,19 +103,27 @@
}
}

td {
.dash-cell {
padding: 15px 10px !important;
overflow: hidden !important;
line-height: 1.25 !important;
text-align: center !important;
transition: all 0.2s ease-out;
transition: all 0.1s ease-out;

&.focused {
//background-color: rgba(154, 212, 255, 0.2) !important;
box-shadow: 0 0 4px #cdd3e2;
// border: 1px #317ed1;
}
* {
background: rgb(49 126 209 / 15%);
color: #205681;
}
}

&::selection {
* {
background: rgb(49 126 209 / 15%);
color: #205681;
}
}

&.unfocused {
caret-color: #317ed1 !important
}
Expand All @@ -119,7 +136,6 @@
display: block !important;
max-width: 500px;
overflow: hidden !important;
font-size: .9em;
font-weight: 300;
text-align: left !important;
text-overflow: ellipsis;
Expand Down Expand Up @@ -220,7 +236,6 @@
.Select-value-label {
padding: 4px 9px;
line-height: 1;
font-size: .8em;
}
}

Expand All @@ -242,7 +257,7 @@
.previous-page {
padding: 7px 11px;
margin: 0 1px;
font-size: 0.9em;
// font-size: 0.9em;
font-weight: 300;
background: #e7f1f2;
border: 1px solid #b8d6da;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 580d411

Please sign in to comment.