Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
92a3c59b
Commit
92a3c59b
authored
14 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
Add a "global variable" App.storeCfgs.
It is fill by the controller get_api.
parent
f5124393
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/plugin_dbui.py
+12
-2
12 additions, 2 deletions
controllers/plugin_dbui.py
static/plugin_dbui/src/appbase.js
+41
-0
41 additions, 0 deletions
static/plugin_dbui/src/appbase.js
with
53 additions
and
2 deletions
controllers/plugin_dbui.py
+
12
−
2
View file @
92a3c59b
...
...
@@ -32,7 +32,8 @@ App.REMOTE_API = {
'
url
'
:
'
/%s/plugin_dbui/call
'
,
'
type
'
:
'
remoting
'
,
'
actions
'
: %s
};
};
App.storeCfgs = %s;
App.withMathJax = %s;
"""
...
...
@@ -128,6 +129,11 @@ def get_api():
di
[
action
]
=
[]
di
[
action
].
append
({
'
name
'
:
method
,
'
len
'
:
nargs
})
# the stores configuration
storeCfgs
=
{}
for
table
in
cfgSvc
.
get_tables
()[
'
tables
'
]:
storeCfgs
[
table
]
=
cfgSvc
.
get_jsonstore
(
table
)
# determine if the MathJax plugin is there
server_path
,
client_path
=
dbui
.
get_reference_paths
(
globals
())
...
...
@@ -136,7 +142,11 @@ def get_api():
# fill the javascript template
app
=
request
.
application
script
=
SCRIPT
%
(
app
,
app
,
json
.
dumps
(
di
),
str
(
withMathJax
).
lower
())
script
=
SCRIPT
%
(
app
,
app
,
json
.
dumps
(
di
),
json
.
dumps
(
storeCfgs
),
str
(
withMathJax
).
lower
())
# return the response as a javascript
response
.
headers
[
'
Content-Type
'
]
=
'
text/javascript
'
...
...
This diff is collapsed.
Click to expand it.
static/plugin_dbui/src/appbase.js
+
41
−
0
View file @
92a3c59b
...
...
@@ -14,6 +14,11 @@ Ext.namespace('App');
* This constants is defined by the server.
*/
/**
* @cfg {Array} App.storeCfgs
* Configuration option for all json stores
*/
/**
* @cfg {String} App.dburl
* Define the URL of the database router/controller
...
...
@@ -40,6 +45,42 @@ App.encodeField = function (table, field) {
return
t
+
f
;
}
/**
* Helper function returning the App.data.DirectStore identifies by its id.
* If the store does not exit it is created and register in the store manager.
*
* NOTE: The storeId is defined by the server as a configuration option
* for each widget: combobox, form and grid.
* The syntax of the storeId is "tableStore".
* If the store does not exist, its configuration is extract from
* the application constant App.storeCfgs.Then it is created and registered.
* In the current frame work a unique store is associated to a database table.
* This property garanty that widget share the same store.
*
* @param {String} storeId
*/
App
.
getDirectStore
=
function
(
storeId
)
{
var
cfg
,
store
,
table
;
store
=
Ext
.
StoreMgr
.
lookup
(
storeId
);
if
(
!
store
&&
!
Ext
.
isString
(
storeId
))
{
throw
new
Error
(
'
Fail to instanciate the store: "
'
+
storeId
+
'
"
'
);
}
if
(
!
store
&&
Ext
.
isString
(
storeId
))
{
table
=
storeId
.
slice
(
0
,
storeId
.
search
(
'
Store
'
));
cfg
=
App
.
storeCfgs
[
table
];
store
=
new
App
.
data
.
DirectStore
(
cfg
);
}
return
store
;
}
/**
* Helper function returning the name of the database table
* associated to the store. works with store configured using the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment