From 8866cbccc878b073fe9a6ca6675ab50f1b0cfda8 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 12 Jul 2021 07:54:41 +0200 Subject: [PATCH] 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 --- www/datastore/Content.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/www/datastore/Content.js b/www/datastore/Content.js index 29d58fc3..e0df4b30 100644 --- a/www/datastore/Content.js +++ b/www/datastore/Content.js @@ -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) {