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
w2pext
plugin_dbui
Commits
43f8aa89
Commit
43f8aa89
authored
Jan 05, 2012
by
Renaud Le Gac
Browse files
Release version 0.4.4
parent
380a5191
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
168 additions
and
114 deletions
+168
-114
buildVersion.py
buildVersion.py
+19
-7
models/widgets.py
models/widgets.py
+15
-13
modules/plugin_dbui/navtree.py
modules/plugin_dbui/navtree.py
+61
-73
static/plugin_dbui/CHANGELOG
static/plugin_dbui/CHANGELOG
+8
-2
static/plugin_dbui/dbui-debug.js
static/plugin_dbui/dbui-debug.js
+27
-7
static/plugin_dbui/dbui-min.js
static/plugin_dbui/dbui-min.js
+1
-1
static/plugin_dbui/locale/app-lang-fr.js
static/plugin_dbui/locale/app-lang-fr.js
+10
-4
static/plugin_dbui/src/appbase.js
static/plugin_dbui/src/appbase.js
+1
-1
static/plugin_dbui/src/apppanelwithurlselector.js
static/plugin_dbui/src/apppanelwithurlselector.js
+26
-6
No files found.
buildVersion.py
View file @
43f8aa89
...
...
@@ -47,7 +47,7 @@ print '\nStart buildVersion'
#
APP
=
'mygit_dbui_04x'
CHANGELOG
=
'static/plugin_dbui/CHANGELOG'
DBUI_W2P
=
'web2py.plugin.dbui.w2p'
DBUI_W2P
=
'web2py.plugin.dbui.
%s.
w2p'
JSBASE
=
'static/plugin_dbui/src/appbase.js'
JSLIBDEBUG
=
'static/plugin_dbui/dbui-debug.js'
JSLIBMIN
=
'static/plugin_dbui/dbui-min.js'
...
...
@@ -55,6 +55,11 @@ JSLIBSRC = 'static/plugin_dbui/src'
NOW
=
datetime
.
datetime
.
now
()
PACK_PLUGIN_URL
=
'http://localhost:8000/%s/default/pack_plugin'
%
APP
def
get_version
():
s
=
open
(
JSBASE
,
'rb'
).
read
()
m
=
re
.
match
(
"(.+App.version = ')([\w._-]*)(';.*)"
,
s
,
re
.
DOTALL
)
return
m
.
group
(
2
).
replace
(
'.'
,
''
)
#-----------------------------------------------------------------------------
# define main applications
#
...
...
@@ -132,10 +137,13 @@ if not (opt.update or opt.git or opt.yuicompressor or opt.web2py):
#-----------------------------------------------------------------------------
# clean previous build
if
opt
.
clean
:
os
.
remove
(
DBUI_W2P
)
os
.
remove
(
JSLIBDEBUG
)
os
.
remove
(
JSLIBMIN
)
print
'files'
,
DBUI_W2P
,
JSLIBDEBUG
,
JSLIBMIN
,
'removed.'
fn
=
DBUI_W2P
%
get_version
()
for
el
in
(
fn
,
JSLIBDEBUG
,
JSLIBMIN
):
if
os
.
path
.
exists
(
el
):
os
.
remove
(
el
)
print
'file'
,
el
,
'is removed.'
sys
.
exit
(
0
)
#-----------------------------------------------------------------------------
...
...
@@ -229,16 +237,20 @@ if opt.git:
# web2py step
#
if
opt
.
web2py
:
# get the plugin version
version
=
get_version
()
# build the web2py plugin
print
'Build the web2py plugin binary file'
raw_input
(
'Check that the web2py service is running ? Type CR to continue.'
)
f
=
urllib
.
urlopen
(
PACK_PLUGIN_URL
)
s
=
f
.
read
()
fi
=
open
(
DBUI_W2P
,
'wb'
)
fn
=
DBUI_W2P
%
version
fi
=
open
(
fn
,
'wb'
)
fi
.
write
(
s
)
fi
.
close
()
print
'file'
,
DBUI_W2P
,
'is written.'
print
'file'
,
fn
,
'is written.'
#-----------------------------------------------------------------------------
# exit
...
...
models/widgets.py
View file @
43f8aa89
...
...
@@ -179,19 +179,21 @@ gridModifier.set_filters(*filters,
#
# The navigation tree
#
formNode
=
dbui
.
Node
(
T
(
'Forms'
),
db
.
tables
,
configurator
=
lambda
tablename
:
cvtSvc
.
to_form_panel
(
db
[
tablename
]))
gridNode
=
dbui
.
Node
(
T
(
'Tables'
),
db
.
tables
,
configurator
=
lambda
tablename
:
cvtSvc
.
to_grid_panel
(
db
[
tablename
]))
reportNode
=
dbui
.
Node
(
T
(
'Reports'
),
{
'report_1'
:
URL
(
c
=
"reports"
,
f
=
"report_1"
),
'report_2'
:
(
URL
(
c
=
"reports"
,
f
=
"report_2"
),
cvtSvc
.
to_form_items
(
dummy
.
foo1
))},
configurators
=
{
'report_1'
:
dbui
.
to_urlPanel
,
'report_2'
:
dbui
.
to_panelWithUrlSelector
})
formNode
=
dbui
.
Node
(
T
(
'Forms'
))
configurator
=
lambda
tablename
:
cvtSvc
.
to_form_panel
(
db
[
tablename
])
formNode
.
add_children
(
db
.
tables
,
func
=
configurator
)
gridNode
=
dbui
.
Node
(
T
(
'Tables'
))
configurator
=
lambda
tablename
:
cvtSvc
.
to_grid_panel
(
db
[
tablename
])
gridNode
.
add_children
(
db
.
tables
,
func
=
configurator
)
reportNode
=
dbui
.
Node
(
T
(
'Reports'
))
cfg
=
dbui
.
to_urlPanel
(
URL
(
c
=
"reports"
,
f
=
"report_1"
))
reportNode
.
add_child
(
T
(
'report_1'
),
cfg
)
form_items
=
cvtSvc
.
to_form_items
(
dummy
.
foo1
)
cfg
=
dbui
.
to_panelWithUrlSelector
(
URL
(
c
=
"reports"
,
f
=
"report_2"
),
form_items
)
reportNode
.
add_child
(
T
(
'report_2'
),
cfg
)
viewportModifier
=
dbui
.
ViewportModifier
()
viewportModifier
.
add_node
(
formNode
,
gridNode
,
reportNode
)
modules/plugin_dbui/navtree.py
View file @
43f8aa89
...
...
@@ -9,28 +9,36 @@ from gluon import current
from
helper
import
is_mathjax
def
to_panelWithUrlSelector
(
key
,
value
):
"""Return the configuration dictionary for a App.PanelWithUrlSelector.
def
to_panelWithUrlSelector
(
baseUrl
,
formItems
,
ctrlField
=
None
,
title
=
'Configure'
):
"""Return the configuration dictionary for an App.PanelWithUrlSelector.
the main panel displays the URL content while the selector panel shows
a form allowing to change the URL
argument
.
a form allowing to change the URL
setting
.
key
it the name of the leaf
baseUrl
well-formed URL string, i.e http://blabla
value
tuple containing a well form URL string
and a list of configuration dictionary defining each items
embedded in the form.
ctrlField
name of the form field defining the controller
When define the URL become http://blabla/ctrlFieldValue
formItems
a list of configuration dictionary defining the
widget embedded in the form
title
title of the box surrounding form widgets
"""
url
,
cfg_form_items
=
value
cfg
=
{
'baseUrl'
:
url
,
cfg
=
{
'baseUrl'
:
baseUrl
,
'ctrlField'
:
ctrlField
,
'panelCfg'
:
None
,
'selectorCfg'
:
None
,
'xtype'
:
'xpanelwithurlselector'
}
# configuration of the main panel displaying
url
# configuration of the main panel displaying
URL
cfg
[
'panelCfg'
]
=
{
'plugins'
:
[],
'preventBodyReset'
:
True
,
'xtype'
:
'panel'
}
...
...
@@ -40,22 +48,19 @@ def to_panelWithUrlSelector(key, value):
# configuration of the selector
cfg
[
'selectorCfg'
]
=
{
'defaults'
:
{
'anchor'
:
'99%'
},
'items'
:
cfg_
form
_i
tems
,
'title'
:
'Configure'
,
'items'
:
form
I
tems
,
'title'
:
title
,
'xtype'
:
'fieldset'
}
return
cfg
def
to_urlPanel
(
key
,
url
):
def
to_urlPanel
(
url
):
"""Return the configuration dictionary for an Ext.Panel
displaying an URL.
key
it the name of the leaf
url
its content is displayed in the panel
well-formed URL string, i.e http://blabla
"""
cfg
=
{
'autoLoad'
:
url
,
...
...
@@ -72,48 +77,54 @@ def to_urlPanel(key, url):
class
Node
(
object
):
"""Node associating a leaf to a widget.
Leaf names can be a list of string or dictionary keys.
They are translated and sorted by alphabetic order.
Some of them my be hidden depending on the context.
We use a configurator to get the configuration object of the
target widget. It is a function getting the leave names, its
attributes (dictionary value) and returning a dictionary.
Dedicated configurator can be setup for each node if needed.
"""
def
__init__
(
self
,
text
,
leaves
,
configurator
=
None
,
configurators
=
{},
hidden
=
[]
):
def
__init__
(
self
,
text
):
"""Constructor of the node
text
name of the node appearing in the viewport
"""
self
.
text
=
text
self
.
children
=
[]
self
.
hidden
=
[]
def
add_child
(
self
,
text
,
cfg
):
"""Add a child (leaf) to the node.
text
the name of the leaf
cfg
configuration dictionary for the associated
ExtJS widget
"""
di
=
{
'cfg'
:
cfg
,
'leaf'
:
True
,
'text'
:
text
}
self
.
children
.
append
(
di
)
def
add_children
(
self
,
leaves
,
func
=
None
,
hidden
=
[]):
"""Helper method to add children to the node.
leaves
list of string or a dictionary where keys
will be used as leaf names
a list of string
configurator
The default configurator apply to all leaves.
Reference to a function accepting either a leave name
or a leave name and the dictionary value. The function
return the configuration dictionary for the ExtJS widget.
The function defines the type of widget.
configurators
A dictionary with references to configurator.
It can be used to associate a different configurator to
each leaf. The key is the leaf name.
func
function to translate the leaf name into
the configuration dictionary of the associated ExtJS widget
hidden
List of leaves to be hidden. It contains leaves names
"""
self
.
text
=
text
self
.
children
=
[]
List of children to be hidden
Leaf names are translated and sorted by alphabetic order.
"""
# translator
T
=
current
.
T
#
converter to
order leaves in alphabetic order
#
translate and
order leaves in alphabetic order
# according to local setting
cvt
=
{}
for
el
in
leaves
:
...
...
@@ -128,30 +139,7 @@ class Node(object):
if
leaf
in
hidden
:
continue
func
=
configurator
if
leaf
in
configurators
:
func
=
configurators
[
leaf
]
if
isinstance
(
leaves
,
(
list
,
tuple
)):
self
.
_add_children
(
tr_leaf
,
func
(
leaf
))
elif
isinstance
(
leaves
,
dict
):
self
.
_add_children
(
tr_leaf
,
func
(
leaf
,
leaves
[
leaf
]))
def
_add_children
(
self
,
text
,
cfg
):
""" Add a child (leaf) to the node.
text
the name of the leaf
cfg
configuration dictionary for the associated
ExtJS widget
"""
di
=
{
'cfg'
:
cfg
,
'leaf'
:
True
,
'text'
:
text
}
self
.
children
.
append
(
di
)
self
.
add_child
(
tr_leaf
,
func
(
leaf
))
def
get_node
(
self
):
...
...
static/plugin_dbui/CHANGELOG
View file @
43f8aa89
--------------------------------- CHANGE LOG ----------------------------------
HEAD
- script to build the and tag a new version of plugin_dbui
0.4.4 (Jan 2012)
0.4.4 (Jan 2012)
- minor release
- script to build and tag a new version of plugin_dbui
- improve version of AppPanelWithSelector
4.3.0 (Dec 2011)
- Major change which is not backward compatible
...
...
@@ -119,4 +125,4 @@ HEAD
0.1.1
- Tags revision 640 as 0.1.1
- First prototype running with web2py 1.63 and ExtJS 2.2.1 (see also 0.1.0 log)
\ No newline at end of file
- First prototype running with web2py 1.63 and ExtJS 2.2.1 (see also 0.1.0 log)
static/plugin_dbui/dbui-debug.js
View file @
43f8aa89
...
...
@@ -22,7 +22,7 @@ Ext.namespace('App');
/**
* @param {String} App.version version of the library
*/
App
.
version
=
'
0.4.
3
'
;
App
.
version
=
'
0.4.
4
'
;
/**
* Helper function mimicking the encode_field function running on the server
...
...
@@ -1612,7 +1612,11 @@ Ext.preg('pPanelMathJax', App.panel.MathJax);/**
* the selector allow to setup the url parameters and to launch the
* request to the server.
*
* The type of this component is xpanelwithurlselector.
* The url is build as baseUrl or baseUrl/CtrlFieldValue if ctrlField is defined.
* The value of the other field are pass as Field1=Field1Value ,Field2=Field2Value
* in a POST transfert
*
* The type of this component is xpanelwithurlselector.
*
* @extend: App.PanelWithSelector
*
...
...
@@ -1622,10 +1626,21 @@ Ext.namespace('App');
App
.
PanelWithUrlSelector
=
Ext
.
extend
(
App
.
BasePanelWithSelector
,
{
/**
* @param {String}
* @param {String}
baseurl well form url, i.e http://blabla
*/
baseUrl
:
null
,
/**
* @param {String} ctrFiedl name of the field defining the controller
* When define the url become http://blabla/ctrlFieldValue
*/
ctrlField
:
null
,
/**
* Private attributes for internationalization
*/
textLoad
:
'
Loading...
'
,
/**
* Require by the ExtJS model
*/
...
...
@@ -1647,17 +1662,22 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
i
,
panel
=
this
.
getComponent
(
'
mainPanel
'
),
params
=
{},
selector
=
this
.
getComponent
(
'
selectorPanel
'
);
selector
=
this
.
getComponent
(
'
selectorPanel
'
),
url
=
this
.
baseUrl
;
fields
=
selector
.
findByType
(
'
field
'
);
for
(
i
=
0
;
i
<
fields
.
length
;
i
+=
1
)
{
params
[
fields
[
i
].
getName
()]
=
fields
[
i
].
getValue
();
if
(
fields
[
i
].
getName
()
===
this
.
ctrlField
)
{
url
=
url
+
'
/
'
+
fields
[
i
].
getValue
();
}
else
{
params
[
fields
[
i
].
getName
()]
=
fields
[
i
].
getValue
();
}
}
panel
.
load
({
url
:
this
.
baseU
rl
,
url
:
u
rl
,
params
:
params
,
text
:
'
Loading...
'
,
text
:
this
.
textLoad
,
timeout
:
30
});
},
...
...
static/plugin_dbui/dbui-min.js
View file @
43f8aa89
This diff is collapsed.
Click to expand it.
static/plugin_dbui/locale/app-lang-fr.js
View file @
43f8aa89
...
...
@@ -4,6 +4,13 @@
*
*/
if
(
App
.
BasePanelWithSelector
)
{
Ext
.
apply
(
App
.
BasePanelWithSelector
.
prototype
,
{
textGo
:
'
Go
'
,
textReset
:
'
Annuler
'
,
});
}
if
(
App
.
form
.
FormPanel
)
{
Ext
.
apply
(
App
.
form
.
FormPanel
.
prototype
,
{
textCreate
:
'
Créer
'
,
...
...
@@ -49,9 +56,8 @@ if (App.grid.RowEditorContextMenu) {
});
}
if
(
App
.
panel
.
PanelWithSelector
)
{
Ext
.
apply
(
App
.
panel
.
PanelWithSelector
.
prototype
,
{
textGo
:
'
Go
'
,
textReset
:
'
Annuler
'
,
if
(
App
.
PanelWithUrlSelector
)
{
Ext
.
apply
(
App
.
PanelWithUrlSelector
.
prototype
,
{
textLoad
:
'
chargement en cours...
'
,
});
}
static/plugin_dbui/src/appbase.js
View file @
43f8aa89
...
...
@@ -22,7 +22,7 @@ Ext.namespace('App');
/**
* @param {String} App.version version of the library
*/
App
.
version
=
'
0.4.
3
'
;
App
.
version
=
'
0.4.
4
'
;
/**
* Helper function mimicking the encode_field function running on the server
...
...
static/plugin_dbui/src/apppanelwithurlselector.js
View file @
43f8aa89
...
...
@@ -3,7 +3,11 @@
* the selector allow to setup the url parameters and to launch the
* request to the server.
*
* The type of this component is xpanelwithurlselector.
* The url is build as baseUrl or baseUrl/CtrlFieldValue if ctrlField is defined.
* The value of the other field are pass as Field1=Field1Value ,Field2=Field2Value
* in a POST transfert
*
* The type of this component is xpanelwithurlselector.
*
* @extend: App.PanelWithSelector
*
...
...
@@ -13,10 +17,21 @@ Ext.namespace('App');
App
.
PanelWithUrlSelector
=
Ext
.
extend
(
App
.
BasePanelWithSelector
,
{
/**
* @param {String}
* @param {String}
baseurl well form url, i.e http://blabla
*/
baseUrl
:
null
,
/**
* @param {String} ctrFiedl name of the field defining the controller
* When define the url become http://blabla/ctrlFieldValue
*/
ctrlField
:
null
,
/**
* Private attributes for internationalization
*/
textLoad
:
'
Loading...
'
,
/**
* Require by the ExtJS model
*/
...
...
@@ -38,17 +53,22 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
i
,
panel
=
this
.
getComponent
(
'
mainPanel
'
),
params
=
{},
selector
=
this
.
getComponent
(
'
selectorPanel
'
);
selector
=
this
.
getComponent
(
'
selectorPanel
'
),
url
=
this
.
baseUrl
;
fields
=
selector
.
findByType
(
'
field
'
);
for
(
i
=
0
;
i
<
fields
.
length
;
i
+=
1
)
{
params
[
fields
[
i
].
getName
()]
=
fields
[
i
].
getValue
();
if
(
fields
[
i
].
getName
()
===
this
.
ctrlField
)
{
url
=
url
+
'
/
'
+
fields
[
i
].
getValue
();
}
else
{
params
[
fields
[
i
].
getName
()]
=
fields
[
i
].
getValue
();
}
}
panel
.
load
({
url
:
this
.
baseU
rl
,
url
:
u
rl
,
params
:
params
,
text
:
'
Loading...
'
,
text
:
this
.
textLoad
,
timeout
:
30
});
},
...
...
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