-
Notifications
You must be signed in to change notification settings - Fork 4
Navigation system
Vanissoft edited this page Dec 20, 2017
·
1 revision
The navigation in the application is based in AJAX calls and in-place rendering.
The file navigation.html contains the declaration markup for the lateral menu, the main one.
The calling is controlled by a Brython script by means of the binding of buttons.
Each button calls that may be called a "module".
<aside class="navigation"> <nav> <ul class="nav luna-nav"> <li class="nav-category"> Main </li> <li class="active"> <a role="button" id="link_dashboard">Dashboard (template)</a> </li> <li><a role="button" id="link_limitorders">Limit orders</a></li> <li><a role="button" id="link_settings">Settings</a></li>
wmain.py is the Brython code responsible of the mechanics for module loading.
Each button is binded with an AJAX call request for the file specified in the main dictionary.
Menu_binds = {'link_limitorders': 'limit_orders.html', 'link_settings': 'settings.html'}
AJAX call:
def query(url, callback): global Cnt url = url+"&nonce="+str(Cnt) Callbacks[url] = callback req = ajax.ajax() req.open('GET', url, True) req.send() func = partial(ajax_end, url) req.bind('complete', func) Cnt += 1
After the call is completed there is a substitution of page_container div of main.html and proceeds to import and initialize module.
def html_loaded(url, rtn): global ws_comm, Active_module document['page_container'].innerHTML = rtn if 'dashboard' in url: import wmoddashboard Active_module = wmoddashboard elif 'limit_orders' in url: import wmodlimitorders Active_module = wmodlimitorders if Active_module is not None: ws_comm.send({'operation': 'module_activation', 'module': Active_module.Module_name}) Active_module.init(ws_comm)
See Module system