系统设置菜单添加定时任务功能
This commit is contained in:
parent
97c74a0bc3
commit
d47f61302c
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "media_player_client",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "A Quasar Framework app",
|
||||
"productName": "MediaPlayerClient",
|
||||
"author": "fangxiang <fangxiang@cloudview.work>",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -11,6 +11,7 @@ import EventBus, { EventNamesDefine } from "./EventBus";
|
|||
import { EdgeBlendingPoint } from "src/entities/EdgeBlendingEntities";
|
||||
import { ExternalControlTableEntity } from "src/entities/ExternalControlTableEntity";
|
||||
import { SerialPortConfigEntity } from "src/entities/SerialPortConfigEntity";
|
||||
import TimingTaskEntity from "src/entities/TimingTaskEntity";
|
||||
|
||||
class _RpcInfo {
|
||||
send_timestamp: number;
|
||||
|
@ -1004,6 +1005,45 @@ export default class ClientConnection {
|
|||
);
|
||||
}
|
||||
|
||||
public async getTimingTasks() {
|
||||
try {
|
||||
return await this.doRpc<Protocol.GetTimingTasksResponseEntity>(
|
||||
new Protocol.GetTimingTasksRequestEntity()
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async addTimingTask(task: TimingTaskEntity) {
|
||||
try {
|
||||
return await this.doRpc<Protocol.AddTimingTaskResponseEntity>(
|
||||
new Protocol.AddTimingTaskRequestEntity(task)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async editTimingTask(task: TimingTaskEntity) {
|
||||
try {
|
||||
return await this.doRpc<Protocol.EditTimingTaskResponseEntity>(
|
||||
new Protocol.EditTimingTaskRequestEntity(task)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
public async deleteTimingTask(uuid: string) {
|
||||
try {
|
||||
return await this.doRpc<Protocol.DeleteTimingTaskResponseEntity>(
|
||||
new Protocol.DeleteTimingTaskRequestEntity(uuid)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public destory() {
|
||||
if (this.ws) {
|
||||
this.ws.onclose = null;
|
||||
|
|
|
@ -389,55 +389,7 @@ import { useQuasar, date as $date } from "quasar";
|
|||
import { useI18n } from "vue-i18n";
|
||||
import { StringKeyValueEntity } from "src/entities/StringKeyValueEntity";
|
||||
import { PlanEntity } from "src/entities/PlanEntity";
|
||||
|
||||
enum EWeekDays {
|
||||
EWeekNone = 0x00,
|
||||
EWeekMonday = 0x01,
|
||||
EWeekTuesday = 0x02,
|
||||
EWeekWednesday = 0x04,
|
||||
EWeekThursday = 0x08,
|
||||
EWeekFriday = 0x10,
|
||||
EWeekSaturday = 0x20,
|
||||
EWeekSunday = 0x40,
|
||||
|
||||
EWeekAll = EWeekMonday |
|
||||
EWeekTuesday |
|
||||
EWeekWednesday |
|
||||
EWeekThursday |
|
||||
EWeekFriday |
|
||||
EWeekSaturday |
|
||||
EWeekSunday,
|
||||
}
|
||||
|
||||
const _week_days_map = new Map<string, EWeekDays>([
|
||||
["EWeekDays.EWeekNone", EWeekDays.EWeekNone],
|
||||
["EWeekDays.EWeekMonday", EWeekDays.EWeekMonday],
|
||||
["EWeekDays.EWeekTuesday", EWeekDays.EWeekTuesday],
|
||||
["EWeekDays.EWeekWednesday", EWeekDays.EWeekWednesday],
|
||||
["EWeekDays.EWeekThursday", EWeekDays.EWeekThursday],
|
||||
["EWeekDays.EWeekFriday", EWeekDays.EWeekFriday],
|
||||
["EWeekDays.EWeekSaturday", EWeekDays.EWeekSaturday],
|
||||
["EWeekDays.EWeekSunday", EWeekDays.EWeekSunday],
|
||||
["EWeekDays.EWeekAll", EWeekDays.EWeekAll],
|
||||
]);
|
||||
|
||||
const eWeekDaysToStr = (week_days: EWeekDays) => {
|
||||
let ret = "EWeekDays.EWeekNone";
|
||||
_week_days_map.forEach((v, k, m) => {
|
||||
if (v == week_days) {
|
||||
ret = k;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
||||
const getEWeekDays = (str: string) => {
|
||||
try {
|
||||
return _week_days_map.get(str);
|
||||
} catch (e) {
|
||||
return EWeekDays.EWeekNone;
|
||||
}
|
||||
};
|
||||
import { EWeekDays } from "src/entities/EWeekDays";
|
||||
|
||||
const __MIN_DELAY = 10;
|
||||
|
||||
|
|
|
@ -46,19 +46,26 @@
|
|||
align="justify"
|
||||
narrow-indicator
|
||||
class="bg-grey-2 text-teal"
|
||||
@update:model-value="onTabChanged"
|
||||
>
|
||||
<q-tab
|
||||
name="network"
|
||||
:icon="/*language*/ 'img:new_icon/network_setting.png'"
|
||||
icon="img:new_icon/network_setting.png"
|
||||
:label="$t('network setting')"
|
||||
:disable="loading"
|
||||
/>
|
||||
<q-tab
|
||||
name="graphics"
|
||||
:icon="/*picture_in_picture_alt*/ 'img:new_icon/graphics_setting.png'"
|
||||
icon="img:new_icon/graphics_setting.png"
|
||||
:label="$t('graphics setting')"
|
||||
:disable="loading"
|
||||
/>
|
||||
<q-tab
|
||||
name="timing_task"
|
||||
icon="img:new_icon/timing_task.png"
|
||||
:label="$t('timing task')"
|
||||
:disable="loading"
|
||||
/>
|
||||
<q-tab
|
||||
name="other"
|
||||
icon="build"
|
||||
|
@ -399,6 +406,97 @@
|
|||
</q-card>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="timing_task" class="_panel">
|
||||
<q-card class="fit">
|
||||
<q-card-section>
|
||||
<q-form ref="graphics_form" @submit="applyGraphics">
|
||||
<q-list>
|
||||
<div v-for="(item, index) of timing_tasks" :key="index">
|
||||
<q-item clickable>
|
||||
<q-item-section avatar>
|
||||
<q-chip color="teal" text-color="white" icon="alarm">
|
||||
{{ getTaskTypeName(item.task_type) }}
|
||||
</q-chip>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.task_name }}</q-item-label>
|
||||
<q-item-label caption lines="2"
|
||||
><span class="q-mr-md">{{ item.timing_time }}</span>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days & e_week_Days.EWeekMonday
|
||||
"
|
||||
>{{ $t("monday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days & e_week_Days.EWeekTuesday
|
||||
"
|
||||
>{{ $t("tuesday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days &
|
||||
e_week_Days.EWeekWednesday
|
||||
"
|
||||
>{{ $t("wednesday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days &
|
||||
e_week_Days.EWeekThursday
|
||||
"
|
||||
>{{ $t("thursday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days & e_week_Days.EWeekFriday
|
||||
"
|
||||
>{{ $t("friday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days &
|
||||
e_week_Days.EWeekSaturday
|
||||
"
|
||||
>{{ $t("saturday") }}</span
|
||||
>
|
||||
<span
|
||||
class="q-mx-xs"
|
||||
v-if="
|
||||
item.timing_week_days & e_week_Days.EWeekSunday
|
||||
"
|
||||
>{{ $t("sunday") }}</span
|
||||
>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section avatar>
|
||||
<q-btn
|
||||
@click="deleteTimingTask(item)"
|
||||
icon="delete"
|
||||
color="red"
|
||||
flat
|
||||
round
|
||||
>
|
||||
<q-tooltip>
|
||||
{{ $t("delete") }}{{ $t("timing task") }}
|
||||
</q-tooltip>
|
||||
</q-btn>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</div>
|
||||
</q-list>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="other" class="_panel">
|
||||
<q-card class="fit">
|
||||
<q-scroll-area style="height: 55vh">
|
||||
|
@ -792,28 +890,43 @@
|
|||
<q-btn
|
||||
:loading="loading"
|
||||
flat
|
||||
:label="$t('revert and exit')"
|
||||
no-caps
|
||||
:label="tab == 'timing_task' ? $t('exit') : $t('revert and exit')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
/>
|
||||
<q-btn
|
||||
v-if="tab != 'timing_task'"
|
||||
:loading="loading"
|
||||
flat
|
||||
no-caps
|
||||
:label="$t('revert')"
|
||||
color="primary"
|
||||
@click="refresh_all"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="tab != 'timing_task'"
|
||||
:loading="loading"
|
||||
flat
|
||||
no-caps
|
||||
:label="$t('apply')"
|
||||
color="primary"
|
||||
@click="apply"
|
||||
/>
|
||||
<q-btn
|
||||
v-else
|
||||
:loading="loading"
|
||||
flat
|
||||
no-caps
|
||||
:label="$t('add timing task')"
|
||||
color="primary"
|
||||
@click="addTimingTask"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="false"
|
||||
:loading="loading"
|
||||
flat
|
||||
no-caps
|
||||
:label="$t('apply and exit')"
|
||||
color="primary"
|
||||
@click="applyAndExit"
|
||||
|
@ -821,6 +934,8 @@
|
|||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<timing-task-dialog ref="timing_task_dialog" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
@ -854,11 +969,18 @@
|
|||
import { defineComponent, ref, Ref, watch, computed } from "vue";
|
||||
import { useStore } from "src/store";
|
||||
import { useQuasar, SessionStorage } from "quasar";
|
||||
|
||||
import TimingTaskDialog from "src/components/TimingTaskDialog.vue";
|
||||
|
||||
import { useI18n } from "vue-i18n";
|
||||
import GlobalData from "src/common/GlobalData";
|
||||
import { HttpProtocol } from "src/entities/HttpProtocol";
|
||||
import { date } from "quasar";
|
||||
import { Protocol } from "src/entities/WSProtocol";
|
||||
import TimingTaskEntity, {
|
||||
TimingTaskType,
|
||||
} from "src/entities/TimingTaskEntity";
|
||||
import { EWeekDays } from "src/entities/EWeekDays";
|
||||
|
||||
const _time_zones = [
|
||||
"UTC-12(Central Pacific)",
|
||||
|
@ -890,6 +1012,7 @@ const _time_zones = [
|
|||
|
||||
export default defineComponent({
|
||||
name: "ComponentSystemSettingDialog",
|
||||
components: { TimingTaskDialog },
|
||||
|
||||
setup() {
|
||||
let $store = useStore();
|
||||
|
@ -899,6 +1022,8 @@ export default defineComponent({
|
|||
let show_dialog = ref(false);
|
||||
let loading = ref(false);
|
||||
|
||||
const timing_task_dialog: Ref<any> = ref(null);
|
||||
|
||||
let tab = ref("network");
|
||||
|
||||
let auto_ip = ref($t.t("enable"));
|
||||
|
@ -978,6 +1103,7 @@ export default defineComponent({
|
|||
let system_muted = ref($t.t("off"));
|
||||
let system_volume = ref(100);
|
||||
let output_audio_card_options = ref([
|
||||
{ label: $t.t("all"), value: "all" },
|
||||
{ label: "3.5mm", value: "3.5mm" },
|
||||
{ label: "HDMI1", value: "HDMI1" },
|
||||
]);
|
||||
|
@ -1012,6 +1138,8 @@ export default defineComponent({
|
|||
let output_board_volume = ref(100);
|
||||
let output_board_mute = ref($t.t("on"));
|
||||
|
||||
const timing_tasks: Ref<TimingTaskEntity[]> = ref([]);
|
||||
|
||||
const refresh_network = () => {
|
||||
const config = GlobalData.getInstance()?.applicationConfig;
|
||||
if (config) {
|
||||
|
@ -1357,8 +1485,24 @@ export default defineComponent({
|
|||
GlobalData.getInstance().getCurrentClient()?.restoreOutputBoard();
|
||||
};
|
||||
|
||||
const refreshTimingTasks = async () => {
|
||||
try {
|
||||
const response = await GlobalData.getInstance()
|
||||
.getCurrentClient()
|
||||
?.getTimingTasks();
|
||||
if (response) {
|
||||
timing_tasks.value = response.tasks;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
show_dialog,
|
||||
e_week_Days: ref(EWeekDays),
|
||||
timing_task_dialog,
|
||||
timing_tasks,
|
||||
function_output_board_attribute,
|
||||
loading,
|
||||
tab,
|
||||
|
@ -1426,6 +1570,100 @@ export default defineComponent({
|
|||
await apply();
|
||||
show_dialog.value = false;
|
||||
},
|
||||
getTaskTypeName(index: number) {
|
||||
let result = $t.t("unknow");
|
||||
switch (index) {
|
||||
case TimingTaskType.TaskPowerOn:
|
||||
result = $t.t("power on");
|
||||
break;
|
||||
case TimingTaskType.TaskPowerOff:
|
||||
result = $t.t("power off");
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
async addTimingTask() {
|
||||
if (timing_task_dialog.value) {
|
||||
let success = false;
|
||||
try {
|
||||
const result = await timing_task_dialog.value.showDialogAsync();
|
||||
if (result) {
|
||||
const request_param = new TimingTaskEntity();
|
||||
for (const rk of Object.keys(result)) {
|
||||
if ((<any>request_param)[rk] !== undefined) {
|
||||
(<any>request_param)[rk] = result[rk];
|
||||
}
|
||||
}
|
||||
const response = await GlobalData.getInstance()
|
||||
.getCurrentClient()
|
||||
?.addTimingTask(request_param);
|
||||
if (response && response.success) {
|
||||
request_param.uuid = response.uuid;
|
||||
timing_tasks.value.push(request_param);
|
||||
success = true;
|
||||
}
|
||||
} else {
|
||||
// 对话框点击了确定但是返回的数据是空的
|
||||
console.error("addTimingTask result is null!");
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// 对话框点击了取消
|
||||
return;
|
||||
}
|
||||
|
||||
$q.notify({
|
||||
color: success ? "positive" : "negative",
|
||||
icon: success ? "done" : "warning",
|
||||
message:
|
||||
$t.t("add") +
|
||||
$t.t("timing task") +
|
||||
(success ? $t.t("success") : $t.t("fail")) +
|
||||
"!",
|
||||
position: "top",
|
||||
timeout: 2500,
|
||||
});
|
||||
}
|
||||
},
|
||||
async deleteTimingTask(item: TimingTaskEntity) {
|
||||
let success = false;
|
||||
if (item) {
|
||||
try {
|
||||
const response = await GlobalData.getInstance()
|
||||
.getCurrentClient()
|
||||
?.deleteTimingTask(item.uuid);
|
||||
if (response && response.success) {
|
||||
const index = timing_tasks.value.findIndex(
|
||||
(element) => element && element.uuid == item.uuid
|
||||
);
|
||||
if (index != -1) {
|
||||
timing_tasks.value.splice(index, 1);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
$q.notify({
|
||||
color: success ? "positive" : "negative",
|
||||
icon: success ? "done" : "warning",
|
||||
message:
|
||||
$t.t("delete") +
|
||||
$t.t("timing task") +
|
||||
(success ? $t.t("success") : $t.t("fail")) +
|
||||
"!",
|
||||
position: "top",
|
||||
timeout: 2500,
|
||||
});
|
||||
},
|
||||
onTabChanged(value: string) {
|
||||
switch (value) {
|
||||
case "timing_task":
|
||||
refreshTimingTasks();
|
||||
break;
|
||||
}
|
||||
},
|
||||
isIpAddress(str: string) {
|
||||
return (
|
||||
str == "localhost" ||
|
||||
|
|
|
@ -0,0 +1,375 @@
|
|||
<template>
|
||||
<q-dialog
|
||||
persistent
|
||||
v-model="show_dialog"
|
||||
@before-hide="resetData"
|
||||
@keydown="
|
||||
(evt) => {
|
||||
if (!loading && evt.keyCode == 27) {
|
||||
show_dialog = false;
|
||||
}
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 50vw">
|
||||
<q-form @submit="onSubmit">
|
||||
<q-card-section class="q-ma-none q-pa-sm">
|
||||
<div class="row">
|
||||
<div class="col-auto text-h6">
|
||||
{{ type == 1 ? $t("add") : type == 2 ? $t("edit") : $t("view")
|
||||
}}{{ $t("timing task") }}
|
||||
</div>
|
||||
<q-space />
|
||||
<div>
|
||||
<q-btn
|
||||
:loading="loading"
|
||||
flat
|
||||
round
|
||||
icon="close"
|
||||
color="red"
|
||||
v-close-popup
|
||||
>
|
||||
<q-tooltip>
|
||||
{{ $t("close") }}
|
||||
</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-separator />
|
||||
|
||||
<q-card-section style="max-height: 50vh; width: 50vw" class="scroll">
|
||||
<q-list>
|
||||
<q-item>
|
||||
<q-item-section avatar class="width_5_1">{{
|
||||
$t("name") + ":"
|
||||
}}</q-item-section>
|
||||
<q-item-section>
|
||||
<q-input
|
||||
autofocus
|
||||
:loading="loading"
|
||||
:disable="loading"
|
||||
filled
|
||||
v-model="task_name"
|
||||
:hint="$t('please input task name')"
|
||||
lazy-rules
|
||||
:rules="[
|
||||
(val) =>
|
||||
(val && val.length > 0) || $t('Please type something'),
|
||||
]"
|
||||
clearable
|
||||
>
|
||||
</q-input>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item>
|
||||
<q-item-section avatar class="width_5_1"
|
||||
>{{ $t("task type") }}:</q-item-section
|
||||
>
|
||||
<q-item-section>
|
||||
<q-select
|
||||
v-model="timing_type"
|
||||
:loading="loading"
|
||||
:disable="loading"
|
||||
:options="timing_type_options"
|
||||
emit-value
|
||||
map-options
|
||||
/>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item>
|
||||
<q-item-section avatar class="width_5_1">{{
|
||||
$t("time") + ":"
|
||||
}}</q-item-section>
|
||||
<q-item-section>
|
||||
<q-input
|
||||
filled
|
||||
v-model="timing_time"
|
||||
:loading="loading"
|
||||
mask="fulltime"
|
||||
:rules="['fulltime']"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="access_time" class="cursor-pointer">
|
||||
<q-popup-proxy
|
||||
cover
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-time
|
||||
v-model="timing_time"
|
||||
with-seconds
|
||||
format24h
|
||||
now-btn
|
||||
>
|
||||
<div class="row items-center justify-end">
|
||||
<q-btn
|
||||
v-close-popup
|
||||
:label="$t('close')"
|
||||
color="primary"
|
||||
flat
|
||||
/>
|
||||
</div>
|
||||
</q-time>
|
||||
</q-popup-proxy>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item>
|
||||
<q-item-section avatar class="width_5_1">{{
|
||||
$t("loop") + ":"
|
||||
}}</q-item-section>
|
||||
<q-item-section>
|
||||
<div class="row">
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day1" :label="$t('monday')" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day2" :label="$t('tuesday')" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day3" :label="$t('wednesday')" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day4" :label="$t('thursday')" />
|
||||
</q-item-section>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day5" :label="$t('friday')" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day6" :label="$t('saturday')" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-checkbox v-model="day7" :label="$t('sunday')" />
|
||||
</q-item-section>
|
||||
<q-item-section> </q-item-section>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
|
||||
<q-separator />
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
:loading="loading"
|
||||
flat
|
||||
:label="$t('Cancel')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
/>
|
||||
<q-btn
|
||||
ref="accept"
|
||||
flat
|
||||
:label="$t('Accept')"
|
||||
:loading="loading"
|
||||
type="submit"
|
||||
color="primary"
|
||||
/>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.width_5_1 {
|
||||
width: 20%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, watch, computed } from "vue";
|
||||
import { useStore } from "src/store";
|
||||
import GlobalData from "src/common/GlobalData";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { api } from "boot/axios";
|
||||
import { HttpProtocol } from "src/entities/HttpProtocol";
|
||||
import TimingTaskEntity from "src/entities/TimingTaskEntity";
|
||||
import { EWeekDays } from "src/entities/EWeekDays";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ComponentTimingTaskDialog",
|
||||
|
||||
setup() {
|
||||
let $store = useStore();
|
||||
let $q = useQuasar();
|
||||
let $t = useI18n();
|
||||
|
||||
let type = ref(0);
|
||||
|
||||
let show_dialog = ref(false);
|
||||
let loading = ref(false);
|
||||
|
||||
const timing_type_options = ref([
|
||||
{
|
||||
label: $t.t("power on"),
|
||||
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: $t.t("power off"),
|
||||
|
||||
value: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const task_name = ref($t.t("new task"));
|
||||
const timing_type = ref(1);
|
||||
const timing_time = ref("00:09:00");
|
||||
|
||||
let enabled = true;
|
||||
let ext_data = "";
|
||||
|
||||
let day1 = ref(true);
|
||||
let day2 = ref(true);
|
||||
let day3 = ref(true);
|
||||
let day4 = ref(true);
|
||||
let day5 = ref(true);
|
||||
let day6 = ref(true);
|
||||
let day7 = ref(true);
|
||||
|
||||
let _resolve: any = null;
|
||||
let _reject: any = null;
|
||||
|
||||
const clean_promise = () => {
|
||||
try {
|
||||
if (_resolve && typeof _resolve == "function") {
|
||||
_resolve(null);
|
||||
} else if (_reject && typeof _reject == "function") {
|
||||
_reject(null);
|
||||
}
|
||||
_resolve = null;
|
||||
_reject = null;
|
||||
} catch {}
|
||||
};
|
||||
|
||||
return {
|
||||
show_dialog,
|
||||
timing_type_options,
|
||||
timing_type,
|
||||
timing_time,
|
||||
task_name,
|
||||
day1,
|
||||
day2,
|
||||
day3,
|
||||
day4,
|
||||
day5,
|
||||
day6,
|
||||
day7,
|
||||
type,
|
||||
loading,
|
||||
showDialog() {
|
||||
throw "please use showDialogAsync function";
|
||||
},
|
||||
showDialogAsync(_type: number, options: TimingTaskEntity) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clean_promise();
|
||||
|
||||
type.value = _type ?? 1;
|
||||
if (options) {
|
||||
timing_type.value = options.task_type;
|
||||
timing_time.value = options.timing_time;
|
||||
task_name.value = options.task_name;
|
||||
day1.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekMonday) == 0
|
||||
? false
|
||||
: true;
|
||||
day2.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekTuesday) == 0
|
||||
? false
|
||||
: true;
|
||||
day3.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekWednesday) == 0
|
||||
? false
|
||||
: true;
|
||||
day4.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekThursday) == 0
|
||||
? false
|
||||
: true;
|
||||
day5.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekFriday) == 0
|
||||
? false
|
||||
: true;
|
||||
day6.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekSaturday) == 0
|
||||
? false
|
||||
: true;
|
||||
day7.value =
|
||||
(options.timing_week_days & EWeekDays.EWeekSunday) == 0
|
||||
? false
|
||||
: true;
|
||||
}
|
||||
|
||||
_resolve = resolve;
|
||||
_reject = reject;
|
||||
|
||||
show_dialog.value = true;
|
||||
});
|
||||
},
|
||||
resetData() {
|
||||
loading.value = false;
|
||||
timing_type.value = 1;
|
||||
timing_time.value = "00:09:00";
|
||||
task_name.value = $t.t("new task");
|
||||
day1.value = true;
|
||||
day2.value = true;
|
||||
day3.value = true;
|
||||
day4.value = true;
|
||||
day5.value = true;
|
||||
day6.value = true;
|
||||
day7.value = true;
|
||||
|
||||
enabled = true;
|
||||
ext_data = "";
|
||||
|
||||
if (_reject) {
|
||||
try {
|
||||
_reject(null);
|
||||
} catch {}
|
||||
}
|
||||
_resolve = null;
|
||||
_reject = null;
|
||||
},
|
||||
async onSubmit() {
|
||||
loading.value = true;
|
||||
|
||||
const data = new TimingTaskEntity();
|
||||
data.enabled = enabled;
|
||||
data.timing_time = timing_time.value;
|
||||
data.timing_week_days = 0;
|
||||
data.task_name = task_name.value;
|
||||
if (day1.value) data.timing_week_days |= EWeekDays.EWeekMonday;
|
||||
if (day2.value) data.timing_week_days |= EWeekDays.EWeekTuesday;
|
||||
if (day3.value) data.timing_week_days |= EWeekDays.EWeekWednesday;
|
||||
if (day4.value) data.timing_week_days |= EWeekDays.EWeekThursday;
|
||||
if (day5.value) data.timing_week_days |= EWeekDays.EWeekFriday;
|
||||
if (day6.value) data.timing_week_days |= EWeekDays.EWeekSaturday;
|
||||
if (day7.value) data.timing_week_days |= EWeekDays.EWeekSunday;
|
||||
|
||||
data.task_type = timing_type.value;
|
||||
data.ext_data = ext_data;
|
||||
|
||||
if (_resolve) {
|
||||
try {
|
||||
_resolve(data);
|
||||
} catch {}
|
||||
}
|
||||
_resolve = null;
|
||||
_reject = null;
|
||||
loading.value = false;
|
||||
show_dialog.value = false;
|
||||
|
||||
loading.value = false;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,52 @@
|
|||
enum EWeekDays {
|
||||
EWeekNone = 0x00,
|
||||
EWeekMonday = 0x01,
|
||||
EWeekTuesday = 0x02,
|
||||
EWeekWednesday = 0x04,
|
||||
EWeekThursday = 0x08,
|
||||
EWeekFriday = 0x10,
|
||||
EWeekSaturday = 0x20,
|
||||
EWeekSunday = 0x40,
|
||||
|
||||
EWeekAll = EWeekMonday |
|
||||
EWeekTuesday |
|
||||
EWeekWednesday |
|
||||
EWeekThursday |
|
||||
EWeekFriday |
|
||||
EWeekSaturday |
|
||||
EWeekSunday,
|
||||
}
|
||||
|
||||
class EWeekDaysHelper {
|
||||
static _week_days_map = new Map<string, EWeekDays>([
|
||||
["EWeekDays::EWeekNone", EWeekDays.EWeekNone],
|
||||
["EWeekDays::EWeekMonday", EWeekDays.EWeekMonday],
|
||||
["EWeekDays::EWeekTuesday", EWeekDays.EWeekTuesday],
|
||||
["EWeekDays::EWeekWednesday", EWeekDays.EWeekWednesday],
|
||||
["EWeekDays::EWeekThursday", EWeekDays.EWeekThursday],
|
||||
["EWeekDays::EWeekFriday", EWeekDays.EWeekFriday],
|
||||
["EWeekDays::EWeekSaturday", EWeekDays.EWeekSaturday],
|
||||
["EWeekDays::EWeekSunday", EWeekDays.EWeekSunday],
|
||||
["EWeekDays::EWeekAll", EWeekDays.EWeekAll],
|
||||
]);
|
||||
|
||||
static eWeekDaysToStr(week_days: EWeekDays) {
|
||||
let ret = "EWeekDays::EWeekNone";
|
||||
EWeekDaysHelper._week_days_map.forEach((v, k, m) => {
|
||||
if (v == week_days) {
|
||||
ret = k;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
static getEWeekDays(str: string) {
|
||||
try {
|
||||
return EWeekDaysHelper._week_days_map.get(str);
|
||||
} catch (e) {
|
||||
return EWeekDays.EWeekNone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { EWeekDays };
|
|
@ -0,0 +1,16 @@
|
|||
import BaseEntity from "./BaseEntity";
|
||||
|
||||
export default class TimingTaskEntity extends BaseEntity {
|
||||
enabled = false;
|
||||
task_name = "";
|
||||
timing_time = "00:00:00";
|
||||
timing_week_days: number = 0;
|
||||
task_type = 0;
|
||||
ext_data = "";
|
||||
}
|
||||
|
||||
export enum TimingTaskType {
|
||||
UnKnow = 0,
|
||||
TaskPowerOn,
|
||||
TaskPowerOff,
|
||||
}
|
|
@ -9,6 +9,7 @@ import { EdgeBlendingPoint } from "./EdgeBlendingEntities";
|
|||
import { ExternalControlTableEntity } from "./ExternalControlTableEntity";
|
||||
import { SerialPortConfigEntity } from "./SerialPortConfigEntity";
|
||||
import { ConnectTableEntity } from "./ConnectTableEntity";
|
||||
import TimingTaskEntity from "./TimingTaskEntity";
|
||||
|
||||
export namespace Protocol {
|
||||
export class Commands {
|
||||
|
@ -382,19 +383,39 @@ export namespace Protocol {
|
|||
public static get kRpcGetConnectionList() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcGetConnectionList";
|
||||
}
|
||||
|
||||
public static get kRpcSetConnectionItem() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcSetConnectionItem";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
public static get kRpcGetTimingTasks() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcGetTimingTasks";
|
||||
}
|
||||
|
||||
public static get kRpcDeleteTimingTask() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcDeleteTimingTask";
|
||||
}
|
||||
|
||||
public static get kRpcEditTimingTask() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcEditTimingTask";
|
||||
}
|
||||
|
||||
public static get kRpcAddTimingTask() {
|
||||
return Commands.PROTOCOL_PREFIX + "RpcAddTimingTask";
|
||||
}
|
||||
|
||||
static _all_commands = new Set([
|
||||
Commands.kUnKnowCommand,
|
||||
Commands.kSearchDevice,
|
||||
|
@ -494,6 +515,10 @@ export namespace Protocol {
|
|||
Commands.kWindowFullScreen,
|
||||
Commands.kRpcGetDeviceAttribute,
|
||||
Commands.kSetDeviceAttribute,
|
||||
Commands.kRpcAddTimingTask,
|
||||
Commands.kRpcEditTimingTask,
|
||||
Commands.kRpcDeleteTimingTask,
|
||||
Commands.kRpcGetTimingTasks,
|
||||
]);
|
||||
public static get AllCommands() {
|
||||
return this._all_commands;
|
||||
|
@ -2533,4 +2558,84 @@ export namespace Protocol {
|
|||
this.command = Commands.kSetDeviceAttribute;
|
||||
}
|
||||
}
|
||||
|
||||
export class GetTimingTasksRequestEntity extends PacketEntity {
|
||||
constructor(rpc_id = 0) {
|
||||
super();
|
||||
super.command = Commands.kRpcGetTimingTasks;
|
||||
super.flag = PacketEntity.FLAG_REQUEST;
|
||||
super.rpc_id = rpc_id;
|
||||
}
|
||||
timestamp = 0;
|
||||
}
|
||||
|
||||
export class GetTimingTasksResponseEntity extends PacketEntity {
|
||||
constructor() {
|
||||
super();
|
||||
super.flag = PacketEntity.FLAG_RESPONSE;
|
||||
}
|
||||
|
||||
tasks: TimingTaskEntity[] = [];
|
||||
}
|
||||
export class AddTimingTaskRequestEntity extends PacketEntity {
|
||||
constructor(task: TimingTaskEntity, rpc_id = 0) {
|
||||
super();
|
||||
super.command = Commands.kRpcAddTimingTask;
|
||||
super.flag = PacketEntity.FLAG_REQUEST;
|
||||
super.rpc_id = rpc_id;
|
||||
|
||||
this.task = task;
|
||||
}
|
||||
task: TimingTaskEntity;
|
||||
}
|
||||
|
||||
export class AddTimingTaskResponseEntity extends PacketEntity {
|
||||
constructor() {
|
||||
super();
|
||||
super.flag = PacketEntity.FLAG_RESPONSE;
|
||||
}
|
||||
|
||||
success = false;
|
||||
uuid = "";
|
||||
}
|
||||
|
||||
export class DeleteTimingTaskRequestEntity extends PacketEntity {
|
||||
constructor(uuid: string, rpc_id = 0) {
|
||||
super();
|
||||
super.command = Commands.kRpcDeleteTimingTask;
|
||||
super.flag = PacketEntity.FLAG_REQUEST;
|
||||
super.rpc_id = rpc_id;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
export class DeleteTimingTaskResponseEntity extends PacketEntity {
|
||||
constructor() {
|
||||
super();
|
||||
super.flag = PacketEntity.FLAG_RESPONSE;
|
||||
}
|
||||
|
||||
success = false;
|
||||
}
|
||||
|
||||
export class EditTimingTaskRequestEntity extends PacketEntity {
|
||||
constructor(task: TimingTaskEntity, rpc_id = 0) {
|
||||
super();
|
||||
super.command = Commands.kRpcEditTimingTask;
|
||||
super.flag = PacketEntity.FLAG_REQUEST;
|
||||
super.rpc_id = rpc_id;
|
||||
this.task = task;
|
||||
}
|
||||
task: TimingTaskEntity;
|
||||
}
|
||||
|
||||
export class EditTimingTaskResponseEntity extends PacketEntity {
|
||||
constructor() {
|
||||
super();
|
||||
super.flag = PacketEntity.FLAG_RESPONSE;
|
||||
}
|
||||
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ export default {
|
|||
"other setting": "Other",
|
||||
close: "Close",
|
||||
logout: "Logout",
|
||||
all: "All",
|
||||
"window rect": "Window Size",
|
||||
"toolbar edit window rect": "Window Size",
|
||||
"edit window rect": "Window Size Adjust",
|
||||
|
|
|
@ -498,4 +498,14 @@ export default {
|
|||
"set device function": "设置设备功能成功",
|
||||
operator_play_signal_source: "信号源",
|
||||
"toolbar edit window rect": "窗口大小",
|
||||
exit: "退出",
|
||||
"add timing task": "添加定时任务",
|
||||
"timing task": "定时任务",
|
||||
"task type": "任务类型",
|
||||
"please input task name": "请输入任务名称",
|
||||
"task name": "任务名称",
|
||||
add: "添加",
|
||||
"new task": "新建任务",
|
||||
all: "全部",
|
||||
unknow: "未知",
|
||||
};
|
||||
|
|
|
@ -143,6 +143,18 @@
|
|||
>
|
||||
<q-popup-proxy>
|
||||
<q-list class="shadow-2 text-primary">
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="$refs.system_setting_dialog.showDialog()"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon name="img:pad/toolbar/system_setting.png" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
{{ $t("system setting") }}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
|
@ -208,6 +220,7 @@
|
|||
<subtitle-dialog ref="subtitle_dialog" />
|
||||
<advanced-debug-dialog ref="advanced_debug_dialog" />
|
||||
<window-rect-edit-dialog ref="window_rect_edit_dialog" />
|
||||
<system-setting-dialog ref="system_setting_dialog" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
|
@ -221,6 +234,7 @@ import SubtitleDialog from "src/components/SubtitleDialog.vue";
|
|||
import CenterControlDialog from "src/components/CenterControlDialog.vue";
|
||||
import AdvancedDebugDialog from "src/components/AdvancedDebugDialog.vue";
|
||||
import WindowRectEditDialog from "src/components/WindowRectEditDialog.vue";
|
||||
import SystemSettingDialog from "src/components/SystemSettingDialog.vue";
|
||||
|
||||
import GlobalData from "src/common/GlobalData";
|
||||
import { Protocol } from "src/entities/WSProtocol";
|
||||
|
@ -234,6 +248,7 @@ export default defineComponent({
|
|||
SubtitleDialog,
|
||||
AdvancedDebugDialog,
|
||||
WindowRectEditDialog,
|
||||
SystemSettingDialog,
|
||||
},
|
||||
setup() {
|
||||
const $store = useStore();
|
||||
|
|
Loading…
Reference in New Issue