From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 4/5] APTRepositories: make the Suites warnings inline errors
Date: Wed, 30 Jun 2021 17:14:58 +0200 [thread overview]
Message-ID: <20210630151459.231895-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210630151459.231895-1-d.csapak@proxmox.com>
by iterating only once over the info array and adding them directly
to the records this way we can avoid iterating over the records
again
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/node/APTRepositories.js | 100 +++++++++++++++++-------------------
1 file changed, 46 insertions(+), 54 deletions(-)
diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js
index 23cd984..de0197b 100644
--- a/src/node/APTRepositories.js
+++ b/src/node/APTRepositories.js
@@ -157,8 +157,20 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
{
header: gettext('Suites'),
dataIndex: 'Suites',
- renderer: function(suites, cell, record) {
- return suites.join(' ');
+ renderer: function(suites, metaData, record) {
+ let err = '';
+ if (record.data.warnings && record.data.warnings.length > 0) {
+ let txt = [gettext('Warning')];
+ record.data.warnings.forEach((warning) => {
+ if (warning.property === 'Suites') {
+ txt.push(warning.message);
+ }
+ });
+ metaData.tdAttr = `data-qtip="${Ext.htmlEncode(txt.join('<br>'))}"`;
+ metaData.tdCls = 'proxmox-invalid-row';
+ err = '<i class="fa fa-fw critical fa-exclamation-circle"></i> ';
+ }
+ return suites.join(' ') + err;
},
width: 130,
},
@@ -209,53 +221,6 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
},
],
- addAdditionalInfos: function(gridData, infos) {
- let me = this;
-
- let warnings = {};
- let origins = {};
-
- let addLine = function(obj, key, line) {
- if (obj[key]) {
- obj[key] += "\n";
- obj[key] += line;
- } else {
- obj[key] = line;
- }
- };
-
- for (const info of infos) {
- const key = `${info.path}:${info.index}`;
- if (info.kind === 'warning' ||
- (info.kind === 'ignore-pre-upgrade-warning' && !me.majorUpgradeAllowed)
- ) {
- addLine(warnings, key, gettext('Warning') + ": " + info.message);
- } else if (info.kind === 'origin') {
- origins[key] = info.message;
- }
- }
-
- gridData.forEach(function(record) {
- const key = `${record.Path}:${record.Index}`;
- record.Origin = origins[key];
- });
-
- me.rowBodyFeature.getAdditionalData = function(innerData, rowIndex, record, orig) {
- let headerCt = this.view.headerCt;
- let colspan = headerCt.getColumnCount();
-
- const key = `${innerData.Path}:${innerData.Index}`;
- const warning_text = warnings[key];
-
- return {
- rowBody: '<div style="color: red; white-space: pre-line">' +
- Ext.String.htmlEncode(warning_text) + '</div>',
- rowBodyCls: warning_text ? '' : Ext.baseCSSPrefix + 'grid-row-body-hidden',
- rowBodyColspan: colspan,
- };
- };
- },
-
initComponent: function() {
let me = this;
@@ -274,8 +239,6 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
],
});
- let rowBodyFeature = Ext.create('Ext.grid.feature.RowBody', {});
-
let groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: '{[ "File: " + values.name ]} ({rows.length} ' +
'repositor{[values.rows.length > 1 ? "ies" : "y"]})',
@@ -287,8 +250,7 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
Ext.apply(me, {
store: store,
selModel: sm,
- rowBodyFeature: rowBodyFeature,
- features: [groupingFeature, rowBodyFeature],
+ features: [groupingFeature],
});
me.callParent();
@@ -494,16 +456,46 @@ Ext.define('Proxmox.node.APTRepositories', {
errors = data.errors;
digest = data.digest;
+ let infos = {};
+ for (const info of data.infos) {
+ let path = info.path;
+ let idx = info.index;
+
+ if (!infos[path]) {
+ infos[path] = {};
+ }
+ if (!infos[path][idx]) {
+ infos[path][idx] = {
+ origin: '',
+ warnings: [],
+ };
+ }
+
+ if (info.kind === 'origin') {
+ infos[path][idx].origin = info.message;
+ } else if (info.kind === 'warning' ||
+ (info.kind === 'ignore-pre-upgrade-warning' && !repoGrid.majorUpgradeAllowed)
+ ) {
+ infos[path][idx].warnings.push(info);
+ } else {
+ throw 'unknown info';
+ }
+ }
+
+
files.forEach(function(file) {
for (let n = 0; n < file.repositories.length; n++) {
let repo = file.repositories[n];
repo.Path = file.path;
repo.Index = n;
+ if (infos[file.path] && infos[file.path][n]) {
+ repo.Origin = infos[file.path][n].origin || Proxmox.Utils.UnknownText;
+ repo.warnings = infos[file.path][n].warnings || [];
+ }
gridData.push(repo);
}
});
- repoGrid.addAdditionalInfos(gridData, data.infos);
repoGrid.store.loadData(gridData);
me.updateStandardRepos(data['standard-repos']);
--
2.30.2
next prev parent reply other threads:[~2021-06-30 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-30 15:14 [pve-devel] [PATCH widget-toolkit 0/5] some APTRepositories improvements Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 1/5] APTRepositories: change separation style between panels Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 2/5] APTRepositories: make panel scrollable Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 3/5] APTRepositories: change updating button text/state to viewcontroller Dominik Csapak
2021-06-30 15:14 ` Dominik Csapak [this message]
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 5/5] APTRepositories: remove unecessary selection model Dominik Csapak
2021-06-30 19:36 ` [pve-devel] applied-series: [PATCH widget-toolkit 0/5] some APTRepositories improvements Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210630151459.231895-5-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal