2023-03-02 09:42:41 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="integration-automatic">
|
|
|
|
|
<!-- New installation -->
|
|
|
|
|
<h3 class="integration-install">{{$t('integration.newUpgrade')}}</h3>
|
|
|
|
|
<div class="install-step">
|
|
|
|
|
<div class="step-num">1</div>
|
|
|
|
|
<div class="step-right">
|
|
|
|
|
<h4>{{$t('integration.selectAsset')}}</h4>
|
|
|
|
|
<div class="talon-select">
|
|
|
|
|
<span>{{$t('asset.asset')}}</span>
|
2023-03-07 17:37:48 +08:00
|
|
|
<v-selectpage
|
|
|
|
|
:data="assetList"
|
|
|
|
|
:tb-columns="assetColumns"
|
|
|
|
|
:multiple="false"
|
|
|
|
|
:language="language"
|
|
|
|
|
key-field="id"
|
|
|
|
|
show-field="name"
|
|
|
|
|
:width="640"
|
|
|
|
|
v-model="assetId"
|
|
|
|
|
class="form-control"
|
|
|
|
|
:result-format="resultFormat"
|
|
|
|
|
>
|
|
|
|
|
</v-selectpage>
|
2023-03-02 09:42:41 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="install-step" v-if="loadFinish">
|
|
|
|
|
<div class="step-num">2</div>
|
|
|
|
|
<div class="step-right">
|
|
|
|
|
<h4>{{$t('integration.loginAsset')}}</h4>
|
|
|
|
|
<div class="command-box">
|
|
|
|
|
<el-input :disabled="true" :value="curlUrl" size="small">
|
|
|
|
|
<i slot="suffix" class="nz-icon nz-icon-override" @click="copyUrl(curlUrl)" :title="$t('overall.copyText')"></i>
|
|
|
|
|
</el-input>
|
|
|
|
|
</div>
|
|
|
|
|
<h4 style="margin-top:15px">{{$t('integration.autoRemark')}}</h4>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'integration-automatic',
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
loadFinish: false,
|
|
|
|
|
assetId: '',
|
2023-03-07 17:37:48 +08:00
|
|
|
assetList: [],
|
|
|
|
|
// asset表头
|
|
|
|
|
assetColumns: [
|
|
|
|
|
{ title: 'id', data: 'id' },
|
|
|
|
|
{
|
|
|
|
|
title: this.$t('overall.name'),
|
|
|
|
|
data: function (row) {
|
|
|
|
|
if (row.name.length > 15) {
|
|
|
|
|
return row.name.substring(0, 12) + '...'
|
|
|
|
|
}
|
|
|
|
|
return row.name
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ title: 'Manage Ip', data: 'manageIp' },
|
|
|
|
|
{
|
|
|
|
|
title: this.$t('overall.type'),
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.type ? row.type.name : ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: this.$t('asset.model'),
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.model ? row.model.name : ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: this.$t('overall.dc'),
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.dc ? row.dc.name : ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2023-03-02 09:42:41 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created () {
|
|
|
|
|
this.getAssetList()
|
|
|
|
|
this.token = localStorage.getItem('nz-token')
|
|
|
|
|
axios.get('/healthy').then(response => {
|
|
|
|
|
const url = response.request.responseURL
|
|
|
|
|
this.ipAddr = url.split('/healthy')[0]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2023-03-07 17:37:48 +08:00
|
|
|
language () { return this.$store.getters.getLanguage },
|
2023-03-02 09:42:41 +08:00
|
|
|
curlUrl () {
|
|
|
|
|
return 'curl -o- -k -H "Authorization:' + this.token + '" ' + this.ipAddr + '/asset/talon/' + this.assetId + '/install.sh | sudo -E bash'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
getAssetList () {
|
|
|
|
|
const params = {
|
|
|
|
|
pageSize: -1
|
|
|
|
|
}
|
|
|
|
|
this.$get('asset/asset', params).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.assetList = response.data.list
|
|
|
|
|
if (this.assetList && this.assetList.length > 0) {
|
2023-03-07 17:37:48 +08:00
|
|
|
this.assetId = String(this.assetList[0].id)
|
2023-03-02 09:42:41 +08:00
|
|
|
this.loadFinish = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-03-07 17:37:48 +08:00
|
|
|
resultFormat (resp) {
|
|
|
|
|
if (resp && resp.data) {
|
|
|
|
|
const assetData = {}
|
|
|
|
|
assetData.list = resp.data.list
|
|
|
|
|
assetData.totalRow = resp.data.total
|
|
|
|
|
return assetData
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-03-02 09:42:41 +08:00
|
|
|
copyUrl (txt) {
|
|
|
|
|
this.$copyText(txt).then(() => {
|
|
|
|
|
this.$message.success({ message: this.$t('overall.copySuccess') })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|