From 338d9fe757226d084621a5b6010e325c67d9eeb1 Mon Sep 17 00:00:00 2001 From: Steve Nyemba <nyemba@gmail.com> Date: Wed, 29 Jan 2025 13:39:05 -0600 Subject: [PATCH] bug fixes: dashboard utility functions --- bin/qcms | 11 ++++-- cms/engine/plugins/__init__.py | 70 +++++++++++++++++----------------- cms/static/js/dialog.js | 3 ++ cms/static/js/search.js | 14 +++++++ 4 files changed, 59 insertions(+), 39 deletions(-) diff --git a/bin/qcms b/bin/qcms index 3ac518e..a7a5b56 100755 --- a/bin/qcms +++ b/bin/qcms @@ -184,8 +184,11 @@ def plug_info (manifest:Annotated[str,typer.Argument(help="path to manifest file """ manifest = get_manifest(manifest) _config = config.get(manifest) - _root = os.sep.join(manifest.split(os.sep)[:-1] + [_config['layout']['root'],'_plugins']) - if os.path.exists(_root) : + if _config : + _root = os.sep.join(manifest.split(os.sep)[:-1] + [_config['layout']['root'],'_plugins']) + else : + _root = None + if _root and os.path.exists(_root) : # files = os.listdir(_root) _msg = f"""{FAILED} no operation was specified, please use --help option""" # if 'plugins' in _config : @@ -228,8 +231,8 @@ def plug_info (manifest:Annotated[str,typer.Argument(help="path to manifest file print() print(_msg) else: - _msg = f"""{FAILED} no plugin folder found """ - pass + _msg = f"""{FAILED} No plugin folder could be found in {manifest}""" + print (_msg) @cli.command (name='create') diff --git a/cms/engine/plugins/__init__.py b/cms/engine/plugins/__init__.py index 86858f0..de60ce0 100644 --- a/cms/engine/plugins/__init__.py +++ b/cms/engine/plugins/__init__.py @@ -9,42 +9,42 @@ import os # -def stats (_config) : - """ - Returns the statistics of the plugins - """ - _data = [] - for _name in _config : - _log = {"files":_name,"loaded":len(_config[_name]),"logs":json.dumps(_config[_name])} - _data.append(_log) - return pd.DataFrame(_data) - pass -def load(_path,_filename,_name) : - """ - This function will load external module form a given location and return a pointer to a function in a given module - :path absolute path of the file (considered plugin) to be loaded - :name name of the function to be applied - """ - # _path = _args['path'] #os.sep.join([_args['root'],'plugin']) +# def stats (_config) : +# """ +# Returns the statistics of the plugins +# """ +# _data = [] +# for _name in _config : +# _log = {"files":_name,"loaded":len(_config[_name]),"logs":json.dumps(_config[_name])} +# _data.append(_log) +# return pd.DataFrame(_data) +# pass +# def load(_path,_filename,_name) : +# """ +# This function will load external module form a given location and return a pointer to a function in a given module +# :path absolute path of the file (considered plugin) to be loaded +# :name name of the function to be applied +# """ +# # _path = _args['path'] #os.sep.join([_args['root'],'plugin']) - if os.path.isdir(_path): - files = os.listdir(_path) - if files : - files = [name for name in files if name.endswith('.py') and name == _filename] - if files: - _path = os.sep.join([_path,files[0]]) - else: - return None - else: - return None - #-- We have a file ... - # _name = _args['name'] - spec = importlib.util.spec_from_file_location(_filename, _path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - # - # we need to make sure we have the plugin decorator here to make sure +# if os.path.isdir(_path): +# files = os.listdir(_path) +# if files : +# files = [name for name in files if name.endswith('.py') and name == _filename] +# if files: +# _path = os.sep.join([_path,files[0]]) +# else: +# return None +# else: +# return None +# #-- We have a file ... +# # _name = _args['name'] +# spec = importlib.util.spec_from_file_location(_filename, _path) +# module = importlib.util.module_from_spec(spec) +# spec.loader.exec_module(module) +# # +# # we need to make sure we have the plugin decorator here to make sure - return getattr(module,_name) if hasattr(module,_name) else None +# return getattr(module,_name) if hasattr(module,_name) else None diff --git a/cms/static/js/dialog.js b/cms/static/js/dialog.js index c7a5055..3dd652d 100644 --- a/cms/static/js/dialog.js +++ b/cms/static/js/dialog.js @@ -5,6 +5,9 @@ dialog.show = function(_args,_pointer){ // http.setData({title:_title,html:_message},'application/json') var uri = _args.context+'/dialog' http.setHeader('dom',_args.title) + if (_args.uri.match(/=/)){ + _args.uri = _args.uri.split(/=/)[1] + } http.setHeader('uri',_args.uri) http.get(uri,function(x){ $('.jxmodal').remove() diff --git a/cms/static/js/search.js b/cms/static/js/search.js index e69de29..10d33cc 100644 --- a/cms/static/js/search.js +++ b/cms/static/js/search.js @@ -0,0 +1,14 @@ +var Search = function(_searchBoxId,_paneId,_bind){ + var _text = jx.dom.get.value(_searchBoxId) + _regex = new RegExp(_text.toLowerCase()) + _paneId = (_paneId['#'])?_paneId:('#'+_paneId) + $(_paneId).slideUp() + (_paneId).children().each(_index=>{ + _div = $(_paneId).children()[_index] + if (_div._data.match(_regex)){ + $(_div).slideDown() + } + }) + + +} \ No newline at end of file