From 5644e09b6bcc4278b6ba25fffb2834b3ac24c278 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Wed, 4 Sep 2024 15:11:48 -0500 Subject: [PATCH 1/5] bug fix: finalize page loading with scripts running --- cms/static/js/bootup.js | 6 ++++-- cms/static/js/menu.js | 2 ++ cms/templates/index.html | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cms/static/js/bootup.js b/cms/static/js/bootup.js index 6fc6a3f..fd8afb4 100644 --- a/cms/static/js/bootup.js +++ b/cms/static/js/bootup.js @@ -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) } } diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index e0b32a8..f040821 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -347,6 +347,8 @@ menu.tabs.init =function (_layout,_context){ }else{ _layout.order = {menu:[]} } + + var _count = 0 var _items = 0 Object.keys(_layout.menu).forEach(_name=>{ diff --git a/cms/templates/index.html b/cms/templates/index.html index 825a231..bfc6b84 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -53,6 +53,7 @@ Vanderbilt University Medical Center + diff --git a/cms/templates/menu.html b/cms/templates/menu.html index 208f67b..9285419 100644 --- a/cms/templates/menu.html +++ b/cms/templates/menu.html @@ -1,3 +1,4 @@ + {%if system.portal %}
@@ -10,8 +11,4 @@
-{% endif %} - - \ No newline at end of file +{% endif %} \ No newline at end of file From 4382bb2ec7be1ae7732952b1ded121d8d8b3161d Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 9 Sep 2024 11:19:04 -0500 Subject: [PATCH 3/5] bug fixes, and new menu delegate function --- cms/disk.py | 4 ++-- cms/engine/basic.py | 9 +++++++++ cms/index.py | 8 ++++---- cms/static/js/menu.js | 31 +++++++++++++++++++++++++------ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/cms/disk.py b/cms/disk.py index 4437a61..65e94d1 100644 --- a/cms/disk.py +++ b/cms/disk.py @@ -97,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): @@ -123,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) diff --git a/cms/engine/basic.py b/cms/engine/basic.py index 8dd5b2f..7a1da60 100644 --- a/cms/engine/basic.py +++ b/cms/engine/basic.py @@ -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): diff --git a/cms/index.py b/cms/index.py index b6be9e3..5dc3236 100644 --- a/cms/index.py +++ b/cms/index.py @@ -130,9 +130,9 @@ def _aindex (app,resource=None): # """ # global _config # return "0",200 - -@_app.route('/dialog') -def _dialog (): +@_app.route('//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(["
",str( e.render(**_args)),'
']) - _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) diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index 7dc0972..2ffb331 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -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') }) } @@ -129,6 +129,7 @@ menu.events._open = function (id,uri,_context){ $('.content').children().slideUp() $('#'+id).remove() + var httpclient = HttpClient.instance() _context = (_context == null)?'':_context; httpclient.setHeader('uri',uri) @@ -138,14 +139,13 @@ menu.events._open = function (id,uri,_context){ var _html = x.responseText var _dom = $(_html) - if(jx.dom.exists(pid) && jx.dom.exists(id)){ jx.dom.remove(id) } $(pid).append(_dom) var ref = pid + ' #'+id - menu.events.finalize (ref) + // menu.events.finalize (ref) $(pid).children().slideUp('fast', function(){ $(ref ).slideDown('fast',function(){ @@ -174,6 +174,20 @@ 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') @@ -202,6 +216,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,8 +230,7 @@ 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) @@ -224,7 +238,11 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context) } }else{ - window.open(this.data.url,menu.utils.format(this.data.text)) + 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 +260,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { // Object.keys(this._layout.menu) _names.forEach(function(_name){ + var _div = _me._make(_layout.menu[_name]) ; From ab6567176e9d6cd9ff3b2adcc4f70b958f0c7896 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 13 Sep 2024 09:33:52 -0500 Subject: [PATCH 4/5] bug fixes --- cms/index.py | 1 + cms/static/js/dialog.js | 20 +++++++++++++------- cms/static/js/menu.js | 38 ++++++++++++++++++++++++++++++-------- cms/templates/index.html | 1 + 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/cms/index.py b/cms/index.py index 5dc3236..dfc1abd 100644 --- a/cms/index.py +++ b/cms/index.py @@ -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) diff --git a/cms/static/js/dialog.js b/cms/static/js/dialog.js index 9de1b69..c4e9ad9 100644 --- a/cms/static/js/dialog.js +++ b/cms/static/js/dialog.js @@ -1,16 +1,16 @@ 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) } // @@ -27,5 +27,11 @@ dialog.show = function(_title,_internalURI,_message,_pointer){ // } }) + }) -} \ No newline at end of file +} + +if (! qcms){ + var qcms = {} +} +qcms.dialog = dialog \ No newline at end of file diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index 2ffb331..1e7517d 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -125,9 +125,19 @@ 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() @@ -286,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; @@ -297,14 +308,24 @@ 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 - _button._uri = _label._uri - _button.value= text.toLowerCase() + + _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) }) // $(_button).on('click',function (){ // menu.events._open(this.value,this._uri,_context) ;}) @@ -313,7 +334,7 @@ var QCMSTabs = function(_layout,_context,_clickEvent){ } - this._layout = _layout + this.init = function (){ var _me = this; var _make = this._make @@ -330,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 ... diff --git a/cms/templates/index.html b/cms/templates/index.html index ba78f61..9503e7f 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -53,6 +53,7 @@ Vanderbilt University Medical Center + From a0cf018edf06b62985fd9664b4ed8dc397a4e6e8 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 16 Sep 2024 14:13:54 -0500 Subject: [PATCH 5/5] minor bug fixes --- cms/static/js/dialog.js | 4 ++++ cms/static/js/jx/rpc.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cms/static/js/dialog.js b/cms/static/js/dialog.js index c4e9ad9..c7a5055 100644 --- a/cms/static/js/dialog.js +++ b/cms/static/js/dialog.js @@ -13,6 +13,7 @@ dialog.show = function(_args,_pointer){ jx.dom.set.value('dialog-message',_args.message) } + // // In order to perhaps execute any js script that should have been executed on load ... // @@ -27,6 +28,9 @@ dialog.show = function(_args,_pointer){ // } }) + if (_pointer !=null){ + _pointer() + } }) } diff --git a/cms/static/js/jx/rpc.js b/cms/static/js/jx/rpc.js index ebfd127..9f29183 100755 --- a/cms/static/js/jx/rpc.js +++ b/cms/static/js/jx/rpc.js @@ -119,6 +119,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') ; }