7373 </a-select-option >
7474 </a-select >
7575 </a-tooltip >
76+ <a-dropdown style =" margin-left : 8px " :trigger =" ['click']" v-if =" !$store.getters.metrics" v-model =" customColumnsDropdownVisible" >
77+ <a-button >
78+ {{ $t('label.columns') }} <a-icon type =" down" style =" color : rgba (0 ,0 ,0 ,.45 )" />
79+ </a-button >
80+ <a-menu
81+ @click =" () => { customColumnsDropdownVisible = true }"
82+ slot =" overlay" >
83+ <a-menu-item v-for =" (column, idx) in columnKeys" :key =" idx" @click =" updateSelectedColumns(column)" >
84+ <a-checkbox :id =" idx.toString()" :checked =" selectedColumns.includes(getColumnKey(column))" />
85+ {{ $t('label.' + getColumnKey(column)) }}
86+ </a-menu-item >
87+ </a-menu >
88+ </a-dropdown >
7689 </span >
7790 </breadcrumb >
7891 </a-col >
441454 <bulk-action-progress
442455 :showGroupActionModal =" showGroupActionModal"
443456 :selectedItems =" selectedItems"
444- :selectedColumns =" selectedColumns "
457+ :selectedColumns =" bulkColumns "
445458 :message =" modalInfo"
446459 @handle-cancel =" handleCancel" />
447460 </div >
@@ -499,9 +512,13 @@ export default {
499512 apiName: ' ' ,
500513 loading: false ,
501514 actionLoading: false ,
515+ columnKeys: [],
516+ allColumns: [],
502517 columns: [],
518+ bulkColumns: [],
503519 selectedColumns: [],
504520 chosenColumns: [],
521+ customColumnsDropdownVisible: false ,
505522 showGroupActionModal: false ,
506523 selectedItems: [],
507524 items: [],
@@ -716,6 +733,7 @@ export default {
716733 this .actions = []
717734 this .columns = []
718735 this .columnKeys = []
736+ this .selectedColumns = []
719737 const refreshed = (' irefresh' in params)
720738
721739 params .listall = true
@@ -825,7 +843,20 @@ export default {
825843 scopedSlots: { customRender: key },
826844 sorter : function (a , b ) { return genericCompare (a[this .dataIndex ] || ' ' , b[this .dataIndex ] || ' ' ) }
827845 })
846+ this .selectedColumns .push (key)
847+ }
848+ this .allColumns = this .columns
849+
850+ if (! store .getters .metrics ) {
851+ if (! this .$store .getters .customColumns [this .$store .getters .userInfo .id ]) {
852+ this .$store .getters .customColumns [this .$store .getters .userInfo .id ] = {}
853+ this .$store .getters .customColumns [this .$store .getters .userInfo .id ][this .$route .path ] = this .selectedColumns
854+ } else {
855+ this .selectedColumns = this .$store .getters .customColumns [this .$store .getters .userInfo .id ][this .$route .path ] || this .selectedColumns
856+ this .updateSelectedColumns ()
857+ }
828858 }
859+
829860 this .chosenColumns = this .columns .filter (column => {
830861 return ! [this .$t (' label.state' ), this .$t (' label.hostname' ), this .$t (' label.hostid' ), this .$t (' label.zonename' ),
831862 this .$t (' label.zone' ), this .$t (' label.zoneid' ), this .$t (' label.ip' ), this .$t (' label.ipaddress' ), this .$t (' label.privateip' ),
@@ -1218,7 +1249,7 @@ export default {
12181249 eventBus .$emit (' update-bulk-job-status' , this .selectedItems , false )
12191250 this .showGroupActionModal = false
12201251 this .selectedItems = []
1221- this .selectedColumns = []
1252+ this .bulkColumns = []
12221253 this .selectedRowKeys = []
12231254 this .message = {}
12241255 },
@@ -1227,9 +1258,9 @@ export default {
12271258 this .promises = []
12281259 if (! this .dataView && this .currentAction .groupAction && this .selectedRowKeys .length > 0 ) {
12291260 if (this .selectedRowKeys .length > 0 ) {
1230- this .selectedColumns = this .chosenColumns
1261+ this .bulkColumns = this .chosenColumns
12311262 this .selectedItems = this .selectedItems .map (v => ({ ... v, status: ' InProgress' }))
1232- this .selectedColumns .splice (0 , 0 , {
1263+ this .bulkColumns .splice (0 , 0 , {
12331264 dataIndex: ' status' ,
12341265 title: this .$t (' label.operation.status' ),
12351266 scopedSlots: { customRender: ' status' },
@@ -1441,6 +1472,30 @@ export default {
14411472 shouldNavigateBack (action ) {
14421473 return ((action .icon === ' delete' || [' archiveEvents' , ' archiveAlerts' , ' unmanageVirtualMachine' ].includes (action .api )) && this .dataView )
14431474 },
1475+ getColumnKey (name ) {
1476+ if (typeof name === ' object' ) {
1477+ name = Object .keys (name)[0 ]
1478+ }
1479+ return name
1480+ },
1481+ updateSelectedColumns (name ) {
1482+ if (name) {
1483+ name = this .getColumnKey (name)
1484+ if (this .selectedColumns .includes (name)) {
1485+ this .selectedColumns = this .selectedColumns .filter (x => x !== name)
1486+ } else {
1487+ this .selectedColumns .push (name)
1488+ }
1489+ }
1490+
1491+ this .columns = this .allColumns .filter (x => this .selectedColumns .includes (x .dataIndex ))
1492+
1493+ if (! this .$store .getters .customColumns [this .$store .getters .userInfo .id ]) {
1494+ this .$store .getters .customColumns [this .$store .getters .userInfo .id ] = {}
1495+ }
1496+ this .$store .getters .customColumns [this .$store .getters .userInfo .id ][this .$route .path ] = this .selectedColumns
1497+ this .$store .dispatch (' SetCustomColumns' , this .$store .getters .customColumns )
1498+ },
14441499 changeFilter (filter ) {
14451500 const query = Object .assign ({}, this .$route .query )
14461501 delete query .templatefilter
@@ -1609,4 +1664,8 @@ export default {
16091664 display: flex;
16101665 align- items: center;
16111666}
1667+
1668+ .hide {
1669+ display: none ! important;
1670+ }
16121671< / style>
0 commit comments