diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 7e5edda..be5881d 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -932,6 +932,12 @@ export default class ClientConnection { ); } + public restoreDevice(delete_upload: boolean = false) { + this.ws?.send( + JSON.stringify(new Protocol.RestoreDeviceRequestEntity(delete_upload)) + ); + } + public restartDevice(delay_ms?: number) { this.ws?.send( JSON.stringify(new Protocol.RestartDeviceRequestEntity(delay_ms)) diff --git a/src/components/AboutDialog.vue b/src/components/AboutDialog.vue index 3e473ae..69e4044 100644 --- a/src/components/AboutDialog.vue +++ b/src/components/AboutDialog.vue @@ -92,7 +92,13 @@ - +
{{ product_name }} @@ -186,6 +192,51 @@ export default defineComponent({ } } catch {} }, + onRestore() { + $q.dialog({ + title: $t.t("restore"), + message: $t.t( + "are you sure to restore factory settings? the configuration parameters, signal source, mode, and plan will be deleted!" + ), + options: { + type: "checkbox", + model: [], + // inline: true + items: [ + { + label: $t.t("delete upload files ."), + value: "delete_upload", + color: "secondary", + }, + ], + }, + ok: { + label: $t.t("ok"), + noCaps: true, + flat: true, + }, + cancel: { + label: $t.t("cancel"), + noCaps: true, + flat: true, + }, + persistent: true, + }).onOk((data) => { + if (Array.isArray(data)) { + const delete_upload = data.length != 0; + GlobalData.getInstance() + .getCurrentClient() + ?.restoreDevice(delete_upload); + $q.notify({ + color: "positive", + icon: "done", + message: $t.t("send restore command success!"), + position: "top", + timeout: 1500, + }); + } + }); + }, }; }, }); diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 30b7792..e4b4e93 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -2936,4 +2936,18 @@ export namespace Protocol { success = false; } + + export class RestoreDeviceRequestEntity extends PacketEntity { + timestamp = Date.now(); + + delete_upload_dates = false; + constructor(delete_upload_dates = false, rpc_id = 0) { + super(); + + super.command = Commands.kRestoreDevice; + super.flag = PacketEntity.FLAG_REQUEST; + super.rpc_id = rpc_id; + this.delete_upload_dates = delete_upload_dates; + } + } } diff --git a/src/i18n/en-US/index.ts b/src/i18n/en-US/index.ts index a7b2a21..e0b1d19 100644 --- a/src/i18n/en-US/index.ts +++ b/src/i18n/en-US/index.ts @@ -352,4 +352,10 @@ export default { "The detected version does not match, please download the new version!": "The detected version does not match, please download the new version!", "full screen": "Full Screen", + "i have known": "I Have Known", + restore: "Restore", + "send restore command success!": "Send Restore Command Success!", + "delete upload files .": "Delete Upload Files .", + "are you sure to restore factory settings? the configuration parameters, signal source, mode, and plan will be deleted!": + "Are You Sure to Restore Factory Settings? The Configuration Parameters, Signal, Signal Loop, Mode And Mode Plan Will Be Deleted!", }; diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index cfeebf4..760fcd4 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -630,4 +630,8 @@ export default { "检测到的版本不匹配,请下载新版本!", ok: "确定", cancel: "取消", + "send restore command success!": "发送复位指令成功!", + "delete upload files .": "删除上传的文件", + "are you sure to restore factory settings? the configuration parameters, signal source, mode, and plan will be deleted!": + "确定复位吗? 系统配置、信号源、轮询、模式、语言数据将被删除!", };