Commit 098c951a authored by Dietmar Maurer's avatar Dietmar Maurer

FirewallRules: show error messages in rules grid using tooltips.

parent d52bd8b7
...@@ -552,6 +552,17 @@ Ext.define('PVE.FirewallRules', { ...@@ -552,6 +552,17 @@ Ext.define('PVE.FirewallRules', {
} }
tbar.push([ me.removeBtn, me.editBtn ]); tbar.push([ me.removeBtn, me.editBtn ]);
var render_errors = function(name, value, metaData, record) {
var errors = record.data.errors;
if (errors && errors[name]) {
metaData.tdCls = 'x-form-invalid-field';
var html = '<p>' + Ext.htmlEncode(errors[name]) + '</p>';
metaData.tdAttr = 'data-qwidth=600 data-qtitle="ERROR" data-qtip="' +
html.replace(/\"/g,'&quot;') + '"';
}
return value;
};
var columns = [ var columns = [
{ {
// similar to xtype: 'rownumberer', // similar to xtype: 'rownumberer',
...@@ -592,16 +603,25 @@ Ext.define('PVE.FirewallRules', { ...@@ -592,16 +603,25 @@ Ext.define('PVE.FirewallRules', {
{ {
header: gettext('Type'), header: gettext('Type'),
dataIndex: 'type', dataIndex: 'type',
renderer: function(value, metaData, record) {
return render_errors('type', value, metaData, record);
},
width: 50 width: 50
}, },
{ {
header: gettext('Action'), header: gettext('Action'),
dataIndex: 'action', dataIndex: 'action',
renderer: function(value, metaData, record) {
return render_errors('action', value, metaData, record);
},
width: 80 width: 80
}, },
{ {
header: gettext('Macro'), header: gettext('Macro'),
dataIndex: 'macro', dataIndex: 'macro',
renderer: function(value, metaData, record) {
return render_errors('macro', value, metaData, record);
},
width: 80 width: 80
} }
]; ];
...@@ -610,6 +630,9 @@ Ext.define('PVE.FirewallRules', { ...@@ -610,6 +630,9 @@ Ext.define('PVE.FirewallRules', {
columns.push({ columns.push({
header: gettext('Interface'), header: gettext('Interface'),
dataIndex: 'iface', dataIndex: 'iface',
renderer: function(value, metaData, record) {
return render_errors('iface', value, metaData, record);
},
width: 80 width: 80
}); });
} }
...@@ -618,34 +641,49 @@ Ext.define('PVE.FirewallRules', { ...@@ -618,34 +641,49 @@ Ext.define('PVE.FirewallRules', {
{ {
header: gettext('Source'), header: gettext('Source'),
dataIndex: 'source', dataIndex: 'source',
renderer: function(value, metaData, record) {
return render_errors('source', value, metaData, record);
},
width: 100 width: 100
}, },
{ {
header: gettext('Destination'), header: gettext('Destination'),
dataIndex: 'dest', dataIndex: 'dest',
renderer: function(value, metaData, record) {
return render_errors('dest', value, metaData, record);
},
width: 100 width: 100
}, },
{ {
header: gettext('Protocol'), header: gettext('Protocol'),
dataIndex: 'proto', dataIndex: 'proto',
renderer: function(value, metaData, record) {
return render_errors('proto', value, metaData, record);
},
width: 100 width: 100
}, },
{ {
header: gettext('Dest. port'), header: gettext('Dest. port'),
dataIndex: 'dport', dataIndex: 'dport',
renderer: function(value, metaData, record) {
return render_errors('dport', value, metaData, record);
},
width: 100 width: 100
}, },
{ {
header: gettext('Source port'), header: gettext('Source port'),
dataIndex: 'sport', dataIndex: 'sport',
renderer: function(value, metaData, record) {
return render_errors('sport', value, metaData, record);
},
width: 100 width: 100
}, },
{ {
header: gettext('Comment'), header: gettext('Comment'),
dataIndex: 'comment', dataIndex: 'comment',
flex: 1, flex: 1,
renderer: function(value) { renderer: function(value, metaData, record) {
return Ext.util.Format.htmlEncode(value); return render_errors('comment', Ext.util.Format.htmlEncode(value), metaData, record);
} }
} }
]); ]);
...@@ -694,7 +732,7 @@ Ext.define('PVE.FirewallRules', { ...@@ -694,7 +732,7 @@ Ext.define('PVE.FirewallRules', {
extend: 'Ext.data.Model', extend: 'Ext.data.Model',
fields: [ { name: 'enable', type: 'boolean' }, fields: [ { name: 'enable', type: 'boolean' },
'type', 'action', 'macro', 'source', 'dest', 'proto', 'iface', 'type', 'action', 'macro', 'source', 'dest', 'proto', 'iface',
'dport', 'sport', 'comment', 'pos', 'digest' ], 'dport', 'sport', 'comment', 'pos', 'digest', 'errors' ],
idProperty: 'pos' idProperty: 'pos'
}); });
......
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