Compare commits

...

14 Commits

Author SHA1 Message Date
Thomas Lamprecht
a39544136d bump version to 2.6-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-15 17:29:32 +01:00
Thomas Lamprecht
b1c2c8154d add EOL notice component
to avoid copying the same thing to three different product's GUIs
this year..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-15 17:28:57 +01:00
Thomas Lamprecht
ac4b6393d6 bump version to 2.6-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-25 09:34:40 +02:00
Thomas Lamprecht
dfc86baacb buildsys: touch incremental-lint in check target to avoid triggering twice
Without this the check and the, through the 'install' target
triggered, incremental lint target triggered a full eslint run.

Makes it similar to what PBS did from the beginning of eslint
inclusion..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
(cherry picked from commit 557c45056c)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-25 09:32:10 +02:00
Thomas Lamprecht
86568d27c1 cbind mixin: also descend in elements with an cbind property
Not only into those with an xtype one, as we can either have a
implicit default xtype (e.g., in tbars for buttons, or set explicitly
via the `defaults` mechanism) or want to apply cbinds to stores or
other objects.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
(cherry picked from commit 5995eddcc4)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-25 09:32:10 +02:00
Thomas Lamprecht
585f3c31e7 combo grid: load: rework auto-selection and validity logic
We do not want to trigger an autoSelect if there's a value set, even
if it isn't found in the store, as that hides the fact that an (now)
invalid valid is configured from the user, which can be confusing if
something is not working, as when editing an object it seems like a
valid value is selected.

Further, if a value is set we mark the field as invalid from the
start, at least if it's neither disabled nor allowed to have a
value which is does not exists in the backing store.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-07 18:07:38 +02:00
Thomas Lamprecht
a0451be0ca combo grid: reformat/place comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-07 18:07:38 +02:00
Thomas Lamprecht
1b0b0c9c7b object grid: line-wrap cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-23 16:23:17 +02:00
Thomas Lamprecht
dc6f0d6399 bump version to 2.5-6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-21 17:40:26 +02:00
Thomas Lamprecht
bb22262862 object grid: improve/add to documentation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-21 17:39:43 +02:00
Thomas Lamprecht
c92dd68bab object grid: allow one to declaratively specify rows
So that users of this component do not necesacrrily need to add an
initComponent override and make the `me.add_XYZ_row()` there, but
instead can use something like:

  gridRows: [
    {
      xtype: 'text',
      name: 'http-proxy',
      text: gettext('HTTP proxy'),
      defaultValue: Proxmox.Utils.noneText,
      vtype: 'HttpProxy',
      deleteEmpty: true,
    },
  ],

I avoid using `rows` as config key as that is internally used for
quite a few things, and potentially some existing users (did not
checked all). We can still switch to that easily if it is deemed to
be better...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-21 17:39:43 +02:00
Thomas Lamprecht
22b189e40c object grid: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-21 17:39:43 +02:00
Thomas Lamprecht
2e8620aea2 bump version to 2.5-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 10:30:43 +02:00
Lorenz Stechauner
229cf5a35d disk smart: fix non working smart value window
fix regression in refactor from commit 7eb1fb18ad

Reported in forum:
https://forum.proxmox.com/threads/gui-disks-tab-cant-showup-smart-values.89180/
https://forum.proxmox.com/threads/smart-values-bug-in-6-4-6.89179/

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 10:30:02 +02:00
8 changed files with 147 additions and 38 deletions

27
debian/changelog vendored
View File

@ -1,3 +1,30 @@
proxmox-widget-toolkit (2.6-2) buster; urgency=medium
* add EOL notice component
-- Proxmox Support Team <support@proxmox.com> Tue, 15 Mar 2022 17:29:26 +0100
proxmox-widget-toolkit (2.6-1) buster; urgency=medium
* combo grid: load: rework auto-selection and validity logic to ensure it's
always shown if a (now) invalid value is configured
* cbind mixin: also descend in elements with an cbind property
-- Proxmox Support Team <support@proxmox.com> Fri, 25 Jun 2021 09:32:40 +0200
proxmox-widget-toolkit (2.5-6) buster; urgency=medium
* object grid: allow one to declaratively specify rows
-- Proxmox Support Team <support@proxmox.com> Fri, 21 May 2021 17:39:59 +0200
proxmox-widget-toolkit (2.5-5) pve pmg; urgency=medium
* disks: fix regression in S.M.A.R.T. window
-- Proxmox Support Team <support@proxmox.com> Fri, 14 May 2021 10:30:39 +0200
proxmox-widget-toolkit (2.5-4) pve pmg; urgency=medium
* info widget: set default usage warning threshold from 60% to 75%

View File

@ -40,6 +40,7 @@ JSSRC= \
button/HelpButton.js \
grid/ObjectGrid.js \
grid/PendingObjectGrid.js \
panel/EOLNotice.js \
panel/DiskList.js \
panel/InputPanel.js \
panel/InfoWidget.js \
@ -88,6 +89,7 @@ all: ${SUBDIRS}
check: lint
lint: ${JSSRC}
eslint --strict ${JSSRC}
touch ".lint-incremental"
proxmoxlib.js: .lint-incremental ${JSSRC}
# add the version as comment in the file

View File

@ -43,6 +43,14 @@
color: #FF6C59;
}
.pwt-eol-icon {
position: relative;
float: left;
margin-right: 5px;
font-size: 1.3em;
color: #FF6C59;
}
/* reduce chart legend space usage to something more sane */
.x-legend-item {
padding: 0.4em 0.8em 0.4em 1.8em;

View File

@ -425,14 +425,12 @@ Ext.define('Proxmox.form.ComboGrid', {
if (me.enableLoadMask) {
delete me.enableLoadMask;
// if the picker exists,
// we reset its minheight to the saved let/0
// we have to update the layout, otherwise the height
// gets not recalculated
// if the picker exists, we reset its minHeight to the previous saved one or 0
if (me.picker) {
me.picker.setMinHeight(me.savedMinHeight || 0);
Proxmox.Utils.setErrorMask(me.picker);
delete me.savedMinHeight;
// we have to update the layout, otherwise the height gets not recalculated
me.picker.updateLayout();
}
}
@ -447,15 +445,19 @@ Ext.define('Proxmox.form.ComboGrid', {
}
if (!found) {
let rec = me.store.first();
if (me.autoSelect && rec && rec.data) {
def = rec.data[me.valueField];
me.setValue(def, true);
} else if (!me.allowBlank && !(Ext.isArray(def) ? def.length : def)) {
me.setValue(def);
if (!me.notFoundIsValid && !me.isDisabled()) {
me.markInvalid(me.blankText);
if (!(Ext.isArray(def) ? def.length : def)) {
let rec = me.store.first();
if (me.autoSelect && rec && rec.data) {
def = rec.data[me.valueField];
me.setValue(def, true);
} else if (!me.allowBlank) {
me.setValue(def);
if (!me.isDisabled()) {
me.markInvalid(me.blankText);
}
}
} else if (!me.notFoundIsValid && !me.isDisabled()) {
me.markInvalid(gettext('Invalid Value'));
}
}
} else {

View File

@ -1,24 +1,53 @@
/* Renders a list of key values objets
/** Renders a list of key values objets
Mandatory Config Parameters:
mandatory config parameters:
rows: an object container where each propery is a key-value object we want to render
let rows = {
keyboard: {
header: gettext('Keyboard Layout'),
editor: 'Your.KeyboardEdit',
required: true
},
optional:
disabled: setting this parameter to true will disable selection and focus on the
proxmoxObjectGrid as well as greying out input elements.
Useful for a readonly tabular display
rows: {
keyboard: {
header: gettext('Keyboard Layout'),
editor: 'Your.KeyboardEdit',
required: true
},
// ...
},
Convenience Helper:
As alternative you can use the common add-row helper like `add_text_row`, but you need to
call it in an overridden initComponent before `me.callParent(arguments)` gets executed.
For a declarative approach you can use the `gridRows` configuration to pass an array of
objects with each having at least a `xtype` to match `add_XTYPE_row` and a field-name
property, for example:
gridRows: [
{
xtype: 'text',
name: 'http-proxy',
text: gettext('HTTP proxy'),
defaultValue: Proxmox.Utils.noneText,
vtype: 'HttpProxy',
deleteEmpty: true,
},
],
Optional Configs:
disabled:: setting this parameter to true will disable selection and focus on
the proxmoxObjectGrid as well as greying out input elements. Useful for a
readonly tabular display
*/
Ext.define('Proxmox.grid.ObjectGrid', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.proxmoxObjectGrid'],
// can be used as declarative replacement over manually calling the add_XYZ_row helpers,
// see top-level doc-comment above for details/example
gridRows: [],
disabled: false,
hideHeaders: true,
@ -80,8 +109,7 @@ Ext.define('Proxmox.grid.ObjectGrid', {
name: name,
deleteEmpty: !!opts.deleteEmpty,
emptyText: opts.defaultValue,
labelWidth: Proxmox.Utils.compute_min_label_width(
text, opts.labelWidth),
labelWidth: Proxmox.Utils.compute_min_label_width(text, opts.labelWidth),
vtype: opts.vtype,
fieldLabel: text,
},
@ -114,8 +142,7 @@ Ext.define('Proxmox.grid.ObjectGrid', {
defaultValue: opts.defaultValue || 0,
checked: !!opts.defaultValue,
deleteDefaultValue: !!opts.deleteDefaultValue,
labelWidth: Proxmox.Utils.compute_min_label_width(
text, opts.labelWidth),
labelWidth: Proxmox.Utils.compute_min_label_width(text, opts.labelWidth),
fieldLabel: text,
},
},
@ -148,8 +175,7 @@ Ext.define('Proxmox.grid.ObjectGrid', {
emptyText: gettext('Default'),
deleteEmpty: !!opts.deleteEmpty,
value: opts.defaultValue,
labelWidth: Proxmox.Utils.compute_min_label_width(
text, opts.labelWidth),
labelWidth: Proxmox.Utils.compute_min_label_width(text, opts.labelWidth),
fieldLabel: text,
},
},
@ -246,6 +272,17 @@ Ext.define('Proxmox.grid.ObjectGrid', {
initComponent: function() {
let me = this;
for (const rowdef of me.gridRows || []) {
let addFn = me[`add_${rowdef.xtype}_row`];
if (typeof addFn !== 'function') {
throw `unknown object-grid row xtype '${rowdef.xtype}'`;
} else if (typeof rowdef.name !== 'string') {
throw `object-grid row need a valid name string-property!`;
} else {
addFn.call(me, rowdef.name, rowdef.text || rowdef.name, rowdef);
}
}
let rows = me.rows;
if (!me.rstore) {
@ -269,13 +306,13 @@ Ext.define('Proxmox.grid.ObjectGrid', {
});
if (rows) {
Ext.Object.each(rows, function(key, rowdef) {
for (const [key, rowdef] of Object.entries(rows)) {
if (Ext.isDefined(rowdef.defaultValue)) {
store.add({ key: key, value: rowdef.defaultValue });
} else if (rowdef.required) {
store.add({ key: key, value: undefined });
}
});
}
}
if (me.sorterFn) {

View File

@ -88,7 +88,7 @@ Ext.define('Proxmox.Mixin.CBind', {
found = false;
for (i = 0; i < arrayLength; i++) {
el = org[i];
if (el.constructor === Object && el.xtype) {
if (el.constructor === Object && (el.xtype || el.cbind)) {
found = true;
break;
}
@ -99,7 +99,7 @@ Ext.define('Proxmox.Mixin.CBind', {
copy = [];
for (i = 0; i < arrayLength; i++) {
el = org[i];
if (el.constructor === Object && el.xtype) {
if (el.constructor === Object && (el.xtype || el.cbind)) {
elcopy = cloneTemplateObject(el);
if (elcopy.cbind) {
applyCBind(elcopy);
@ -123,7 +123,7 @@ Ext.define('Proxmox.Mixin.CBind', {
res[prop] = el;
continue;
}
if (el.constructor === Object && el.xtype) {
if (el.constructor === Object && (el.xtype || el.cbind)) {
copy = cloneTemplateObject(el);
if (copy.cbind) {
applyCBind(copy);
@ -146,7 +146,7 @@ Ext.define('Proxmox.Mixin.CBind', {
el = me[prop];
if (el === undefined || el === null) continue;
if (typeof el === 'object' && el.constructor === Object) {
if (el.xtype && prop !== 'config') {
if ((el.xtype || el.cbind) && prop !== 'config') {
me[prop] = cloneTemplateObject(el);
}
} else if (el.constructor === Array) {

33
src/panel/EOLNotice.js Normal file
View File

@ -0,0 +1,33 @@
// not realy a panel descendant, but its the best (existing) place for this
Ext.define('Proxmox.EOLNotice', {
extend: 'Ext.Component',
alias: 'widget.proxmoxEOLNotice',
padding: '0 5',
config: {
product: '',
version: '',
eolDate: '',
href: '',
},
autoEl: {
tag: 'div',
'data-qtip': gettext("You won't get any security fixes after the End-Of-Life date. Please consider upgrading."),
},
initComponent: function() {
let me = this;
let href = me.href.startsWith('http') ? me.href : `https://${me.href}`;
let message = Ext.String.format(
gettext('Support for {0} {1} ends on {2}'), me.product, me.version, me.eolDate);
me.html = `<i class="fa pwt-eol-icon fa-exclamation-triangle"></i>
<a href="${href}" target="_blank">${message} <i class="fa fa-external-link"></i></a>
`;
me.callParent();
},
});

View File

@ -136,7 +136,7 @@ Ext.define('Proxmox.window.DiskSmart', {
me.down('#text').setVisible(true);
} else {
grid.setVisible(true);
me.down('#textContainer').setVisible(false);
me.down('#text').setVisible(false);
grid.setStore(rec.attributes());
}
}