From af694a3dd31db7de19e0a825fd87d163cc430c05 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 25 Jun 2024 08:42:11 -0500 Subject: [PATCH] bug fixes, optimizations --- cms/engine/basic.py | 2 +- index.py | 38 +++++++++++++------------------------- static/js/dialog.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 static/js/dialog.js diff --git a/cms/engine/basic.py b/cms/engine/basic.py index 6d5ea90..02e0454 100644 --- a/cms/engine/basic.py +++ b/cms/engine/basic.py @@ -315,7 +315,7 @@ class Accessor (Initializer): self._config = json.loads(_stream) elif type(_stream) == io.StringIO : self._config = json.loads( _stream.read()) - self._ISCLOUD = 'source' in self._config['system'] and self._config['system']['source']['id'] == 'cloud' + self._ISCLOUD = 'source' in self._config['system'] and self._config['system']['source'] and self._config['system']['source']['id'] == 'cloud' # # # self._name = self._config['system']['name'] if 'name' in self._config['system'] else _args['name'] diff --git a/index.py b/index.py index 01e5fe8..131371c 100644 --- a/index.py +++ b/index.py @@ -15,6 +15,10 @@ import io import base64 from jinja2 import Environment, BaseLoader import typer +from typing_extensions import Annotated +from typing import Optional + + import pandas as pd import uuid import datetime @@ -274,30 +278,12 @@ def _open(id): _setHandler(id) # _route.set(id) return _index() -# -# Let us bootup the application -# SYS_ARGS = {} - -# if len(sys.argv) > 1: - -# N = len(sys.argv) -# for i in range(1,N): -# value = None -# if sys.argv[i].startswith('--'): -# key = sys.argv[i][2:] #.replace('-','') -# SYS_ARGS[key] = 1 -# if i + 1 < N: -# value = sys.argv[i + 1] = sys.argv[i+1].strip() -# if key and value and not value.startswith('--'): -# SYS_ARGS[key] = value - - - -# i += 2 @cli.command() -def start (path:str='config.json',shared:bool=False) : +def start ( + path:Annotated[str,typer.Argument(help="path of the manifest file")]='qcms-manifest.json', + shared:bool=False) : """ This function is designed to start the application with its associated manifest (configuration) location :path path to the the manifest @@ -307,9 +293,11 @@ def start (path:str='config.json',shared:bool=False) : if os.path.exists(path) and os.path.isfile(path): _args = {'path':path} - if shared : - _args['location'] = path - _args['shared'] = shared + # if shared : + # _args['location'] = path + # _args['shared'] = shared + _args['location'] = path + _args['shared'] = shared # _route = cms.engine.Router(**_args) #path=path,shared=shared) @@ -318,7 +306,7 @@ def start (path:str='config.json',shared:bool=False) : # _args = _route.get().get_app() _args = _route.get().app() _app.secret_key = str(uuid.uuid4()) - _app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(minutes=30) + _app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(hours=24) _app.run(**_args) _status = 'found' else: diff --git a/static/js/dialog.js b/static/js/dialog.js new file mode 100644 index 0000000..9de1b69 --- /dev/null +++ b/static/js/dialog.js @@ -0,0 +1,31 @@ +var dialog = {} +dialog.context = '' +dialog.show = function(_title,_internalURI,_message,_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) + 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) + + } + // + // In order to perhaps execute any js script that should have been executed on load ... + // + + var scripts = $('.jxmodal script') + jx.utils.patterns.visitor(scripts,function(_item){ + if(_item.text.trim().length > 0){ + var _routine = eval(_item.text) + // + //@TODO: + // Find a way to add the running function into the page to enable scripts to work + // + } + }) + }) +} \ No newline at end of file