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;
},
updateGroupNotes: function(view) {
Proxmox.Utils.API2Request({
url: `/api2/extjs/admin/datastore/${view.datastore}/groups`,
method: 'GET',
success: function(response) {
let groups = response.result.data;
let map = {};
for (const group of groups) {
map[`${group["backup-type"]}/${group["backup-id"]}`] = group["comment"];
updateGroupNotes: async function(view) {
try {
let { result: { data: groups } } = await Proxmox.Async.api2({
url: `/api2/extjs/admin/datastore/${view.datastore}/groups`,
});
let map = {};
for (const group of groups) {
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') {
node.set(
'comment',
map[`${node.data.backup_type}/${node.data.backup_id}`],
{ dirty: false },
);
}
});
},
});
});
} catch (err) {
console.debug(err);
}
},
onLoad: function(store, records, success, operation) {