diff --git a/paramecio2/libraries/datetime.py b/paramecio2/libraries/datetime.py index db2683e..9ad9703 100644 --- a/paramecio2/libraries/datetime.py +++ b/paramecio2/libraries/datetime.py @@ -217,7 +217,7 @@ def obtain_timestamp(timeform): # timestamp is gmt time, convert in normal time -def timestamp_to_datetime(timestamp): +def timestamp_to_datetime(timestamp, sql_format_time=sql_format_time): """Turn datetime in YYYYMMDDHHmmss format. @@ -233,7 +233,7 @@ def timestamp_to_datetime(timestamp): # Get a utc timestamp and convert to local -def timestamp_to_datetime_local(timestamp, tz=''): +def timestamp_to_datetime_local(timestamp, tz='', sql_format_time=sql_format_time): """Get a utc timestamp and convert to timezone datetime in YYYYMMDDHHmmss format. Args: diff --git a/paramecio2/libraries/db/extrafields/jsonfield.py b/paramecio2/libraries/db/extrafields/jsonfield.py new file mode 100644 index 0000000..84eb3eb --- /dev/null +++ b/paramecio2/libraries/db/extrafields/jsonfield.py @@ -0,0 +1,84 @@ +from paramecio2.libraries.db.webmodel import WebModel, PhangoField +try: + + import ujson as json +except: + import json + +class JsonField(PhangoField): + + def __init__(self, name, field_type, required=False): + + super().__init__(name, required) + + self.field_type=field_type + + self.error_default='Sorry, the json dict is invalid' + + self.set_default='NOT NULL' + + def check(self, value): + + if type(value).__name__=='str': + try: + + value=json.loads(value) + + except json.JSONDecodeError: + + value={} + self.error=True + self.txt_error=self.error_default + + elif type(value).__name__!='dict': + + value={} + self.error=True + self.txt_error=self.error_default + + for k,v in value.items(): + + value[k]=self.field_type.check(v) + + final_value=json.dumps(value) + + #final_value=WebModel.escape_sql(final_value) + + return final_value + + def get_type_sql(self): + + return 'LONGTEXT '+self.set_default + + def show_formatted(self, value): + + return ", ".join(value) + +# You need check the values previously. + +class JsonValueField(PhangoField): + + def __init__(self, name, required=False): + + super().__init__(name, required) + + self.error_default='Sorry, the json dict is invalid' + + #self.set_default='NOT NULL' + + def get_type_sql(self): + + return 'JSON' + + def check(self, value): + + try: + final_value=json.dumps(value) + + except json.JSONDecodeError: + + value={} + self.error=True + self.txt_error=self.error_default + + return final_value diff --git a/paramecio2/modules/admin/media/css/admin.css b/paramecio2/modules/admin/media/css/admin.css index 92327c3..06d4212 100644 --- a/paramecio2/modules/admin/media/css/admin.css +++ b/paramecio2/modules/admin/media/css/admin.css @@ -814,6 +814,65 @@ a.form_button_tab:hover } +/* Loading */ +/*
*/ + +.lds-dual-ring { + display: inline-block; + width: 80px; + height: 80px; +} +.lds-dual-ring:after { + content: " "; + display: block; + width: 64px; + height: 64px; + margin: 8px; + border-radius: 50%; + border: 6px solid #000; + border-color: #000 transparent #000 transparent; + animation: lds-dual-ring 1.2s linear infinite; +} +@keyframes lds-dual-ring { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + +/* Block screen while loading */ + +#layer_loading { + + z-index:50000; + /*background-color:rgba(0,0,0,0.4);*/ + /*opacity:0.5;*/ + position:absolute; + width:100%; + height:100%; + overflow:auto; + + +} + +#container_loading { + + z-index:50001; + overflow:auto; + /* border: solid #fbfbfb 4px;*/ + position:absolute; + overflow:visible; + width:100%; + height:100%; + display: flex; + align-items: center; + justify-content: center; + +} + + /* Media queries */ @media only screen and (max-width: 800px) { diff --git a/paramecio2/modules/admin/templates/dashboard.phtml b/paramecio2/modules/admin/templates/dashboard.phtml index 033a9af..5265fac 100644 --- a/paramecio2/modules/admin/templates/dashboard.phtml +++ b/paramecio2/modules/admin/templates/dashboard.phtml @@ -21,6 +21,7 @@ ${load_js()|n} +
@@ -40,7 +41,7 @@ ${load_js()|n} <% from paramecio2.libraries.config_admin import config_admin - + %> % for admin in config_admin: @@ -53,7 +54,7 @@ ${load_js()|n} % if len(admin)==3: <% - if admin[2]+'/'==path_module: + if admin[2]==path_module: class_selected='selected_menu' %> diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29