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: { ...@@ -739,6 +739,53 @@ Ext.define('PVE.Utils', { statics: {
var nw = window.open("?" + url, '_blank', var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427"); "innerWidth=745,innerheight=427");
nw.focus(); 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', { ...@@ -88,7 +88,7 @@ Ext.define('PVE.dc.HAConfig', {
method: 'GET', method: 'GET',
failure: function(response, opts) { failure: function(response, opts) {
me.clusterInfo = {}; me.clusterInfo = {};
me.setLoading(response.htmlStatus); PVE.Utils.setErrorMask(me, response.htmlStatus);
}, },
success: function(response, opts) { success: function(response, opts) {
me.clusterInfo = getClusterInfo(response.result.data); me.clusterInfo = getClusterInfo(response.result.data);
......
...@@ -86,32 +86,7 @@ Ext.define('PVE.grid.ObjectGrid', { ...@@ -86,32 +86,7 @@ Ext.define('PVE.grid.ObjectGrid', {
} }
})); }));
var load_count = 0; PVE.Utils.monStoreErrors(me, rstore);
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);
});
Ext.applyIf(me, { Ext.applyIf(me, {
store: store, store: store,
......
...@@ -111,14 +111,7 @@ Ext.define('PVE.node.NetworkView', { ...@@ -111,14 +111,7 @@ Ext.define('PVE.node.NetworkView', {
del_btn.setDisabled(!rec); del_btn.setDisabled(!rec);
}; };
me.mon(rstore, 'load', function(s, records, success) { PVE.Utils.monStoreErrors(me, rstore);
if (!success) {
me.setLoading("Data load error");
return;
} else {
me.setLoading(false);
}
});
var render_ports = function(value, metaData, record) { var render_ports = function(value, metaData, record) {
if (value === 'bridge') { if (value === 'bridge') {
......
...@@ -107,32 +107,7 @@ Ext.define('PVE.node.ServiceView', { ...@@ -107,32 +107,7 @@ Ext.define('PVE.node.ServiceView', {
me.mon(store, 'datachanged', set_button_status); me.mon(store, 'datachanged', set_button_status);
var load_count = 0; PVE.Utils.monStoreErrors(me, rstore);
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);
});
Ext.apply(me, { Ext.apply(me, {
store: store, store: store,
......
...@@ -178,15 +178,15 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -178,15 +178,15 @@ Ext.define('PVE.openvz.NetworkView', {
load: function() { load: function() {
var me = this; var me = this;
me.setLoading(true); PVE.Utils.setErrorMask(me, true);
PVE.Utils.API2Request({ PVE.Utils.API2Request({
url: me.url, url: me.url,
failure: function(response, opts) { failure: function(response, opts) {
me.setLoading('Error: ' + response.htmlStatus); PVE.Utils.setErrorMask(me, 'Error: ' + response.htmlStatus);
}, },
success: function(response, opts) { success: function(response, opts) {
me.setLoading(false); PVE.Utils.setErrorMask(me, false);
var result = Ext.decode(response.responseText); var result = Ext.decode(response.responseText);
var data = result.data || {}; var data = result.data || {};
me.dataCache = data; me.dataCache = data;
......
...@@ -66,7 +66,7 @@ Ext.define('PVE.panel.LogView', { ...@@ -66,7 +66,7 @@ Ext.define('PVE.panel.LogView', {
}, },
method: 'GET', method: 'GET',
success: function(response) { success: function(response) {
me.setLoading(false); PVE.Utils.setErrorMask(me, false);
var list = response.result.data; var list = response.result.data;
var total = response.result.total; var total = response.result.total;
var first = 0, last = 0; var first = 0, last = 0;
...@@ -89,7 +89,7 @@ Ext.define('PVE.panel.LogView', { ...@@ -89,7 +89,7 @@ Ext.define('PVE.panel.LogView', {
}, },
failure: function(response) { failure: function(response) {
var msg = response.htmlStatus; 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