ui: update group notes: fix obj access and rewrite to async

eslint is configured to not allow using quoted object keys if they
could be just passed in dot notation, e.g.,
wrong: `group["comment"]`
good:  `group.comment`

It's not a big problem but eslint fails the build with the wrong one,
so this needs to be fixed anyway..

Also, rewrite to async, shorter and less indentation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-07-12 07:54:41 +02:00
parent b3477d286f
commit 8866cbccc8
1 changed files with 17 additions and 20 deletions

View File

@ -125,27 +125,24 @@ Ext.define('PBS.DataStoreContent', {
return groups; return groups;
}, },
updateGroupNotes: function(view) { updateGroupNotes: async function(view) {
Proxmox.Utils.API2Request({ try {
url: `/api2/extjs/admin/datastore/${view.datastore}/groups`, let { result: { data: groups } } = await Proxmox.Async.api2({
method: 'GET', url: `/api2/extjs/admin/datastore/${view.datastore}/groups`,
success: function(response) { });
let groups = response.result.data; let map = {};
let map = {}; for (const group of groups) {
for (const group of groups) { map[`${group["backup-type"]}/${group["backup-id"]}`] = group.comment;
map[`${group["backup-type"]}/${group["backup-id"]}`] = group["comment"]; }
view.getRootNode().cascade(node => {
if (node.parentNode && node.parentNode.id === 'root') {
let group = `${node.data.backup_type}/${node.data.backup_id}`;
node.set('comment', map[group], { dirty: false });
} }
view.getRootNode().cascade(node => { });
if (node.parentNode && node.parentNode.id === 'root') { } catch (err) {
node.set( console.debug(err);
'comment', }
map[`${node.data.backup_type}/${node.data.backup_id}`],
{ dirty: false },
);
}
});
},
});
}, },
onLoad: function(store, records, success, operation) { onLoad: function(store, records, success, operation) {