# -*- 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 Window = dbui.Window #------------------------------------------------------------------------------- # # APPLICATION # #------------------------------------------------------------------------------- appNode = None if session.role == ADMIN: appNode = Node(T('Application')) prefLeaf = Window(closable=True, items=[cfgPreferences], layout='fit', modal=True, title=T('Preferences')) appNode.add_child(T('preferences'), prefLeaf) if "auth" in globals(): appNode.add_child(T('users'), to_grid('auth_user')) appNode.add_child(T('groups'), to_grid('auth_group')) appNode.add_child(T('relation user / groups'), to_grid('auth_membership')) #------------------------------------------------------------------------------- # # CONFIGURE HARVESTERS # #------------------------------------------------------------------------------- confHarvesterNode = None if session.role in (ADMIN, USER): confHarvesterNode = Node(T('Configure harvesters')) confHarvesterNode.add_child(T('harvesters'), to_grid('harvesters')) confHarvesterNode.add_child(T('relation harvesters / categories'), to_grid('controllers')) confHarvesterNode.add_child(T("author's rescue list"), to_grid('my_authors')) #------------------------------------------------------------------------------- # # CONFIGURE LISTS # #------------------------------------------------------------------------------- confListNode = None if session.role == ADMIN: confListNode = Node(T('Configure lists')) # NOTE: hide axes table which contains static data # confListNode.add_child('axes', to_grid('axes')) confListNode.add_child(T('renderers'), to_grid('renderers')) confListNode.add_child(T('sections'), to_grid('sections')) confListNode.add_child(T('lists'), to_grid('lists')) #------------------------------------------------------------------------------- # # CONFIGURE METRICs # #------------------------------------------------------------------------------- confMetricNode = None if session.role == ADMIN: confMetricNode = Node(T('Configure graphs and metrics')) confMetricNode.add_child(T('graphs'), to_grid('graphs')) confMetricNode.add_child(T('metrics'), to_grid('metrics')) #------------------------------------------------------------------------------- # # DATA INSTITUT # #------------------------------------------------------------------------------- dataInstituteNode = None if session.role == ADMIN: leaves = ('affiliation_keys', 'projects', 'teams') dataInstituteNode = Node(T('Data institute')) dataInstituteNode.add_children(leaves, func=to_grid) dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation')) #------------------------------------------------------------------------------- # # DATA PUBLICATIONS # #------------------------------------------------------------------------------- dataPublicationeNode = None if session.role in (ADMIN, USER): leaves = ('categories', 'collaborations', 'countries', 'publications', 'publishers', 'status') if session.role == USER: leaves = ('categories', 'publications') dataPublicationeNode = Node(T('Data publications')) dataPublicationeNode.add_children(leaves, func=to_grid) #------------------------------------------------------------------------------- # # HARVESTER NODE # #------------------------------------------------------------------------------- harvestNode = None if session.role in (ADMIN, USER): freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector, baseUrl=URL('harvest', 'free_run'), selectorTitle='Fill all fields', timeout=ONE_HOUR) harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector, baseUrl=URL('harvest', 'run'), extField='format', timeout=ONE_HOUR) runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector, baseUrl=URL('harvest', 'run_all'), extField='format', timeout=ONE_HOUR) harvestNode = Node(T('Harvest')) harvestNode.add_child(T('run a free harvester'), freeLeaf) harvestNode.add_child(T('run a harvester'), harvesterLeaf) harvestNode.add_child(T('run all harvesters'), runAllLeaf) harvestNode.sort_children() #------------------------------------------------------------------------------- # # HELP NODE # #------------------------------------------------------------------------------- loader = dict(autoLoad=True, renderer='html', scripts=False, url=URL('plugin_dbui', 'about')) aboutLeaf = Panel(loader=loader, autoScroll=True) loader = dict(autoLoad=True, renderer='html', scripts=True, url=URL('plugin_dbui', 'documentations_table')) docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) loader = dict(autoLoad=True, renderer='html', scripts=True, url=URL('default', 'guides')) guidesLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) 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('guides'), guidesLeaf) helpNode.add_child(T('versions'), versionLeaf) if session.role == ADMIN: helpNode.add_child(T('documentations'), docLeaf) helpNode.sort_children() #------------------------------------------------------------------------------- # # REPORT NODE # #------------------------------------------------------------------------------- loader = dict(autoLoad=True, renderer='html', scripts=True, url=URL('graphs', 'dashboard')) dashBoardLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) graphLeaf = PanelWithUrlSelector(virtdb.graph_selector, baseUrl=URL('graphs', 'index'), extField='format') listLeaf = PanelWithUrlSelector(virtdb.list_selector, baseUrl=URL('lists', 'index'), extField='format', plugins=['pMathJax']) metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, baseUrl=URL('metrics', 'index'), extField='format') reportNode = Node(T('Reports')) reportNode.add_child(T('dashboard'), dashBoardLeaf) reportNode.add_child(T('lists'), listLeaf) reportNode.add_child(T('metrics'), metricLeaf) reportNode.add_child(T('graphs'), graphLeaf) #------------------------------------------------------------------------------- # # WIZARD NODE # #------------------------------------------------------------------------------- wizardNode = None if session.role in (ADMIN, USER): authorLeaf = PanelWithUrlSelector(virtdb.authors_selector, baseUrl=URL('wizards', 'extract_authors')) checkLeaf = PanelWithUrlSelector(virtdb.check_selector, baseUrl=URL('wizards', 'check_validate'), extField='format', timeout=ONE_HOUR) editLeaf = PanelWithUrlSelector(virtdb.edit_insert_selector, baseUrl=URL('harvest', 'edit_insert'), selectorTitle='Fill all fields') marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector, selectorTitle='Fill all fields', baseUrl=URL('harvest', 'insert_marcxml')) wizardNode = Node(T('Wizards')) wizardNode.add_child(T('extract authors'), authorLeaf) if session.role == ADMIN: wizardNode.add_child(T('check and validate'), checkLeaf) else: wizardNode.add_child(T('check'), checkLeaf) wizardNode.add_child(T('edit and insert'), editLeaf) wizardNode.add_child(T('insert MARCXML'), marc12Leaf) wizardNode.sort_children() #------------------------------------------------------------------------------- # # VIEWPORT # #------------------------------------------------------------------------------- nodes = [helpNode, appNode, wizardNode, confHarvesterNode, confListNode, confMetricNode, dataInstituteNode, dataPublicationeNode, harvestNode, reportNode] viewportModifier = dbui.ViewportModifier() viewportModifier.add_node(*nodes) viewportModifier.configure(tabTitleTpl="{1}") # NOTE the session.auth only exit when the user is logged if "auth" in globals(): viewportModifier.configure(logged=False, plugins=['pViewportLogin']) if session.role in (ADMIN, USER): viewportModifier.configure(logged=True) viewportModifier.default_node(T('Data publications'), T('publications')) else: viewportModifier.default_node(T('Reports'), T('dashboard'))