From 2511d6ff9b12cc48834dccc1479f76c3321f57f1 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Sat, 26 Feb 2022 13:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD,=E4=BF=AE=E5=A4=8D=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=BD=AE=E8=AF=A2=E4=B8=8D=E6=9B=B4=E6=96=B0=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 28 ++++- src/common/RemoteDataExangeProcesser.ts | 2 +- src/components/PollingSettingDialog.vue | 30 +++++- src/components/PollingTree.vue | 134 +++++++++++++++++++----- src/entities/WSProtocol.ts | 57 ++++++++++ src/i18n/zh-CN/index.ts | 5 + src/pages/WallPage.vue | 58 +++++----- src/store/index.ts | 1 - 8 files changed, 255 insertions(+), 60 deletions(-) diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 10d2443..f03e1f0 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -1,3 +1,4 @@ +import { PollingEntity } from "./../entities/PollingEntity"; import ReconnectingWebSocket from "reconnecting-websocket"; import NormalWindowRequestEntity from "src/entities/NormalWindowRequestEntity"; import { PlanEntity } from "src/entities/PlanEntity"; @@ -375,6 +376,30 @@ export default class ClientConnection { } } + public async addPolling( + group_uuid: string, + name: string, + datas: StringKeyValueEntity[] + ) { + try { + return await this.doRpc( + new Protocol.AddPollingRequestEntity(0, group_uuid, name, datas, "") + ); + } catch (e) { + console.error(e); + } + } + + public async editPolling(entity: PollingEntity) { + try { + return await this.doRpc( + new Protocol.EditPollingRequestEntity(0, entity) + ); + } catch (e) { + console.error(e); + } + } + public async deletePolling(uuid: string) { try { return await this.doRpc( @@ -745,10 +770,11 @@ export default class ClientConnection { public async setPollingData( window_id: number, + name: string, datas?: StringKeyValueEntity[] ) { return await this.doRpc( - new Protocol.SetPollingDataRequestEntity(window_id, datas) + new Protocol.SetPollingDataRequestEntity(window_id, name, datas) ); } diff --git a/src/common/RemoteDataExangeProcesser.ts b/src/common/RemoteDataExangeProcesser.ts index 0ecaefc..6a2d5e4 100644 --- a/src/common/RemoteDataExangeProcesser.ts +++ b/src/common/RemoteDataExangeProcesser.ts @@ -288,7 +288,7 @@ export default class RemoteDataExangeProcesser { } break; - case Protocol.Commands.kRpcAddPollingGroup: + case Protocol.Commands.kRpcAddPolling: { const temp = JSON.parse( notify.data diff --git a/src/components/PollingSettingDialog.vue b/src/components/PollingSettingDialog.vue index 71b0473..dff2906 100644 --- a/src/components/PollingSettingDialog.vue +++ b/src/components/PollingSettingDialog.vue @@ -40,6 +40,23 @@ + + +
+ {{ $t("polling name") }}: +
+ +
= ref([]); let signals = ref(GlobalData.getInstance().signal_source); + let polling_name = ref(""); const columns = [ { @@ -228,10 +246,11 @@ export default defineComponent({ show_context_menu, target_dom, signals, + polling_name, loga(a: any) { console.log(a); }, - showDialog(options: StringKeyValueEntity[] | null) { + showDialog(name: string, options: StringKeyValueEntity[] | null) { show_dialog.value = true; if (options) { datas.value = []; @@ -239,8 +258,9 @@ export default defineComponent({ datas.value.push(item); } } + polling_name.value = name ?? $t.t("new polling"); }, - showDialogAsync(options: StringKeyValueEntity[] | null) { + showDialogAsync(name: string, options: StringKeyValueEntity[] | null) { return new Promise((resolve) => { if (_resolve) { _resolve(); @@ -255,6 +275,7 @@ export default defineComponent({ } signals.value = GlobalData.getInstance().signal_source; } + polling_name.value = name ?? $t.t("new polling"); }); }, resetData() { @@ -302,7 +323,10 @@ export default defineComponent({ loading.value = true; try { if (_resolve) { - _resolve(datas.value); + _resolve({ + name: polling_name.value, + datas: datas.value, + }); _resolve = null; } show_dialog.value = false; diff --git a/src/components/PollingTree.vue b/src/components/PollingTree.vue index 0ec63c9..0ac2086 100644 --- a/src/components/PollingTree.vue +++ b/src/components/PollingTree.vue @@ -44,31 +44,21 @@ clickable v-close-popup v-ripple - @click=" - $refs.polling_dialog.showDialog({ - type: 1, - data: { uuid: prop.node.uuid }, - }) - " + @click="addPolling($event, prop.node.item_data)" > - {{ $t("add polling item") }} + {{ $t("add polling") }} {{ $t("edit") }} @@ -117,10 +98,11 @@ +