[IMP] block UI during db creation

bzr revid: xmo@openerp.com-20110802070007-z3ameuhsr84w51cs
This commit is contained in:
Xavier Morel
2011-08-02 09:00:07 +02:00
parent e1b3207935
commit 71862dfc35
3 changed files with 32 additions and 1 deletions
+1
View File
@@ -10,6 +10,7 @@
"static/lib/jquery.validate/jquery.validate.js",
"static/lib/jquery.ba-bbq/jquery.ba-bbq.js",
"static/lib/jquery.contextmenu/jquery.contextmenu.r2.packed.js",
"static/lib/jquery.blockui/jquery.blockUI.js",
"static/lib/jquery.superfish/js/hoverIntent.js",
"static/lib/jquery.superfish/js/superfish.js",
"static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js",
+5 -1
View File
@@ -162,7 +162,11 @@ class Database(openerpweb.Controller):
r = cherrypy.config['openerp.dbfilter'].replace('%h', h).replace('%d', d)
dbs = [i for i in dbs if re.match(r, i)]
return {"db_list": dbs}
@openerpweb.jsonrequest
def progress(self, req, password, id):
return req.session.proxy('db').get_progress(password, id)
@openerpweb.jsonrequest
def create_db(self, req, fields):
+26
View File
@@ -724,6 +724,28 @@ openerp.base.Database = openerp.base.Controller.extend({
});
return result;
},
wait_for_newdb: function (db_creation_id, password) {
var self = this;
self.rpc('/base/database/progress', {
id: db_creation_id,
password: password
}, function (result) {
var progress = result[0];
// I'd display a progress bar, but turns out the progress status
// the server report kind-of blows goats: it's at 0 for ~75% of
// the installation, then jumps to 75%, then jumps down to either
// 0 or ~40%, then back up to 75%, then terminates. Let's keep that
// mess hidden behind a not-very-useful but not overly weird
// message instead.
if (progress < 1) {
setTimeout(function () {
self.wait_for_newdb(db_creation_id, password);
}, 500);
return;
}
$.unblockUI();
});
},
do_db_create: function() {
var self = this;
self.$option_id.html(QWeb.render("CreateDB", self));
@@ -731,11 +753,15 @@ openerp.base.Database = openerp.base.Controller.extend({
self.$option_id.find("form[name=create_db_form]").validate({
submitHandler: function (form) {
var fields = $(form).serializeArray();
$.blockUI();
self.rpc("/base/database/create_db", {'fields': fields}, function(result) {
if (!result.error) {
self.db_list.push(self.to_object(fields)['db_name']);
self.db_list.sort();
self.wait_for_newdb(
result, self.to_object(fields)['super_admin_pwd']);
} else {
$.unblockUI();
$('<div>').dialog({
modal: true,
title: result.title,