forked from jumpserver/lina
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e7b41c
commit 9d9d5c6
Showing
10 changed files
with
3,768 additions
and
3,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<template> | ||
<GenericUpdateFormDialog | ||
v-if="visible" | ||
:selected-rows="selectedRows" | ||
:form-setting="formSetting" | ||
:visible="visible" | ||
v-on="$listeners" | ||
/> | ||
</template> | ||
|
||
<script> | ||
import { GenericUpdateFormDialog } from '@/layout/components' | ||
import getFields from '../fields' | ||
export default { | ||
name: 'FavoriteAssetDialog', | ||
components: { | ||
GenericUpdateFormDialog | ||
}, | ||
props: { | ||
permType: { | ||
type: String, | ||
default: 'asset' | ||
}, | ||
visible: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
selectedRows: { | ||
type: Array, | ||
default: () => ([]) | ||
} | ||
}, | ||
data() { | ||
return { | ||
formSetting: { | ||
url: '', | ||
hasSaveContinue: false, | ||
initial: {}, | ||
fields: [], | ||
fieldsMeta: {} | ||
} | ||
} | ||
}, | ||
created() { | ||
this.init() | ||
}, | ||
methods: { | ||
init() { | ||
let url | ||
const fieldsManager = getFields.bind(this)() | ||
const fields = [ | ||
'users', 'user_groups', 'accounts', | ||
'actions', 'is_active', 'date_start', 'date_expired' | ||
] | ||
const fieldsMeta = { | ||
users: fieldsManager.users, | ||
user_groups: fieldsManager.user_groups, | ||
accounts: fieldsManager.accounts, | ||
date_start: fieldsManager.date_start, | ||
date_expired: fieldsManager.date_expired, | ||
is_active: fieldsManager.is_active, | ||
actions: { | ||
label: this.$t('common.Action') | ||
} | ||
} | ||
if (this.permType !== 'asset') { | ||
url = '/api/v1/perms/application-permissions/' | ||
fields.splice(2, 0, 'applications') | ||
Object.assign(fieldsMeta, { applications: fieldsManager.applications }) | ||
} else { | ||
url = '/api/v1/perms/asset-permissions/' | ||
fields.splice(2, 0, ...['assets', 'nodes']) | ||
Object.assign(fieldsMeta, { | ||
assets: fieldsManager.assets, | ||
nodes: fieldsManager.nodes | ||
}) | ||
} | ||
this.$data.formSetting.url = url | ||
this.$data.formSetting.fields = fields | ||
this.$data.formSetting.fieldsMeta = fieldsMeta | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<GenericCreateUpdatePage :fields="fields" :initial="initial" :url="url" /> | ||
</template> | ||
|
||
<script> | ||
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage' | ||
export default { | ||
name: 'FavoriteNodeCreateUpdate', | ||
components: { | ||
GenericCreateUpdatePage | ||
}, | ||
data() { | ||
return { | ||
initial: {}, | ||
fields: [ | ||
[this.$t('common.Basic'), ['name']] | ||
], | ||
url: '/api/v1/assets/favorite-nodes/' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<GenericListPage :header-actions="headerActions" :table-config="tableConfig" /> | ||
</template> | ||
|
||
<script> | ||
import { GenericListPage } from '@/layout/components' | ||
export default { | ||
components: { | ||
GenericListPage | ||
}, | ||
data() { | ||
return { | ||
tableConfig: { | ||
url: '/api/v1/assets/favorite-nodes/', | ||
columns: ['name', 'actions'], | ||
columnsShow: { | ||
min: ['name', 'actions'], | ||
default: ['name', 'actions'] | ||
} | ||
}, | ||
headerActions: { | ||
hasExport: false, | ||
hasImport: false, | ||
createRoute: 'FavoriteNodeCreate' | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<template> | ||
<Dialog | ||
v-if="iVisible" | ||
:destroy-on-close="true" | ||
:show-cancel="false" | ||
:show-confirm="false" | ||
:title="$tc('assets.CollectingAsset')" | ||
:visible.sync="iVisible" | ||
top="35vh" | ||
width="40%" | ||
> | ||
<el-row :gutter="20"> | ||
<el-col :md="4" :sm="24"> | ||
<div style="line-height: 34px">{{ $t('assets.FavoriteNode') }}</div> | ||
</el-col> | ||
<el-col :md="14" :sm="24"> | ||
<select v-model="favoriteNodeId" class="el-input__inner"> | ||
<option value="" disabled selected hidden>请选择</option> | ||
<option v-for="(item, index) in favoriteNodes" :key="index" :value="item.id">{{ item.name }}</option> | ||
</select> | ||
</el-col> | ||
<el-col :md="4" :sm="24"> | ||
<el-button | ||
:loading="loading" | ||
size="mini" | ||
style="line-height:20px " | ||
type="primary" | ||
@click="dialogConfirm" | ||
> | ||
{{ this.$t('common.Confirm') }} | ||
</el-button> | ||
</el-col> | ||
</el-row> | ||
</Dialog> | ||
</template> | ||
|
||
<script> | ||
import Dialog from '@/components/Dialog/index.vue' | ||
export default { | ||
name: 'FavoriteAssetDialog', | ||
components: { | ||
Dialog | ||
}, | ||
props: { | ||
visible: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
loading: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
cell: { | ||
type: String, | ||
default: '' | ||
}, | ||
allFavorites: { | ||
type: Array, | ||
default: () => [] | ||
} | ||
}, | ||
data() { | ||
return { | ||
favoriteNodeId: '', | ||
favoriteNodes: [] | ||
} | ||
}, | ||
computed: { | ||
iVisible: { | ||
get() { | ||
return this.visible | ||
}, | ||
set(val) { | ||
this.$emit('update:visible', val) | ||
} | ||
} | ||
}, | ||
mounted() { | ||
this.getAllFavoriteNodes() | ||
}, | ||
methods: { | ||
getAllFavoriteNodes() { | ||
this.$axios.get('/api/v1/assets/favorite-nodes/').then(resp => { | ||
this.favoriteNodes = resp | ||
}) | ||
}, | ||
dialogConfirm() { | ||
console.log(this.cell) | ||
console.log(this.favoriteNodeId) | ||
if (this.favoriteNodeId === '') { | ||
return this.$message.error(this.$tc('assets.TestFavoriteNodeErrorMsg')) | ||
} | ||
const data = { asset: this.cell, favoriteNode: this.favoriteNodeId } | ||
const url = '/api/v1/assets/favorite-assets/' | ||
this.$axios.post(url, data).then((res) => { | ||
this.favoriteNodeId = '' | ||
this.allFavorites.push({ asset: this.cell }) | ||
this.$message.success(this.$i18n.t('common.CollectionSucceed')) | ||
}).finally(() => { | ||
this.iVisible = false | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> | ||
|
Oops, something went wrong.