mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 07:16:52 -06:00
764677431f
Following changes done for the framework: - Framework for creating React based dynamic form view out of a pre-defined UI schema. Previously, it was based on Backform/Backbone. - The new framework and components will use MaterialUI as the base. Previously, Bootstrap/Backform/jQuery components were used. - The new code uses JSS instead of CSS since material UI and most modern React libraries also use JSS. In the future, this will allow us to change the theme in real-time without refresh. - 90% code covered by 80-85 new jasmine test cases. - Server group node UI Schema migration to new, with schema test cases. - Server node UI Schema migration to new, with schema test cases. - Database node UI Schema migration to new, with schema test cases. - Few other UI changes. Fixes #6130
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
import os
|
|
import json
|
|
from pgadmin.utils.preferences import Preferences
|
|
|
|
|
|
def get_all_themes():
|
|
# Themes file is copied in generated directory
|
|
theme_file_path = os.path.join(
|
|
os.path.dirname(os.path.realpath(__file__)),
|
|
'../../static/js/generated',
|
|
'pgadmin.themes.json'
|
|
)
|
|
|
|
all_themes = {
|
|
"standard": {
|
|
"disp_name": "Standard",
|
|
"cssfile": "pgadmin",
|
|
"preview_img": "standard_preview.png"
|
|
}
|
|
}
|
|
|
|
try:
|
|
all_themes.update(json.load(open(theme_file_path)))
|
|
except Exception as _:
|
|
pass
|
|
|
|
return all_themes
|
|
|
|
|
|
def themes(app):
|
|
@app.context_processor
|
|
def inject_theme_func():
|
|
def get_theme_css():
|
|
all_themes = get_all_themes()
|
|
theme_css = all_themes['standard']['cssfile'] + '.css'
|
|
try:
|
|
misc_preference = Preferences.module('misc')
|
|
theme = misc_preference.preference('theme').get()
|
|
if theme in all_themes:
|
|
theme_css = all_themes[theme]['cssfile'] + '.css'
|
|
except Exception:
|
|
# Let the default theme go if exception occurs
|
|
pass
|
|
|
|
return theme_css, theme
|
|
|
|
return {
|
|
'get_theme_css': get_theme_css,
|
|
}
|