Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
33868299
Commit
33868299
authored
Nov 21, 2016
by
LE GAC Renaud
Browse files
Add the class EvtUiViewport.
parent
bd6debe4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
319 additions
and
0 deletions
+319
-0
modules/plugin_tev/ui_viewport.py
modules/plugin_tev/ui_viewport.py
+319
-0
No files found.
modules/plugin_tev/ui_viewport.py
0 → 100644
View file @
33868299
# -*- coding: utf-8 -*-
"""Main user interface the viewport
"""
import
plugin_dbui
as
dbui
from
gluon
import
current
from
gluon.html
import
URL
Node
=
dbui
.
Node
Panel
=
dbui
.
Panel
to_grid
=
lambda
tablename
:
dbui
.
to_gridPanel
(
db
[
tablename
])
class
EvtUiViewport
(
object
):
"""Configure the viewport.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
selector_panel (gluon.storage.Storage):
configuration of the selector panel.
"""
def
__init__
(
self
,
db
,
T
,
selector_panel
):
nodes
=
[
EvtUiViewport
.
help_node
(
db
,
T
),
EvtUiViewport
.
app_node
(
db
,
T
),
EvtUiViewport
.
configure_node
(
db
,
T
),
EvtUiViewport
.
meta_node
(
db
,
T
),
EvtUiViewport
.
object_node
(
db
,
T
),
EvtUiViewport
.
event_node
(
db
,
T
),
EvtUiViewport
.
list_node
(
db
,
T
,
selector_panel
),
EvtUiViewport
.
metric1d_node
(
db
,
T
,
selector_panel
),
EvtUiViewport
.
metric2d_node
(
db
,
T
,
selector_panel
),
EvtUiViewport
.
graph_node
(
db
,
T
,
selector_panel
)]
modifier
=
dbui
.
ViewportModifier
()
modifier
.
add_node
(
*
nodes
)
modifier
.
configure
(
tabTitleTpl
=
"{1}"
)
if
current
.
session
.
auth
:
modifier
.
configure
(
logged
=
True
,
plugins
=
[
'pViewportLogin'
])
modifier
.
default_node
(
T
(
'Events'
),
T
(
'history'
))
@
staticmethod
def
app_node
(
db
,
T
):
"""To deal with authentication and preferences.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
None
if
"auth"
in
globals
():
node
=
Node
(
T
(
'CAS'
))
add_child
=
node
.
add_child
add_child
(
T
(
'users'
),
to_grid
(
'auth_user'
))
add_child
(
T
(
'groups'
),
to_grid
(
'auth_group'
))
add_child
(
T
(
'relation user / groups'
),
to_grid
(
'auth_membership'
))
return
node
@
staticmethod
def
help_node
(
db
,
T
):
"""To deal with documentation and version.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
loader
=
dict
(
autoLoad
=
True
,
renderer
=
'html'
,
url
=
URL
(
'plugin_dbui'
,
'about'
))
aboutLeaf
=
Panel
(
loader
=
loader
,
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'
])
node
=
Node
(
T
(
'Help'
))
add_child
=
node
.
add_child
add_child
(
T
(
'about'
),
aboutLeaf
)
add_child
(
T
(
'documentations'
),
docLeaf
)
add_child
(
T
(
'versions'
),
versionLeaf
)
node
.
sort_children
()
return
node
@
staticmethod
def
configure_node
(
db
,
T
):
"""To configure lists and metrics.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'Configure'
))
add_child
=
node
.
add_child
add_child
(
T
(
'the lists'
),
to_grid
(
'lists'
))
add_child
(
T
(
'the metrics 1d'
),
to_grid
(
'metrics1d'
))
add_child
(
T
(
'the metrics 2d'
),
to_grid
(
'metrics2d'
))
add_child
(
T
(
'the graphs'
),
to_grid
(
'graphs'
))
return
node
@
staticmethod
def
event_node
(
db
,
T
):
"""To deal with event.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'Events'
))
add_child
=
node
.
add_child
add_child
(
T
(
'definitions'
),
to_grid
(
'events'
))
add_child
(
T
(
'history'
),
to_grid
(
'history'
))
return
node
@
staticmethod
def
meta_node
(
db
,
T
):
"""To deal with meta data.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'Metadata'
))
add_child
=
node
.
add_child
add_child
(
T
(
'domains'
),
to_grid
(
'domains'
))
add_child
(
T
(
'fundings'
),
to_grid
(
'fundings'
))
add_child
(
T
(
'teams'
),
to_grid
(
'teams'
))
add_child
(
T
(
'projects'
),
to_grid
(
'projects'
))
node
.
sort_children
()
return
node
@
staticmethod
def
object_node
(
db
,
T
):
"""To deal with object and people.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'People and objects'
))
add_child
=
node
.
add_child
add_child
(
T
(
'people'
),
to_grid
(
'people'
))
add_child
(
T
(
'people_categories'
),
to_grid
(
'people_categories'
))
add_child
(
T
(
'objects'
),
to_grid
(
'objects'
))
add_child
(
T
(
'object_categories'
),
to_grid
(
'object_categories'
))
node
.
sort_children
()
return
node
@
staticmethod
def
list_node
(
db
,
T
,
selector_panel
):
"""To deal with lists.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
selector_panel (gluon.storage.Storage):
configuration of the selector panel.
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'The lists'
))
add_child
=
node
.
add_child
for
row
in
db
(
db
.
lists
.
id
>
0
).
select
(
orderby
=
db
.
lists
.
name
):
panel
=
selector_panel
panel
.
baseUrl
=
URL
(
'report'
,
'grid'
)
panel
.
baseParams
=
{
'id_lists'
:
row
.
id
}
add_child
(
row
.
name
,
panel
)
return
node
@
staticmethod
def
metric1d_node
(
db
,
T
,
selector_panel
):
"""To deal with one-dimension metrics.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
selector_panel (gluon.storage.Storage):
configuration of the selector panel.
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'The metrics 1d'
))
add_child
=
node
.
add_child
for
row
in
db
(
db
.
metrics1d
.
id
>
0
).
select
(
orderby
=
db
.
metrics1d
.
name
):
panel
=
selector_panel
panel
.
baseUrl
=
URL
(
'report'
,
'grid'
)
panel
.
baseParams
=
{
'id_metrics1d'
:
row
.
id
}
add_child
(
row
.
name
,
panel
)
node
.
sort_children
()
return
node
@
staticmethod
def
metric2d_node
(
db
,
T
,
selector_panel
):
"""To deal wiht two-dimension metrics.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
selector_panel (gluon.storage.Storage):
configuration of the selector panel.
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'The metrics 2d'
))
add_child
=
node
.
add_child
for
row
in
db
(
db
.
metrics2d
.
id
>
0
).
select
(
orderby
=
db
.
metrics2d
.
name
):
panel
=
selector_panel
panel
.
baseUrl
=
URL
(
'report'
,
'grid'
)
panel
.
baseParams
=
{
'id_metrics2d'
:
row
.
id
}
node
.
add_child
(
row
.
name
,
panel
)
node
.
sort_children
()
return
node
@
staticmethod
def
graph_node
(
db
,
T
,
selector_panel
):
"""To deal with graphs.
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
selector_panel (gluon.storage.Storage):
configuration of the selector panel.
Returns:
dbui.Node:
the configuration of a tree node.
"""
node
=
Node
(
T
(
'The graphs'
))
for
row
in
db
(
db
.
graphs
.
id
>
0
).
select
(
orderby
=
db
.
graphs
.
name
):
panel
=
selector_panel
panel
.
baseUrl
=
URL
(
'report'
,
'graph_mpl'
)
panel
.
baseParams
=
{
'id_graphs'
:
row
.
id
}
node
.
add_child
(
row
.
name
,
panel
)
return
node
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment