注册页面添加中控、输出板选项。

This commit is contained in:
fangxiang 2022-04-27 16:28:34 +08:00
parent f5d80ea5be
commit 61ee7a9ae6
10 changed files with 273 additions and 7 deletions

View File

@ -538,6 +538,22 @@ export default class ClientConnection {
}
}
public async getDeviceAttribute() {
try {
return await this.doRpc<Protocol.GetDeviceAttributeResponseEntity>(
new Protocol.GetDeviceAttributeRequestEntity()
);
} catch (e) {
console.error(e);
}
}
public setDeviceAttribute(attribute: number) {
this.ws?.send(
JSON.stringify(new Protocol.SetDeviceAttributeRequestEntity(attribute))
);
}
public moveWindow(window_id: number, x: number, y: number) {
this.ws?.send(
JSON.stringify(new Protocol.MoveWindowRequestEntity(window_id, x, y))

View File

@ -172,7 +172,21 @@ export default class Initializer {
await Common.waitFor(100);
}
// get device attribute
{
await this.getApplicationConfig();
GlobalData.getInstance()
.getCurrentClient()
?.getDeviceAttribute()
.then((response) => {
if (response && typeof response.attribute != "undefined") {
this.options.$store.commit(
"setDeviceAttribute",
response.attribute
);
}
});
}
this.initSignalSourceTree();
this.initModeTree();

View File

@ -563,6 +563,16 @@ export default class RemoteDataExangeProcesser {
}
}
break;
case Protocol.Commands.kSetDeviceAttribute:
{
const temp = JSON.parse(
notify.data
) as Protocol.SetDeviceAttributeNotifyEntity;
if (temp) {
$store.commit("setDeviceAttribute", temp.attribute);
}
}
break;
}
} catch {}
}

View File

@ -39,8 +39,38 @@
<q-card-section style="max-height: 50vh; width: 35vw" class="scroll">
<q-list>
<q-item>
<q-item-section avatar>{{ $t("function") }}:</q-item-section>
<q-item-section>
<q-btn @click="restartDevice"> Restart </q-btn>
<q-checkbox
v-model="function_output_board"
:label="$t('output board')"
color="cyan"
:loading="loading"
:disable="loading"
/>
</q-item-section>
<q-item-section>
<q-checkbox
v-model="function_center_control"
:label="$t('center control')"
color="cyan"
:loading="loading"
:disable="loading"
/>
</q-item-section>
<q-item-section>
<q-btn
@click="setDeviceAttribute"
:label="$t('commit')"
outline
color="primary"
/>
</q-item-section>
</q-item>
<q-separator />
<q-item>
<q-item-section>
<q-btn @click="restartDevice"> {{ $t("restart") }} </q-btn>
</q-item-section>
</q-item>
</q-list>
@ -65,11 +95,12 @@
<style scoped></style>
<script lang="ts">
import { defineComponent, ref, watch, computed } from "vue";
import { defineComponent, ref, watch, computed, nextTick } from "vue";
import { useStore } from "src/store";
import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import GlobalData from "src/common/GlobalData";
import { Protocol } from "src/entities/WSProtocol";
export default defineComponent({
name: "ComponentAdvancedDebugDialog",
@ -82,20 +113,68 @@ export default defineComponent({
let show_dialog = ref(false);
let loading = ref(false);
const function_center_control = ref(false);
const function_output_board = ref(false);
return {
show_dialog,
loading,
function_center_control,
function_output_board,
showDialog() {
show_dialog.value = true;
setTimeout(async () => {
try {
const response = await GlobalData.getInstance()
.getCurrentClient()
?.getDeviceAttribute();
if (response) {
nextTick(() => {
function_center_control.value =
(response.attribute &
Protocol.EDeviceAttribute.CenterControl) !=
0;
function_output_board.value =
(response.attribute &
Protocol.EDeviceAttribute.OutputBoard) !=
0;
});
}
} catch {}
}, 0);
},
resetData() {
loading.value = false;
function_center_control.value = false;
function_output_board.value = false;
},
restartDevice() {
GlobalData.getInstance().getCurrentClient()?.restartDevice();
},
setDeviceAttribute() {
let attribute = Protocol.EDeviceAttribute.None;
if (function_center_control.value) {
attribute |= Protocol.EDeviceAttribute.CenterControl;
}
if (function_output_board.value) {
attribute |= Protocol.EDeviceAttribute.OutputBoard;
}
GlobalData.getInstance()
.getCurrentClient()
?.setDeviceAttribute(attribute);
$q.notify({
color: "positive",
icon: "done",
message: $t.t("set device function") + $t.t("success") + "!",
position: "top",
timeout: 1500,
});
},
};
},
});

View File

@ -256,6 +256,32 @@
</q-input>
</q-item-section>
</q-item>
<q-item v-if="register_type == 'online'">
<q-item-section avatar class="header_label">
{{ $t("function") }}
</q-item-section>
<q-item-section>
<div class="row q-gutter-sm">
<q-checkbox
v-model="function_output_board"
:label="$t('output board')"
color="cyan"
class="offset-md-1 col"
:loading="loading"
:disable="loading"
/>
<q-checkbox
v-model="function_center_control"
:label="$t('center control')"
color="cyan"
class="offset-md-1 col"
:loading="loading"
:disable="loading"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</q-card-section>
@ -307,6 +333,7 @@ import { useQuasar, copyToClipboard } from "quasar";
import { useI18n } from "vue-i18n";
import GlobalData from "src/common/GlobalData";
import QrcodeVue from "qrcode.vue";
import { Protocol } from "src/entities/WSProtocol";
export default defineComponent({
name: "ComponentRegisterDialog",
@ -331,6 +358,9 @@ export default defineComponent({
const ext_flag = ref(false);
const server_address = ref("");
const function_center_control = ref(false);
const function_output_board = ref(false);
const trial_days = ref(0);
const last_days = ref(0);
const register_date = ref("");
@ -347,6 +377,9 @@ export default defineComponent({
trial_days.value = 0;
register_date.value = "";
last_days.value = 0;
function_center_control.value = false;
function_output_board.value = false;
};
const showDialog = async () => {
@ -389,6 +422,8 @@ export default defineComponent({
licence_file,
select_file_dialog,
server_address,
function_output_board,
function_center_control,
copyToClipboard,
isShow() {
return show_dialog.value;
@ -467,10 +502,10 @@ export default defineComponent({
resolve(false);
}
});
console.log(licence_str);
// console.log(licence_str);
if (requested && licence_str) {
active_code.value = licence_str;
console.log(licence_str);
// console.log(licence_str);
} else {
$q.notify({
color: "negative",
@ -500,6 +535,19 @@ export default defineComponent({
success = response.success;
}
if (success) {
let attribute = Protocol.EDeviceAttribute.None;
if (function_center_control.value) {
attribute |= Protocol.EDeviceAttribute.CenterControl;
}
if (function_output_board.value) {
attribute |= Protocol.EDeviceAttribute.OutputBoard;
}
GlobalData.getInstance()
.getCurrentClient()
?.setDeviceAttribute(attribute);
}
$q.notify({
color: success ? "positive" : "negative",
icon: success ? "done" : "warning",

View File

@ -388,6 +388,12 @@ export namespace Protocol {
public static get kWindowFullScreen() {
return Commands.PROTOCOL_PREFIX + "WindowFullScreen";
}
public static get kSetDeviceAttribute() {
return Commands.PROTOCOL_PREFIX + "SetDeviceAttribute";
}
public static get kRpcGetDeviceAttribute() {
return Commands.PROTOCOL_PREFIX + "RpcGetDeviceAttribute";
}
static _all_commands = new Set([
Commands.kUnKnowCommand,
@ -486,6 +492,8 @@ export namespace Protocol {
Commands.kRpcGetConnectionList,
Commands.kRpcSetConnectionItem,
Commands.kWindowFullScreen,
Commands.kRpcGetDeviceAttribute,
Commands.kSetDeviceAttribute,
]);
public static get AllCommands() {
return this._all_commands;
@ -2463,4 +2471,66 @@ export namespace Protocol {
window_id: number;
full_screen: boolean;
}
export enum EDeviceAttribute {
None_All = 0x0000,
None = 0x0001,
OutputBoard = 0x0002,
CenterControl = 0x0004,
Reserve2 = 0x0008,
Reserve3 = 0x0010,
Reserve4 = 0x0020,
Reserve5 = 0x0040,
Reserve6 = 0x0080,
Reserve7 = 0x0100,
Reserve8 = 0x0200,
Reserve9 = 0x0400,
Reserve10 = 0x0800,
Reserve11 = 0x1000,
Reserve12 = 0x2000,
Reserve13 = 0x4000,
Reserve14 = 0x8000,
All = 0xffff,
}
export class GetDeviceAttributeRequestEntity extends PacketEntity {
constructor(rpc_id = 0) {
super();
super.command = Commands.kRpcGetDeviceAttribute;
super.flag = PacketEntity.FLAG_REQUEST;
super.rpc_id = rpc_id;
}
timestamp = 0;
}
export class GetDeviceAttributeResponseEntity extends PacketEntity {
constructor() {
super();
super.flag = PacketEntity.FLAG_RESPONSE;
}
attribute = 0;
}
export class SetDeviceAttributeRequestEntity extends PacketEntity {
constructor(attribute: number, rpc_id = 0) {
super();
super.command = Commands.kSetDeviceAttribute;
super.flag = PacketEntity.FLAG_REQUEST;
super.rpc_id = rpc_id;
this.attribute = attribute;
}
attribute: number = 0;
}
export class SetDeviceAttributeNotifyEntity extends PacketEntity {
attribute: number = 0;
constructor() {
super();
this.command = Commands.kSetDeviceAttribute;
}
}
}

View File

@ -225,6 +225,7 @@ export default {
contrast: "对比度",
hue: "锐度",
"device resolution": "设备分辨率",
"output board": "输出板",
"output board resolution": "输出板分辨率",
"use ntp": "使用NTP服务器",
"current datetime": "当前日期时间",
@ -492,4 +493,7 @@ export default {
"desktop height": "桌面高度",
px: "像素",
Warning: "警告",
function: "功能",
commit: "提交",
"set device function": "设置设备功能成功",
};

View File

@ -185,7 +185,7 @@
</template>
<script lang="ts">
import { defineComponent, Ref, ref, computed } from "vue";
import { defineComponent, Ref, ref, computed, watch } from "vue";
import { Cookies, SessionStorage, useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import { useStore } from "src/store";

View File

@ -197,6 +197,7 @@
/>
<q-btn
v-if="function_center_control"
stretch
flat
stack
@ -365,7 +366,7 @@
</style>
<script lang="ts">
import { defineComponent, ref, Ref, computed } from "vue";
import { defineComponent, ref, Ref, computed, watch } from "vue";
import { useStore } from "src/store";
import GridSettingDialog from "src/components/GridSettingDialog.vue";
@ -424,6 +425,12 @@ export default defineComponent({
const edge_blending_dialog: Ref<any> = ref(null);
const register_dialog: Ref<any> = ref(null);
const function_center_control = ref(
($store.state.device_attribute &
Protocol.EDeviceAttribute.CenterControl) !=
0
);
let system_run_time = 0;
let system_idle_time = 0;
let current_system_time = 0;
@ -518,11 +525,21 @@ export default defineComponent({
} catch {}
}
);
watch(
() => $store.state.device_attribute,
(value) => {
function_center_control.value =
(value & Protocol.EDeviceAttribute.CenterControl) != 0;
}
);
return {
show_advanced_menu,
plan_running,
edge_blending_dialog,
register_dialog,
function_center_control,
async backupDB() {
let client = GlobalData.getInstance().getCurrentClient();

View File

@ -61,6 +61,7 @@ export interface StateInterface {
pollings: PollingEntity[];
signal_sources: SignalSourceEntity[];
landspace: boolean;
device_attribute: number;
}
// provide typings for `this.$store`
@ -308,6 +309,7 @@ export default store(function (/* { ssrContext } */) {
pollings: [],
signal_sources: [],
landspace: window.innerWidth > window.innerHeight,
device_attribute: 0,
},
mutations: {
@ -319,6 +321,12 @@ export default store(function (/* { ssrContext } */) {
state.landspace = playload;
}
},
setDeviceAttribute(state: StateInterface, playload?: any) {
const num = parseInt(playload);
if (!isNaN(num) && num >= 0) {
state.device_attribute = num;
}
},
setArrayValue(state: StateInterface, playload?: any) {
if (Array.isArray(playload.value)) {
const arr: Array<any> = (<any>state)[playload.name];