Commit 0d9e9220 authored by Dietmar Maurer's avatar Dietmar Maurer

comp.setLoading() is buggy in ExtJS 4.0.7, so we use el.mask() instead

parent 0f75822f
......@@ -739,6 +739,53 @@ Ext.define('PVE.Utils', { statics: {
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
},
// comp.setLoading() is buggy in ExtJS 4.0.7, so we
// use el.mask() instead
setErrorMask: function(comp, msg) {
var el = comp.el;
if (!el) {
return;
}
if (!msg) {
el.unmask();
} else {
if (msg === true) {
el.mask(gettext("Loading..."));
} else {
el.mask(msg);
}
}
},
monStoreErrors: function(me, store) {
me.mon(store, 'beforeload', function(s, operation, eOpts) {
if (!me.loadCount) {
me.loadCount = 0; // make sure it is numeric
PVE.Utils.setErrorMask(me, true);
}
});
// only works with 'pve' proxy
me.mon(store.proxy, 'afterload', function(proxy, request, success) {
me.loadCount++;
if (success) {
PVE.Utils.setErrorMask(me, false);
return;
}
var msg;
var operation = request.operation;
var error = operation.getError();
if (error.statusText) {
msg = error.statusText + ' (' + error.status + ')';
} else {
msg = gettext('Connection error');
}
PVE.Utils.setErrorMask(me, msg);
});
}
}});
......
......@@ -88,7 +88,7 @@ Ext.define('PVE.dc.HAConfig', {
method: 'GET',
failure: function(response, opts) {
me.clusterInfo = {};
me.setLoading(response.htmlStatus);
PVE.Utils.setErrorMask(me, response.htmlStatus);
},
success: function(response, opts) {
me.clusterInfo = getClusterInfo(response.result.data);
......
......@@ -86,32 +86,7 @@ Ext.define('PVE.grid.ObjectGrid', {
}
}));
var load_count = 0;
me.mon(rstore, 'beforeload', function(s, operation, eOpts) {
if (!load_count) {
me.setLoading(true);
}
});
me.mon(rstore.proxy, 'afterload', function(proxy, request, success) {
load_count++;
me.setLoading(false);
if (success) {
return;
}
var msg;
var operation = request.operation;
var error = operation.getError();
if (error.statusText) {
msg = error.statusText + ' (' + error.status + ')';
} else {
msg = gettext('Connection error');
}
me.setLoading(msg);
});
PVE.Utils.monStoreErrors(me, rstore);
Ext.applyIf(me, {
store: store,
......
......@@ -111,14 +111,7 @@ Ext.define('PVE.node.NetworkView', {
del_btn.setDisabled(!rec);
};
me.mon(rstore, 'load', function(s, records, success) {
if (!success) {
me.setLoading("Data load error");
return;
} else {
me.setLoading(false);
}
});
PVE.Utils.monStoreErrors(me, rstore);
var render_ports = function(value, metaData, record) {
if (value === 'bridge') {
......
......@@ -107,32 +107,7 @@ Ext.define('PVE.node.ServiceView', {
me.mon(store, 'datachanged', set_button_status);
var load_count = 0;
me.mon(rstore, 'beforeload', function(s, operation, eOpts) {
if (!load_count) {
me.setLoading(true);
}
});
me.mon(rstore.proxy, 'afterload', function(proxy, request, success) {
load_count++;
me.setLoading(false);
if (success) {
return;
}
var msg;
var operation = request.operation;
var error = operation.getError();
if (error.statusText) {
msg = error.statusText + ' (' + error.status + ')';
} else {
msg = gettext('Connection error');
}
me.setLoading(msg);
});
PVE.Utils.monStoreErrors(me, rstore);
Ext.apply(me, {
store: store,
......
......@@ -178,15 +178,15 @@ Ext.define('PVE.openvz.NetworkView', {
load: function() {
var me = this;
me.setLoading(true);
PVE.Utils.setErrorMask(me, true);
PVE.Utils.API2Request({
url: me.url,
failure: function(response, opts) {
me.setLoading('Error: ' + response.htmlStatus);
PVE.Utils.setErrorMask(me, 'Error: ' + response.htmlStatus);
},
success: function(response, opts) {
me.setLoading(false);
PVE.Utils.setErrorMask(me, false);
var result = Ext.decode(response.responseText);
var data = result.data || {};
me.dataCache = data;
......
......@@ -66,7 +66,7 @@ Ext.define('PVE.panel.LogView', {
},
method: 'GET',
success: function(response) {
me.setLoading(false);
PVE.Utils.setErrorMask(me, false);
var list = response.result.data;
var total = response.result.total;
var first = 0, last = 0;
......@@ -89,7 +89,7 @@ Ext.define('PVE.panel.LogView', {
},
failure: function(response) {
var msg = response.htmlStatus;
me.setLoading(msg);
PVE.Utils.setErrorMask(me, msg);
}
});
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment