From cd968f9cbecb0712433670c5e77173bc48146c77 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Thu, 24 Feb 2022 20:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=AE=E8=AF=A2=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E8=B0=83=E6=95=B4=E7=B3=BB=E7=BB=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/common/ClientConnection.ts | 14 ++ src/common/GlobalData.ts | 11 ++ src/common/Initializer.ts | 24 +++ src/common/RemoteDataExangeProcesser.ts | 94 +++++++++++ src/components/PollingTree.vue | 215 ++++++++++++++++++++++++ src/components/SignalSourceTree.vue | 1 + src/components/SystemSettingDialog.vue | 72 ++++---- src/entities/MultimediaWindowEntity.ts | 2 +- src/entities/PollingEntity.ts | 52 ++++++ src/entities/SignalSourceEntity.ts | 4 + src/entities/WSProtocol.ts | 120 ++++++++++++- src/i18n/zh-CN/index.ts | 1 + src/pages/LeftToolBar.vue | 8 +- src/pages/WallPage.vue | 100 +++++++---- src/store/index.ts | 72 ++++++++ 16 files changed, 719 insertions(+), 73 deletions(-) create mode 100644 src/components/PollingTree.vue create mode 100644 src/entities/PollingEntity.ts diff --git a/package.json b/package.json index c376d76..c48c6e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "media_player_client", - "version": "1.2.3", + "version": "1.2.5", "description": "A Quasar Framework app", "productName": "MediaPlayerClient", "author": "fangxiang ", diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 960bb3b..a81ebc3 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -533,6 +533,10 @@ export default class ClientConnection { this.ws?.send(JSON.stringify(data)); } + public openPolling(data: Protocol.OpenPollingRequestEntity) { + this.ws?.send(JSON.stringify(data)); + } + public focusIn(window_id: number) { this.ws?.send( JSON.stringify( @@ -755,6 +759,16 @@ export default class ClientConnection { } } + public async getPollings() { + try { + return await this.doRpc( + new Protocol.GetPollingsRequestEntity() + ); + } catch (e) { + console.error(e); + } + } + public destory() { if (this.ws) { this.ws.onclose = null; diff --git a/src/common/GlobalData.ts b/src/common/GlobalData.ts index 2e9fe29..5008731 100644 --- a/src/common/GlobalData.ts +++ b/src/common/GlobalData.ts @@ -1,3 +1,4 @@ +import { PollingEntity } from "./../entities/PollingEntity"; import { SessionStorage } from "quasar"; import ApplicationConfigEntity from "src/entities/ApplicationConfigEntity"; import { HttpProtocol } from "src/entities/HttpProtocol"; @@ -76,6 +77,16 @@ export default class GlobalData { this._plans = plans; } + _pollings: PollingEntity[] = []; + + public get pollings() { + return this._pollings; + } + + public set pollings(pollings: PollingEntity[]) { + this._pollings = pollings; + } + constructor() { const url: string | null = SessionStorage.getItem("url"); let name: string | null = SessionStorage.getItem("name"); diff --git a/src/common/Initializer.ts b/src/common/Initializer.ts index bf7a1e7..f699b67 100644 --- a/src/common/Initializer.ts +++ b/src/common/Initializer.ts @@ -31,6 +31,13 @@ export default class Initializer { ?.getPlans()) as Protocol.GetPlansResponseEntity; } + private async getPollings() { + const global_data = GlobalData.getInstance(); + return (await global_data + .getCurrentClient() + ?.getPollings()) as Protocol.GetPollingsResponseEntity; + } + private async initSignalSourceTree() { const options = this.options; const $store = options?.$store; @@ -80,6 +87,22 @@ export default class Initializer { } } + private async initPollingTree() { + const options = this.options; + const $store = options.$store; + if ($store) { + try { + let response = await this.getPollings(); + if (response) { + $store.commit("buildPollingTree", { options, response }); + GlobalData.getInstance().pollings = response.pollings; + } + } catch (e) { + console.error(e); + } + } + } + private async getApplicationConfig() { const global_data = GlobalData.getInstance(); global_data.applicationConfig = ( @@ -136,6 +159,7 @@ export default class Initializer { this.initSignalSourceTree(); this.initModeTree(); this.initPlanTree(); + this.initPollingTree(); this.getCurrentRunningPlan(); this.getWindows(); } diff --git a/src/common/RemoteDataExangeProcesser.ts b/src/common/RemoteDataExangeProcesser.ts index 6a5593e..0ecaefc 100644 --- a/src/common/RemoteDataExangeProcesser.ts +++ b/src/common/RemoteDataExangeProcesser.ts @@ -288,6 +288,100 @@ export default class RemoteDataExangeProcesser { } break; + case Protocol.Commands.kRpcAddPollingGroup: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingAddNotifyEntity; + if (temp) { + GlobalData.getInstance().pollings.push(temp.polling); + $store.commit("addPollingTreeItem", { + parent: temp.polling.group_uuid, + is_group: false, + item_data: temp.polling, + }); + } + } + break; + case Protocol.Commands.kRpcDeletePolling: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingDeleteNotifyEntity; + if (temp) { + let pos = GlobalData.getInstance().pollings.findIndex( + (element) => element && element.uuid == temp.uuid + ); + if (pos != -1) { + GlobalData.getInstance().pollings.splice(pos, 1); + } + $store.commit("deletePollingTreeItem", { + is_group: false, + uuid: temp.uuid, + }); + } + } + break; + case Protocol.Commands.kRpcEditPolling: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingEditNotifyEntity; + if (temp) { + let pos = GlobalData.getInstance().pollings.findIndex( + (element) => element && element.uuid == temp.polling.uuid + ); + if (pos != -1) { + GlobalData.getInstance().pollings[pos] = temp.polling; + } + $store.commit("setPollingTreeItem", { + is_group: false, + item_data: temp.polling, + }); + } + } + break; + case Protocol.Commands.kRpcAddPollingGroup: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingGroupAddNotifyEntity; + if (temp) { + $store.commit("addPollingTreeItem", { + parent: temp.polling_group.parent_uuid, + is_group: true, + item_data: temp.polling_group, + }); + } + } + break; + case Protocol.Commands.kRpcDeletePollingGroup: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingGroupDeleteNotifyEntity; + if (temp) { + $store.commit("deletePollingTreeItem", { + is_group: true, + uuid: temp.uuid, + }); + } + } + break; + case Protocol.Commands.kRpcEditPollingGroup: + { + const temp = JSON.parse( + notify.data + ) as Protocol.PollingGroupEditNotifyEntity; + if (temp) { + $store.commit("setPollingTreeItem", { + is_group: true, + item_data: temp.polling_group, + }); + } + } + break; + case Protocol.Commands.kRpcAddSignalSource: { const temp = JSON.parse( diff --git a/src/components/PollingTree.vue b/src/components/PollingTree.vue new file mode 100644 index 0000000..2a57aa5 --- /dev/null +++ b/src/components/PollingTree.vue @@ -0,0 +1,215 @@ + + + diff --git a/src/components/SignalSourceTree.vue b/src/components/SignalSourceTree.vue index dc646c9..cdc423d 100644 --- a/src/components/SignalSourceTree.vue +++ b/src/components/SignalSourceTree.vue @@ -193,6 +193,7 @@ export default defineComponent({ }, onDragStart(e: DragEvent, node: SignalSourceTreeItemEntity) { e.dataTransfer?.setData("uuid", node.uuid); + e.dataTransfer?.setData("type", "signal_source"); e.dataTransfer?.setData("node_object", JSON.stringify(node)); if (e.dataTransfer) { e.dataTransfer.dropEffect = "move"; diff --git a/src/components/SystemSettingDialog.vue b/src/components/SystemSettingDialog.vue index e887c8b..7e5463d 100644 --- a/src/components/SystemSettingDialog.vue +++ b/src/components/SystemSettingDialog.vue @@ -192,7 +192,7 @@ - + {{ $t("brightness") + ":" }} @@ -213,7 +213,7 @@ /> - + {{ $t("contrast") + ":" }} @@ -234,7 +234,7 @@ /> - + {{ $t("hue") + ":" }} @@ -283,19 +283,6 @@ /> - - {{ - $t("output board resolution") + ":" - }} - - - - @@ -614,6 +601,19 @@ /> + + {{ + $t("output board resolution") + ":" + }} + + + + - element && - element == support_resolutions.current_output_board_resolution - ); - output_board_resolution.value = - val ?? output_board_resolution_options.value[0]; - } - { let val = device_resolution_options.value.find( (element) => @@ -959,6 +939,24 @@ export default defineComponent({ output_board_rotate.value = settings.rotate; output_board_volume.value = settings.volume; output_board_mute.value = settings.mute ? $t.t("on") : $t.t("off"); + + { + output_board_resolution_options.value = []; + for (const item of Object.keys( + settings.output_board_support_resolutions + ).sort()) { + output_board_resolution_options.value.push( + (settings.output_board_support_resolutions as any)[item] + ); + } + + const val = output_board_resolution_options.value.find( + (element) => + element && element == settings.current_output_board_resolution + ); + output_board_resolution.value = + val ?? output_board_resolution_options.value[0]; + } } }; @@ -1027,7 +1025,6 @@ export default defineComponent({ request.brightness = parseInt(brightness.value.toString()); request.contrast = parseInt(contrast.value.toString()); request.hue = parseInt(hue.value.toString()); - request.output_board_resolution = output_board_resolution.value; request.device_resolution = device_resolution.value; request.rotate = parseInt(device_rotate.value.toString()); @@ -1171,6 +1168,7 @@ export default defineComponent({ request.rotate = parseInt(output_board_rotate.value.toString()); request.volume = parseInt(output_board_volume.value.toString()); request.mute = output_board_mute.value == $t.t("on"); + request.output_board_resolution = output_board_resolution.value; let success = false; try { diff --git a/src/entities/MultimediaWindowEntity.ts b/src/entities/MultimediaWindowEntity.ts index 71b50b0..aadfa9d 100644 --- a/src/entities/MultimediaWindowEntity.ts +++ b/src/entities/MultimediaWindowEntity.ts @@ -15,7 +15,7 @@ export class MultimediaWindowEntity extends BaseEntity { playing: boolean = false; play_speed: number = 1; polling: boolean = false; - polling_signal_sources: StringKeyValueEntity[] = []; + polling_uuid: string = ""; } export class WindowOpenNotifyEntity extends MultimediaWindowEntity { diff --git a/src/entities/PollingEntity.ts b/src/entities/PollingEntity.ts new file mode 100644 index 0000000..ae2a71f --- /dev/null +++ b/src/entities/PollingEntity.ts @@ -0,0 +1,52 @@ +import BaseEntity from "./BaseEntity"; +import { StringKeyValueEntity } from "./StringKeyValueEntity"; + +export class PollingEntity extends BaseEntity { + name: string = ""; + group_uuid = ""; + polling_signal_sources: StringKeyValueEntity[] = []; + note: string = ""; + + public static copy(dest: PollingEntity, src?: PollingEntity) { + if (!src) { + src = new PollingEntity(); + } + + dest.uuid = src.uuid; + dest.base_note = src.base_note; + dest.name = src.name; + dest.polling_signal_sources = src.polling_signal_sources; + dest.group_uuid = src.group_uuid; + dest.note = src.note; + } +} + +export class PollingGroupEntity extends BaseEntity { + parent_uuid: string = ""; + name: string = ""; +} + +export class PollingTreeItemEntity { + uuid = ""; + parent = ""; + name = ""; + is_group = false; + children: PollingTreeItemEntity[] = []; + item_data: PollingEntity | null = null; + + constructor( + uuid?: string, + parent?: string, + name?: string, + is_group?: boolean, + item_data?: any, + children?: PollingTreeItemEntity[] + ) { + this.uuid = uuid ?? ""; + this.parent = parent ?? ""; + this.name = name ?? ""; + this.is_group = is_group ?? false; + this.children = children ?? (Array.isArray(children) ? children : []); + this.item_data = item_data; + } +} diff --git a/src/entities/SignalSourceEntity.ts b/src/entities/SignalSourceEntity.ts index 953adfc..3daeef5 100644 --- a/src/entities/SignalSourceEntity.ts +++ b/src/entities/SignalSourceEntity.ts @@ -9,6 +9,8 @@ export class SignalSourceEntity extends BaseEntity { ext_data: string = ""; group_uuid = ""; system_default: boolean = false; + local_file_flag: boolean = false; + note: string = ""; public static copy(dest: SignalSourceEntity, src?: SignalSourceEntity) { if (!src) { @@ -25,6 +27,8 @@ export class SignalSourceEntity extends BaseEntity { dest.ext_data = src.ext_data; dest.group_uuid = src.group_uuid; dest.system_default = src.system_default; + dest.local_file_flag = src.local_file_flag; + dest.note = src.note; } } diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index a0c72ad..01b87cb 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -4,6 +4,7 @@ import ApplicationConfigEntity from "./ApplicationConfigEntity"; import { ModeEntity } from "./ModeEntity"; import { PlanEntity } from "./PlanEntity"; import SubtitleEntity from "./SubtitleEntity"; +import { PollingEntity, PollingGroupEntity } from "./PollingEntity"; export namespace Protocol { export class Commands { @@ -48,6 +49,10 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "RpcGetPlans"; } + public static get kRpcGetPollings() { + return Commands.PROTOCOL_PREFIX + "RpcGetPollings"; + } + public static get kRpcGetApplicationConfig() { return Commands.PROTOCOL_PREFIX + "RpcGetApplicationConfig"; } @@ -63,10 +68,15 @@ export namespace Protocol { public static get kSetWindowGeometry() { return Commands.PROTOCOL_PREFIX + "SetWindowGeometry"; } + public static get kOpenWindow() { return Commands.PROTOCOL_PREFIX + "OpenWindow"; } + public static get kOpenPolling() { + return Commands.PROTOCOL_PREFIX + "OpenPolling"; + } + public static get kCloseWindow() { return Commands.PROTOCOL_PREFIX + "CloseWindow"; } @@ -167,6 +177,30 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "RpcEditPlan"; } + public static get kRpcAddPollingGroup() { + return Commands.PROTOCOL_PREFIX + "RpcAddPollingGroup"; + } + + public static get kRpcDeletePollingGroup() { + return Commands.PROTOCOL_PREFIX + "RpcDeletePollingGroup"; + } + + public static get kRpcEditPollingGroup() { + return Commands.PROTOCOL_PREFIX + "RpcEditPollingGroup"; + } + + public static get kRpcAddPolling() { + return Commands.PROTOCOL_PREFIX + "RpcAddPolling"; + } + + public static get kRpcEditPolling() { + return Commands.PROTOCOL_PREFIX + "RpcEditPolling"; + } + + public static get kRpcDeletePolling() { + return Commands.PROTOCOL_PREFIX + "RpcDeletePolling"; + } + public static get kRunPlan() { return Commands.PROTOCOL_PREFIX + "RunPlan"; } @@ -309,11 +343,13 @@ export namespace Protocol { Commands.kRpcGetSignalSources, Commands.kRpcGetModes, Commands.kRpcGetPlans, + Commands.kRpcGetPollings, Commands.kRpcGetApplicationConfig, Commands.kMoveWindow, Commands.kResizeWindow, Commands.kSetWindowGeometry, Commands.kOpenWindow, + Commands.kOpenPolling, Commands.kCloseWindow, Commands.kTopWindow, Commands.kLowerWindow, @@ -339,6 +375,12 @@ export namespace Protocol { Commands.kRpcAddPlan, Commands.kRpcDeletePlan, Commands.kRpcEditPlan, + Commands.kRpcAddPollingGroup, + Commands.kRpcDeletePollingGroup, + Commands.kRpcEditPollingGroup, + Commands.kRpcAddPolling, + Commands.kRpcEditPolling, + Commands.kRpcDeletePolling, Commands.kSetApplicationConfig, Commands.kRpcGetSubtitle, Commands.kRpcSetSubtitle, @@ -610,6 +652,34 @@ export namespace Protocol { } } + export class OpenPollingRequestEntity extends PacketEntity { + polling_uuid: string = ""; + x: number = 0; + y: number = 0; + width: number = 0; + height: number = 0; + volume: number = 80; + muted: boolean = true; + paused: boolean = false; + play_speed: number = 1; + + constructor( + polling_uuid: string, + x: number, + y: number, + width: number, + height: number + ) { + super(); + this.command = Commands.kOpenPolling; + this.polling_uuid = polling_uuid ?? ""; + this.x = x ?? 0; + this.y = y ?? 0; + this.width = width ?? 0; + this.height = height ?? 0; + } + } + export class WindowCloseNotifyEntity extends PacketEntity { window_id: number = 0; constructor() { @@ -1340,7 +1410,6 @@ export namespace Protocol { hue: number = 100; rotate: number = 0; device_resolution: string = "3840x2160@60"; - output_board_resolution: string = "1920x1080"; constructor(rcp_id?: number) { super(); @@ -1395,8 +1464,6 @@ export namespace Protocol { } export class GetSupportResolutionsResponseEntity extends Protocol.PacketEntity { - output_board_support_resolutions: Object = {}; - current_output_board_resolution: string = ""; device_support_resolutions: Object = {}; current_device_resolution: string = ""; @@ -1425,6 +1492,8 @@ export namespace Protocol { rotate: number = 0; volume: number = 0; mute: boolean = false; + output_board_support_resolutions: Object = {}; + current_output_board_resolution: string = ""; constructor() { super(); @@ -1440,6 +1509,7 @@ export namespace Protocol { rotate: number = 0; volume: number = 0; mute: boolean = false; + output_board_resolution: string = "1920x1080"; constructor(rcp_id?: number) { super(); @@ -1729,4 +1799,48 @@ export namespace Protocol { this.command = Commands.kRpcGetUsbDevices; } } + + export class GetPollingsRequestEntity extends PacketEntity { + timestamp = new Date().getMilliseconds(); + + constructor(rpcid?: number) { + super(); + this.rpc_id = rpcid ?? 0; + this.command = Commands.kRpcGetPollings; + } + } + + export class GetPollingsResponseEntity extends PacketEntity { + pollings: PollingEntity[] = []; + polling_groups: [] = []; + + constructor() { + super(); + this.command = Commands.kRpcGetPollings; + } + } + + export class PollingAddNotifyEntity extends Protocol.PacketEntity { + polling: PollingEntity = new PollingEntity(); + } + + export class PollingDeleteNotifyEntity extends Protocol.PacketEntity { + uuid: string = ""; + } + + export class PollingEditNotifyEntity extends Protocol.PacketEntity { + polling: PollingEntity = new PollingEntity(); + } + + export class PollingGroupAddNotifyEntity extends Protocol.PacketEntity { + polling_group: PollingGroupEntity = new PollingGroupEntity(); + } + + export class PollingGroupDeleteNotifyEntity extends Protocol.PacketEntity { + uuid: string = ""; + } + + export class PollingGroupEditNotifyEntity extends Protocol.PacketEntity { + polling_group: PollingGroupEntity = new PollingGroupEntity(); + } } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 9192c94..b69cd23 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -339,4 +339,5 @@ export default { usb6: "USB6", usb7: "USB7", usb8: "USB8", + polling: "轮询", }; diff --git a/src/pages/LeftToolBar.vue b/src/pages/LeftToolBar.vue index 43ebbc2..bbe347d 100644 --- a/src/pages/LeftToolBar.vue +++ b/src/pages/LeftToolBar.vue @@ -11,7 +11,7 @@ style="color: red" > - + @@ -19,6 +19,9 @@ + + + @@ -27,11 +30,12 @@