* [pbs-devel] [PATCH proxmox-backup 1/2] make user properties deletable
@ 2020-11-11 12:34 Dominik Csapak
2020-11-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: UserView: render name as 'Firstname Lastname' Dominik Csapak
2020-11-11 13:15 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] make user properties deletable Thomas Lamprecht
0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2020-11-11 12:34 UTC (permalink / raw)
To: pbs-devel
by using our usual pattern for the update call
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/access/user.rs | 35 +++++++++++++++++++++++++++++++++++
www/window/UserEdit.js | 12 ++++++++++++
2 files changed, 47 insertions(+)
diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs
index b4cb1942..49ddff65 100644
--- a/src/api2/access/user.rs
+++ b/src/api2/access/user.rs
@@ -268,6 +268,21 @@ pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<
Ok(user)
}
+#[api()]
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all="kebab-case")]
+#[allow(non_camel_case_types)]
+pub enum DeletableProperty {
+ /// Delete the comment property.
+ comment,
+ /// Delete the firstname property.
+ firstname,
+ /// Delete the lastname property.
+ lastname,
+ /// Delete the email property.
+ email,
+}
+
#[api(
protected: true,
input: {
@@ -303,6 +318,14 @@ pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<
schema: user::EMAIL_SCHEMA,
optional: true,
},
+ delete: {
+ description: "List of properties to delete.",
+ type: Array,
+ optional: true,
+ items: {
+ type: DeletableProperty,
+ }
+ },
digest: {
optional: true,
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
@@ -326,6 +349,7 @@ pub fn update_user(
firstname: Option<String>,
lastname: Option<String>,
email: Option<String>,
+ delete: Option<Vec<DeletableProperty>>,
digest: Option<String>,
) -> Result<(), Error> {
@@ -340,6 +364,17 @@ pub fn update_user(
let mut data: user::User = config.lookup("user", userid.as_str())?;
+ if let Some(delete) = delete {
+ for delete_prop in delete {
+ match delete_prop {
+ DeletableProperty::comment => data.comment = None,
+ DeletableProperty::firstname => data.firstname = None,
+ DeletableProperty::lastname => data.lastname = None,
+ DeletableProperty::email => data.email = None,
+ }
+ }
+ }
+
if let Some(comment) = comment {
let comment = comment.trim().to_string();
if comment.is_empty() {
diff --git a/www/window/UserEdit.js b/www/window/UserEdit.js
index d39a85d2..aaae835f 100644
--- a/www/window/UserEdit.js
+++ b/www/window/UserEdit.js
@@ -100,17 +100,26 @@ Ext.define('PBS.window.UserEdit', {
xtype: 'proxmoxtextfield',
name: 'firstname',
fieldLabel: gettext('First Name'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
},
{
xtype: 'proxmoxtextfield',
name: 'lastname',
fieldLabel: gettext('Last Name'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
},
{
xtype: 'proxmoxtextfield',
name: 'email',
fieldLabel: gettext('E-Mail'),
vtype: 'proxmoxMail',
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
},
],
@@ -119,6 +128,9 @@ Ext.define('PBS.window.UserEdit', {
xtype: 'proxmoxtextfield',
name: 'comment',
fieldLabel: gettext('Comment'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
},
],
},
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/2] ui: UserView: render name as 'Firstname Lastname'
2020-11-11 12:34 [pbs-devel] [PATCH proxmox-backup 1/2] make user properties deletable Dominik Csapak
@ 2020-11-11 12:34 ` Dominik Csapak
2020-11-11 13:15 ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-11 13:15 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] make user properties deletable Thomas Lamprecht
1 sibling, 1 reply; 4+ messages in thread
From: Dominik Csapak @ 2020-11-11 12:34 UTC (permalink / raw)
To: pbs-devel
instead of only the firstname
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/config/UserView.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/www/config/UserView.js b/www/config/UserView.js
index c2556b97..f030b30c 100644
--- a/www/config/UserView.js
+++ b/www/config/UserView.js
@@ -76,6 +76,17 @@ Ext.define('PBS.config.UserView', {
}).show();
},
+ renderName: function(val, cell, rec) {
+ let name = [];
+ if (rec.data.firstname) {
+ name.push(rec.data.firstname);
+ }
+ if (rec.data.lastname) {
+ name.push(rec.data.lastname);
+ }
+ return name.join(' ');
+ },
+
renderUsername: function(userid) {
return Ext.String.htmlEncode(userid.match(/^(.+)@([^@]+)$/)[1]);
},
@@ -181,6 +192,7 @@ Ext.define('PBS.config.UserView', {
width: 150,
sortable: true,
dataIndex: 'firstname',
+ renderer: 'renderName',
},
{
header: gettext('Comment'),
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup 1/2] make user properties deletable
2020-11-11 12:34 [pbs-devel] [PATCH proxmox-backup 1/2] make user properties deletable Dominik Csapak
2020-11-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: UserView: render name as 'Firstname Lastname' Dominik Csapak
@ 2020-11-11 13:15 ` Thomas Lamprecht
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2020-11-11 13:15 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
On 11.11.20 13:34, Dominik Csapak wrote:
> by using our usual pattern for the update call
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/api2/access/user.rs | 35 +++++++++++++++++++++++++++++++++++
> www/window/UserEdit.js | 12 ++++++++++++
> 2 files changed, 47 insertions(+)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-11 13:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 12:34 [pbs-devel] [PATCH proxmox-backup 1/2] make user properties deletable Dominik Csapak
2020-11-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: UserView: render name as 'Firstname Lastname' Dominik Csapak
2020-11-11 13:15 ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-11 13:15 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] make user properties deletable Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox