取消
@@ -133,7 +179,10 @@
:step="2"
:active-icon="require('@/assets/imgs/progress_ic_bushudata.png')"
>
-
+
前往查看
@@ -160,35 +209,38 @@ import appBuildStep from "@/components/app-build-steps/app-build-step";
import apassDialog from "@/components/apass-dialog";
import codes from "@/components/codes";
var checkNumber = (rule, value, callback) => {
- if (!value) {
- return callback(new Error('不能为空'));
- }
- setTimeout(() => {
- if (new RegExp("^[1-9][0-9]*$").test(value)) {
- callback();
- } else {
- callback(new Error('请输入正整数'))
- }
- });
- };
-var checkName = (rule, value, callback)=>{
+ if (!value) {
+ return callback(new Error("不能为空"));
+ }
+ setTimeout(() => {
+ if (new RegExp("^[1-9][0-9]*$").test(value)) {
+ callback();
+ } else {
+ callback(new Error("请输入正整数"));
+ }
+ });
+};
+var checkName = (rule, value, callback) => {
if (new RegExp("^[a-z]([0-9]||[a-z]||-)*$").test(value)) {
callback();
} else {
- callback(new Error('小写字母开头,可以由小写字母、数字、- 组成'))
+ callback(new Error("小写字母开头,可以由小写字母、数字、- 组成"));
}
-}
+};
+import deploymentInfo from "@/components/deployment-info";
+
export default {
components: {
appBuildSteps,
appBuildStep,
apassDialog,
+ deploymentInfo,
"v-apaas-code": codes,
},
data: () => ({
step: 0,
- senior_flag:false,
- begin_code:'',
+ senior_flag: false,
+ begin_code: "",
dialogInfo: {
title: "",
msg: "",
@@ -198,32 +250,42 @@ export default {
namespace: "",
name: "",
},
- app_set:{
- title:'',
- vision:'',
- memory:'',
- memory_type:1,
- cpu:'',
- watch:0,
- save_memory:'',
- code:''
+ app_set: {
+ title: "",
+ vision: "",
+ memory: "",
+ memory_type: 1,
+ cpu: "",
+ watch: 0,
+ save_memory: "",
+ code: "",
},
- area_options:[
+ area_options: [
{
- name:'12312',
- value:1
- }
+ name: "12312",
+ value: 1,
+ },
+ ],
+ vision_arr: ["1.0.1", "10.1.2", "2.2.3"],
+ save_arr: [
+ "2GI",
+ "4GI",
+ "8GI",
+ "16GI",
+ "32GI",
+ "64GI",
+ "128GI",
+ "256GI",
+ "512GI",
],
- vision_arr:['1.0.1','10.1.2','2.2.3'],
- save_arr:['2GI','4GI','8GI','16GI','32GI','64GI','128GI','256GI','512GI'],
- memory_arr:[
+ memory_arr: [
{
- value:1,
- label:'MI',
+ value: 1,
+ label: "MI",
},
{
- value:2,
- label:'GI',
+ value: 2,
+ label: "GI",
},
],
image_rules: {
@@ -232,56 +294,89 @@ export default {
],
name: [
{ required: true, message: "请输入应用部署名称", trigger: "blur" },
- { validator: checkName, trigger: 'blur' }
+ { validator: checkName, trigger: "blur" },
],
},
app_set_rules: {
- title: [
- { required: true, message: "请输入标题", trigger: "blur" },
- ],
+ title: [{ required: true, message: "请输入标题", trigger: "blur" }],
memory: [
{ required: true, message: "请输入内存", trigger: "blur" },
- { validator: checkNumber, trigger: 'blur' }
+ { validator: checkNumber, trigger: "blur" },
],
cpu: [
{ required: true, message: "请输入cpu", trigger: "blur" },
- { validator: checkNumber, trigger: 'blur' }
+ { validator: checkNumber, trigger: "blur" },
],
vision: [{ required: true, message: "请选择版本号", trigger: "change" }],
- save_memory: [{ required: true, message: "请选择存储容量", trigger: "change" }],
+ save_memory: [
+ { required: true, message: "请选择存储容量", trigger: "change" },
+ ],
},
+ evtUuid: "",
+ evtSource: null,
+ listStatus: [],
+ state: "",
+ text: "",
+ url: "",
+ act: 0,
+ stateList: [
+ {
+ name: "获取部署参数",
+ value: "values",
+ content: "获取部署参数",
+ state: 1,
+ },
+ {
+ name: "拉取部署文件",
+ value: "pull-chart",
+ content: "拉取部署文件",
+ state: 1,
+ },
+ {
+ name: "开始部署",
+ value: "install",
+ content: "开始部署",
+ state: 1,
+ },
+ {
+ name: "部署状态",
+ value: "deploy-status",
+ content: "部署状态",
+ state: 2,
+ },
+ ],
}),
methods: {
- get_step_info(){
+ get_step_info() {
this.$http
.get(`/apaas/hubApi/market/step/${this.$route.params.app_id}`)
.then((response) => {
console.log(JSON.parse(response.data.data));
- })
+ });
},
- deal_code(n){
- if(n){
- this.begin_code = this.app_set.code
- }else{
- this.app_set.code = this.begin_code
+ deal_code(n) {
+ if (n) {
+ this.begin_code = this.app_set.code;
+ } else {
+ this.app_set.code = this.begin_code;
}
- this.senior_flag = false
+ this.senior_flag = false;
},
- sub_yy_form(formName){
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.nextStep()
- } else {
- console.log('error submit!!');
- return false;
- }
- });
+ sub_yy_form(formName) {
+ this.$refs[formName].validate((valid) => {
+ if (valid) {
+ this.nextStep();
+ } else {
+ console.log("error submit!!");
+ return false;
+ }
+ });
},
- openstart(){
- if(this.app_set.watch){
- this.app_set.watch = 0
- }else{
- this.app_set.watch = 1
+ openstart() {
+ if (this.app_set.watch) {
+ this.app_set.watch = 0;
+ } else {
+ this.app_set.watch = 1;
}
},
preStep() {
@@ -290,19 +385,98 @@ export default {
nextStep() {
this.step++;
},
+ getStatus() {
+ let evtUuid = Math.random()
+ .toString(16)
+ .substr(3);
+ let evtSource = new EventSource(
+ `/apaas/hubApi/event/subscribe/deploy/${evtUuid}`
+ );
+
+ this.evtUuid = evtUuid;
+ this.evtSource = evtSource;
+
+ evtSource.addEventListener("message", function(e) {
+ if (this.listStatus.map((o) => o.status).indexOf(e.lastEventId) == -1) {
+ if (this.listStatus.length) {
+ this.listStatus[this.listStatus.length - 1].success = "success";
+ }
+
+ this.listStatus.push({
+ status: e.lastEventId,
+ success: JSON.parse(e.data).state,
+ data: JSON.parse(e.data).data,
+ });
+
+ this.text = this.listStatus[this.listStatus.length - 1].data;
+ this.text = "" + this.text;
+ this.text = this.text.replace(
+ /\n/g,
+ "\n"
+ );
+ this.text = this.text.replace(/>==>/g, ">>");
+ this.act = this.listStatus.length - 1;
+ } else {
+ let i = this.listStatus.map((o) => o.status).indexOf(e.lastEventId);
+ let item = this.listStatus[i].data;
+
+ item = item + "\n" + JSON.parse(e.data).data;
+
+ this.listStatus[i].data = item;
+ this.text = this.listStatus[this.listStatus.length - 1].data;
+ this.text = "" + this.text;
+ this.text = this.text.replace(
+ /\n/g,
+ "\n"
+ );
+ this.text = this.text.replace(/>==>/g, ">>");
+ this.act = this.listStatus.length - 1;
+
+ if (JSON.parse(e.data).state != "notes") {
+ this.listStatus[i].success = JSON.parse(e.data).state;
+ }
+ }
+
+ if (JSON.parse(e.data).state == "success") {
+ this.state = "部署成功!";
+ this.url = `https://${window.location.host}/apaas/ui/#/pods?namespace=${this.baseInfoForm.namespace}`;
+ }
+
+ for (let i = 0; i < this.listStatus.length; i++) {
+ switch (this.listStatus[i].status) {
+ case "values":
+ this.listStatus[i].statusHan = "获取部署参数";
+ break;
+ case "pull-chart":
+ this.listStatus[i].statusHan = "拉取部署文件";
+ break;
+ case "install":
+ this.listStatus[i].statusHan = "开始部署";
+ break;
+ case "deploy-status":
+ this.listStatus[i].statusHan = "部署状态";
+ break;
+ default:
+ this.listStatus[i].statusHan = "其他";
+ break;
+ }
+ }
+ });
+ },
},
created() {
- this.get_step_info()
+ this.getStatus();
+ this.get_step_info();
},
};