From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dcsapak@zita.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id A59BD6169E
 for <pbs-devel@lists.proxmox.com>; Thu,  9 Jul 2020 13:38:23 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id A19EF11E59
 for <pbs-devel@lists.proxmox.com>; Thu,  9 Jul 2020 13:38:23 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 1EFA411E4E
 for <pbs-devel@lists.proxmox.com>; Thu,  9 Jul 2020 13:38:22 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DD3DC40B4E
 for <pbs-devel@lists.proxmox.com>; Thu,  9 Jul 2020 13:38:21 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu,  9 Jul 2020 13:38:21 +0200
Message-Id: <20200709113821.9152-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200709113821.9152-1-d.csapak@proxmox.com>
References: <20200709113821.9152-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery
 methods
 NO_DNS_FOR_FROM         0.379 Envelope sender has no MX or A DNS records
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_NONE                0.001 SPF: sender does not publish an SPF Record
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] ui: add TaskButton in header
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 09 Jul 2020 11:38:23 -0000

opens a grid with the running tasks and a shortcut the the node tasks

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
i am not set on the text/icon or colors, but it seemed somewhat sensible
 www/MainView.js               |  4 ++
 www/Makefile                  |  1 +
 www/button/TaskButton.js      | 92 +++++++++++++++++++++++++++++++++++
 www/css/ext6-pbs.css          | 19 ++++++++
 www/dashboard/RunningTasks.js |  2 +
 5 files changed, 118 insertions(+)
 create mode 100644 www/button/TaskButton.js

diff --git a/www/MainView.js b/www/MainView.js
index cb7a81d..1dd315b 100644
--- a/www/MainView.js
+++ b/www/MainView.js
@@ -224,6 +224,10 @@ Ext.define('PBS.MainView', {
 		    href: '/docs/index.html',
 		    margin: '0 5 0 0',
 		},
+		{
+		    xtype: 'pbsTaskButton',
+		    margin: '0 5 0 0',
+		},
 		{
 		    reference: 'logoutButton',
 		    xtype: 'button',
diff --git a/www/Makefile b/www/Makefile
index b205f67..f75082b 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -9,6 +9,7 @@ JSSRC=							\
 	form/RemoteSelector.js				\
 	form/DataStoreSelector.js			\
 	data/RunningTasksStore.js			\
+	button/TaskButton.js				\
 	config/UserView.js				\
 	config/RemoteView.js				\
 	config/ACLView.js				\
diff --git a/www/button/TaskButton.js b/www/button/TaskButton.js
new file mode 100644
index 0000000..67cc147
--- /dev/null
+++ b/www/button/TaskButton.js
@@ -0,0 +1,92 @@
+Ext.define('PBS.TaskButton', {
+    extend: 'Ext.button.Button',
+    alias: 'widget.pbsTaskButton',
+
+    config: {
+	badgeText: '0',
+	badgeCls: '',
+    },
+
+    iconCls: 'fa fa-list',
+    userCls: 'pmx-has-badge',
+    text: gettext('Tasks'),
+
+    setText: function(value) {
+	let me = this;
+	me.realText = value;
+	let badgeText = me.getBadgeText();
+	let badgeCls = me.getBadgeCls();
+	let text = `${value} <span class="pmx-button-badge ${badgeCls}">${badgeText}</span>`;
+	return me.callParent([text]);
+    },
+
+    getText: function() {
+	let me = this;
+	return me.realText;
+    },
+
+    setBadgeText: function(value) {
+	let me = this;
+	me.badgeText = value.toString();
+	return me.setText(me.getText());
+    },
+
+    setBadgeCls: function(value) {
+	let me = this;
+	let res = me.callParent([value]);
+	let badgeText = me.getBadgeText();
+	me.setBadgeText(badgeText);
+	return res;
+    },
+
+    handler: function() {
+	let me = this;
+	if (me.grid.isVisible()) {
+	    me.grid.setVisible(false);
+	} else {
+	    me.grid.showBy(me, 'tr-br');
+	}
+    },
+
+    initComponent: function() {
+	let me = this;
+
+	me.grid = Ext.create({
+	    xtype: 'pbsRunningTasks',
+	    title: '',
+	    hideHeaders: false,
+	    floating: true,
+
+	    width: 600,
+
+	    bbar: [
+		'->',
+		{
+		    xtype: 'button',
+		    text: gettext('Show All Tasks'),
+		    handler: function() {
+			var mainview = me.up('mainview');
+			mainview.getController().redirectTo('pbsServerAdministration:tasks');
+			me.grid.hide();
+		    },
+		},
+	    ],
+
+	    listeners: {
+		'taskopened': function() {
+		    me.grid.hide();
+		},
+	    },
+	});
+	me.callParent();
+	me.mon(me.grid.getStore().rstore, 'load', function(store, records, success) {
+	    if (!success) return;
+
+	    let count = records.length;
+	    let text = count > 9 ? '9+' : count.toString();
+	    let cls = count > 0 ? 'active': '';
+	    me.setBadgeText(text);
+	    me.setBadgeCls(cls);
+	});
+    },
+});
diff --git a/www/css/ext6-pbs.css b/www/css/ext6-pbs.css
index e634cfc..551d1d1 100644
--- a/www/css/ext6-pbs.css
+++ b/www/css/ext6-pbs.css
@@ -190,3 +190,22 @@ p.logs {
     visibility: hidden;
     width: 5px;
 }
+
+.pmx-has-badge .x-btn-inner {
+    padding: 0 0 0 5px;
+    min-width: 24px;
+}
+
+.pmx-button-badge {
+    display: inline-block;
+    font-weight: bold;
+    border-radius: 20px;
+    background-color: #AAA;
+    padding: 2px 3px;
+    min-width: 24px;
+    line-height: 1em;
+}
+
+.pmx-button-badge.active {
+    background-color: #F00;
+}
diff --git a/www/dashboard/RunningTasks.js b/www/dashboard/RunningTasks.js
index e31218e..4c1d4d1 100644
--- a/www/dashboard/RunningTasks.js
+++ b/www/dashboard/RunningTasks.js
@@ -18,6 +18,8 @@ Ext.define('PBS.RunningTasks', {
 		upid: record.data.upid,
 		endtime: record.data.endtime,
 	    }).show();
+
+	    view.fireEvent('taskopened', view, record.data.upid);
 	},
 
 	openTaskItemDblClick: function(grid, record) {
-- 
2.20.1