Fixes in json and dashboard
This commit is contained in:
parent
fa8b8be4f5
commit
8c2bcdc74a
5 changed files with 148 additions and 4 deletions
|
|
@ -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:
|
||||
|
|
|
|||
84
paramecio2/libraries/db/extrafields/jsonfield.py
Normal file
84
paramecio2/libraries/db/extrafields/jsonfield.py
Normal file
|
|
@ -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
|
||||
|
|
@ -814,6 +814,65 @@ a.form_button_tab:hover
|
|||
|
||||
}
|
||||
|
||||
/* Loading */
|
||||
/* <div class="lds-dual-ring"></div> */
|
||||
|
||||
.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) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ ${load_js()|n}
|
|||
</%block>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layer_loading" style="display:none;"><div id="container_loading"><div class="lds-dual-ring"></div></div></div>
|
||||
<div id="languages_general">
|
||||
</div>
|
||||
<div id="logout">
|
||||
|
|
@ -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'
|
||||
|
||||
%>
|
||||
|
|
|
|||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue