You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2023/10/10 05:37:39 UTC

[cloudstack] branch main updated: ui: Fix sorter across different components (#8046)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 66e5d41a15f ui: Fix sorter across different components (#8046)
66e5d41a15f is described below

commit 66e5d41a15fa2700e7c64046732669d1b2a49001
Author: Vishesh <vi...@gmail.com>
AuthorDate: Tue Oct 10 11:07:28 2023 +0530

    ui: Fix sorter across different components (#8046)
    
    This PR fixes sorting in tables by columns in the UI
---
 ui/src/components/view/EventsTab.vue     | 2 +-
 ui/src/views/AutogenView.vue             | 2 +-
 ui/src/views/compute/ChangeAffinity.vue  | 6 +++---
 ui/src/views/compute/ResetSshKeyPair.vue | 2 +-
 ui/src/views/compute/ResetUserData.vue   | 2 +-
 ui/src/views/infra/CpuSockets.vue        | 6 +++---
 ui/src/views/infra/Metrics.vue           | 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/ui/src/components/view/EventsTab.vue b/ui/src/components/view/EventsTab.vue
index 899a43042e9..bd01b3f57c2 100644
--- a/ui/src/components/view/EventsTab.vue
+++ b/ui/src/components/view/EventsTab.vue
@@ -155,7 +155,7 @@ export default {
           key: columnKey,
           title: this.$t('label.' + String(columnKey).toLowerCase()),
           dataIndex: columnKey,
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+          sorter: (a, b) => { return genericCompare(a[columnKey] || '', b[columnKey] || '') }
         })
       }
       if (this.columns.length > 0) {
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index 8513c0341c9..038867830f7 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -861,7 +861,7 @@ export default {
           key: key,
           title: this.$t('label.' + String(title).toLowerCase()),
           dataIndex: key,
-          sorter: function (a, b) { return genericCompare(a[key] || '', b[key] || '') }
+          sorter: (a, b) => genericCompare(a[key] || '', b[key] || '')
         })
         this.selectedColumns.push(key)
       }
diff --git a/ui/src/views/compute/ChangeAffinity.vue b/ui/src/views/compute/ChangeAffinity.vue
index 917521748cd..9230db9f163 100644
--- a/ui/src/views/compute/ChangeAffinity.vue
+++ b/ui/src/views/compute/ChangeAffinity.vue
@@ -76,17 +76,17 @@ export default {
         {
           dataIndex: 'name',
           title: this.$t('label.name'),
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+          sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
         },
         {
           dataIndex: 'type',
           title: this.$t('label.type'),
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+          sorter: (a, b) => genericCompare(a?.type || '', b?.type || '')
         },
         {
           dataIndex: 'description',
           title: this.$t('label.description'),
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+          sorter: (a, b) => genericCompare(a?.description || '', b?.description || '')
         }
       ],
       selectedRowKeys: [],
diff --git a/ui/src/views/compute/ResetSshKeyPair.vue b/ui/src/views/compute/ResetSshKeyPair.vue
index 7babb952396..cc64caa86b4 100644
--- a/ui/src/views/compute/ResetSshKeyPair.vue
+++ b/ui/src/views/compute/ResetSshKeyPair.vue
@@ -79,7 +79,7 @@ export default {
         {
           dataIndex: 'name',
           title: this.$t('label.name'),
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') },
+          sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
           width: '40%'
         },
         {
diff --git a/ui/src/views/compute/ResetUserData.vue b/ui/src/views/compute/ResetUserData.vue
index 33643368ddc..6c57d13dc21 100644
--- a/ui/src/views/compute/ResetUserData.vue
+++ b/ui/src/views/compute/ResetUserData.vue
@@ -151,7 +151,7 @@ export default {
         {
           dataIndex: 'name',
           title: this.$t('label.name'),
-          sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') },
+          sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
           width: '40%'
         },
         {
diff --git a/ui/src/views/infra/CpuSockets.vue b/ui/src/views/infra/CpuSockets.vue
index 7b6798e306e..97b27221647 100644
--- a/ui/src/views/infra/CpuSockets.vue
+++ b/ui/src/views/infra/CpuSockets.vue
@@ -135,18 +135,18 @@ export default {
       this.columns.push({
         dataIndex: 'name',
         title: this.$t('label.hypervisor'),
-        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+        sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
       })
 
       this.columns.push({
         dataIndex: 'hosts',
         title: this.$t('label.hosts'),
-        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+        sorter: (a, b) => genericCompare(a?.hosts || '', b?.hosts || '')
       })
       this.columns.push({
         dataIndex: 'cpusockets',
         title: this.$t('label.cpu.sockets'),
-        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+        sorter: (a, b) => genericCompare(a?.cpusockets || '', b?.cpusockets || '')
       })
 
       this.items = []
diff --git a/ui/src/views/infra/Metrics.vue b/ui/src/views/infra/Metrics.vue
index 9f222c6ec0a..010059b885e 100644
--- a/ui/src/views/infra/Metrics.vue
+++ b/ui/src/views/infra/Metrics.vue
@@ -183,13 +183,13 @@ export default {
       this.columns.push({
         dataIndex: 'name',
         title: this.$t('label.name'),
-        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+        sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
       })
 
       this.columns.push({
         dataIndex: 'value',
         title: this.$t('label.value'),
-        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }
+        sorter: (a, b) => genericCompare(a?.value || '', b?.value || '')
       })
     },
     getRowClassName (record, index) {