forked from JointCloud/JCC-RIP
fix
This commit is contained in:
parent
2ec9f5605a
commit
f4cb190c8d
|
@ -2,6 +2,6 @@
|
|||
ENV = 'development'
|
||||
|
||||
# base api
|
||||
VUE_APP_BASE_API = ''
|
||||
VUE_APP_BASE_API = '/jcc-ks'
|
||||
VUE_APP_FUNCTION_API = ''
|
||||
VUE_APP_PUBLIC_SOURCE_API = ''
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
ENV = 'production'
|
||||
|
||||
# base api
|
||||
VUE_APP_BASE_API = 'prod-api'
|
||||
VUE_APP_BASE_API = '/jcc-ks'
|
||||
VUE_APP_FUNCTION_API = 'apis/v1'
|
||||
VUE_APP_PUBLIC_SOURCE_API = '/monitor'
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 概览统计
|
||||
const virtualPreUrl = '/jcc-vm'
|
||||
export function getDashboardCounts() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/counts',
|
||||
url: virtualPreUrl + '/v1/harvester/counts',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -11,7 +12,7 @@ export function getDashboardCounts() {
|
|||
// 概览事件
|
||||
export function getDashboardEvents() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/events',
|
||||
url: virtualPreUrl + '/v1/harvester/events',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -19,7 +20,7 @@ export function getDashboardEvents() {
|
|||
// 概览info
|
||||
export function getDashboardInfo() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/nodes',
|
||||
url: virtualPreUrl + '/v1/harvester/nodes',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ export function getDashboardInfo() {
|
|||
// 概览获取内存cpu使用量
|
||||
export function getUsageStatus() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/pods',
|
||||
url: virtualPreUrl + '/v1/harvester/pods',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ export function getUsageStatus() {
|
|||
// 概览获取存储数据
|
||||
export function getStorageStatus() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/longhorn.io.nodes',
|
||||
url: virtualPreUrl + '/v1/harvester/longhorn.io.nodes',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -43,7 +44,7 @@ export function getStorageStatus() {
|
|||
// cpu 内存状态获取
|
||||
// export function getUsageStatus() {
|
||||
// return request({
|
||||
// url: '/virtual/v1/metrics.k8s.io.nodes',
|
||||
// url: virtualPreUrl + '/v1/metrics.k8s.io.nodes',
|
||||
// method: 'get'
|
||||
// })
|
||||
// }
|
||||
|
@ -51,7 +52,7 @@ export function getStorageStatus() {
|
|||
// cpu 内存状态获取
|
||||
export function getUsageStatusByName(name) {
|
||||
return request({
|
||||
url: `/virtual/v1/metrics.k8s.io.nodes/${name}`,
|
||||
url: `${virtualPreUrl}/v1/metrics.k8s.io.nodes/${name}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ export function getUsageStatusByName(name) {
|
|||
// 虚拟机管理-主机列表
|
||||
export function getVirtualHosts() {
|
||||
return request({
|
||||
url: '/virtual/v1/nodes',
|
||||
url: virtualPreUrl + '/v1/nodes',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -67,7 +68,7 @@ export function getVirtualHosts() {
|
|||
// 虚拟机管理云设置数据获取
|
||||
export function getConfigMap() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/configmaps',
|
||||
url: virtualPreUrl + '/v1/harvester/configmaps',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ export function getConfigMap() {
|
|||
// http://localhost:9527/virtual/v1/harvester/secrets
|
||||
export function getSecrets() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/secrets',
|
||||
url: virtualPreUrl + '/v1/harvester/secrets',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ export function getSecrets() {
|
|||
// 虚拟机创建 - 卷的密钥提交
|
||||
export function postSecret(namespace, data) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/secrets/' + namespace,
|
||||
url: virtualPreUrl + '/v1/harvester/secrets/' + namespace,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -92,7 +93,7 @@ export function postSecret(namespace, data) {
|
|||
// 密钥修改
|
||||
export function putSecret(namespace, name, data) {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/secrets/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/secrets/${namespace}/${name}`,
|
||||
method: 'pur',
|
||||
data: data
|
||||
})
|
||||
|
@ -102,7 +103,7 @@ export function putSecret(namespace, name, data) {
|
|||
// https://10.105.20.1/v1/harvester/harvesterhci.io.virtualmachinetemplates
|
||||
export function getVMTemplate() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/harvesterhci.io.virtualmachinetemplates',
|
||||
url: virtualPreUrl + '/v1/harvester/harvesterhci.io.virtualmachinetemplates',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ export function getVMTemplate() {
|
|||
// https://10.105.20.1/v1/harvester/harvesterhci.io.virtualmachinetemplateversions
|
||||
export function getVMTemplateVersion() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/harvesterhci.io.virtualmachinetemplateversions',
|
||||
url: virtualPreUrl + '/v1/harvester/harvesterhci.io.virtualmachinetemplateversions',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -122,7 +123,7 @@ export function getVMTemplateVersion() {
|
|||
// https://10.105.20.1/v1/harvester/secrets/clonede
|
||||
export function postVirtualMachine(query) {
|
||||
return request({
|
||||
url: '/virtual/v1/kubevirt.io.virtualmachines',
|
||||
url: virtualPreUrl + '/v1/kubevirt.io.virtualmachines',
|
||||
method: 'post',
|
||||
data: query
|
||||
})
|
||||
|
@ -130,7 +131,7 @@ export function postVirtualMachine(query) {
|
|||
|
||||
export function putVirtualMachine(name, namespace = 'default', query) {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}`,
|
||||
method: 'put',
|
||||
data: query
|
||||
})
|
||||
|
@ -139,7 +140,7 @@ export function putVirtualMachine(name, namespace = 'default', query) {
|
|||
export function getHostYaml(name, isYaml = false) {
|
||||
console.log(isYaml)
|
||||
return request({
|
||||
url: '/virtual/api/v1/nodes/' + name,
|
||||
url: virtualPreUrl + '/api/v1/nodes/' + name,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Accept': isYaml ? 'application/yaml' : 'application/json'
|
||||
|
@ -149,7 +150,7 @@ export function getHostYaml(name, isYaml = false) {
|
|||
|
||||
export function putHostYaml(name, yaml) {
|
||||
return request({
|
||||
url: '/virtual/v1/nodes/' + name,
|
||||
url: virtualPreUrl + '/v1/nodes/' + name,
|
||||
method: 'put',
|
||||
data: yaml
|
||||
})
|
||||
|
@ -158,7 +159,7 @@ export function putHostYaml(name, yaml) {
|
|||
// 虚拟机管理-虚拟机列表
|
||||
export function getVirtualMachines() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/kubevirt.io.virtualmachines',
|
||||
url: virtualPreUrl + '/v1/harvester/kubevirt.io.virtualmachines',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -166,7 +167,7 @@ export function getVirtualMachines() {
|
|||
// 虚拟机管理-虚拟机列表
|
||||
export function getVirtualMachinesInstances() {
|
||||
return request({
|
||||
url: '/virtual/v1/kubevirt.io.virtualmachineinstances',
|
||||
url: virtualPreUrl + '/v1/kubevirt.io.virtualmachineinstances',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -174,14 +175,14 @@ export function getVirtualMachinesInstances() {
|
|||
// 主机详情-网络
|
||||
export function getNodeNetworks() {
|
||||
return request({
|
||||
url: '/virtual/v1/network.harvesterhci.io.nodenetworks',
|
||||
url: virtualPreUrl + '/v1/network.harvesterhci.io.nodenetworks',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getVirtualMachineImage() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvesterhci.io.virtualmachineimages',
|
||||
url: virtualPreUrl + '/v1/harvesterhci.io.virtualmachineimages',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -189,7 +190,7 @@ export function getVirtualMachineImage() {
|
|||
// 虚拟机管理-卷列表
|
||||
// export function getDataVolume() {
|
||||
// return request({
|
||||
// url: '/virtual/v1/cdi.kubevirt.io.datavolume',
|
||||
// url: virtualPreUrl + '/v1/cdi.kubevirt.io.datavolume',
|
||||
// method: 'get'
|
||||
// })
|
||||
// }
|
||||
|
@ -197,14 +198,14 @@ export function getVirtualMachineImage() {
|
|||
// 虚拟机管理-卷列表 新
|
||||
export function getDataVolumeNew() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/persistentvolumeclaims',
|
||||
url: virtualPreUrl + '/v1/harvester/persistentvolumeclaims',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getDataVolumeYaml(name, isYaml = false, namespace = 'default') {
|
||||
return request({
|
||||
url: '/virtual/api/v1/namespaces/' + namespace + '/persistentvolumeclaims/' + name,
|
||||
url: virtualPreUrl + '/api/v1/namespaces/' + namespace + '/persistentvolumeclaims/' + name,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Accept': isYaml ? 'application/yaml' : 'application/json'
|
||||
|
@ -214,7 +215,7 @@ export function getDataVolumeYaml(name, isYaml = false, namespace = 'default') {
|
|||
|
||||
export function putDataVolumeYaml(name, yaml, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
method: 'put',
|
||||
data: yaml
|
||||
})
|
||||
|
@ -222,14 +223,14 @@ export function putDataVolumeYaml(name, yaml, namespace = 'default') {
|
|||
|
||||
export function editDataVolume(name, data, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function createDataVolume(data) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/persistentvolumeclaims',
|
||||
url: virtualPreUrl + '/v1/harvester/persistentvolumeclaims',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -237,14 +238,14 @@ export function createDataVolume(data) {
|
|||
|
||||
export function deleteDataVolume(name, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/persistentvolumeclaims/${namespace}/${name}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getVirtualMachineYaml(name, isYaml = false, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/apis/kubevirt.io/v1/namespaces/${namespace}/virtualmachines/${name}`,
|
||||
url: `${virtualPreUrl}/apis/kubevirt.io/v1/namespaces/${namespace}/virtualmachines/${name}`,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Accept': isYaml ? 'application/yaml' : 'application/json'
|
||||
|
@ -254,7 +255,7 @@ export function getVirtualMachineYaml(name, isYaml = false, namespace = 'default
|
|||
|
||||
export function putVirtualMachineYaml(name, yaml, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/v1/kubevirt.io.virtualmachines/${namespace}/${name}`,
|
||||
url: `${virtualPreUrl}/v1/kubevirt.io.virtualmachines/${namespace}/${name}`,
|
||||
method: 'put',
|
||||
data: yaml
|
||||
})
|
||||
|
@ -264,7 +265,7 @@ export function putVirtualMachineYaml(name, yaml, namespace = 'default') {
|
|||
// https://10.105.20.1/v1/harvester/k8s.cni.cncf.io.network-attachment-definitions
|
||||
export function getNetworkList() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/k8s.cni.cncf.io.network-attachment-definitions',
|
||||
url: virtualPreUrl + '/v1/harvester/k8s.cni.cncf.io.network-attachment-definitions',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -272,7 +273,7 @@ export function getNetworkList() {
|
|||
// 命名空间 列表
|
||||
export function getNamespaceList() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/namespaces',
|
||||
url: virtualPreUrl + '/v1/harvester/namespaces',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -280,7 +281,7 @@ export function getNamespaceList() {
|
|||
// 命名空间 详情
|
||||
export function getNamespaceYaml(namespace, isYaml = false) {
|
||||
return request({
|
||||
url: '/virtual/api/v1/namespaces/' + namespace,
|
||||
url: virtualPreUrl + '/api/v1/namespaces/' + namespace,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Accept': isYaml ? 'application/yaml' : 'application/json'
|
||||
|
@ -291,7 +292,7 @@ export function getNamespaceYaml(namespace, isYaml = false) {
|
|||
// 修改命名空间
|
||||
export function putNamespaceYaml(namespace, yaml) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/namespaces/' + namespace,
|
||||
url: virtualPreUrl + '/v1/harvester/namespaces/' + namespace,
|
||||
method: 'put',
|
||||
data: yaml
|
||||
})
|
||||
|
@ -300,7 +301,7 @@ export function putNamespaceYaml(namespace, yaml) {
|
|||
// 创建命名空间 https://10.105.20.1/v1/harvester/namespaces
|
||||
export function postNamespace(data) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/namespaces',
|
||||
url: virtualPreUrl + '/v1/harvester/namespaces',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -308,21 +309,21 @@ export function postNamespace(data) {
|
|||
|
||||
export function deleteNamespace(namespace) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/namespaces/' + namespace,
|
||||
url: virtualPreUrl + '/v1/harvester/namespaces/' + namespace,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getHostNetwork(name) {
|
||||
return request({
|
||||
url: '/virtual/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
|
||||
url: virtualPreUrl + '/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function putHostNetwork(name, data) {
|
||||
return request({
|
||||
url: '/virtual/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
|
||||
url: virtualPreUrl + '/v1/network.harvesterhci.io.nodenetworks/harvester-system/' + name + '-vlan',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
|
@ -330,34 +331,34 @@ export function putHostNetwork(name, data) {
|
|||
// 虚拟机管理-镜像列表
|
||||
export function getImages() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvesterhci.io.virtualmachineimages',
|
||||
url: virtualPreUrl + '/v1/harvesterhci.io.virtualmachineimages',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function createImages(data) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/harvesterhci.io.virtualmachineimages',
|
||||
url: virtualPreUrl + '/v1/harvester/harvesterhci.io.virtualmachineimages',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function deleteImage(name, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/harvesterhci.io.virtualmachineimages/${namespace}/` + name,
|
||||
url: `${virtualPreUrl}/v1/harvester/harvesterhci.io.virtualmachineimages/${namespace}/` + name,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
export function editImage(name, data) {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/harvesterhci.io.virtualmachineimages/default/' + name,
|
||||
url: virtualPreUrl + '/v1/harvester/harvesterhci.io.virtualmachineimages/default/' + name,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function getImagesYaml(name, isYaml = false, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`,
|
||||
url: `${virtualPreUrl}/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Accept': isYaml ? 'application/yaml' : 'application/json'
|
||||
|
@ -367,7 +368,7 @@ export function getImagesYaml(name, isYaml = false, namespace = 'default') {
|
|||
|
||||
export function putImagesYaml(name, yaml, namespace = 'default') {
|
||||
return request({
|
||||
url: `/virtual/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`,
|
||||
url: `${virtualPreUrl}/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`,
|
||||
method: 'put',
|
||||
data: yaml
|
||||
})
|
||||
|
@ -405,7 +406,7 @@ export function putHostNetwork(name, data) {
|
|||
|
||||
export function postSSHKey(data, namespace) {
|
||||
return request({
|
||||
url: `/virtual/v1/harvesterhci.io.keypairs/${namespace}`,
|
||||
url: `${virtualPreUrl}/v1/harvesterhci.io.keypairs/${namespace}`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -413,14 +414,14 @@ export function postSSHKey(data, namespace) {
|
|||
|
||||
export function getSSHKey() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvesterhci.io.keypairs',
|
||||
url: virtualPreUrl + '/v1/harvesterhci.io.keypairs',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function createVirtualMachine(data) {
|
||||
return request({
|
||||
url: '/virtual/v1/kubevirt.io.virtualmachines',
|
||||
url: virtualPreUrl + '/v1/kubevirt.io.virtualmachines',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -428,7 +429,7 @@ export function createVirtualMachine(data) {
|
|||
|
||||
export function virtualMachineAction(name, namespace = 'default', action) {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}?action=${action}`,
|
||||
url: `${virtualPreUrl}/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}?action=${action}`,
|
||||
method: 'post',
|
||||
data: {}
|
||||
})
|
||||
|
@ -436,14 +437,14 @@ export function virtualMachineAction(name, namespace = 'default', action) {
|
|||
|
||||
export function hostAction(name, action) {
|
||||
return request({
|
||||
url: '/virtual/v1/nodes/' + name + '?action=' + action,
|
||||
url: virtualPreUrl + '/v1/nodes/' + name + '?action=' + action,
|
||||
method: 'post',
|
||||
data: {}
|
||||
})
|
||||
}
|
||||
|
||||
export function getVirtualNode() {
|
||||
var newUrl = '/virtual/v1/nodes'
|
||||
var newUrl = virtualPreUrl + '/v1/nodes'
|
||||
return request({
|
||||
url: newUrl,
|
||||
method: 'Get'
|
||||
|
@ -452,7 +453,7 @@ export function getVirtualNode() {
|
|||
|
||||
export function moveVirtualNode(id, namespace, data) {
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${id}?action=migrate`,
|
||||
url: `${virtualPreUrl}/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${id}?action=migrate`,
|
||||
method: 'Post',
|
||||
data
|
||||
})
|
||||
|
@ -464,7 +465,7 @@ export function deleteVirtualMachine(name, namespace, diskList) {
|
|||
newUrl += 'removedDisks=' + diskList[i] + '&'
|
||||
}
|
||||
return request({
|
||||
url: `/virtual/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}?${newUrl}propagationPolicy=Foreground`,
|
||||
url: `${virtualPreUrl}/v1/harvester/kubevirt.io.virtualmachines/${namespace}/${name}?${newUrl}propagationPolicy=Foreground`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ export default {
|
|||
|
||||
getVirtualStorage() {
|
||||
return request({
|
||||
url: '/virtual/v1/harvester/longhorn.io.nodes',
|
||||
url: '/jcc-vm/v1/harvester/longhorn.io.nodes',
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
|
@ -515,7 +515,7 @@ export default {
|
|||
// cpu 内存状态获取
|
||||
getUsageStatus() {
|
||||
return request({
|
||||
url: '/virtual/v1/metrics.k8s.io.nodes',
|
||||
url: '/jcc-vm/v1/metrics.k8s.io.nodes',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,26 +12,26 @@ export function login(data) {
|
|||
})
|
||||
}
|
||||
|
||||
export function harvesterLogin(data) {
|
||||
return request({
|
||||
url: '/virtual/v3-public/localProviders/local?action=login',
|
||||
method: 'post',
|
||||
// params: { action: 'login'},
|
||||
data: data,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
}
|
||||
export function harvesterFirstLogin(data) {
|
||||
return request({
|
||||
url: '/virtual/v3-public/authProviders',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
}
|
||||
// export function harvesterLogin(data) {
|
||||
// return request({
|
||||
// url: '/virtual/v3-public/localProviders/local?action=login',
|
||||
// method: 'post',
|
||||
// // params: { action: 'login'},
|
||||
// data: data,
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json;charset=UTF-8'
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// export function harvesterFirstLogin(data) {
|
||||
// return request({
|
||||
// url: '/virtual/v3-public/authProviders',
|
||||
// method: 'get',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json;charset=UTF-8'
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
export function blockChainLogin(query) {
|
||||
return request({
|
||||
|
|
|
@ -3,8 +3,9 @@ import store from './store'
|
|||
import { Message } from 'element-ui'
|
||||
import NProgress from 'nprogress' // progress bar
|
||||
import 'nprogress/nprogress.css' // progress bar style
|
||||
import { getToken } from '@/utils/auth' // get token from cookie
|
||||
import { setToken, getToken } from '@/utils/auth' // get token from cookie
|
||||
import getPageTitle from '@/utils/get-page-title'
|
||||
// import Cookies from 'js-cookie'
|
||||
|
||||
NProgress.configure({ showSpinner: false }) // NProgress Configuration
|
||||
|
||||
|
@ -17,8 +18,13 @@ router.beforeEach(async(to, from, next) => {
|
|||
// set page title
|
||||
document.title = getPageTitle(to.meta.title)
|
||||
|
||||
if (to.query.token) {
|
||||
// Cookies.set('loginToken', to.query.token)
|
||||
setToken(to.query.token)
|
||||
}
|
||||
// determine whether the user has logged in
|
||||
const hasToken = getToken()
|
||||
|
||||
if (hasToken) {
|
||||
if (to.path === '/login') {
|
||||
// if is logged in, redirect to the home page
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { login, harvesterLogin, blockChainLogin } from '@/api/user'
|
||||
// import { login, harvesterLogin, blockChainLogin } from '@/api/user'
|
||||
import { login } from '@/api/permissionManagement'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { resetRouter } from '@/router'
|
||||
|
||||
|
@ -31,42 +32,49 @@ const mutations = {
|
|||
state.routesType = routesType
|
||||
}
|
||||
}
|
||||
function encrypt(salt, str) {
|
||||
return mix(salt, window.btoa(str))
|
||||
}
|
||||
// function encrypt(salt, str) {
|
||||
// return mix(salt, window.btoa(str))
|
||||
// }
|
||||
|
||||
function mix(salt, str) {
|
||||
if (str.length > salt.length) {
|
||||
salt += str.slice(0, str.length - salt.length)
|
||||
}
|
||||
// function mix(salt, str) {
|
||||
// if (str.length > salt.length) {
|
||||
// salt += str.slice(0, str.length - salt.length)
|
||||
// }
|
||||
|
||||
const ret = []
|
||||
const prefix = []
|
||||
for (let i = 0, len = salt.length; i < len; i++) {
|
||||
const tomix = str.length > i ? str.charCodeAt(i) : 64
|
||||
const sum = salt.charCodeAt(i) + tomix
|
||||
prefix.push(sum % 2 === 0 ? '0' : '1')
|
||||
ret.push(String.fromCharCode(Math.floor(sum / 2)))
|
||||
}
|
||||
// const ret = []
|
||||
// const prefix = []
|
||||
// for (let i = 0, len = salt.length; i < len; i++) {
|
||||
// const tomix = str.length > i ? str.charCodeAt(i) : 64
|
||||
// const sum = salt.charCodeAt(i) + tomix
|
||||
// prefix.push(sum % 2 === 0 ? '0' : '1')
|
||||
// ret.push(String.fromCharCode(Math.floor(sum / 2)))
|
||||
// }
|
||||
|
||||
return `${window.btoa(prefix.join(''))}@${ret.join('')}`
|
||||
}
|
||||
// return `${window.btoa(prefix.join(''))}@${ret.join('')}`
|
||||
// }
|
||||
const actions = {
|
||||
// user login
|
||||
login({ commit }, userInfo) {
|
||||
const { username, password } = userInfo
|
||||
return Promise.all([
|
||||
login({ 'username': username.trim(), 'encrypt': encrypt('kubesphere', password) }),
|
||||
harvesterLogin({ 'username': 'admin', 'password': 'xNudt@123456', 'description': 'UI Session', 'responseType': 'cookie', 'ttl': 57600000 }),
|
||||
blockChainLogin({
|
||||
'user': 'exploreradmin',
|
||||
'password': 'exploreradminpw',
|
||||
'network': 'agridepart-network'
|
||||
})]).then(response => {
|
||||
commit('SET_TOKEN', response[2].token)
|
||||
setToken(response[2].token)
|
||||
// Cookies.set('bToken', response[2].token)
|
||||
return login(username, password).then(response => {
|
||||
const data = response.data
|
||||
const tokenStr = data.tokenHead + data.token
|
||||
commit('SET_TOKEN', tokenStr)
|
||||
setToken(tokenStr)
|
||||
console.log(tokenStr)
|
||||
})
|
||||
// return Promise.all([
|
||||
// login({ 'username': username.trim(), 'encrypt': encrypt('kubesphere', password) }),
|
||||
// harvesterLogin({ 'username': 'admin', 'password': 'xNudt@123456', 'description': 'UI Session', 'responseType': 'cookie', 'ttl': 57600000 }),
|
||||
// blockChainLogin({
|
||||
// 'user': 'exploreradmin',
|
||||
// 'password': 'exploreradminpw',
|
||||
// 'network': 'agridepart-network'
|
||||
// })]).then(response => {
|
||||
// commit('SET_TOKEN', response[2].token)
|
||||
// setToken(response[2].token)
|
||||
// // Cookies.set('bToken', response[2].token)
|
||||
// })
|
||||
},
|
||||
|
||||
// get user info
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Cookies from 'js-cookie'
|
||||
|
||||
const TokenKey = 'bToken'
|
||||
const TokenKey = 'loginToken'
|
||||
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
|
|
|
@ -2,7 +2,7 @@ import axios from 'axios'
|
|||
import { Message, MessageBox } from 'element-ui'
|
||||
import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import Cookies from 'js-cookie'
|
||||
// import Cookies from 'js-cookie'
|
||||
|
||||
// create an axios instance
|
||||
const service = axios.create({
|
||||
|
@ -20,8 +20,9 @@ service.interceptors.request.use(
|
|||
// do something before request is sent
|
||||
// kubesphere
|
||||
// Cookies.set('CSRF', '4d2f9a95f8')
|
||||
if (store.getters.token && config.url.indexOf('/virtual/') === -1 && config.url.indexOf('blockChain') === -1 && config.url.indexOf('dockerhub/api') === -1) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||
config.headers['Authorization'] = getToken()
|
||||
if (store.getters.token && config.url.indexOf('/jcc-vm/') === -1 && config.url.indexOf('blockChain') === -1 && config.url.indexOf('dockerhub/api') === -1) {
|
||||
// config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||
// kubesphere删除
|
||||
if (config.method === 'delete') {
|
||||
config.headers['Content-Type'] = 'application/json'
|
||||
|
@ -32,22 +33,22 @@ service.interceptors.request.use(
|
|||
}
|
||||
// 区块链
|
||||
if (config.url.indexOf('blockChain') !== -1) {
|
||||
config.headers['Authorization'] = 'bearer ' + Cookies.get('bToken')
|
||||
// config.headers['Authorization'] = 'bearer ' + Cookies.get('bToken')
|
||||
}
|
||||
// harvester 登陆
|
||||
if (config.url.indexOf('/virtual/') !== -1) {
|
||||
const csrf = Cookies.get('CSRF')
|
||||
if (csrf) {
|
||||
config.headers['x-api-csrf'] = csrf
|
||||
}
|
||||
if (config.url.indexOf('/virtual/') > -1 && config.headers['Accept'] !== 'application/yaml') {
|
||||
if (config.url.indexOf('/jcc-vm/') !== -1) {
|
||||
// const csrf = Cookies.get('CSRF')
|
||||
// if (csrf) {
|
||||
// config.headers['x-api-csrf'] = csrf
|
||||
// }
|
||||
if (config.url.indexOf('/jcc-vm/') > -1 && config.headers['Accept'] !== 'application/yaml') {
|
||||
config.headers['Content-Type'] = 'application/json'
|
||||
config.headers['Accept'] = 'application/json'
|
||||
}
|
||||
}
|
||||
if (config.url.indexOf('jcc-admin') !== -1) {
|
||||
config.headers['Authorization'] = Cookies.get('loginToken')
|
||||
}
|
||||
// if (config.url.indexOf('jcc-admin') !== -1) {
|
||||
// config.headers['Authorization'] = Cookies.get('loginToken')
|
||||
// }
|
||||
// kubesphere 登陆
|
||||
// if (config.url === '/login') {
|
||||
// config.headers = {
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
<script>
|
||||
import { isString } from '@/utils/validate'
|
||||
// import SocialSign from './components/SocialSignin'
|
||||
import Cookies from 'js-cookie'
|
||||
import { harvesterFirstLogin } from '@/api/user'
|
||||
// import Cookies from 'js-cookie'
|
||||
// import { harvesterFirstLogin } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
|
@ -96,8 +96,8 @@ export default {
|
|||
}
|
||||
return {
|
||||
loginForm: {
|
||||
username: 'nudt',
|
||||
password: 'Nudt@123'
|
||||
username: '',
|
||||
password: ''
|
||||
},
|
||||
loginRules: {
|
||||
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
||||
|
@ -164,14 +164,14 @@ export default {
|
|||
this.$refs.loginForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
const csrf = Cookies.get('CSRF')
|
||||
if (!csrf) {
|
||||
harvesterFirstLogin().then(() => {
|
||||
this.login()
|
||||
})
|
||||
} else {
|
||||
this.login()
|
||||
}
|
||||
// const csrf = Cookies.get('CSRF')
|
||||
// if (!csrf) {
|
||||
// harvesterFirstLogin().then(() => {
|
||||
// this.login()
|
||||
// })
|
||||
// } else {
|
||||
this.login()
|
||||
// }
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -37,33 +37,15 @@ module.exports = {
|
|||
errors: true
|
||||
},
|
||||
proxy: {
|
||||
'^/login': {
|
||||
ws: false,
|
||||
target: 'https://10.101.15.6/prod-api/'/* 测试环境 */
|
||||
// target: 'https://jointcloud.net/prod-api/'/* 演示环境 */
|
||||
'/jcc-admin': {
|
||||
target: 'http://10.101.15.6:8000/',
|
||||
secure: false
|
||||
},
|
||||
// '^/v1': {
|
||||
// '^/login': {
|
||||
// ws: false,
|
||||
// secure: false,
|
||||
// changeOrigin: true,
|
||||
// target: 'https://103.116.78.162:30443/'
|
||||
// target: 'https://10.101.15.6/prod-api/'/* 测试环境 */
|
||||
// // target: 'https://jointcloud.net/prod-api/'/* 演示环境 */
|
||||
// },
|
||||
// '/v3-public': {
|
||||
// ws: false,
|
||||
// secure: false,
|
||||
// changeOrigin: true,
|
||||
// target: 'https://103.116.78.162:30443/'
|
||||
// },
|
||||
'/kapis': {
|
||||
// ws: true,
|
||||
// target: 'http://124.71.196.205:30881/' /* EduCoder */
|
||||
// target: 'http://119.3.157.144:30881/', /* KubeX */
|
||||
// target: 'http://10.105.20.3:30880/'/* Host */
|
||||
target: 'https://10.101.15.6/prod-api/'/* 测试环境 */
|
||||
// target: 'https://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
// target: 'http://39.103.233.49:30881/', /* BJ-Member2 */
|
||||
// changeOrigin: true,
|
||||
},
|
||||
'^/dockerhub/api/': {
|
||||
target: 'http://10.105.20.3:30880/'
|
||||
// pathRewrite: {
|
||||
|
@ -71,66 +53,48 @@ module.exports = {
|
|||
// },
|
||||
// secure: false
|
||||
},
|
||||
'^/prom': {
|
||||
ws: false,
|
||||
target: 'http://119.3.157.144:9090/', /* KubeX */
|
||||
pathRewrite: {
|
||||
'^/prom': ''
|
||||
}
|
||||
},
|
||||
'^/blockChain': {
|
||||
ws: false,
|
||||
target: 'https://106.53.150.192/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/api/': {
|
||||
'^/jcc-ks': {
|
||||
ws: false,
|
||||
target: 'https://10.101.15.6/apis', /* 测试环境 */
|
||||
changeOrigin: true,
|
||||
// target: 'http://10.105.20.4:30766'
|
||||
target: 'https://10.101.15.6/prod-api/' /* 测试环境 */
|
||||
// target: 'https://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
secure: false
|
||||
},
|
||||
'^/apis/': {
|
||||
'^/jcc-vm': {
|
||||
ws: false,
|
||||
target: 'https://10.101.15.6/prod-api/' /* 测试环境 */
|
||||
// target: 'https://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
// changeOrigin: true,
|
||||
target: 'https://10.101.15.6/apis', /* 测试环境 */
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/jcc-extend/': {
|
||||
ws: false,
|
||||
target: 'http://10.101.15.6/apis/v1' /* 测试环境 */
|
||||
// target: 'http://10.101.15.6/apis/v1' /* 演示环境 */
|
||||
},
|
||||
'^/virtual': {
|
||||
ws: false,
|
||||
// target: 'https://10.101.15.6/', /* 测试环境 */
|
||||
target: 'https://jointcloud.net/', /* 演示环境 */
|
||||
// target: 'https://10.105.20.1/',
|
||||
target: 'https://10.101.15.6/apis', /* 测试环境 */
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
// pathRewrite: {
|
||||
// '^/virtual': ''
|
||||
// }
|
||||
},
|
||||
'^/jcc-faas-manager': {
|
||||
ws: false,
|
||||
target: 'https://10.101.15.6/apis/v1' /* 测试环境 */
|
||||
// target: 'https://jointcloud.net/apis/v1' /* 演示环境 */
|
||||
// changeOrigin: true,
|
||||
target: 'https://10.101.15.6/apis', /* 测试环境 */
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/jcc-mall': {
|
||||
ws: false,
|
||||
target: 'https://10.101.15.6/apis/v1' /* 测试环境 */
|
||||
// target: 'https://jointcloud.net/apis/v1' /* 演示环境 */
|
||||
// changeOrigin: true,
|
||||
},
|
||||
'/kapis/terminal.kubesphere.io': {
|
||||
ws: true,
|
||||
target: 'https://10.101.15.6/apis', /* 测试环境 */
|
||||
changeOrigin: true,
|
||||
target: 'ws://jointcloud.net/prod-api/' /* 测试环境 */
|
||||
// target: 'ws://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
secure: false
|
||||
},
|
||||
// '/kapis/terminal.kubesphere.io': {
|
||||
// ws: true,
|
||||
// changeOrigin: true,
|
||||
// target: 'ws://jointcloud.net/prod-api/' /* 测试环境 */
|
||||
// // target: 'ws://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
// },
|
||||
'/monitoringscreen/': {
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
|
@ -141,10 +105,6 @@ module.exports = {
|
|||
ws: false,
|
||||
target: 'https://10.101.15.6/' /* 测试环境 */
|
||||
// target: 'https://jointcloud.net/prod-api/' /* 演示环境 */
|
||||
},
|
||||
'/jcc-admin': {
|
||||
target: 'http://10.101.15.6:8000/',
|
||||
secure: false
|
||||
}
|
||||
}
|
||||
// before: require('./mock/mock-server.js')
|
||||
|
|
Loading…
Reference in New Issue