You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2023/04/21 08:49:10 UTC
[kylin] 10/17: KYLIN-5509 add the select all option when export models
This is an automated email from the ASF dual-hosted git repository.
xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit beec59208ded73c4d346013be09a306a0ee3cfb0
Author: Qian Xia <la...@gmail.com>
AuthorDate: Wed Apr 12 17:33:03 2023 +0800
KYLIN-5509 add the select all option when export models
---
.../common/ModelsExportModal/ModelsExportModal.vue | 43 +++++++++++-----------
.../components/common/ModelsExportModal/locales.js | 3 +-
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/kystudio/src/components/common/ModelsExportModal/ModelsExportModal.vue b/kystudio/src/components/common/ModelsExportModal/ModelsExportModal.vue
index 197fb87320..9c2b38d3c6 100644
--- a/kystudio/src/components/common/ModelsExportModal/ModelsExportModal.vue
+++ b/kystudio/src/components/common/ModelsExportModal/ModelsExportModal.vue
@@ -23,24 +23,9 @@
</div>
</div>
<p class="export-tips">{{$t('exportOneModelTip')}}</p>
- <!-- <p v-if="choosedModelsArr.length > 0" class="choosed-block">{{choosedModelsArr.join(', ')}}</p> -->
- <!-- <el-tree
- highlight-current
- v-if="type === 'all'"
- check-strictly
- class="model-tree"
- ref="tree"
- node-key="id"
- v-show="!isTreeEmpty"
- :data="models"
- :props="{ label: 'name', isLeaf: true }"
- :show-checkbox="getIsNodeShowCheckbox"
- :render-content="renderContent"
- :filter-node-method="handleFilterNode"
- @check="handleSelectModels"
- /> -->
<div class="export-model-list" v-if="type === 'all'">
<el-checkbox-group v-model="selectedModals" @change="handleSelectModels">
+ <el-checkbox label="all" :disabled="allModelItems.status === 'BROKEN'" v-if="type === 'all'"><span>{{$t(allModelItems.name)}}</span></el-checkbox>
<el-checkbox v-for="item in exportModal.list" :disabled="item.status === 'BROKEN'" :label="item.id" :key="item.id">
<el-tooltip :content="$t('exportBrokenModelCheckboxTip')" effect="dark" placement="top" :disabled="item.status !== 'BROKEN'">
<span>{{item.name}}</span>
@@ -82,6 +67,7 @@ import vuex, { actionTypes } from '../../../store'
import locales from './locales'
import store from './store'
import OverflowTextTooltip from '../OverflowTextTooltip/OverflowTextTooltip.vue'
+import { objectClone } from '../../../util'
vuex.registerModule(['modals', 'ModelsExportModal'], store)
@@ -148,15 +134,26 @@ export default class ModelsExportModal extends Vue {
newVal && !oldVal && (this.exportModalList = this.models)
}
+ get allModelItems () {
+ return {
+ has_multiple_partition_values: this.models.filter(it => it.has_multiple_partition_values).length > 0,
+ has_override_props: this.models.filter(it => it.has_override_props).length > 0,
+ has_recommendations: this.models.filter(it => it.has_recommendations).length > 0,
+ name: 'selectAll',
+ id: 'all',
+ status: this.models.filter(it => it.status === 'BROKEN').length === this.models.length ? 'BROKEN' : 'ONLINE'
+ }
+ }
+
getIsNodeShowCheckbox (data) {
return data.nodeType === 'model'
}
changeCheckboxType (type) {
if (type === 'ops') {
- return this.models.filter(it => this.selectedModals.includes(it.id) && !it.has_override_props).length
+ return (this.type === 'all' ? [...this.models, this.allModelItems] : this.models).filter(it => this.selectedModals.includes(it.id) && !it.has_override_props).length
} else if (type === 'mult-partition') {
- return this.models.filter(it => this.selectedModals.includes(it.id) && !it.has_multiple_partition_values).length
+ return (this.type === 'all' ? [...this.models, this.allModelItems] : this.models).filter(it => this.selectedModals.includes(it.id) && !it.has_multiple_partition_values).length
}
}
@@ -206,8 +203,8 @@ export default class ModelsExportModal extends Vue {
}
handleSelectModels (data) {
- const hasOverrideProps = this.models.filter(it => data.includes(it.id) && it.has_override_props)
- const hasMultPartitions = this.models.filter(it => data.includes(it.id) && it.has_multiple_partition_values)
+ const hasOverrideProps = (this.type === 'all' ? [...this.models, this.allModelItems] : this.models).filter(it => data.includes(it.id) && it.has_override_props)
+ const hasMultPartitions = (this.type === 'all' ? [...this.models, this.allModelItems] : this.models).filter(it => data.includes(it.id) && it.has_multiple_partition_values)
this.setModalForm({
ids: data,
exportOverProps: !hasOverrideProps.length && this.form.exportOverProps ? false : this.form.exportOverProps,
@@ -251,9 +248,13 @@ export default class ModelsExportModal extends Vue {
async handleSubmit () {
const { project, form } = this
this.isSubmiting = true
+ const formData = objectClone(form)
+ if (formData.ids.includes('all')) {
+ formData.ids = this.models.map(it => it.uuid)
+ }
try {
// if (this.type !== 'all') {
- await this.downloadModelsMetadata({ project, form })
+ await this.downloadModelsMetadata({ project, form: formData })
// } else {}
this.handleClose(true)
this.$message.success(this.$t('exportSuccess'))
diff --git a/kystudio/src/components/common/ModelsExportModal/locales.js b/kystudio/src/components/common/ModelsExportModal/locales.js
index fac6fc0ea2..483b3fa9c3 100644
--- a/kystudio/src/components/common/ModelsExportModal/locales.js
+++ b/kystudio/src/components/common/ModelsExportModal/locales.js
@@ -18,6 +18,7 @@ export default {
disabledOverrideTip: 'No overrides for the selected model(s)',
exportBrokenModelCheckboxTip: 'Can\'t export model file at the moment as the model is BROKEN',
subPartitionValues: 'Sub partition values',
- disabledMultPartitionTip: 'No subpartitions included in the selected model(s)'
+ disabledMultPartitionTip: 'No subpartitions included in the selected model(s)',
+ selectAll: 'Select All'
}
}