# -*- coding: utf-8 -*- """ widgets viewport """ # helper function translating a tablename into the grid configuration to_grid = lambda tablename: dbui.to_gridPanel(db[tablename]) # short cuts Node = dbui.Node Panel = dbui.Panel PanelWithUrlSelector = dbui.to_panelWithUrlSelector #------------------------------------------------------------------------------- # # CAS # #------------------------------------------------------------------------------- casNode = None if "auth" in globals(): casNode = Node(T('CAS')) casNode.add_child(T('users'), to_grid('auth_user')) casNode.add_child(T('groups'), to_grid('auth_group')) casNode.add_child(T('relation user / groups'), to_grid('auth_membership')) #------------------------------------------------------------------------------- # # HELP NODE # #------------------------------------------------------------------------------- loader = dict(autoLoad=True, renderer='html', url=URL('plugin_dbui', 'about')) aboutLeaf = Panel(loader=loader, autoScroll=True) # loader = dict(autoLoad=True, # renderer='html', # scripts=True, # url=URL('plugin_dbui', 'documentations')) # # docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) loader = dict(autoLoad=True, renderer='html', url=URL('default', 'documentations')) docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException']) loader = dict(autoLoad=True, renderer='html', scripts=True, url=URL('plugin_dbui', 'versions')) versionLeaf = Panel(loader=loader, plugins=['pPanelLoaderException']) helpNode = Node(T('Help')) helpNode.add_child(T('about'), aboutLeaf) helpNode.add_child(T('documentations'), docLeaf) helpNode.add_child(T('versions'), versionLeaf) helpNode.sort_children() #------------------------------------------------------------------------------- # # CONFIGURE # #------------------------------------------------------------------------------- cfgNode = Node(T('Configure')) cfgNode.add_child(T('the lists'), to_grid('lists')) cfgNode.add_child(T('the metrics 1d'), to_grid('metrics1d')) cfgNode.add_child(T('the metrics 2d'), to_grid('metrics2d')) cfgNode.add_child(T('the graphs'), to_grid('graphs')) #------------------------------------------------------------------------------- # # META DATA # #------------------------------------------------------------------------------- metaNode = Node(T('Metadata')) metaNode.add_child(T('fundings'), to_grid('fundings')) metaNode.add_child(T('teams'), to_grid('teams')) metaNode.add_child(T('people'), to_grid('people')) metaNode.add_child(T('people_categories'), to_grid('people_categories')) metaNode.add_child(T('projects'), to_grid('projects')) metaNode.sort_children() #------------------------------------------------------------------------------- # # EVENT # #------------------------------------------------------------------------------- eventNode = Node(T('Events')) eventNode.add_child(T('definitions'), to_grid('events')) eventNode.add_child(T('history'), to_grid('history')) #------------------------------------------------------------------------------- # # LIST # #------------------------------------------------------------------------------- listNode = Node(T('The lists')) for row in db(db.lists.id > 0).select(orderby=db.lists.name): leaf = PanelWithUrlSelector(virtdb.grid_selector, baseUrl=URL('report', 'grid'), baseParams={'id_lists': row.id}) listNode.add_child(row.name, leaf) #------------------------------------------------------------------------------- # # METRIC 1D # #------------------------------------------------------------------------------- metric1dNode = Node(T('The metrics 1d')) for row in db(db.metrics1d.id > 0).select(orderby=db.metrics1d.name): leaf = PanelWithUrlSelector(virtdb.grid_selector, baseUrl=URL('report', 'grid'), baseParams={'id_metrics1d': row.id}) metric1dNode.add_child(row.name, leaf) metric1dNode.sort_children() #------------------------------------------------------------------------------- # # METRIC 2D # #------------------------------------------------------------------------------- metric2dNode = Node(T('The metrics 2d')) for row in db(db.metrics2d.id > 0).select(orderby=db.metrics2d.name): leaf = PanelWithUrlSelector(virtdb.grid_selector, baseUrl=URL('report', 'grid'), baseParams={'id_metrics2d': row.id}) metric2dNode.add_child(row.name, leaf) metric2dNode.sort_children() #------------------------------------------------------------------------------- # # GRAPH # Define by the 2D metrics # #------------------------------------------------------------------------------- graphNode = Node(T('The graphs')) for row in db(db.graphs.id > 0).select(orderby=db.graphs.name): leaf = PanelWithUrlSelector(virtdb.graph_selector, baseUrl=URL('report', 'graph_mpl'), baseParams={'id_graphs': row.id}) graphNode.add_child(row.name, leaf) #------------------------------------------------------------------------------- # # VIEWPORT # #------------------------------------------------------------------------------- nodes = [helpNode, casNode, cfgNode, metaNode, eventNode, listNode, metric1dNode, metric2dNode, graphNode] viewportModifier = dbui.ViewportModifier() viewportModifier.add_node(*nodes) viewportModifier.configure(tabTitleTpl="{1}") if session.auth: viewportModifier.configure(logged=True, plugins=['pViewportLogin']) viewportModifier.default_node(T('Events'), T('history'))