From: Stefan Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-backup v3 3/6] fix #3607: ui: add a separate notes view for longer markdown notes
Date: Fri, 4 Mar 2022 12:31:59 +0100 [thread overview]
Message-ID: <20220304113202.4137916-4-s.sterz@proxmox.com> (raw)
In-Reply-To: <20220304113202.4137916-1-s.sterz@proxmox.com>
since markdown notes might be rather long, this commit adds a tab
similar to pve's datacenter or node notes.
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
---
www/Makefile | 2 +
www/NavigationTree.js | 6 ++
www/NodeNotes.js | 22 +++++++
www/panel/MarkdownNotes.js | 130 +++++++++++++++++++++++++++++++++++++
4 files changed, 160 insertions(+)
create mode 100644 www/NodeNotes.js
create mode 100644 www/panel/MarkdownNotes.js
diff --git a/www/Makefile b/www/Makefile
index 455fbeec..aff0c901 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -81,6 +81,7 @@ JSSRC= \
panel/StorageAndDisks.js \
panel/UsageChart.js \
panel/NodeInfo.js \
+ panel/MarkdownNotes.js \
ZFSList.js \
DirectoryList.js \
LoginView.js \
@@ -98,6 +99,7 @@ JSSRC= \
datastore/DataStoreList.js \
ServerStatus.js \
ServerAdministration.js \
+ NodeNotes.js \
Dashboard.js \
${TAPE_UI_FILES} \
NavigationTree.js \
diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index 576d05ab..916582ef 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -32,6 +32,12 @@ Ext.define('PBS.store.NavigationStore', {
path: 'pbsDashboard',
leaf: true,
},
+ {
+ text: gettext('Notes'),
+ iconCls: 'fa fa-sticky-note-o',
+ path: 'pbsNodeNotes',
+ leaf: true,
+ },
{
text: gettext('Configuration'),
iconCls: 'fa fa-gears',
diff --git a/www/NodeNotes.js b/www/NodeNotes.js
new file mode 100644
index 00000000..7fa3f2e6
--- /dev/null
+++ b/www/NodeNotes.js
@@ -0,0 +1,22 @@
+// Needs to be its own xtype for `path` to work in `NavigationTree`
+Ext.define('PBS.NodeNotes', {
+ extend: 'Ext.panel.Panel',
+ xtype: 'pbsNodeNotes',
+
+ scrollable: true,
+ layout: 'fit',
+
+ items: [
+ {
+ xtype: 'container',
+ layout: 'fit',
+ items: [{
+ xtype: 'pbsMarkdownNotes',
+ tools: false,
+ border: false,
+ node: 'localhost',
+ enableTbar: true,
+ }],
+ },
+ ],
+});
diff --git a/www/panel/MarkdownNotes.js b/www/panel/MarkdownNotes.js
new file mode 100644
index 00000000..6d601401
--- /dev/null
+++ b/www/panel/MarkdownNotes.js
@@ -0,0 +1,130 @@
+Ext.define('PBS.panel.MarkdownNotes', {
+ extend: 'Ext.panel.Panel',
+ xtype: 'pbsMarkdownNotes',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ title: gettext("Notes"),
+ bodyPadding: 10,
+ scrollable: true,
+ animCollapse: false,
+ maxLength: 64*1022,
+
+ cbindData: function(initalConfig) {
+ let me = this;
+
+ if (!me.node) {
+ throw 'no node provided, cannot construct url';
+ }
+
+ me.url = `/api2/extjs/nodes/${me.node}/config`;
+ return {};
+ },
+
+ run_editor: function() {
+ let me = this;
+ Ext.create('Proxmox.window.Edit', {
+ title: gettext('Notes'),
+ onlineHelp: 'markdown_basics',
+ width: 800,
+ height: 600,
+ resizable: true,
+ layout: 'fit',
+ defaultButton: undefined,
+ items: {
+ xtype: 'textarea',
+ maxLength: me.maxLength,
+ name: 'description',
+ height: '100%',
+ value: '',
+ hideLabel: true,
+ emptyText: gettext('You can use Markdown for rich text formatting.'),
+ fieldStyle: {
+ 'white-space': 'pre-wrap',
+ 'font-family': 'monospace',
+ },
+ },
+ url: me.url,
+ listeners: {
+ destroy: function() {
+ me.load();
+ },
+ },
+ autoShow: true,
+ autoLoad: true,
+ });
+ },
+
+ setNotes: function(value) {
+ let me = this;
+ var data = value || '';
+
+ let mdHtml = Proxmox.Markdown.parse(data);
+ me.update(mdHtml);
+
+ if (me.collapsible && me.collapseMode === 'auto') {
+ me.setCollapsed(data === '');
+ }
+ },
+
+ load: function() {
+ var me = this;
+
+ Proxmox.Utils.API2Request({
+ url: me.url,
+ waitMsgTarget: me,
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ me.setCollapsed(false);
+ },
+ success: function(response, opts) {
+ me.setNotes(response.result.data.description);
+ },
+ });
+ },
+
+ listeners: {
+ render: function(c) {
+ var me = this;
+ me.getEl().on('dblclick', me.run_editor, me);
+ },
+ afterlayout: function() {
+ let me = this;
+ if (me.collapsible && !me.getCollapsed() && me.collapseMode === 'always') {
+ me.setCollapsed(true);
+ me.collapseMode = ''; // only once, on initial load!
+ }
+ },
+ },
+
+ tools: [{
+ type: 'gear',
+ handler: function() {
+ this.up('panel').run_editor();
+ },
+ }],
+
+ tbar: {
+ itemId: 'tbar',
+ hidden: true,
+ items: [
+ {
+ text: gettext('Edit'),
+ handler: function() {
+ this.up('panel').run_editor();
+ },
+ },
+ ],
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ me.callParent();
+
+ if (me.enableTbar === true) {
+ me.down('#tbar').setVisible(true);
+ }
+
+ me.load();
+ },
+});
--
2.30.2
WARNING: multiple messages have this Message-ID
From: Stefan Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v3 3/6] fix #3607: ui: add a separate notes view for longer markdown notes
Date: Fri, 4 Mar 2022 12:31:59 +0100 [thread overview]
Message-ID: <20220304113202.4137916-4-s.sterz@proxmox.com> (raw)
In-Reply-To: <20220304113202.4137916-1-s.sterz@proxmox.com>
since markdown notes might be rather long, this commit adds a tab
similar to pve's datacenter or node notes.
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
---
www/Makefile | 2 +
www/NavigationTree.js | 6 ++
www/NodeNotes.js | 22 +++++++
www/panel/MarkdownNotes.js | 130 +++++++++++++++++++++++++++++++++++++
4 files changed, 160 insertions(+)
create mode 100644 www/NodeNotes.js
create mode 100644 www/panel/MarkdownNotes.js
diff --git a/www/Makefile b/www/Makefile
index 455fbeec..aff0c901 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -81,6 +81,7 @@ JSSRC= \
panel/StorageAndDisks.js \
panel/UsageChart.js \
panel/NodeInfo.js \
+ panel/MarkdownNotes.js \
ZFSList.js \
DirectoryList.js \
LoginView.js \
@@ -98,6 +99,7 @@ JSSRC= \
datastore/DataStoreList.js \
ServerStatus.js \
ServerAdministration.js \
+ NodeNotes.js \
Dashboard.js \
${TAPE_UI_FILES} \
NavigationTree.js \
diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index 576d05ab..916582ef 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -32,6 +32,12 @@ Ext.define('PBS.store.NavigationStore', {
path: 'pbsDashboard',
leaf: true,
},
+ {
+ text: gettext('Notes'),
+ iconCls: 'fa fa-sticky-note-o',
+ path: 'pbsNodeNotes',
+ leaf: true,
+ },
{
text: gettext('Configuration'),
iconCls: 'fa fa-gears',
diff --git a/www/NodeNotes.js b/www/NodeNotes.js
new file mode 100644
index 00000000..7fa3f2e6
--- /dev/null
+++ b/www/NodeNotes.js
@@ -0,0 +1,22 @@
+// Needs to be its own xtype for `path` to work in `NavigationTree`
+Ext.define('PBS.NodeNotes', {
+ extend: 'Ext.panel.Panel',
+ xtype: 'pbsNodeNotes',
+
+ scrollable: true,
+ layout: 'fit',
+
+ items: [
+ {
+ xtype: 'container',
+ layout: 'fit',
+ items: [{
+ xtype: 'pbsMarkdownNotes',
+ tools: false,
+ border: false,
+ node: 'localhost',
+ enableTbar: true,
+ }],
+ },
+ ],
+});
diff --git a/www/panel/MarkdownNotes.js b/www/panel/MarkdownNotes.js
new file mode 100644
index 00000000..6d601401
--- /dev/null
+++ b/www/panel/MarkdownNotes.js
@@ -0,0 +1,130 @@
+Ext.define('PBS.panel.MarkdownNotes', {
+ extend: 'Ext.panel.Panel',
+ xtype: 'pbsMarkdownNotes',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ title: gettext("Notes"),
+ bodyPadding: 10,
+ scrollable: true,
+ animCollapse: false,
+ maxLength: 64*1022,
+
+ cbindData: function(initalConfig) {
+ let me = this;
+
+ if (!me.node) {
+ throw 'no node provided, cannot construct url';
+ }
+
+ me.url = `/api2/extjs/nodes/${me.node}/config`;
+ return {};
+ },
+
+ run_editor: function() {
+ let me = this;
+ Ext.create('Proxmox.window.Edit', {
+ title: gettext('Notes'),
+ onlineHelp: 'markdown_basics',
+ width: 800,
+ height: 600,
+ resizable: true,
+ layout: 'fit',
+ defaultButton: undefined,
+ items: {
+ xtype: 'textarea',
+ maxLength: me.maxLength,
+ name: 'description',
+ height: '100%',
+ value: '',
+ hideLabel: true,
+ emptyText: gettext('You can use Markdown for rich text formatting.'),
+ fieldStyle: {
+ 'white-space': 'pre-wrap',
+ 'font-family': 'monospace',
+ },
+ },
+ url: me.url,
+ listeners: {
+ destroy: function() {
+ me.load();
+ },
+ },
+ autoShow: true,
+ autoLoad: true,
+ });
+ },
+
+ setNotes: function(value) {
+ let me = this;
+ var data = value || '';
+
+ let mdHtml = Proxmox.Markdown.parse(data);
+ me.update(mdHtml);
+
+ if (me.collapsible && me.collapseMode === 'auto') {
+ me.setCollapsed(data === '');
+ }
+ },
+
+ load: function() {
+ var me = this;
+
+ Proxmox.Utils.API2Request({
+ url: me.url,
+ waitMsgTarget: me,
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ me.setCollapsed(false);
+ },
+ success: function(response, opts) {
+ me.setNotes(response.result.data.description);
+ },
+ });
+ },
+
+ listeners: {
+ render: function(c) {
+ var me = this;
+ me.getEl().on('dblclick', me.run_editor, me);
+ },
+ afterlayout: function() {
+ let me = this;
+ if (me.collapsible && !me.getCollapsed() && me.collapseMode === 'always') {
+ me.setCollapsed(true);
+ me.collapseMode = ''; // only once, on initial load!
+ }
+ },
+ },
+
+ tools: [{
+ type: 'gear',
+ handler: function() {
+ this.up('panel').run_editor();
+ },
+ }],
+
+ tbar: {
+ itemId: 'tbar',
+ hidden: true,
+ items: [
+ {
+ text: gettext('Edit'),
+ handler: function() {
+ this.up('panel').run_editor();
+ },
+ },
+ ],
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ me.callParent();
+
+ if (me.enableTbar === true) {
+ me.down('#tbar').setVisible(true);
+ }
+
+ me.load();
+ },
+});
--
2.30.2
next prev parent reply other threads:[~2022-03-04 11:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 11:31 [pve-devel] [PATCH SERIES v3 0/6] fix #3607: add notes to functionality in webui Stefan Sterz
2022-03-04 11:31 ` [pbs-devel] " Stefan Sterz
2022-03-04 11:31 ` [pve-devel] [PATCH proxmox-backup v3 1/6] fix #3067: api: add support for multi-line comments in node.cfg Stefan Sterz
2022-03-04 11:31 ` [pbs-devel] " Stefan Sterz
2022-03-23 8:15 ` [pve-devel] " Wolfgang Bumiller
2022-03-23 8:15 ` Wolfgang Bumiller
2022-03-23 9:53 ` [pve-devel] applied: " Thomas Lamprecht
2022-03-23 9:53 ` [pbs-devel] applied: " Thomas Lamprecht
2022-03-04 11:31 ` [pve-devel] [PATCH proxmox-backup v3 2/6] fix #3607: docs: add markdown primer from pve to pbs Stefan Sterz
2022-03-04 11:31 ` [pbs-devel] " Stefan Sterz
2022-03-04 11:31 ` Stefan Sterz [this message]
2022-03-04 11:31 ` [pbs-devel] [PATCH proxmox-backup v3 3/6] fix #3607: ui: add a separate notes view for longer markdown notes Stefan Sterz
2022-03-23 11:08 ` [pve-devel] " Thomas Lamprecht
2022-03-23 11:08 ` [pbs-devel] " Thomas Lamprecht
2022-03-04 11:32 ` [pve-devel] [PATCH widget-toolkit v3 4/6] toolkit: add markdown based NotesView and NotesEdit Stefan Sterz
2022-03-04 11:32 ` [pbs-devel] " Stefan Sterz
2022-03-23 11:04 ` [pve-devel] " Thomas Lamprecht
2022-03-23 11:04 ` [pbs-devel] " Thomas Lamprecht
2022-03-04 11:32 ` [pve-devel] [PATCH proxmox-backup v3 5/6] fix #3607: ui: refactor notes by moving the panel/window to widget kit Stefan Sterz
2022-03-04 11:32 ` [pbs-devel] " Stefan Sterz
2022-03-23 11:09 ` [pve-devel] " Thomas Lamprecht
2022-03-23 11:09 ` [pbs-devel] " Thomas Lamprecht
2022-03-04 11:32 ` [pve-devel] [PATCH manager v3 6/6] ui: move NotesView panel and NotesEdit window " Stefan Sterz
2022-03-04 11:32 ` [pbs-devel] " Stefan Sterz
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=20220304113202.4137916-4-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pbs-devel@lists.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.