sureshanaparti commented on a change in pull request #353:
URL: https://github.com/apache/cloudstack-primate/pull/353#discussion_r429897348



##########
File path: src/views/iam/RolePermissionTab.vue
##########
@@ -227,6 +232,47 @@ export default {
         this.resetNewFields()
         this.fetchData()
       })
+    },
+    csv ({ data = null, columnDelimiter = ',', lineDelimiter = '\n' }) {
+      let result = null
+      let ctr = null
+
+      if (data === null || !data.length) {
+        return null
+      }
+
+      var keys = ['rule', 'permission', 'description']
+
+      result = ''
+      result += keys.join(columnDelimiter)
+      result += lineDelimiter
+
+      data.forEach(item => {
+        ctr = 0
+        keys.forEach(key => {
+          if (ctr > 0) {
+            result += columnDelimiter
+          }
+
+          if (item[key] === undefined) {
+            item[key] = ''
+          }
+          result += typeof item[key] === 'string' && 
item[key].includes(columnDelimiter) ? `"${item[key]}"` : item[key]
+          ctr++
+        })
+        result += lineDelimiter
+      })
+
+      return result
+    },
+    exportRolePermissions () {
+      const csvData = this.csv({ data: this.rules })
+
+      const hiddenElement = document.createElement('a')

Review comment:
       > we need to delete this element?
   
   element for the csv data to download as a file




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to