mirror of
https://github.com/dkmstr/openuds.git
synced 2025-08-29 01:50:00 +03:00
updated client to allow some more customizations from dashboard
This commit is contained in:
@ -45,6 +45,7 @@ REMOVED = {
|
||||
'Cluster': ('Destination CPU Load', 'Migration CPU Load', 'Migration Free Memory'),
|
||||
'IPAUTH': ('autoLogin',),
|
||||
'VMWare': ('minUsableDatastoreGB', 'maxRetriesOnError'),
|
||||
'HyperV': ('minUsableDatastoreGB',)
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,6 +43,7 @@ GLOBAL_SECTION: str = 'UDS'
|
||||
# For save when initialized
|
||||
SECURITY_SECTION: str = 'Security'
|
||||
# CLUSTER_SECTION: str = 'Cluster'
|
||||
CUSTOM_SECTION: str = 'Custom'
|
||||
|
||||
_saveLater = []
|
||||
_getLater = []
|
||||
@ -50,6 +51,7 @@ _getLater = []
|
||||
# For custom params (for choices mainly)
|
||||
_configParams = {}
|
||||
|
||||
|
||||
class Config:
|
||||
# Fields types, so inputs get more "beautiful"
|
||||
TEXT_FIELD: int = 0
|
||||
@ -280,8 +282,6 @@ class GlobalConfig:
|
||||
# Max time needed to get a service "fully functional" before it's considered "failed" and removed
|
||||
# The time is in seconds
|
||||
MAX_INITIALIZING_TIME: Config.Value = Config.section(GLOBAL_SECTION).value('maxInitTime', '3601', type=Config.NUMERIC_FIELD)
|
||||
# Custom HTML for login page
|
||||
CUSTOM_HTML_LOGIN: Config.Value = Config.section(GLOBAL_SECTION).value('customHtmlLogin', '', type=Config.LONGTEXT_FIELD)
|
||||
# Maximum logs per user service
|
||||
MAX_LOGS_PER_ELEMENT: Config.Value = Config.section(GLOBAL_SECTION).value('maxLogPerElement', '100', type=Config.NUMERIC_FIELD)
|
||||
# Time to restrain a deployed service in case it gives some errors at some point
|
||||
@ -333,9 +333,14 @@ class GlobalConfig:
|
||||
UDS_ID: Config.Value = Config.section(GLOBAL_SECTION).value('UDS ID', cryptoManager().uuid(), type=Config.READ_FIELD)
|
||||
|
||||
# Site display name & copyright info
|
||||
SITE_NAME: Config.Value = Config.section(GLOBAL_SECTION).value('Site name', 'UDS Enterprise', type=Config.TEXT_FIELD)
|
||||
SITE_COPYRIGHT: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright info', '© Virtual Cable S.L.U.', type=Config.TEXT_FIELD)
|
||||
SITE_COPYRIGHT_LINK: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright link', 'https://www.udsenterprise.com', type=Config.TEXT_FIELD)
|
||||
SITE_NAME: Config.Value = Config.section(CUSTOM_SECTION).value('Site name', 'UDS Enterprise', type=Config.TEXT_FIELD)
|
||||
SITE_COPYRIGHT: Config.Value = Config.section(CUSTOM_SECTION).value('Site copyright info', '© Virtual Cable S.L.U.', type=Config.TEXT_FIELD)
|
||||
SITE_COPYRIGHT_LINK: Config.Value = Config.section(CUSTOM_SECTION).value('Site copyright link', 'https://www.udsenterprise.com', type=Config.TEXT_FIELD)
|
||||
SITE_LOGO_NAME: Config.Value = Config.section(CUSTOM_SECTION).value('Logo name', 'UDS', type=Config.TEXT_FIELD)
|
||||
SITE_CSS: Config.Value = Config.section(CUSTOM_SECTION).value('CSS', '', type=Config.LONGTEXT_FIELD)
|
||||
|
||||
# Custom HTML for login page
|
||||
# CUSTOM_HTML_LOGIN: Config.Value = Config.section(CUSTOM_SECTION).value('customHtmlLogin', '', type=Config.LONGTEXT_FIELD)
|
||||
|
||||
EXPERIMENTAL_FEATURES: Config.Value = Config.section(GLOBAL_SECTION).value('Experimental Features', '0', type=Config.BOOLEAN_FIELD)
|
||||
|
||||
|
40
server/src/uds/migrations/0038_auto_20200505_config.py
Normal file
40
server/src/uds/migrations/0038_auto_20200505_config.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Generated by Django 3.0.3 on 2020-05-05 11:12
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
MOVEABLES = (
|
||||
'Site name',
|
||||
'Site copyright info',
|
||||
'Site copyright link',
|
||||
'Site Logo name'
|
||||
)
|
||||
|
||||
OLD_SECTION = 'UDS'
|
||||
NEW_SECTION = 'Custom'
|
||||
|
||||
def move(apps, old_section: str, new_section: str) -> None:
|
||||
model = apps.get_model('uds', 'Config')
|
||||
# Ensure NEW section values does not exists
|
||||
model.objects.filter(section=new_section, key__in=MOVEABLES).delete()
|
||||
for v in model.objects.filter(section=old_section, key__in=MOVEABLES):
|
||||
v.section = new_section
|
||||
v.save()
|
||||
|
||||
def updateConfig(apps, schema_editor) -> None:
|
||||
move(apps, OLD_SECTION, NEW_SECTION)
|
||||
|
||||
def reverseConfig(apps, schema_editor) -> None:
|
||||
move(apps, NEW_SECTION, OLD_SECTION)
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0037_service_token'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
updateConfig,
|
||||
reverseConfig
|
||||
)
|
||||
]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -114,6 +114,7 @@ def udsJs(request: 'HttpRequest') -> str:
|
||||
'site_name': GlobalConfig.SITE_NAME.get(),
|
||||
'site_copyright_info': GlobalConfig.SITE_COPYRIGHT.get(),
|
||||
'site_copyright_link': GlobalConfig.SITE_COPYRIGHT_LINK.get(),
|
||||
'site_logo_name': GlobalConfig.SITE_LOGO_NAME.get(),
|
||||
'messages': {
|
||||
# Calendar denied message
|
||||
'calendarDenied': GlobalConfig.LIMITED_BY_CALENDAR_TEXT.get().strip() or gettext('Access limited by calendar')
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
from django.http import HttpResponse
|
||||
# from django.views.decorators.cache import cache_page
|
||||
from uds.core.util.config import Config
|
||||
from uds.core.util.config import GlobalConfig
|
||||
|
||||
|
||||
# @cache_page(3600, key_prefix='custom', cache='memory')
|
||||
@ -41,6 +41,6 @@ def custom(request, component):
|
||||
|
||||
if component == 'styles.css':
|
||||
content_type = 'text/css'
|
||||
value = Config.section('__custom').value('style').get(force=True)
|
||||
value = GlobalConfig.SITE_CSS.get(True)
|
||||
|
||||
return HttpResponse(content_type=content_type, content=value)
|
||||
|
Reference in New Issue
Block a user