Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 153e331

Browse files
committed
refactor: instance update config api
1 parent 6e8ee77 commit 153e331

File tree

5 files changed

+66
-143
lines changed

5 files changed

+66
-143
lines changed

src/app/views/InstanceDetail.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,11 @@ Copyright (C) 2022 MCSManager <[email protected]>
500500
</Panel>
501501

502502
<NetworkTip
503-
v-if="instanceInfo.config?.extraServiceConfig"
504-
v-model:visible="networkTip"
503+
ref="networkTip"
505504
:extraServiceConfig="instanceInfo.config.extraServiceConfig"
506-
@submit="saveConfig"
507-
>
508-
</NetworkTip>
505+
:instanceUuid="instanceUuid"
506+
:serviceUuid="serviceUuid"
507+
></NetworkTip>
509508

510509
<!-- 命令助手 -->
511510
<CommandAssist v-model="commandAssistPanel" :result="commandAssistCallback"></CommandAssist>
@@ -599,7 +598,7 @@ export default {
599598
router.go(-1);
600599
},
601600
openNetwork() {
602-
this.networkTip = true;
601+
this.$refs.networkTip.open();
603602
},
604603
instanceTypeChange(type) {
605604
const config = INSTANCE_TYPE_DEF_CONFIG[type];
@@ -637,12 +636,9 @@ export default {
637636
} else {
638637
postData.docker.extraVolumes = [];
639638
}
640-
console.log(this.instanceInfo.config);
641639
if (!this.instanceInfo.config.endTime) postData.endTime = "";
642640
else if (typeof this.instanceInfo.config.endTime === "object")
643641
postData.endTime = this.instanceInfo.config.endTime.toLocaleDateString();
644-
645-
console.log(postData);
646642
await request({
647643
method: "PUT",
648644
url: API_INSTANCE,

src/app/views/Terminal/TermSetting.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ export default {
239239
terminalOption: {
240240
...this.options
241241
},
242-
pingConfig: {},
243-
eventTask: {},
244242
crlf: this.options.crlf,
245243
ie: this.options.ie,
246244
oe: this.options.oe,

src/app/views/Terminal/index.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,14 @@
546546
>
547547
</TermSetting>
548548

549-
<NetworkTip v-model:visible="visibleNetworkTip" :daemonUuid="serviceUuid"></NetworkTip>
549+
<NetworkTip
550+
ref="networkTip"
551+
:extraServiceConfig="instanceInfo.config.extraServiceConfig"
552+
:instanceUuid="instanceUuid"
553+
:serviceUuid="serviceUuid"
554+
>
555+
</NetworkTip>
556+
550557
<DockerInfo
551558
v-if="instanceInfo.config.docker"
552559
ref="dockerInfoDialog"
@@ -997,9 +1004,8 @@ export default {
9971004
url: API_INSTANCE_UPDATE,
9981005
params: { remote_uuid: this.serviceUuid, uuid: this.instanceUuid },
9991006
data: {
1000-
pingConfig: this.pingConfigForm.is ? this.pingConfigForm : {},
1001-
eventTask: this.eventConfigPanel.visible ? this.eventConfigPanel : {},
1002-
terminalOption: {}
1007+
pingConfig: this.pingConfigForm.is ? this.pingConfigForm : null,
1008+
eventTask: this.eventConfigPanel.visible ? this.eventConfigPanel : null
10031009
}
10041010
});
10051011
this.$message({
@@ -1176,6 +1182,10 @@ export default {
11761182
} catch (error) {
11771183
console.error(error);
11781184
// neglect
1185+
} finally {
1186+
if (this.visibleNetworkTip) {
1187+
this.$refs.networkTip.open();
1188+
}
11791189
}
11801190
11811191
// Listen for window change events

src/components/NetworkTip.vue

Lines changed: 46 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<!--
2+
Copyright (C) 2022 MCSManager <[email protected]>
3+
-->
14
<template>
25
<Dialog v-model="v" :cancel="close">
36
<template #title> {{ $t("CommonText.012") }} </template>
@@ -65,12 +68,15 @@
6568
</div>
6669

6770
<div v-if="viewType === 2">
68-
<p class="sub-title-title row-mb">
69-
{{ $t("components.NetworkTip.008") }}
70-
</p>
71-
<p class="sub-title-title">
72-
{{ $t("components.NetworkTip.009") }}
73-
</p>
71+
<div class="row-mb">
72+
<p class="sub-title-title">
73+
{{ $t("components.NetworkTip.008") }}
74+
</p>
75+
<p class="sub-title-title">
76+
{{ $t("components.NetworkTip.009") }}
77+
</p>
78+
</div>
79+
7480
<!-- <p>
7581
{{ $t("CommonText.013") }}
7682
<span class="color-gray" v-if="taskInfo.status == 0"> {{ $t("CommonText.014") }} </span>
@@ -151,35 +157,16 @@
151157
</template>
152158

153159
<script>
154-
// "extraServiceConfig": { "isOpenFrp": false, "openFrpTunnelId": "", "openFrpToken": "" } }
155160
import Dialog from "@/components/Dialog";
156161
import SelectBlock from "@/components/SelectBlock";
157-
// import {
158-
// API_INSTANCE_ASYNC_QUERY,
159-
// API_INSTANCE_ASYNC_STOP,
160-
// API_INSTANCE_ASYNC_TASK
161-
// } from "@/app/service/common";
162162
import { request } from "@/app/service/protocol";
163-
import { API_FORWARD_REQUEST, QUERY_PUBLIC_IP } from "../app/service/common";
163+
import { API_FORWARD_REQUEST, API_INSTANCE_UPDATE, QUERY_PUBLIC_IP } from "../app/service/common";
164164
export default {
165165
components: {
166166
Dialog,
167167
SelectBlock
168168
},
169-
props: {
170-
visible: {
171-
type: Boolean,
172-
default: false
173-
},
174-
daemonUuid: {
175-
type: String,
176-
default: ""
177-
},
178-
extraServiceConfig: {
179-
type: Object,
180-
default: () => {}
181-
}
182-
},
169+
props: ["serviceUuid", "instanceUuid", "extraServiceConfig"],
183170
184171
data() {
185172
return {
@@ -188,13 +175,12 @@ export default {
188175
ipv4: "",
189176
indexCode: "",
190177
tunnelId: "",
191-
config: {},
178+
// config: {},
192179
taskInfo: {
193180
status: 0,
194181
taskId: "--",
195182
ip: ""
196-
},
197-
timeTask: null
183+
}
198184
};
199185
},
200186
@@ -205,17 +191,9 @@ export default {
205191
206192
isFromTerminal() {
207193
const r = this.$route.query.network_tip ? true : false;
208-
209194
return r;
210195
}
211196
},
212-
watch: {
213-
visible(n) {
214-
this.v = n;
215-
this.config = this.extraServiceConfig;
216-
if (n) this.init();
217-
}
218-
},
219197
220198
methods: {
221199
async getPublicIP() {
@@ -233,117 +211,58 @@ export default {
233211
}
234212
},
235213
236-
clearIntervalTask() {
237-
if (this.timeTask) clearInterval(this.timeTask);
238-
},
239-
240214
init() {
241-
this.clearIntervalTask();
242215
this.getPublicIP();
243216
},
244217
245-
show() {
246-
this.$emit("update:visible", true);
218+
open() {
219+
this.init();
220+
this.v = true;
247221
},
248222
249223
close() {
250-
this.$emit("update:visible", false);
224+
this.v = false;
251225
this.clearIntervalTask();
252226
this.viewType = 0;
253227
},
254228
255229
select(type) {
230+
console.log("extraServiceConfig", this.extraServiceConfig);
231+
this.config = this.extraServiceConfig;
256232
this.viewType = type;
257233
},
258234
259-
saveConfig() {
235+
async saveConfig() {
260236
this.$emit("submit", this.config);
237+
await this.updateFrpConfig();
261238
this.close();
262-
}
263-
264-
// async startHiPer() {
265-
// if (!this.indexCode) {
266-
// return this.$message({
267-
// message: window.$t("components.NetworkTip.015"),
268-
// type: "error"
269-
// });
270-
// }
271-
272-
// try {
273-
// await request({
274-
// method: "POST",
275-
// url: API_INSTANCE_ASYNC_TASK,
276-
// params: {
277-
// remote_uuid: this.daemonUuid,
278-
// uuid: "-",
279-
// task_name: "hiper"
280-
// },
281-
// data: {
282-
// indexCode: this.indexCode
283-
// }
284-
// });
285-
// this.$message({
286-
// message: this.$t("general.success"),
287-
// type: "success"
288-
// });
289-
// } catch (error) {
290-
// this.$message({
291-
// message: `${this.$t("general.error")}: ${error.message}`,
292-
// type: "error"
293-
// });
294-
// }
295-
// },
296-
297-
// async stopHiPer() {
298-
// try {
299-
// await request({
300-
// method: "POST",
301-
// url: API_INSTANCE_ASYNC_STOP,
302-
// params: {
303-
// remote_uuid: this.daemonUuid,
304-
// uuid: "-",
305-
// task_name: "hiper"
306-
// },
307-
// data: {
308-
// taskId: this.taskInfo.taskId
309-
// }
310-
// });
311-
// this.$message({
312-
// message: this.$t("general.success"),
313-
// type: "success"
314-
// });
315-
// } catch (error) {
316-
// this.$message({
317-
// message: `${this.$t("general.error")}: ${error.message}`,
318-
// type: "error"
319-
// });
320-
// }
321-
// },
322-
323-
// async queryStatus() {
324-
// const taskInfo = await request({
325-
// method: "POST",
326-
// url: API_INSTANCE_ASYNC_QUERY,
327-
// params: {
328-
// remote_uuid: this.daemonUuid,
329-
// uuid: "-",
330-
// task_name: "hiper"
331-
// },
332-
// data: {}
333-
// });
239+
},
334240
335-
// if (taskInfo.length > 0) {
336-
// this.taskInfo = taskInfo[0];
337-
// }
338-
// }
241+
async updateFrpConfig() {
242+
try {
243+
await request({
244+
method: "PUT",
245+
url: API_INSTANCE_UPDATE,
246+
params: { remote_uuid: this.serviceUuid, uuid: this.instanceUuid },
247+
data: {
248+
extraServiceConfig: this.config
249+
}
250+
});
251+
this.$message({
252+
type: "success",
253+
message: this.$t("termSet.setUpdate")
254+
});
255+
} catch (error) {
256+
this.$message({
257+
message: `${this.$t("general.error")}: ${error.message}`,
258+
type: "error"
259+
});
260+
}
261+
}
339262
}
340263
};
341264
</script>
342265

343-
<!--
344-
Copyright (C) 2022 MCSManager <[email protected]>
345-
-->
346-
347266
<style scoped>
348267
.wrapper {
349268
margin: 16px;

src/language/zh_cn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@
11251125
"010": "IP 地址:",
11261126
"011": "访问密钥",
11271127
"012": "密钥是使用 FRP 网络的必备钥匙,您可以点击底部的“获取密钥”来获得。",
1128-
"013": "请输入密钥",
1128+
"013": "请输入密钥,列如:3vz4776d72b28sfw13eefasx9eb01548",
11291129
"014": "注册账号并获取密钥",
11301130
"015": "请填写索引码",
11311131
"016": "Hi~,第一次部署服务器吗?请选择一个网络连接方式吧!",

0 commit comments

Comments
 (0)