widgets_viewport.py 5.81 KB
Newer Older
1 2 3 4
# -*- coding: utf-8 -*-
""" widgets viewport

"""
5 6
# helper function translating a tablename into the grid configuration
to_grid = lambda tablename: dbui.to_gridPanel(db[tablename]) 
LE GAC Renaud's avatar
LE GAC Renaud committed
7

8 9 10 11
# short cuts
Node = dbui.Node
Panel = dbui.Panel
PanelWithUrlSelector = dbui.to_panelWithUrlSelector
12

13
#-------------------------------------------------------------------------------
LE GAC Renaud's avatar
LE GAC Renaud committed
14
#
15
# CAS
LE GAC Renaud's avatar
LE GAC Renaud committed
16
#
17
#-------------------------------------------------------------------------------
18
casNode = None
19
if "auth" in globals():
20
    
21
    casNode = Node(T('CAS'))
LE GAC Renaud's avatar
LE GAC Renaud committed
22

23 24 25 26 27
    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'))

#-------------------------------------------------------------------------------
28
#
29
# HELP NODE
30
#
31
#-------------------------------------------------------------------------------
32 33 34 35 36 37
loader = dict(autoLoad=True,
              renderer='html',
              url=URL('plugin_dbui', 'about'))

aboutLeaf = Panel(loader=loader, autoScroll=True)

LE GAC Renaud's avatar
LE GAC Renaud committed
38 39 40 41 42 43
# loader = dict(autoLoad=True,
#               renderer='html',
#               scripts=True,
#               url=URL('plugin_dbui', 'documentations'))
# 
# docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True)
44

45 46
loader = dict(autoLoad=True,
              renderer='html',
LE GAC Renaud's avatar
LE GAC Renaud committed
47
              url=URL('default', 'documentations'))
48

LE GAC Renaud's avatar
LE GAC Renaud committed
49
docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'])
50

51 52 53 54 55 56
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('plugin_dbui', 'versions'))

versionLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'])
57

58 59
helpNode = Node(T('Help'))
helpNode.add_child(T('about'), aboutLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
60
helpNode.add_child(T('documentations'), docLeaf)
61 62 63 64 65
helpNode.add_child(T('versions'), versionLeaf)
helpNode.sort_children()

#-------------------------------------------------------------------------------
#
66 67 68 69
# CONFIGURE
#
#-------------------------------------------------------------------------------
cfgNode = Node(T('Configure'))
70 71 72 73
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'))
74 75 76 77

#-------------------------------------------------------------------------------
#
# META DATA
78 79
#
#-------------------------------------------------------------------------------
LE GAC Renaud's avatar
LE GAC Renaud committed
80
metaNode = Node(T('Metadata'))
81 82 83 84 85 86 87 88 89 90 91 92 93
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'))
LE GAC Renaud's avatar
LE GAC Renaud committed
94
eventNode.add_child(T('definitions'), to_grid('events'))
95 96 97 98 99 100 101 102
eventNode.add_child(T('history'), to_grid('history'))

#-------------------------------------------------------------------------------
#
# LIST
#
#-------------------------------------------------------------------------------
listNode = Node(T('The lists'))
103

104
for row in db(db.lists.id > 0).select(orderby=db.lists.name):
105
     
106 107
    leaf = PanelWithUrlSelector(virtdb.grid_selector, 
                                baseUrl=URL('report', 'grid'),
108
                                baseParams={'id_lists': row.id})
109
     
110
    listNode.add_child(row.name, leaf)
111 112 113

#-------------------------------------------------------------------------------
#
114
# METRIC 1D
115 116
#
#-------------------------------------------------------------------------------
117
metric1dNode = Node(T('The metrics 1d'))
118

119
for row in db(db.metrics1d.id > 0).select(orderby=db.metrics1d.name):
120

121 122 123
    leaf = PanelWithUrlSelector(virtdb.grid_selector, 
                                baseUrl=URL('report', 'grid'),
                                baseParams={'id_metrics1d': row.id})
124
     
125 126 127 128 129 130 131 132 133 134
    metric1dNode.add_child(row.name, leaf)

metric1dNode.sort_children()

#-------------------------------------------------------------------------------
#
# METRIC 2D
#
#-------------------------------------------------------------------------------
metric2dNode = Node(T('The metrics 2d'))
135

136
for row in db(db.metrics2d.id > 0).select(orderby=db.metrics2d.name):
137

138 139 140
    leaf = PanelWithUrlSelector(virtdb.grid_selector, 
                                baseUrl=URL('report', 'grid'),
                                baseParams={'id_metrics2d': row.id})
141
     
142
    metric2dNode.add_child(row.name, leaf)
143

144
metric2dNode.sort_children()
145

146 147
#-------------------------------------------------------------------------------
#
148
# GRAPH
149
# Define by the 2D metrics
150
#
151
#-------------------------------------------------------------------------------
152
graphNode = Node(T('The graphs'))
153

154
for row in db(db.graphs.id > 0).select(orderby=db.graphs.name):
155 156
     
    leaf = PanelWithUrlSelector(virtdb.graph_selector, 
157
                                baseUrl=URL('report', 'graph_mpl'),
158
                                baseParams={'id_graphs': row.id})
159
     
160
    graphNode.add_child(row.name, leaf)
161

162
#-------------------------------------------------------------------------------
163
#
164
# VIEWPORT
165
#
166 167 168
#-------------------------------------------------------------------------------
nodes = [helpNode, 
         casNode,
169 170 171 172
         cfgNode,
         metaNode,
         eventNode,
         listNode,
173 174
         metric1dNode,
         metric2dNode, 
175
         graphNode]
176

177
viewportModifier = dbui.ViewportModifier()
178 179 180
viewportModifier.add_node(*nodes)

viewportModifier.configure(tabTitleTpl="{1}")
181

182
if session.auth:
183
    viewportModifier.configure(logged=True, plugins=['pViewportLogin'])
184
    
185
viewportModifier.default_node(T('Events'), T('history'))