Commit 1adcb9f9 authored by 徐一鸣's avatar 徐一鸣

一键部署数据处理

parent d38804f0
...@@ -184,10 +184,10 @@ ...@@ -184,10 +184,10 @@
style="margin-top: 30px;" style="margin-top: 30px;"
></deployment-info> ></deployment-info>
<div class="apass_button step_action"> <div class="apass_button step_action">
<el-button type="primary"> <el-button type="primary" v-if="finallyState === 1">
前往查看 前往查看
</el-button> </el-button>
<el-button type="primary"> <el-button type="primary" v-if="finallyState === 2">
重新部署 重新部署
</el-button> </el-button>
</div> </div>
...@@ -238,7 +238,7 @@ export default { ...@@ -238,7 +238,7 @@ export default {
"v-apaas-code": codes, "v-apaas-code": codes,
}, },
data: () => ({ data: () => ({
step: 0, step: 2,
senior_flag: false, senior_flag: false,
begin_code: "", begin_code: "",
dialogInfo: { dialogInfo: {
...@@ -314,95 +314,8 @@ export default { ...@@ -314,95 +314,8 @@ export default {
}, },
evtUuid: "", evtUuid: "",
evtSource: null, evtSource: null,
listStatus: [], stateList: [],
state: "", finallyState: 0,
text: "",
url: "",
act: 0,
stateList: [
{
name: "获取部署参数",
value: "values",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 1.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "拉取部署文件",
value: "pull-chart",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 2.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "开始部署",
value: "install",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 3.0.0",
"",
"======================================",
],
state: 1,
},
{
name: "部署状态",
value: "deploy-status",
content: [
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
"host: mapvideo.wodcloud.com",
"repository: hub.wodcloud.com/apaas/apaas-mapvideos",
"tag: 4.0.0",
"",
"======================================",
],
state: 2,
},
],
}), }),
methods: { methods: {
get_step_info() { get_step_info() {
...@@ -454,72 +367,124 @@ export default { ...@@ -454,72 +367,124 @@ export default {
this.evtUuid = evtUuid; this.evtUuid = evtUuid;
this.evtSource = evtSource; this.evtSource = evtSource;
evtSource.addEventListener("message", function(e) { let messages = [
if (this.listStatus.map((o) => o.status).indexOf(e.lastEventId) == -1) { {
if (this.listStatus.length) { id: "values",
this.listStatus[this.listStatus.length - 1].success = "success"; type: "message",
} data: {
state: "notes",
data: "======================================",
},
},
{
id: "values",
type: "message",
data: {
state: "notes",
data:
"host: mapvideo.wodcloud.com\nrepository: hub.wodcloud.com/apaas/apaas-mapvideos\ntag: 1.0.0\n",
},
},
{
id: "values",
type: "message",
data: {
state: "notes",
data: "======================================",
},
},
{
id: "pull-chart",
type: "message",
data: {
state: "notes",
data: "正在下载charts文件 apaas-mapvideos-1.0",
},
},
{
id: "pull-chart",
type: "message",
data: {
state: "notes",
data: "下载charts文件apaas-mapvideos-1.0成功",
},
},
{
id: "pull-chart",
type: "message",
data: { state: "notes", data: "正在解压 apaas-ui-1.0.0.tgz" },
},
{
id: "pull-chart",
type: "message",
data: { state: "notes", data: "解压 apaas-ui-1.0.0.tgz 完成" },
},
{
id: "install",
type: "message",
data: {
state: "notes",
data:
"NAME: ram001\nLAST DEPLOYED: Wed Jul 1 16:09:25 2020\nNAMESPACE: test\nSTATUS: DEPLOYED\n\nRESOURCES:\n==\u003e v1/Pod(related)\nNAME READY STATUS RESTARTS AGE\nram001-65c84bfd8d-xmt2k 0/1 ContainerCreating 0 \u003cinvalid\u003e\n\n==\u003e v1/Service\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nram001 ClusterIP 10.3.181.74 \u003cnone\u003e 80/TCP \u003cinvalid\u003e\n\n==\u003e v1beta1/Deployment\nNAME READY UP-TO-DATE AVAILABLE AGE\nram001 0/1 1 0 \u003cinvalid\u003e\n\n==\u003e v1beta1/Ingress\nNAME HOSTS ADDRESS PORTS AGE\nram001 mapvideo.wodcloud.com 80 \u003cinvalid\u003e\n\n\n",
},
},
{
id: "deploy-status",
type: "message",
data: {
state: "success",
data: "在命名空间 test 下部署 ram001 成功!",
},
},
];
this.listStatus.push({ messages.forEach((msg, index) => {
status: e.lastEventId, setTimeout(() => {
success: JSON.parse(e.data).state, this.updateStatus(msg);
data: JSON.parse(e.data).data, }, (index + 1) * 200);
}); });
this.text = this.listStatus[this.listStatus.length - 1].data; evtSource.addEventListener("message", (event) => {
this.text = "<span class='linenum'></span>" + this.text; console.log(event);
this.text = this.text.replace( });
/\n/g, },
"\n<span class='linenum'></span>" updateStatus(event) {
); let names = {
this.text = this.text.replace(/>==>/g, ">>"); values: "获取部署参数",
this.act = this.listStatus.length - 1; "pull-chart": "拉取部署文件",
} else { install: "开始部署",
let i = this.listStatus.map((o) => o.status).indexOf(e.lastEventId); "deploy-status": "部署状态",
let item = this.listStatus[i].data; };
let currentState = this.stateList.find((state) => {
return state.value === event.id;
});
item = item + "\n" + JSON.parse(e.data).data; if (!currentState) {
if (this.stateList.length > 0) {
this.stateList[this.stateList.length - 1].state = 1;
}
this.listStatus[i].data = item; this.stateList.push({
this.text = this.listStatus[this.listStatus.length - 1].data; name: names[event.id],
this.text = "<span class='linenum'></span>" + this.text; value: event.id,
this.text = this.text.replace( content: [],
/\n/g, state: 0,
"\n<span class='linenum'></span>" });
);
this.text = this.text.replace(/>==>/g, ">>");
this.act = this.listStatus.length - 1;
if (JSON.parse(e.data).state != "notes") { currentState = this.stateList[this.stateList.length - 1];
this.listStatus[i].success = JSON.parse(e.data).state; }
}
}
if (JSON.parse(e.data).state == "success") { currentState.content.push(...event.data.data.split("\n"));
this.state = "部署成功!";
this.url = `https://${window.location.host}/apaas/ui/#/pods?namespace=${this.baseInfoForm.namespace}`;
}
for (let i = 0; i < this.listStatus.length; i++) { if (event.id === "deploy-status") {
switch (this.listStatus[i].status) { let finallyState = event.data.state === "success" ? 1 : 2;
case "values": this.finallyState = finallyState;
this.listStatus[i].statusHan = "获取部署参数"; currentState.state = finallyState;
break; } else {
case "pull-chart": if (event.data.state !== "notes") {
this.listStatus[i].statusHan = "拉取部署文件"; currentState.state = 2;
break;
case "install":
this.listStatus[i].statusHan = "开始部署";
break;
case "deploy-status":
this.listStatus[i].statusHan = "部署状态";
break;
default:
this.listStatus[i].statusHan = "其他";
break;
}
} }
}); }
}, },
}, },
created() { created() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment