bug fixes with layout and dependencies

master
Steve Nyemba 10 months ago
parent 576e5d918a
commit 31565bfd53

@ -103,7 +103,6 @@ def html (uri,_config) :
# _link = '/'.join(['api/cloud/download?doc='+_prefix,'_images']) # _link = '/'.join(['api/cloud/download?doc='+_prefix,'_images'])
print (uri)
_html = _handler.get_file_contents(uri).decode('utf-8')#.replace('.attachments.', copy.deepcopy(_link)) _html = _handler.get_file_contents(uri).decode('utf-8')#.replace('.attachments.', copy.deepcopy(_link))
# print ([uri,uri[-2:] ,uri[-2:] in ['md','MD','markdown']]) # print ([uri,uri[-2:] ,uri[-2:] in ['md','MD','markdown']])
_handler.logout() _handler.logout()

@ -69,7 +69,7 @@ class Loader :
del _item['uri'] del _item['uri']
_item = dict(_item,**_overwrite[text]) _item = dict(_item,**_overwrite[text])
if 'uri' in _item and _item['type'] != 'open': if 'uri' in _item and 'type' in _item and _item['type'] != 'open':
_item['uri'] = _item['uri'].replace(_layout['root'],'') _item['uri'] = _item['uri'].replace(_layout['root'],'')
_submenu[_index] = _item _submenu[_index] = _item
@ -91,7 +91,7 @@ class Loader :
_item = _system['routes'][_text] _item = _system['routes'][_text]
if 'menu' not in _item : if 'menu' not in _item :
continue continue
uri = f'{_context}/set/{_text}' uri = f'{_context}/{_text}'
# _items.append ({"text":_text,'uri':uri,'type':'open'}) # _items.append ({"text":_text,'uri':uri,'type':'open'})
_label = _item['menu'] _label = _item['menu']
if _label not in _menu : if _label not in _menu :
@ -136,7 +136,7 @@ class Loader :
if not os.path.exists(PATH) and self._location and os.path.exists(self._location) : if not os.path.exists(PATH) and self._location and os.path.exists(self._location) :
# #
# overriding the location of plugins ... # overriding the location of plugins ...
PATH = self._location PATH = os.sep.join([self._location, _config['layout']['root'],'_plugins'])
_map = {} _map = {}
# if not os.path.exists(PATH) : # if not os.path.exists(PATH) :
@ -149,6 +149,7 @@ class Loader :
_path = os.sep.join([PATH,_key+".py"]) _path = os.sep.join([PATH,_key+".py"])
if not os.path.exists(_path): if not os.path.exists(_path):
print ([' ?? ',_path])
continue continue
for _name in _conf[_key] : for _name in _conf[_key] :
_pointer = self._load_plugin(path=_path,name=_name) _pointer = self._load_plugin(path=_path,name=_name)
@ -213,6 +214,8 @@ class Getter (Loader):
_icon = os.sep.join([_root,_icon]) _icon = os.sep.join([_root,_icon])
_system['icon'] = _icon _system['icon'] = _icon
self._config['system'] = _system self._config['system'] = _system
if self._caller :
_system['caller'] = {'icon': self._caller.system()['icon']}
def html(self,uri,id,_args={},_system={}) : def html(self,uri,id,_args={},_system={}) :
""" """
This function reads a given uri and returns the appropriate html document, and applies environment context This function reads a given uri and returns the appropriate html document, and applies environment context
@ -300,7 +303,7 @@ class Router :
for _name in _system : for _name in _system :
_path = _system[_name]['path'] _path = _system[_name]['path']
self._apps[_name] = Getter(path=_path,caller=_app,location=_path) self._apps[_name] = Getter(path=_path,caller=_app,location=_path)
# self._apps[_name].load() print ([_name, self._apps[_name].plugins().keys()])
self._apps['main'] = _app self._apps['main'] = _app
def set(self,_id): def set(self,_id):
self._id = _id self._id = _id

@ -179,8 +179,13 @@ def cms_page():
_handler = _route.get() _handler = _route.get()
_config = _handler.config() _config = _handler.config()
_uri = os.sep.join([_config['layout']['root'],request.headers['uri']]) # _uri = os.sep.join([_config['layout']['root'],request.headers['uri']])
_id = request.headers['dom'] _uri = request.headers['uri']
if 'dom' not in request.headers :
_id = _uri.split('/')[-1].split('.')[0]
else:
_id = request.headers['dom']
print ([_id,_uri])
_args = {'layout':_config['layout']} _args = {'layout':_config['layout']}
if 'plugins' in _config: if 'plugins' in _config:
_args['routes'] = _config['plugins'] _args['routes'] = _config['plugins']
@ -202,7 +207,7 @@ def _cms_page ():
_handler = _route.get() _handler = _route.get()
_config = _handler.config() _config = _handler.config()
_uri = request.args['uri'] _uri = request.args['uri']
_uri = os.sep.join([_config['layout']['root'],_uri]) # _uri = os.sep.join([_config['layout']['root'],_uri])
_title = request.args['title'] if 'title' in request.args else '' _title = request.args['title'] if 'title' in request.args else ''
_args = {'system':_handler.system()} #cms.components.get_system(_config) } _args = {'system':_handler.system()} #cms.components.get_system(_config) }
# if 'plugins' in _config: # if 'plugins' in _config:
@ -217,7 +222,11 @@ def set(id):
global _route global _route
_handler = _route.set(id) _handler = _route.set(id)
return redirect('/') return redirect('/')
@_app.route('/<id>')
def _open(id):
global _route
_route.set(id)
return _index()
# #
# Let us bootup the application # Let us bootup the application
SYS_ARGS = {} SYS_ARGS = {}

@ -10,6 +10,8 @@
align-items: center; align-items: center;
} }
.menu .icon {padding:4px;}
.menu .icon img {width:30px; height:30px;}
.menu .item { .menu .item {
font-weight:bold; font-weight:bold;
cursor:pointer; cursor:pointer;

@ -4,7 +4,7 @@
display:grid; display:grid;
grid-template-columns: 50% 50% ; gap:4px; grid-template-columns: 50% 50% ; gap:4px;
grid-template-rows: 48px 48px auto 32px; grid-template-rows: 48px 48px auto 32px;
font-family: helvetica; font-family: sans-serif;
font-weight: lighter; font-weight: lighter;
font-size:18px; font-size:18px;
line-height: 1.5; line-height: 1.5;
@ -12,15 +12,23 @@
; ;
} }
.main .header { .main .header {
height:48px;
grid-row:1; grid-row:1;
grid-column: 1 / span 2; grid-column: 1 / span 2;
display:grid;
grid-template-columns: 50px auto; gap:4px;
line-height: 1;
} }
.main .header .title {font-size:28px; text-transform: capitalize; font-weight:bold}
.main .header img { width:40px; margin:4px;} .main .header .subtitle {font-size:14px}
.main .menu { grid-row:2; grid-column: 1 / span 2; background-color: #f3f3f3; } .main .header img { width:44px; height:44px;}
.main .menu { grid-row:2; grid-column: 1 / span 2; background-color: #f3f3f3;
display:grid; grid-template-columns: 75px repeat(3,250px) ; gap:4px;
align-items: left;
padding:4px;
}
.main .content { .main .content {
grid-row:3; grid-row:3;
grid-column: 1 ; grid-column: 1 ;
@ -47,6 +55,7 @@
border-left:3px dotted gray; border-left:3px dotted gray;
grid-column: 2; grid-column: 2;
font-family: sans-serif; font-family: sans-serif;
padding-left: 10px;
} }
@ -58,6 +67,8 @@
} }
.main .footer {grid-row:4; grid-column: 1 / span 2; font-size:13px; font-weight: lighter;} .main .footer {grid-row:4; grid-column: 1 / span 2; font-size:13px; font-weight: lighter;}
blockquote { border-left:8px solid GRAY;margin-right:8px}
blockquote .code {padding:10px; font-size:16px; font-family: courier; background-color:black; color: #d3d3d3}
/** /**
* styling tables here * styling tables here
*/ */

@ -10,7 +10,7 @@
} }
.main .header { height:64px; .main .header { height:64px;
display:grid; display:grid;
grid-template-columns: 40px auto; grid-template-columns: 50px auto;
border-bottom: 2px double #CAD5E0; border-bottom: 2px double #CAD5E0;
padding:4px; padding:4px;
gap:4px; gap:4px;
@ -18,19 +18,19 @@
} }
.main .header .icon {width:40px; height:40px;} .main .header .icon {width:50px; height:50px;}
.main .header .icon img {width:40px; height:40px;} .main .header .icon img {width:48px; height:48px;}
.main .header .title { font-size:32px; text-transform: uppercase; font-weight:bold} .main .header .title { font-size:32px; text-transform: uppercase; font-weight:bold}
.main .header .subtitle {font-style:italic;font-size:14px; color:gray; text-transform: capitalize;} .main .header .subtitle {font-style:italic;font-size:14px; color:gray; text-transform: capitalize;}
.main .header img {height:48px; margin:4px;}
.main .menu {border:0; background-color: #f3f3f3;} .main .menu {border:0; background-color: #f3f3f3;}
.main .content img{ /* .main .content img{
width:99%; width:99%;
border:1px solid #CAD5E0; border:1px solid #CAD5E0;
padding:8px; padding:8px;
background-color:#f3f3f3; background-color:#f3f3f3;
} } */
/* .main .content table thead tr:first-child { /* .main .content table thead tr:first-child {
padding:4px; padding:4px;

@ -77,10 +77,31 @@ menu.apply_link =function(_args){
http.get('/dialog',function(x){ http.get('/dialog',function(x){
jx.modal.show({html:x.responseText,id:'dialog'}) jx.modal.show({html:x.responseText,id:'dialog'})
console.log([$('.jxmodal')])
menu.runScript ('.jxmodal')
}) })
} }
}else{ }else{
window.open(_args.url,_args.text) window.open(_args.url,_args.text)
} }
} }
var _delegate = {scripts:{}}
menu.runScript = function(_id){
var scripts = $(_id+' script')
jx.utils.patterns.visitor(scripts,function(_item){
if(_item.text.trim().length > 0){
var _code = eval(_item.text)
var id = _id
if (_item.parentNode != null){
var id = _item.parentNode.id == null?_item.parentNode.className : _item.parentNode.id
}
id = (id != null)?id : _id
// _delegate.scripts[id] = _code
}
})
}

@ -3,5 +3,5 @@
<div class="active" align="center" onclick="$('.jxmodal').slideUp()"><i class="fa-solid fa-times"></i></div> <div class="active" align="center" onclick="$('.jxmodal').slideUp()"><i class="fa-solid fa-times"></i></div>
</div> </div>
<br> <br>
<div>{{html|safe}}</div> <div style="padding:10px; max-height:700px; overflow: hidden;overflow-y: auto;">{{html|safe}}</div>

@ -42,6 +42,67 @@ Vanderbilt University Medical Center
</head> </head>
<script> <script>
sessionStorage.setItem('{{system.id}}','{{system.context|safe}}') sessionStorage.setItem('{{system.id}}','{{system.context|safe}}')
var _layout = {{layout|tojson}}
//
// Rendering here requires an observer design pattern because calls are asynchronous
//
/**
* @id _domURI of the pane where the output is to be written
* @uri _fileURI of the file
*/
var CMSObserver = function(_domId,_fileURI){
this._domId = _domId
this._fileURI = _fileURI
this.apply = function (_caller){
var http = HttpClient.instance()
http.setHeader('uri',_fileURI)
var uri = '{{context}}/page'
try{
http.post(uri,function(x){
console.log(jx.dom.exists(_domId))
if (x.status == 200){
// jx.dom.set.value(_domId,x.responseText)
var _domElement = jx.dom.get.instance('div')
_domElement.innerHTML = x.responseText
jx.dom.append(_domId, _domElement)
}
_caller.notify()
})
}catch(error){
_caller.notify()
}
}
}
var finalize = function(_id){
this.apply = function(_caller){
menu.runScript('#'+_id)
}
}
if (_layout.on != null ){
//
// load and error are required
$(document).ready(function(){
jx.utils.keys(_layout.on.load).forEach(function(_id){
var observers =
jx.utils.patterns.visitor(_layout.on.load[_id], function(_uri){
return new CMSObserver(_id,_uri)
})
observers.push(new finalize(_id))
//
// At this point we can execute the observer design pattern
//
jx.utils.patterns.observer(observers,'apply')
})
})
}
</script> </script>
<body> <body>
@ -51,7 +112,7 @@ Vanderbilt University Medical Center
{%include "header.html" %} {%include "header.html" %}
</div> </div>
<div class="menu"> <div id="menu" class="menu">
{%include "menu.html" %} {%include "menu.html" %}
</div> </div>
<div class="content"> <div class="content">
@ -59,11 +120,11 @@ Vanderbilt University Medical Center
{%include "content.html" %} {%include "content.html" %}
</div> </div>
<div class="pane"> <div id="pane" class="pane">
{%include "pane.html" %} {%include "pane.html" %}
</div> </div>
<div class="footer"> <div id="footer" class="footer">
{%include "footer.html" %} {%include "footer.html" %}
</div> </div>
</div> </div>

@ -1,13 +1,18 @@
{%if system.portal %} {%if system.portal %}
<div align="center" class="active" onclick="window.open('{{system.context}}/set/main','_self')"><i class="fa-solid fa-house"></i></div> <div align="center" class="icon active" onclick="window.open('{{system.context}}/set/main','_self')">
<img src="{{system.caller.icon}}" style="height:100%"/>
</div>
{% else %} {% else %}
<div></div> <div class="icon">
<i class="fa-solid fa-home"></i>
</div>
{% endif %} {% endif %}
{% for _name in layout.menu %} {% for _name in layout.menu %}
<div class="item"> <div class="item">
<div> <div>
<i class="{{layout.icons[_name]}}"></i> <i class="{{layout.icons[_name]}}"></i>
{{_name}}</div> {{_name.replace('-', ' ').replace('_',' ')}}
</div>
{%if layout.menu[_name] %} {%if layout.menu[_name] %}
<div class="sub-menu border-round border"> <div class="sub-menu border-round border">
@ -23,7 +28,7 @@
<div class="active" onclick='menu.apply_link({{_item|tojson}})'> <div class="active" onclick='menu.apply_link({{_item|tojson}})'>
{% endif %} {% endif %}
<i class="fa-solid fa-chevron-right" style="margin-right:4px"></i> <i class="fa-solid fa-chevron-right" style="margin-right:4px"></i>
{{_item.text}} {{_item.text.replace('-',' ').replace('_',' ')}}
</div> </div>
{%endfor%} {%endfor%}

Loading…
Cancel
Save