Merge pull request 'v2.1' (#11) from v2.1 into master

Reviewed-on: cloud/cms#11
master
Steve L. Nyemba 3 months ago
commit 8b7202fa80

@ -85,7 +85,6 @@ def read (**_args):
"""
request = _args['request']
_layout = _args['config']['layout']
_uri = request.args['uri'] # if 'location' in _layout :
# _uri = os.sep.join([_layout['location'],_uri])
_uri = _realpath(_uri, _args['config'])
@ -98,11 +97,10 @@ def read (**_args):
# Inferring the type of the data to be returned
_mimeType = 'application/octet-stream'
_extension = _uri.split('.')[-1]
if _extension in ['css','js','csv'] :
if _extension in ['css','js','csv','html'] :
_mimeType = f'text/{_extension}'
elif _extension in ['png','jpg','jpeg'] :
_mimeType = f'image/{_extension}'
return _stream, _mimeType
return None,_mimeType
def exists(**_args):
@ -124,6 +122,7 @@ def html(_uri,_config) :
if not _config :
_api = os.sep.join(['api/disk/read?uri=',_layout['root']])
else:
_api = os.sep.join([f'{_context}/api/disk/read?uri=',_layout['root']])
if f"{_layout['root']}{os.sep}" in _html :
_html = _html.replace(f"{_layout['root']}",_api)

@ -170,6 +170,7 @@ class Initializer :
_index = 0
for _item in _submenu :
text = _item['text'].strip()
if text in _overwrite :
if 'uri' in _item and 'url' in _overwrite[text] :
del _item['uri']
@ -204,6 +205,7 @@ class Initializer :
#
# If there are missing items in the sorting
_missing = list(set(self._menu.keys()) - set(_sortedmenu))
if _missing :
for _name in _missing :
_menu[_name] = self._menu[_name]
@ -234,6 +236,13 @@ class Initializer :
#
# update the menu items and the configuration
#
_keys = list(_menu.keys())
# for _key in _keys :
# if len(_menu[_key]) == 0 :
# del _menu[_key]
# #
# # doing some house-keeping work here to make sure the front-end gets clean data
# #
_layout['menu'] = _menu
self._config['layout'] = _layout
def _ilogo(self):

@ -130,9 +130,9 @@ def _aindex (app,resource=None):
# """
# global _config
# return "0",200
@_app.route('/dialog')
def _dialog ():
@_app.route('/<app>/dialog')
@_app.route('/dialog',defaults={'app':'main'})
def _dialog (app):
# global _config
global _route
_handler = _route.get()
@ -140,7 +140,7 @@ def _dialog ():
_id = request.headers['dom']
# _html = ''.join(["<div style='padding:1%'>",str( e.render(**_args)),'</div>'])
_args = _route.render(_uri,'html',session.get('app_id','main'))
_args = _route.render(_uri,'html',app) #session.get('app_id','main'))
_args['title'] = _id
return render_template('dialog.html',**_args) #title=_id,html=_html)
@ -210,6 +210,7 @@ def _post (app_id,key,module,name):
# global _route
# _handler = _route.get()
# app_id = '/'.join([app_id,key]) if key else app_id
_handler = _getHandler(app_id,key)
return _delegate(_handler,module,name)

@ -28,7 +28,7 @@ bootup.CMSObserver = function(_sysId,_domId,_fileURI){
// _domElement.className = 'busy-loading'
// jx.dom.append(_domId, _domElement)
http.post(uri,function(x){
if (x.status == 200){
if (x.status == 200 && x.readyState == 4){
setTimeout(function(){
_content = $(x.responseText)
@ -38,7 +38,7 @@ bootup.CMSObserver = function(_sysId,_domId,_fileURI){
$(_pid).remove()
}
$('#'+_domId).append(x.responseText)
},1500)
},10)
}
@ -56,7 +56,9 @@ bootup.CMSObserver = function(_sysId,_domId,_fileURI){
// Finalize the process of rendering the content on the fly
bootup.finalize = function(_id){
this.apply = function(_caller){
menu.runScript('#'+_id)
// menu.runScript('#'+_id)
setTimeout(function(){menu.events.finalize(_id);},1000)
// menu.events.finalize(_id)
}
}

@ -1,18 +1,19 @@
var dialog = {}
dialog.context = ''
dialog.show = function(_title,_internalURI,_message,_pointer){
dialog.show = function(_args,_pointer){
var http = HttpClient.instance()
// http.setData({title:_title,html:_message},'application/json')
var uri = dialog.context+'/dialog'
http.setHeader('dom',_title)
http.setHeader('uri',_internalURI)
var uri = _args.context+'/dialog'
http.setHeader('dom',_args.title)
http.setHeader('uri',_args.uri)
http.get(uri,function(x){
$('.jxmodal').remove()
jx.modal.show({html:x.responseText,id:'body'})
if(jx.dom.exists('dialog-message') && _message != null){
jx.dom.set.value('dialog-message',_message)
if(jx.dom.exists('dialog-message') && _args.message != null){
jx.dom.set.value('dialog-message',_args.message)
}
//
// In order to perhaps execute any js script that should have been executed on load ...
//
@ -27,5 +28,14 @@ dialog.show = function(_title,_internalURI,_message,_pointer){
//
}
})
if (_pointer !=null){
_pointer()
}
})
}
if (! qcms){
var qcms = {}
}
qcms.dialog = dialog

@ -118,6 +118,9 @@ jx.ajax.get.instance = function(){
}
}
this.delete = function (url,callback){
this.send(url,callback,'DELETE')
}
this.put = function(url,callback){
this.send(url,callback,'PUT') ;

@ -117,7 +117,7 @@ menu.events._dialog = function (_item,_context){
http.get(_context+'/dialog',function(x){
jx.modal.show({html:x.responseText,id:'dialog'})
// menu.events.finalize ('.jxmodal')
menu.events.finalize ('.jxmodal')
})
}
@ -125,31 +125,39 @@ menu.events._open = function (id,uri,_context){
id = id.replace(/ /g,'-')
var pid = '#content'
$('.content').children().slideUp()
// if ( $('#'+id).parent() == null){
// $('.content').children().slideUp()
// }else{
// var parent = $('#'+id).parent()
// parent.slideUp()
// if (parent[0].id == null){
// pid = ('.' + parent[0].className)
// }else{
// pid = ('#'+parent[0].id)
// }
// }
$('#'+id).remove()
var httpclient = HttpClient.instance()
_context = (_context == null)?'':_context;
httpclient.setHeader('uri',uri)
httpclient.setHeader('dom',id)
httpclient.post(_context+'/page',function(x){
if(x.readyState == 4 && x.status == 200){
var _html = x.responseText
var _dom = $(_html)
if(jx.dom.exists(pid) && jx.dom.exists(id)){
jx.dom.remove(id)
}
$(pid).append(_dom)
// jx.dom.append(pid,_dom)
// $('#'+id).show('fast',function(){
// $('#'+pid).slideUp()
// })
var ref = pid + ' #'+id
// menu.events.finalize (ref)
$(pid).children().slideUp('fast', function(){
$(ref ).slideDown('fast',function(){
$(pid).slideDown('fast',function(){
@ -163,7 +171,8 @@ menu.events._open = function (id,uri,_context){
})
menu.events.finalize (ref)
}
// $('.content').append(_dom)
@ -175,8 +184,23 @@ menu.utils = {}
menu.utils.format = function(text){
return text.replace(/(-|_)/g,' ').trim()
}
menu.utils._delegate = function (_id,_itemIndex,_index) {
if ($(_id).children().length >= _itemIndex ){
var _node = $(_id).children()[_itemIndex ]
if ($(_node).children().length >= _index ){
var _node = $(_node).children()[_index]
_node = $(_node).find('.active')
if ($(_node).length > 0 ){
$(_node)[0].click()
}
}
}
}
menu.events.finalize = function (ref) {
var scripts = $(ref+' script')
jx.utils.patterns.visitor(scripts,function(_item){
if(_item.text.trim().length > 0){
@ -202,6 +226,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) {
this._make = function (_items){
var _panes = []
var _context = this._context ;
_items.forEach(_item=>{
var _div = jx.dom.get .instance('DIV')
@ -215,17 +240,20 @@ var QCMSBasic= function(_layout,_context,_clickEvent) {
$(_div).on('click', function (){
//
// how do we process this ...
if(this.data.uri) {
if(this.data.uri && this.data.type != 'open') {
if (this.data.type == 'dialog') {
menu.events._dialog(this.data,_context)
}else{
menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context)
}
}else{
if (this.data.uri != null){
window.open(this.data.uri,'_self')
}else{
window.open(this.data.url,menu.utils.format(this.data.text))
}
}
})
@ -242,6 +270,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) {
// Object.keys(this._layout.menu)
_names.forEach(function(_name){
var _div = _me._make(_layout.menu[_name]) ;
@ -267,6 +296,7 @@ var QCMSTabs = function(_layout,_context,_clickEvent){
this.tabs = jx.dom.get.instance('DIV')
this.tabs.className = 'tabs'
this._context = _context
this._layout = _layout
this._make = function (text,_item,_event){
var text = text.trim().replace(/(_|-)/ig,' ').trim()
var _context = this._context;
@ -278,19 +308,33 @@ var QCMSTabs = function(_layout,_context,_clickEvent){
_button.type= 'radio'
_button.id = text+'tab'
_button.name = 'menu-tabs'
_label.innerHTML = text.toLowerCase()
_label._uri = _item[0].uri
_label.data = {id:text.toLowerCase(),uri:_item[0].uri}
// _button._uri = _label._uri
// if(this._layout.icons[text] != null) {
var _icon = jx.dom.get.instance('I')
_icon.className = this._layout.icons[text]
$(_label).append(_icon)
text = ' ' + text
// }
$(_label).append(text)
// _button.value= text.toLowerCase()
$(_button).val(text.toLowerCase())
_label.htmlFor = _button.id
$(_label).on('click',function (){
menu.events._open(this.innerHTML,this._uri,_context)
menu.events._open(this.data.id,this.data.uri,_context)
})
// $(this.tabs).append( [_button,_label])
// $(_button).on('click',function (){
// menu.events._open(this.value,this._uri,_context) ;})
return [_button,_label]
}
this._layout = _layout
this.init = function (){
var _me = this;
var _make = this._make
@ -307,6 +351,7 @@ var QCMSTabs = function(_layout,_context,_clickEvent){
this.tabs.className = 'tabs'
$('.main .menu').append(this.tabs)
$('.main .menu').css({'border':'1px solid transparent'})
$('.main .menu').css({'grid-template-columns':'64px auto'})
}
//
// We need to load the pages here ...
@ -316,7 +361,8 @@ var QCMSTabs = function(_layout,_context,_clickEvent){
}
menu.tabs = { }
menu.delegate = { }
// menu.tabs.make = function(text,_clickEvent){
// var _id = text.trim()
// if (text.match(/\//)){
@ -331,7 +377,7 @@ menu.tabs = { }
// $(_label).on('click',_clickEvent)
// return [_button,_label]
// }
menu.tabs.init =function (_layout,_context){
menu.init =function (_layout,_context){
//
// Let us determine what kind of menu is suited for this
// @TODO: Make menus configurable i.e on other areas of the site
@ -347,6 +393,8 @@ menu.tabs.init =function (_layout,_context){
}else{
_layout.order = {menu:[]}
}
var _count = 0
var _items = 0
Object.keys(_layout.menu).forEach(_name=>{
@ -359,10 +407,9 @@ menu.tabs.init =function (_layout,_context){
}else{
var _menuObject = new QCMSBasic (_layout,_context)
}
// console.log(_layout)
// var _tabs = new QCMSTabs (_layout)
console.log(_menuObject)
_menuObject.init()
}

@ -53,10 +53,12 @@ Vanderbilt University Medical Center
<script src="{{system.parentContext}}/static/js/menu.js"></script>
<script src="{{system.parentContext}}/static/js/search.js"></script>
<script src="{{system.parentContext}}/static/js/bootup.js"></script>
<script src="{{system.parentContext}}/static/js/dialog.js"></script>
<script src="{{system.parentContext}}/static/js/apexcharts/apexcharts.min.js"></script>
<script src="{{system.parentContext}}/static/js/fontawesome/js/all.js"></script>
</head>
<script>
sessionStorage.setItem('{{system.id}}','{{system.context|safe}}')
// sessionStorage.setItem('{{system.id}}','{{system.context|safe}}')
var _layout = {{layout|tojson}}
@ -64,8 +66,11 @@ Vanderbilt University Medical Center
$(document).ready( function(){
bootup.init('{{system.id}}',_layout)
menu.init({{layout|tojson}},'{{system.context}}')
})
</script>
<body>

@ -1,3 +1,4 @@
{%if system.portal %}
<div class="icon active">
@ -11,7 +12,3 @@
<i class="fa-solid fa-home"></i>
</div>
{% endif %}
<script>
menu.tabs.init({{layout|tojson}},'{{system.context}}')
</script>
Loading…
Cancel
Save