| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :single-actions="singleActions"
- :group-actions="groupActions"
- :export-data-options="exportDataOptions" />
- </template>
- <script>
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import { getEnabledSwitchActions, getSetPublicAction } from '@/utils/common/tableActions'
- import SingleActionsMixin from '../mixins/singleActions'
- import ColumnsMixin from '../mixins/columns'
- import {
- ROBOT_TYPES,
- } from '../constants'
- import {
- getStatusFilter,
- getEnabledFilter,
- getTenantFilter,
- getDomainFilter,
- getCreatedAtFilter,
- } from '@/utils/common/tableFilter'
- export default {
- name: 'RobotList',
- mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
- props: {
- id: String,
- getParams: {
- type: Object,
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'robots',
- apiVersion: 'v1',
- getParams: this.getParam,
- filterOptions: {
- name: {
- label: this.$t('system.text_101'),
- filter: true,
- formatter: val => {
- return `name.contains("${val}")`
- },
- },
- status: getStatusFilter('robot'),
- enabled: getEnabledFilter(),
- type: {
- label: this.$t('system.text_48'),
- dropdown: true,
- items: ROBOT_TYPES,
- },
- projects: getTenantFilter(),
- project_domains: getDomainFilter(),
- created_at: getCreatedAtFilter(),
- },
- hiddenColumns: ['address', 'created_at'],
- }),
- exportDataOptions: {
- items: [
- { label: 'ID', key: 'id' },
- { label: this.$t('system.text_101'), key: 'name' },
- { label: this.$t('table.title.enable_status'), key: 'enabled' },
- { label: this.$t('system.text_48'), key: 'type' },
- { label: this.$t('res.project'), key: 'tenant' },
- { label: this.$t('table.title.share_range'), key: 'public_scope' },
- { label: 'Webhook/URL', key: 'address' },
- { label: this.$t('common.createdAt'), key: 'created_at' },
- ],
- },
- groupActions: [{
- label: this.$t('system.text_128'),
- permission: 'robots_create',
- action: () => {
- this.createDialog('CreateRobotDialog', {
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- return {
- buttonType: 'primary',
- }
- },
- }, {
- label: this.$t('system.text_166'),
- actions: () => {
- return [
- getSetPublicAction(this, {
- name: this.$t('system.robot'),
- scope: 'project',
- resource: 'robots',
- apiVersion: 'v1',
- }, {
- permission: 'robots_perform_public',
- meta: (row) => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (this.list.selectedItems.some(item => !this.isPower(item))) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- }),
- {
- label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
- permission: 'robots_perform_change_owner',
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- onManager: this.onManager,
- name: this.$t('system.robot'),
- resource: 'robots',
- apiVersion: 'v1',
- })
- },
- meta: (row) => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (this.list.selectedItems.some(item => !this.isPower(item))) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- },
- ...getEnabledSwitchActions(this, undefined, ['robots_perform_enable', 'robots_perform_disable'], {
- resourceName: this.$t('system.robot'),
- metas: [
- () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (this.list.selectedItems.some(item => !this.isPower(item))) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (this.list.selectedItems.some(item => !this.isPower(item))) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- ],
- }),
- {
- label: this.$t('system.text_129'),
- permission: 'robots_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('system.text_129'),
- name: this.$t('system.robot'),
- onManager: this.onManager,
- })
- },
- meta: () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (this.list.selectedItems.some(item => !this.isPower(item))) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return this.$getDeleteResult(this.list.selectedItems)
- },
- },
- ]
- },
- meta: () => {
- return {
- validate: !!this.list.selectedItems.length,
- }
- },
- }],
- }
- },
- created () {
- this.initSidePageTab('detail')
- this.list.fetchData()
- },
- methods: {
- getParam () {
- const ret = {
- ...this.getParams,
- details: true,
- }
- return ret
- },
- handleOpenSidepage (row) {
- this.sidePageTriggerHandle(this, 'RobotSidePage', {
- id: row.id,
- resource: 'robots',
- apiVersion: 'v1',
- getParams: this.getParam,
- }, {
- list: this.list,
- })
- },
- },
- }
- </script>
|