public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH cluster/manager v2] add dc notes
@ 2021-09-22 10:42 Dominik Csapak
  2021-09-22 10:42 ` [pve-devel] [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config Dominik Csapak
  2021-09-22 10:42 ` [pve-devel] [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes Dominik Csapak
  0 siblings, 2 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-09-22 10:42 UTC (permalink / raw)
  To: pve-devel

resend of dominics previous series of this fix
changes from v1:
* removed the (imho) unecessary parsing of the nonexisting 'description'
  field in the datacenter.cfg, we never had it before and now it only
  exists as comment, no need to add it to the description (since it
  cannot exist using only our tools)
* fixed the maxLen also for the datacenter notes in the ui
* improved commit subject for manager

pve-cluster:

Dominic Jäger (1):
  dc.cfg: Add notes to datacenter config

 data/PVE/DataCenterConfig.pm | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

pve-manager:

Dominic Jäger (1):
  ui: close #3504: Add datacenter notes

 www/manager6/dc/Config.js       |  6 +++++
 www/manager6/panel/NotesView.js | 48 +++++++++++++++++----------------
 2 files changed, 31 insertions(+), 23 deletions(-)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config
  2021-09-22 10:42 [pve-devel] [PATCH cluster/manager v2] add dc notes Dominik Csapak
@ 2021-09-22 10:42 ` Dominik Csapak
  2021-10-04  7:37   ` [pve-devel] applied: " Thomas Lamprecht
  2021-09-22 10:42 ` [pve-devel] [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes Dominik Csapak
  1 sibling, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2021-09-22 10:42 UTC (permalink / raw)
  To: pve-devel; +Cc: Dominic Jäger

From: Dominic Jäger <d.jaeger@proxmox.com>

Similar to notes for nodes.
datacenter.cfg normally uses key-value pairs defined in the schema.
We bypass this to allow potentially long comments at the top.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 data/PVE/DataCenterConfig.pm | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
index 24ebf3f..fa8ba4a 100644
--- a/data/PVE/DataCenterConfig.pm
+++ b/data/PVE/DataCenterConfig.pm
@@ -181,6 +181,13 @@ my $datacenter_schema = {
 	    format => $u2f_format,
 	    description => 'u2f',
 	},
+	description => {
+	    type => 'string',
+	    description => "Datacenter description. Shown in the web-interface datacenter notes panel."
+		." This is saved as comment inside the configuration file.",
+	    maxLength => 64 * 1024,
+	    optional => 1,
+	},
     },
 };
 
@@ -190,8 +197,21 @@ sub get_datacenter_schema { return $datacenter_schema };
 sub parse_datacenter_config {
     my ($filename, $raw) = @_;
 
+    # description may be comment or key-value pair (or both)
+    my $comment = '';
+    my @lines = split(/\n/, $raw);
+    foreach my $line (@lines) {
+	if ($line =~ /^\#(.*)\s*$/) {
+	    $comment .= PVE::Tools::decode_text($1) . "\n";
+	}
+    }
+
+    # parse_config ignores lines with # => use $raw
     my $res = PVE::JSONSchema::parse_config($datacenter_schema, $filename, $raw // '');
 
+    $res->{description} = $comment;
+
+
     if (my $migration = $res->{migration}) {
 	$res->{migration} = PVE::JSONSchema::parse_property_string($migration_format, $migration);
     }
@@ -251,7 +271,16 @@ sub write_datacenter_config {
 	$cfg->{u2f} = PVE::JSONSchema::print_property_string($u2f, $u2f_format);
     }
 
-    return PVE::JSONSchema::dump_config($datacenter_schema, $filename, $cfg);
+    my $comment = '';
+    # add description as comment to top of file
+    my $description = $cfg->{description} || '';
+    foreach my $line (split(/\n/, $description)) {
+	$comment .= '#' .  PVE::Tools::encode_text($line) . "\n";
+    }
+    delete $cfg->{description}; # add only as comment, no additional key-value pair
+    my $dump = PVE::JSONSchema::dump_config($datacenter_schema, $filename, $cfg);
+
+    return $comment . "\n" . $dump;
 }
 
 PVE::Cluster::cfs_register_file('datacenter.cfg',
-- 
2.30.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes
  2021-09-22 10:42 [pve-devel] [PATCH cluster/manager v2] add dc notes Dominik Csapak
  2021-09-22 10:42 ` [pve-devel] [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config Dominik Csapak
@ 2021-09-22 10:42 ` Dominik Csapak
  2021-11-09 17:42   ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2021-09-22 10:42 UTC (permalink / raw)
  To: pve-devel; +Cc: Dominic Jäger

From: Dominic Jäger <d.jaeger@proxmox.com>

Like notes for nodes.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/Config.js       |  6 +++++
 www/manager6/panel/NotesView.js | 48 +++++++++++++++++----------------
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 934952d9..eb4c7805 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -27,6 +27,12 @@ Ext.define('PVE.dc.Config', {
 		iconCls: 'fa fa-book',
 		itemId: 'summary',
 	    },
+	    {
+		xtype: 'pveNotesView',
+		title: gettext('Notes'),
+		iconCls: 'fa fa-sticky-note-o',
+		itemId: 'notes',
+	    },
 	    {
 		title: gettext('Cluster'),
 		xtype: 'pveClusterAdministration',
diff --git a/www/manager6/panel/NotesView.js b/www/manager6/panel/NotesView.js
index b281f892..7c8299d0 100644
--- a/www/manager6/panel/NotesView.js
+++ b/www/manager6/panel/NotesView.js
@@ -6,6 +6,7 @@ Ext.define('PVE.panel.NotesView', {
     bodyPadding: 10,
     scrollable: true,
     animCollapse: false,
+    maxLength: 64 * 1024,
 
     tbar: {
 	itemId: 'tbar',
@@ -79,37 +80,38 @@ Ext.define('PVE.panel.NotesView', {
     }],
 
     initComponent: function() {
-	var me = this;
+	const me = this;
+	const type = me.pveSelNode.data.type;
 
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) {
-	    throw "no node name specified";
-	}
+	if (me.pveSelNode.data.id === 'root') {
+	    me.url = '/api2/extjs/cluster/options';
+	} else {
+	    const nodename = me.pveSelNode.data.node;
+	    if (!nodename) {
+		throw "no node name specified";
+	    }
 
-	let type = me.pveSelNode.data.type;
-	if (!Ext.Array.contains(['node', 'qemu', 'lxc'], type)) {
-	    throw 'invalid type specified';
-	}
+	    if (!Ext.Array.contains(['node', 'qemu', 'lxc'], type)) {
+		throw 'invalid type specified';
+	    }
 
-	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid && type !== 'node') {
-	    throw "no VM ID specified";
-	}
+	    const vmid = me.pveSelNode.data.vmid;
+	    if (!vmid && type !== 'node') {
+		throw "no VM ID specified";
+	    }
 
-	me.url = `/api2/extjs/nodes/${nodename}/`;
+	    me.url = `/api2/extjs/nodes/${nodename}/`;
 
-	// add the type specific path if qemu/lxc and set the backend's maxLen
-	if (type === 'qemu' || type === 'lxc') {
-	    me.url += `${type}/${vmid}/`;
-	    me.maxLength = 8 * 1024;
-	} else {
-	    me.maxLength = 64 * 1024;
+	    // add the type specific path if qemu/lxc and set the backend's maxLen
+	    if (type === 'qemu' || type === 'lxc') {
+		me.url += `${type}/${vmid}/`;
+		me.maxLength = 8 * 1024;
+	    }
+	    me.url += 'config';
 	}
 
-	me.url += 'config';
-
 	me.callParent();
-	if (type === 'node') {
+	if (type === 'node' || type === '') { // '' is for datacenter
 	    me.down('#tbar').setVisible(true);
 	} else if (me.pveSelNode.data.template !== 1) {
 	    me.setCollapsible(true);
-- 
2.30.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied: [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config
  2021-09-22 10:42 ` [pve-devel] [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config Dominik Csapak
@ 2021-10-04  7:37   ` Thomas Lamprecht
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2021-10-04  7:37 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 22.09.21 12:42, Dominik Csapak wrote:
> From: Dominic Jäger <d.jaeger@proxmox.com>
> 
> Similar to notes for nodes.
> datacenter.cfg normally uses key-value pairs defined in the schema.
> We bypass this to allow potentially long comments at the top.
> 
> Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  data/PVE/DataCenterConfig.pm | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied: [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes
  2021-09-22 10:42 ` [pve-devel] [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes Dominik Csapak
@ 2021-11-09 17:42   ` Thomas Lamprecht
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2021-11-09 17:42 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 22.09.21 12:42, Dominik Csapak wrote:
> From: Dominic Jäger <d.jaeger@proxmox.com>
> 
> Like notes for nodes.
> 
> Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  www/manager6/dc/Config.js       |  6 +++++
>  www/manager6/panel/NotesView.js | 48 +++++++++++++++++----------------
>  2 files changed, 31 insertions(+), 23 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-09 17:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 10:42 [pve-devel] [PATCH cluster/manager v2] add dc notes Dominik Csapak
2021-09-22 10:42 ` [pve-devel] [PATCH cluster v2 1/1] dc.cfg: Add notes to datacenter config Dominik Csapak
2021-10-04  7:37   ` [pve-devel] applied: " Thomas Lamprecht
2021-09-22 10:42 ` [pve-devel] [PATCH manager v2 1/1] ui: close #3504: Add datacenter notes Dominik Csapak
2021-11-09 17:42   ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal