diff --git a/cms/__init__.py b/cms/__init__.py index 42ce092..c0f7b95 100644 --- a/cms/__init__.py +++ b/cms/__init__.py @@ -8,6 +8,8 @@ import importlib import importlib.util import json +from . import apexchart + class Plugin : # # decorator for plugin functions, this is a preliminary to enable future developement @@ -121,60 +123,3 @@ class Plugin : return _data,_code,{'Content-Type':_mimeType} pass - -# def _get_config (path) : -# if os.path.exists(path) : -# f = open(path) -# _conf = json.loads(f.read()) -# f.close() -# else: -# _conf = {} -# return _conf -# def _isvalid(_allowed,**_args): - -# if not list(set(_allowed) - set(_args.keys())) : -# _pargs = {} -# for key in _allowed : -# _pargs [key] = _args[key] -# return _pargs -# return False - -# def write_config(_config, path): -# f = open(path,'w') -# f.write( json.dumps(_config)) ; -# f.close() - -# def _system(**_args): -# """ -# Both version and context must be provided otherwise they are ignored -# :version -# :context context -# """ -# _info = _isvalid(['version','context'],**_args) -# _info['theme'] = 'default.css' -# _info = _info if _info else {'version':'0.0.0','context':'','theme':'default.css'} -# if _info : -# _info['logo'] = None if 'logo' not in _args else _args['logo'] -# # -# # There is an aggregation entry here in app -# _appInfo = {'debug':True,'port':8084,'threaded':True,'host':'0.0.0.0'} -# if 'app' not in _args: -# _info['app'] = _appInfo -# else: -# _info['app'] = dict(_appInfo,**_args['app']) - -# return _info -# def _header(**_args): -# return _isvalid(['logo','title','subtitle'],**_args) -# def _layout(**_args): -# _info = _isvalid(['root','index'],**_args) -# _info['on'] = {"load":{},"error":{}} -# _url = 'qcms.co' -# _overwrite = {"folder1":{"type":"redirect","url":_url},"folder2":{"type":"dialog"},"folder3":{"type":"dialog","url":_url}} -# _info['icons'] = {"comment":"use folder names as keys and fontawesome type as values to add icons to menu"} -# _info["api"] = {"comment":"use keys as uri and function calls as values"} -# _info['map'] = {}, -# _info['order'] = {'menu':[]} -# _info['overwrite'] = _overwrite -# return _info - \ No newline at end of file diff --git a/cms/static/js/dashboard.js b/cms/static/js/dashboard.js index f4c1df9..fd4d47b 100644 --- a/cms/static/js/dashboard.js +++ b/cms/static/js/dashboard.js @@ -179,20 +179,52 @@ if(!qcms){ var qcms = {} } -var _dashboard = function(_context,_uri){ - this._context = _context ; +qcms.dashboard = function(_uri,_id){ this._uri = _uri - - this.get = function (_args){ + this._id = _id + this.get = function (){ var _uri = this._uri ; - if (this._context){ - _uri = this._context + _uri - } var http = HttpClient.instance() http.setHeader('Content-Type','application/json') - http.setData(JSON.stringify(_args)) + //http.setData(JSON.stringify(_args)) + var _render = this.render + var _id = this._id http.post(_uri,function(x){ - if(x.readyState == 4 && x.status == 200){} + if(x.readyState == 4 && x.status == 200){ + var _logs = JSON.parse(x.responseText) + _events = [] + _logs.forEach(_item=>{ + + var _e = _render(_item,_id) + if (_e != null){ + _events.push(_e) + } + }) + _events.forEach(_e=>{ _e.render() }) + } }) } + this.render = function (_item,_id){ + if (! _item.options){ + // + // This is html to be rendered + if(_item.constructor.name == 'Array'){ + _item.forEach(_div =>{$(_id).append(_div) }) + }else{ + + $(_id).append($(_item)) + } + return null + }else { + // + // rendering apexcharts + // + var _divChart = jx.dom.get.instance('DIV') + _divChart.className = 'chart '+_item.type + $(_id).append(_divChart) + var _chart = new ApexCharts(_divChart,_item.options) + return _chart ; + + } + } }