This commit is contained in:
ann 2021-08-03 17:36:24 +08:00
parent 7d4ab2ef6b
commit ff22e55b1a
7 changed files with 190 additions and 61 deletions

View File

@ -3,21 +3,21 @@ import request from '@/utils/request'
// 虚拟机管理-主机列表 // 虚拟机管理-主机列表
export function getVirtualHosts() { export function getVirtualHosts() {
return request({ return request({
url: '/v1/nodes', url: '/virtual/v1/nodes',
method: 'get' method: 'get'
}) })
} }
export function getHostYaml(name) { export function getHostYaml(name) {
return request({ return request({
url: '/v1/nodes/' + name, url: '/virtual/v1/nodes/' + name,
method: 'get' method: 'get'
}) })
} }
export function putHostYaml(name, yaml) { export function putHostYaml(name, yaml) {
return request({ return request({
url: '/v1/nodes/' + name, url: '/virtual/v1/nodes/' + name,
method: 'put', method: 'put',
data: yaml data: yaml
}) })
@ -26,21 +26,21 @@ export function putHostYaml(name, yaml) {
// 虚拟机管理-虚拟机列表 // 虚拟机管理-虚拟机列表
export function getVirtualMachines() { export function getVirtualMachines() {
return request({ return request({
url: '/v1/kubevirt.io.virtualmachines', url: '/virtual/v1/kubevirt.io.virtualmachines',
method: 'get' method: 'get'
}) })
} }
export function getNodeNetworks() { export function getNodeNetworks() {
return request({ return request({
url: '/v1/network.harvesterhci.io.nodenetworks', url: '/virtual/v1/network.harvesterhci.io.nodenetworks',
method: 'get' method: 'get'
}) })
} }
export function getVirtualMachineImage() { export function getVirtualMachineImage() {
return request({ return request({
url: '/v1/harvesterhci.io.virtualmachineimages', url: '/virtual/v1/harvesterhci.io.virtualmachineimages',
method: 'get' method: 'get'
}) })
} }
@ -48,21 +48,24 @@ export function getVirtualMachineImage() {
// 虚拟机管理-卷列表 // 虚拟机管理-卷列表
export function getDataVolume() { export function getDataVolume() {
return request({ return request({
url: '/v1/cdi.kubevirt.io.datavolume', url: '/virtual/v1/cdi.kubevirt.io.datavolume',
method: 'get' method: 'get'
}) })
} }
export function getDataVolumeYaml(name) { export function getDataVolumeYaml(name) {
return request({ return request({
url: '/proxy/apis/cdi.kubevirt.io/v1beta1/namespaces/default/datavolumes/' + name, url: '/virtual/apis/cdi.kubevirt.io/v1beta1/namespaces/default/datavolumes/' + name,
method: 'get' method: 'get',
headers: {
'Accept': 'application/yaml'
}
}) })
} }
export function putDataVolumeYaml(name, yaml) { export function putDataVolumeYaml(name, yaml) {
return request({ return request({
url: '/proxy/apis/cdi.kubevirt.io/v1beta1/namespaces/default/datavolumes/' + name, url: '/virtual/apis/cdi.kubevirt.io/v1beta1/namespaces/default/datavolumes/' + name,
method: 'put', method: 'put',
data: yaml data: yaml
}) })
@ -70,14 +73,14 @@ export function putDataVolumeYaml(name, yaml) {
export function getVirtualMachineYaml(name) { export function getVirtualMachineYaml(name) {
return request({ return request({
url: '/apis/kubevirt.io/v1/namespaces/default/virtualmachines/' + name, url: '/virtual/apis/kubevirt.io/v1/namespaces/default/virtualmachines/' + name,
method: 'get' method: 'get'
}) })
} }
export function putVirtualMachineYaml(name, yaml) { export function putVirtualMachineYaml(name, yaml) {
return request({ return request({
url: '/kubevirt.io/v1/namespaces/default/virtualmachines/' + name, url: '/virtual/kubevirt.io/v1/namespaces/default/virtualmachines/' + name,
method: 'put', method: 'put',
data: yaml data: yaml
}) })
@ -85,14 +88,14 @@ export function putVirtualMachineYaml(name, yaml) {
export function getHostNetwork(name) { export function getHostNetwork(name) {
return request({ return request({
url: '/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan', url: '/virtual/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
method: 'get' method: 'get'
}) })
} }
export function putHostNetwork(name, data) { export function putHostNetwork(name, data) {
return request({ return request({
url: '/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan', url: '/virtual/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
method: 'put', method: 'put',
data: data data: data
}) })
@ -100,7 +103,7 @@ export function putHostNetwork(name, data) {
export function postSSHKey(data) { export function postSSHKey(data) {
return request({ return request({
url: '/v1/harvesterhci.io.keypairs', url: '/virtual/v1/harvesterhci.io.keypairs',
method: 'post', method: 'post',
data: data data: data
}) })

View File

@ -153,21 +153,21 @@ export default {
// 通道hash查询接口 // 通道hash查询接口
getCurrentChannel() { getCurrentChannel() {
return request({ return request({
url: `/apiLedger/curChannel`, url: `/blockChain/apiLedger/curChannel`,
method: 'get' method: 'get'
}) })
}, },
// 通道指标统计查询接口 4个数据 还差2个 // 通道指标统计查询接口 4个数据 还差2个
getStatisticsCount(hash) { getStatisticsCount(hash) {
return request({ return request({
url: `/apiLedger/status/${hash}`, url: `/blockChain/apiLedger/status/${hash}`,
method: 'get' method: 'get'
}) })
}, },
// 块链列表 // 块链列表
getBlockList(hash, query) { getBlockList(hash, query) {
return request({ return request({
url: `/apiLedger/blockAndTxList/${hash}/0`, url: `/blockChain/apiLedger/blockAndTxList/${hash}/0`,
method: 'get', method: 'get',
params: query params: query
}) })
@ -175,17 +175,64 @@ export default {
// 交易列表 // 交易列表
getTradeList(hash) { getTradeList(hash) {
return request({ return request({
url: `/apiLedger/txList/${hash}/0/0`, url: `/blockChain/apiLedger/txList/${hash}/0/0`,
method: 'get' method: 'get'
}) })
}, },
// 交易详情 // 交易详情
getTradeDetail(hash, tradeHash) { getTradeDetail(hash, tradeHash) {
return request({ return request({
url: `/apiLedger/transaction/${hash}/${tradeHash}`, url: `/blockChain/apiLedger/transaction/${hash}/${tradeHash}`,
method: 'get' method: 'get'
}) })
} },
// 函数
createFunction(query) {
return request({
url: '/function/createFunction',
method: 'post',
data: query,
});
},
deleteFunctionByName() {
return request({
url: '/function/delete/functionByName',
method: 'delete',
});
},
deleteFunction(functionId) {
return request({
url: `/function/deleteFunction/${functionId}`,
method: 'delete',
});
},
getFunctionByFunctionName() {
return request({
url: '/function/delete/functionByName',
method: 'get',
});
},
invokeFunction(query) {
return request({
url: '/function/invokeFunction',
method: 'post',
data: query,
});
},
listFunctions(query) {
return request({
url: '/function/lists',
method: 'get',
params: query || { page: 1, size: 10 },
});
},
updateFunction() {
return request({
url: '/function/updateFunction',
method: 'put',
});
},
} }

View File

@ -11,7 +11,7 @@ export function login(data) {
export function harvesterLogin(data) { export function harvesterLogin(data) {
return request({ return request({
url: '/v3-public/localProviders/local?action=login', url: '/virtual/v3-public/localProviders/local?action=login',
method: 'post', method: 'post',
// params: { action: 'login'}, // params: { action: 'login'},
data: data, data: data,
@ -23,7 +23,7 @@ export function harvesterLogin(data) {
export function blockChainLogin(query) { export function blockChainLogin(query) {
return request({ return request({
url: `/authLedger/login`, url: `/blockChain/authLedger/login`,
method: 'post', method: 'post',
data: query, data: query,
headers: { headers: {

View File

@ -18,13 +18,13 @@ const service = axios.create({
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
// do something before request is sent // do something before request is sent
if (store.getters.token && config.url.indexOf('/v1/') !== 0 && config.url.indexOf('apiLedger') === -1) { if (store.getters.token && config.url.indexOf('/virtual/v1/') !== 0 && config.url.indexOf('blockChain/apiLedger') === -1) {
config.headers['Authorization'] = 'Bearer ' + getToken() config.headers['Authorization'] = 'Bearer ' + getToken()
} }
if (config.url.indexOf('apiLedger') !== -1) { if (config.url.indexOf('blockChain/apiLedger') !== -1) {
config.headers['Authorization'] = 'bearer ' + Cookies.get('htoken') config.headers['Authorization'] = 'bearer ' + Cookies.get('htoken')
} }
if (config.url.indexOf('v3-public') !== -1) { if (config.url.indexOf('/virtual/v3-public') !== -1) {
const csrf = Cookies.get('CSRF') const csrf = Cookies.get('CSRF')
if (csrf) { if (csrf) {
config.headers['x-api-csrf'] = csrf config.headers['x-api-csrf'] = csrf
@ -35,7 +35,7 @@ service.interceptors.request.use(
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }
} }
if (config.url.indexOf('/v1/') === 0) { if (config.url.indexOf('/virtual/v1/') === 0) {
config.headers = { config.headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json' 'Accept': 'application/json'

View File

@ -79,11 +79,11 @@
<span>交易</span> <span>交易</span>
</div> </div>
<div v-if="tradeList.length>0" class=""> <div v-if="tradeList.length>0" class="">
<div v-for="i in 5" :key="i" class="blockInfo" @click="getTradeDetail(tradeList[i])"> <div v-for="i in tradeListLength" :key="i" class="blockInfo" @click="getTradeDetail(tradeList[i-1])">
<div class="blockInfoIcon"><svg-icon icon-class="money" /></div> <div class="blockInfoIcon"><svg-icon icon-class="money" /></div>
<span class="time">{{ tradeList[i].createdt }}</span> <span class="time">{{ tradeList[i-1].createdt}}</span>
<span class="title">交易ID</span> <span class="title">交易ID</span>
<span class="info">{{ tradeList[i].txhash }}</span> <span class="info">{{ tradeList[i-1].txhash}}</span>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -105,6 +105,11 @@ export default {
TradeLineChart, TradeLineChart,
FormData FormData
}, },
computed: {
tradeListLength() {
return this.tradeList.length >= 5 ? 5 : this.tradeList.length
}
},
data() { data() {
return { return {
status: { status: {

View File

@ -1,12 +1,12 @@
<template> <template>
<div> <div class="cloudComputation">
<el-card class="basicInfo" shadow="never"> <el-card class="basicInfo" shadow="never">
<img src="@/assets/img/pod.png" class="sidebar-logo" alt="容器组"> <img src="@/assets/img/pod.png" class="sidebar-logo" alt="容器组">
<h4>函数</h4> <h4>函数</h4>
<span class="tips" /> <span class="tips" />
</el-card> </el-card>
<el-card shadow="never"> <el-card shadow="never">
<el-button style="margin-top:30px" @click="dialogCreateVisible=true">创建函数</el-button> <el-button style="margin-top:30px" type="primary" @click="dialogCreateVisible=true">创建函数</el-button>
<el-row :gutter="30"> <el-row :gutter="30">
<el-col v-for="(item,index) in functionList" :key="index" :span="6"> <el-col v-for="(item,index) in functionList" :key="index" :span="6">
<el-card class="functionCard"> <el-card class="functionCard">
@ -202,7 +202,7 @@ export default {
} }
}, },
mounted() { mounted() {
// this.getList() this.getList()
}, },
methods: { methods: {
currentChange(e) { currentChange(e) {
@ -239,17 +239,17 @@ export default {
}) })
}, },
getList() { getList() {
// const query = { const query = {
// page: this.page, page: this.page,
// size: this.size size: this.size
// } }
// this.$Api.cloudComputation.listFunctions(query).then((res) => { this.$Api.listFunctions(query).then((res) => {
// this.functionList = res.rows; this.functionList = res.data.rows;
// this.total = res.total; this.total = res.data.total;
// }); });
}, },
deleteFunc(id) { deleteFunc(id) {
this.$Api.cloudComputation.deleteFunction(id).then((res) => { this.$Api.deleteFunction(id).then((res) => {
if (res) { if (res) {
this.$message.success('操作成功') this.$message.success('操作成功')
this.getList() this.getList()
@ -264,11 +264,13 @@ export default {
goDetail(val) { goDetail(val) {
// this.form = val; // this.form = val;
// this.activeName = '2'; // this.activeName = '2';
this.form = val;
this.dialogExecuteVisible = true;
}, },
createFunc() { createFunc() {
// //
const funcForm = { code: { zipFile: this.form.runEnv === 'java8' ? this.fileList[0].code : this.transBase64(this.code) }, ...this.form } const funcForm = { code: { zipFile: this.form.runEnv === 'java8' ? this.fileList[0].code : this.transBase64(this.code) }, ...this.form }
this.$Api.cloudComputation.createFunction(funcForm).then((res) => { this.$Api.createFunction(funcForm).then((res) => {
if (res) { if (res) {
this.$message.success('创建函数成功') this.$message.success('创建函数成功')
this.goDetail(this.form) this.goDetail(this.form)
@ -279,7 +281,7 @@ export default {
return Buffer.from(code).toString('base64') return Buffer.from(code).toString('base64')
}, },
invoke() { invoke() {
this.$Api.cloudComputation.invokeFunction({ functionName: this.form.functionName, jsonObject: this.jsonObject }).then((res) => { this.$Api.invokeFunction({ functionName: this.form.functionName, jsonObject: this.jsonObject }).then((res) => {
if (res) { if (res) {
console.log(res) console.log(res)
this.result = 'hello world' this.result = 'hello world'
@ -293,6 +295,73 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss">
.cloudComputation{
.el-tabs__header{
margin-bottom: 0;
}
.bg-gray{
padding: 20px;
}
.codemirror {
width: 100%;
height: 100%;
margin: 0;
overflow: auto;
}
.funcTable{
margin-bottom: 30px;
border-spacing: 0;
tr{
border-top: 1px solid #ebeef5;
}
tr:last-child(){
border-bottom: 1px solid #ebeef5;
}
td{
width: 16.6%;
padding-left:10px;
border-left: 1px solid #ebeef5;
}
td:last-child(){
border-right: 1px solid #ebeef5;
}
}
.progress{
width: 300px;
margin: 30px auto;
}
.invokeBtn{
margin: 40px auto;
}
}
.functionCard{
margin: 30px auto;
.el-card__body{
padding:0;
padding-bottom: 20px;
text-align: center;
}
.title{
margin:20px;
margin-bottom: 10px;
}
.el-button--text{
line-height: 1.1rem;
}
p{
margin: 10px 20px;
// margin-bottom: 10px;
}
.el-button{
margin:10px;
}
.insideFloatRight {
margin: 0;
padding:0;
float: right;
}
}
</style> </style>

View File

@ -41,18 +41,18 @@ module.exports = {
ws: false, ws: false,
target: 'http://119.45.100.73:30881/', /* Host */ target: 'http://119.45.100.73:30881/', /* Host */
}, },
'^/v1': { // '^/v1': {
ws: false, // ws: false,
secure: false, // secure: false,
changeOrigin: true, // changeOrigin: true,
target: 'https://103.116.78.162:30443/' // target: 'https://103.116.78.162:30443/'
}, // },
'/v3-public': { // '/v3-public': {
ws: false, // ws: false,
secure: false, // secure: false,
changeOrigin: true, // changeOrigin: true,
target: 'https://103.116.78.162:30443/' // target: 'https://103.116.78.162:30443/'
}, // },
'/kapis': { '/kapis': {
// ws: true, // ws: true,
// target: 'http://124.71.196.205:30881/' /* EduCoder */ // target: 'http://124.71.196.205:30881/' /* EduCoder */
@ -68,9 +68,9 @@ module.exports = {
'^/prom': '' '^/prom': ''
} }
}, },
'^/apiLedger': { '^/blockChain': {
ws: false, ws: false,
target: 'http://124.71.195.158:8080/', target: 'http://106.53.150.192/',
changeOrigin: true, changeOrigin: true,
}, },
'^/api/': { '^/api/': {
@ -83,11 +83,16 @@ module.exports = {
target: 'http://119.45.100.73:30881/', /* Host */ target: 'http://119.45.100.73:30881/', /* Host */
// changeOrigin: true, // changeOrigin: true,
}, },
'^/authLedger': { '^/virtual': {
ws: false, ws: false,
target: 'http://124.71.195.158:8080/', target: 'http://106.53.150.192/',
changeOrigin: true, changeOrigin: true,
}, },
'^/function': {
ws: false,
target: 'http://106.53.150.192:8004/',
// changeOrigin: true,
},
'/kapis/terminal.kubesphere.io': { '/kapis/terminal.kubesphere.io': {
ws: true, ws: true,
changeOrigin: true, changeOrigin: true,