[pmg-devel] [PATCH pmg-gui 1/1] add 'Request Quarantine Link' Button to LoginView

Stoiko Ivanov s.ivanov at proxmox.com
Tue Nov 17 14:27:07 CET 2020


On Tue, 17 Nov 2020 09:05:13 +0100
Dominik Csapak <d.csapak at proxmox.com> wrote:

> if the template has 'quarantinelink' enabled, we
> show a button 'Request Quarantine Link' on the quarantine login ui
> 
> there a user can enter their e-mail and request a link to the quarantine
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  js/LoginView.js   | 33 +++++++++++++++++++++++++++++++++
>  pmg-index.html.tt |  3 ++-
>  2 files changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/js/LoginView.js b/js/LoginView.js
> index 8e610aa..5546517 100644
> --- a/js/LoginView.js
> +++ b/js/LoginView.js
> @@ -10,6 +10,10 @@ Ext.define('PMG.LoginView', {
>  
>  	    let realmfield = me.lookup('realmfield');
>  
> +	    let enableQuarantineLink = view.targetview === 'quarantineview' && !!Proxmox.QuarantineLink;
as talked off-list - for me it was confusing to have the button only
available on the quarantine view. - No hard feelings on the topic
though... 


> +
> +	    me.lookup('quarantineButton').setVisible(enableQuarantineLink);
> +
>  	    if (view.targetview !== 'quarantineview') {
>  		return;
>  	    }
> @@ -65,6 +69,28 @@ Ext.define('PMG.LoginView', {
>  	    }
>  	},
>  
> +	openQuarantineLinkWindow: function() {
> +	    let me = this;
> +	    me.lookup('loginwindow').setVisible(false);
> +	    Ext.create('Proxmox.window.Edit', {
> +		title: gettext('Request Quarantine Link'),
> +		url: '/quarantine/sendlink',
> +		method: 'POST',
> +		items: [
> +		    {
> +			xtype: 'proxmoxtextfield',
> +			name: 'mail',
> +			fieldLabel: gettext('Your E-Mail'),
> +		    },
> +		],
> +		listeners: {
> +		    destroy: function() {
> +			me.lookup('loginwindow').show(true);
> +		    },
> +		},
> +	    }).show();
> +	},
> +
>  	control: {
>  	    'field[name=lang]': {
>  		change: function(f, value) {
> @@ -76,6 +102,9 @@ Ext.define('PMG.LoginView', {
>  		    window.location.reload();
>  		},
>  	    },
> +	    'button[reference=quarantineButton]': {
> +		click: 'openQuarantineLinkWindow',
> +	    },
>  	    'button[reference=loginButton]': {
>  		click: 'submitForm',
>  	    },
> @@ -172,6 +201,10 @@ Ext.define('PMG.LoginView', {
>                          },
>  		    ],
>  		    buttons: [
> +			{
> +			    text: gettext('Request Quarantine Link'),
> +			    reference: 'quarantineButton',
> +			},
>  			{
>  			    text: gettext('Login'),
>  			    reference: 'loginButton',
> diff --git a/pmg-index.html.tt b/pmg-index.html.tt
> index 4faf0cf..4a29ba2 100644
> --- a/pmg-index.html.tt
> +++ b/pmg-index.html.tt
> @@ -30,7 +30,8 @@
>          Setup: { auth_cookie_name: 'PMGAuthCookie' },
>          NodeName: '[% nodename %]',
>          UserName: '[% username %]',
> -        CSRFPreventionToken: '[% token %]'
> +        CSRFPreventionToken: '[% token %]',
> +        QuarantineLink: [% IF quarantinelink %] true [% ELSE %] false [% END %],
>        };
>      </script>
>      <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>





More information about the pmg-devel mailing list