2021-08-24 15:20:01 +08:00
|
|
|
<template>
|
2021-12-23 11:36:25 +08:00
|
|
|
<q-scroll-area :style="{ height: content_height + 'px' }" style="width: 20vw">
|
2021-08-24 15:20:01 +08:00
|
|
|
<q-tree ref="tree" :nodes="tree_nodes" node-key="uuid" labelKey="name">
|
|
|
|
<template v-slot:default-header="prop">
|
|
|
|
<q-item
|
|
|
|
class="full-width"
|
|
|
|
clickable
|
2022-06-14 17:58:27 +08:00
|
|
|
:disable="!$store.state.power_state"
|
2022-07-19 16:59:26 +08:00
|
|
|
:draggable="prop.node.uuid != '' && $store.state.power_state"
|
2021-08-24 15:20:01 +08:00
|
|
|
@dragstart="(evt) => onDragStart(evt, prop.node)"
|
2022-07-19 16:59:26 +08:00
|
|
|
@dragover="(evt) => onDragOver(evt, prop.node)"
|
|
|
|
@drop="(evt) => onDrop(evt, prop.node)"
|
2022-01-25 11:34:07 +08:00
|
|
|
@click="
|
|
|
|
$store.commit(
|
|
|
|
'setSelectedSignalSource',
|
|
|
|
prop.node.is_group
|
|
|
|
? $store.state.selected_signal_source
|
|
|
|
: prop.node.uuid
|
|
|
|
)
|
|
|
|
"
|
|
|
|
:style="{
|
|
|
|
border:
|
|
|
|
$store.state.selected_signal_source == prop.node.uuid
|
|
|
|
? '1px solid #aacceec2'
|
|
|
|
: 'none',
|
|
|
|
}"
|
2021-08-24 15:20:01 +08:00
|
|
|
>
|
2022-07-19 16:59:26 +08:00
|
|
|
<!-- {{ prop.node }} -->
|
2021-08-24 15:20:01 +08:00
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon
|
2022-07-19 16:59:26 +08:00
|
|
|
style="pointer-events: none"
|
2021-08-24 15:20:01 +08:00
|
|
|
:name="
|
|
|
|
prop.node.is_group
|
|
|
|
? 'img:source_icon/group.png'
|
|
|
|
: getItemIcon(prop.node.item_data?.window_type)
|
|
|
|
"
|
|
|
|
color="orange"
|
|
|
|
size="28px"
|
|
|
|
class="q-mr-sm"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>
|
|
|
|
<div class="text-weight-bold text-primary">
|
|
|
|
{{ prop.node.name }}
|
|
|
|
</div>
|
|
|
|
</q-item-section>
|
2022-06-14 17:58:27 +08:00
|
|
|
<q-popup-proxy
|
|
|
|
:context-menu="$store.state.power_state"
|
|
|
|
@before-show="updateContextMenu"
|
|
|
|
>
|
2021-08-24 15:20:01 +08:00
|
|
|
<q-list>
|
2022-05-12 20:48:22 +08:00
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
|
|
|
v-close-popup
|
2022-05-13 15:47:36 +08:00
|
|
|
v-if="prop.node.item_data?.window_type == 'EwindowType::HdmiIn'"
|
2022-05-12 20:48:22 +08:00
|
|
|
@click="setHdmiInDecodeType(1, 'NV12')"
|
|
|
|
>
|
|
|
|
<q-item-section>
|
|
|
|
{{ $t("lossy ") + $t("picture quality") }}
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section side v-if="lossy_pic">
|
|
|
|
<q-icon name="done" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
|
|
|
v-close-popup
|
2022-05-13 15:47:36 +08:00
|
|
|
v-if="prop.node.item_data?.window_type == 'EwindowType::HdmiIn'"
|
2022-05-12 20:48:22 +08:00
|
|
|
@click="setHdmiInDecodeType(1, 'NV16')"
|
|
|
|
>
|
|
|
|
<q-item-section>
|
|
|
|
{{ $t("lossless ") + $t("picture quality") }}
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section side v-if="!lossy_pic">
|
|
|
|
<q-icon name="done" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
|
2021-08-24 15:20:01 +08:00
|
|
|
<q-item
|
|
|
|
v-if="
|
2022-04-07 11:43:18 +08:00
|
|
|
prop.node.name == $t('signal source') ||
|
2021-08-24 15:20:01 +08:00
|
|
|
(prop.node.is_group &&
|
|
|
|
prop.node.item_data &&
|
|
|
|
!prop.node.item_data.system_default)
|
|
|
|
"
|
|
|
|
clickable
|
|
|
|
v-close-popup
|
|
|
|
v-ripple
|
|
|
|
@click="
|
|
|
|
$refs.signal_source_dialog.showDialog({
|
|
|
|
type: 1,
|
|
|
|
parent_node: prop.node.uuid,
|
|
|
|
})
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<q-item-section avatar><q-icon name="add" /></q-item-section>
|
|
|
|
<q-item-section>{{
|
|
|
|
$t("add signal source item")
|
|
|
|
}}</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-close-popup
|
|
|
|
v-if="
|
2022-04-07 11:43:18 +08:00
|
|
|
prop.node.name == $t('signal source') ||
|
2021-08-24 15:20:01 +08:00
|
|
|
(prop.node.is_group &&
|
|
|
|
prop.node.item_data &&
|
|
|
|
!prop.node.item_data.system_default)
|
|
|
|
"
|
|
|
|
v-ripple
|
|
|
|
@click="
|
|
|
|
() =>
|
|
|
|
$refs.group_dialog.showDialog({
|
|
|
|
type: 1,
|
|
|
|
data: prop.node,
|
|
|
|
})
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<q-item-section avatar
|
|
|
|
><q-icon name="create_new_folder"
|
|
|
|
/></q-item-section>
|
|
|
|
<q-item-section>{{ $t("add group") }}</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
|
|
|
v-close-popup
|
|
|
|
v-if="
|
2022-09-28 09:24:54 +08:00
|
|
|
prop.node.item_data &&
|
|
|
|
prop.node.item_data.uuid &&
|
|
|
|
!prop.node.item_data.system_default
|
2021-08-24 15:20:01 +08:00
|
|
|
"
|
|
|
|
@click="
|
|
|
|
() =>
|
|
|
|
(prop.node.is_group
|
|
|
|
? $refs.group_dialog
|
|
|
|
: $refs.signal_source_dialog
|
|
|
|
).showDialog({
|
|
|
|
type: 2,
|
|
|
|
data: prop.node,
|
|
|
|
})
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<q-item-section avatar><q-icon name="edit" /></q-item-section>
|
|
|
|
<q-item-section>{{ $t("edit") }}</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
|
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
|
|
|
v-close-popup
|
|
|
|
v-if="
|
2022-09-28 09:24:54 +08:00
|
|
|
prop.node.item_data &&
|
|
|
|
prop.node.item_data.uuid &&
|
|
|
|
!prop.node.item_data.system_default
|
2021-08-24 15:20:01 +08:00
|
|
|
"
|
|
|
|
@click="
|
|
|
|
(evt) => deleteItem(evt, prop.node.is_group, prop.node.uuid)
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<q-item-section avatar
|
|
|
|
><q-icon color="red" name="delete"
|
|
|
|
/></q-item-section>
|
|
|
|
<q-item-section>{{ $t("delete") }} </q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</q-list>
|
|
|
|
</q-popup-proxy>
|
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
</q-tree>
|
2021-11-05 09:15:51 +08:00
|
|
|
</q-scroll-area>
|
2021-08-24 15:20:01 +08:00
|
|
|
<signal-source-group-dialog ref="group_dialog" />
|
|
|
|
<signal-source-dialog ref="signal_source_dialog" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-07-19 16:59:26 +08:00
|
|
|
import { defineComponent, computed, onMounted, ref } from "vue";
|
2021-08-24 15:20:01 +08:00
|
|
|
import { useStore } from "src/store";
|
2022-07-19 16:59:26 +08:00
|
|
|
import {
|
|
|
|
SignalSourceEntity,
|
|
|
|
SignalSourceTreeItemEntity,
|
|
|
|
} from "src/entities/SignalSourceEntity";
|
2021-08-24 15:20:01 +08:00
|
|
|
import SignalSourceGroupDialog from "src/components/SignalSourceGroupDialog.vue";
|
|
|
|
import SignalSourceDialog from "src/components/SignalSourceDialog.vue";
|
|
|
|
import { Common } from "src/common/Common";
|
|
|
|
import GlobalData from "src/common/GlobalData";
|
2022-07-19 16:59:26 +08:00
|
|
|
import { useQuasar, extend } from "quasar";
|
2021-08-24 15:20:01 +08:00
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
import EventBus, { EventNamesDefine } from "src/common/EventBus";
|
|
|
|
import { Protocol } from "src/entities/WSProtocol";
|
2021-08-25 17:30:02 +08:00
|
|
|
import { NotifyMessage } from "src/common/ClientConnection";
|
2021-08-24 15:20:01 +08:00
|
|
|
|
|
|
|
export default defineComponent({
|
2021-12-23 17:08:21 +08:00
|
|
|
name: "ComponentSignalSourceTree",
|
2021-08-24 15:20:01 +08:00
|
|
|
|
|
|
|
components: { SignalSourceGroupDialog, SignalSourceDialog },
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
const $store = useStore();
|
|
|
|
const $q = useQuasar();
|
|
|
|
const $t = useI18n();
|
|
|
|
|
2022-05-12 20:48:22 +08:00
|
|
|
const lossy_pic = ref(false);
|
|
|
|
|
2021-12-23 11:36:25 +08:00
|
|
|
const content_height = ref(0);
|
|
|
|
|
|
|
|
const refresh_content_height = () => {
|
|
|
|
content_height.value = window.innerHeight - 135;
|
|
|
|
};
|
|
|
|
refresh_content_height();
|
|
|
|
|
|
|
|
EventBus.getInstance().on(EventNamesDefine.WindowResize, () => {
|
|
|
|
refresh_content_height();
|
|
|
|
});
|
|
|
|
|
2021-08-24 15:20:01 +08:00
|
|
|
const tree_nodes = computed({
|
|
|
|
get: () => $store.state.signal_source_tree,
|
|
|
|
set: (val) => $store.commit("setSignalSourceTree", val),
|
|
|
|
});
|
|
|
|
|
|
|
|
const tree: any | null = ref(null);
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2022-03-03 16:36:47 +08:00
|
|
|
while (!tree.value?.nodes?.length) {
|
2021-08-24 15:20:01 +08:00
|
|
|
await Common.waitFor(100);
|
|
|
|
}
|
|
|
|
tree.value?.setExpanded("", true);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
tree,
|
|
|
|
tree_nodes,
|
2021-12-23 11:36:25 +08:00
|
|
|
content_height,
|
2022-05-12 20:48:22 +08:00
|
|
|
lossy_pic,
|
2021-08-24 15:20:01 +08:00
|
|
|
loga(a: any) {
|
|
|
|
console.log(a);
|
|
|
|
},
|
|
|
|
onDragStart(e: DragEvent, node: SignalSourceTreeItemEntity) {
|
|
|
|
e.dataTransfer?.setData("uuid", node.uuid);
|
2022-02-24 20:11:20 +08:00
|
|
|
e.dataTransfer?.setData("type", "signal_source");
|
2022-07-19 16:59:26 +08:00
|
|
|
e.dataTransfer?.setData("group", node.is_group ? "true" : "false");
|
2021-08-24 15:20:01 +08:00
|
|
|
e.dataTransfer?.setData("node_object", JSON.stringify(node));
|
|
|
|
if (e.dataTransfer) {
|
|
|
|
e.dataTransfer.dropEffect = "move";
|
|
|
|
}
|
|
|
|
},
|
2022-07-19 16:59:26 +08:00
|
|
|
onDragOver(e: DragEvent, node: SignalSourceTreeItemEntity) {
|
|
|
|
if (node && node.is_group && !node.item_data?.system_default) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onDrop(e: DragEvent, node: SignalSourceTreeItemEntity) {
|
|
|
|
if (
|
|
|
|
node &&
|
|
|
|
node.is_group &&
|
|
|
|
node.item_data &&
|
|
|
|
!node.item_data.system_default
|
|
|
|
) {
|
|
|
|
if (e.dataTransfer) {
|
|
|
|
const type = e.dataTransfer.getData("type");
|
|
|
|
if (type == "signal_source") {
|
|
|
|
const uuid = e.dataTransfer.getData("uuid");
|
|
|
|
const group = e.dataTransfer.getData("group");
|
|
|
|
if (
|
|
|
|
typeof uuid == "string" &&
|
|
|
|
type &&
|
|
|
|
type.length > 0 &&
|
|
|
|
group &&
|
|
|
|
group.length > 0
|
|
|
|
) {
|
|
|
|
if (group == "true") {
|
|
|
|
const signal_source_group =
|
|
|
|
GlobalData.getInstance().signal_source_groups.find(
|
|
|
|
(item) => item && (item as any).uuid == uuid
|
|
|
|
);
|
|
|
|
if (signal_source_group) {
|
|
|
|
if (
|
|
|
|
signal_source_group.parent_uuid == node.item_data.uuid
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.editSignalSourceGroup(
|
|
|
|
signal_source_group.uuid,
|
|
|
|
signal_source_group.name,
|
|
|
|
node.item_data.uuid
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
console.log("can't find signal source group, uuid:" + uuid);
|
|
|
|
}
|
|
|
|
} else if (group == "false") {
|
|
|
|
const signal_source =
|
|
|
|
GlobalData.getInstance().signal_source.find(
|
|
|
|
(item) => item && (item as any).uuid == uuid
|
|
|
|
);
|
|
|
|
if (signal_source) {
|
|
|
|
if (signal_source.group_uuid == node.item_data.uuid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const entity = extend(
|
|
|
|
false,
|
|
|
|
signal_source
|
|
|
|
) as SignalSourceEntity;
|
|
|
|
entity.group_uuid = node.item_data.uuid;
|
|
|
|
GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.editSignalSource(entity);
|
|
|
|
} else {
|
|
|
|
console.log("can't find signal source, uuid:" + uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("type error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-08-24 15:20:01 +08:00
|
|
|
getItemIcon(item_type: string) {
|
|
|
|
return Common.getSignalSourceIcon(item_type);
|
|
|
|
},
|
2022-07-29 16:17:52 +08:00
|
|
|
deleteItem(evt: PointerEvent | null, is_group: boolean, uuid: string) {
|
|
|
|
const show_tooltip = (success: boolean) => {
|
|
|
|
$q.notify({
|
|
|
|
color: success ? "positive" : "negative",
|
|
|
|
icon: success ? "done" : "warning",
|
|
|
|
message:
|
|
|
|
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
|
|
|
|
position: "top",
|
|
|
|
timeout: 1500,
|
|
|
|
});
|
|
|
|
};
|
2021-08-24 15:20:01 +08:00
|
|
|
if (is_group) {
|
2022-07-29 16:17:52 +08:00
|
|
|
$q.dialog({
|
|
|
|
title: $t.t("Confirm"),
|
|
|
|
message: $t.t(
|
|
|
|
"delete group should be delete all child! do you want to delete this group?"
|
|
|
|
),
|
|
|
|
ok: {
|
|
|
|
label: $t.t("ok"),
|
|
|
|
noCaps: true,
|
|
|
|
flat: true,
|
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
label: $t.t("cancel"),
|
|
|
|
noCaps: true,
|
|
|
|
flat: true,
|
|
|
|
},
|
|
|
|
persistent: true,
|
|
|
|
}).onOk(async () => {
|
|
|
|
let success = false;
|
|
|
|
|
|
|
|
let response = await GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.deleteSignalSourceGroup(uuid);
|
|
|
|
if (response) {
|
|
|
|
success = response.success;
|
|
|
|
}
|
|
|
|
show_tooltip(success);
|
|
|
|
});
|
2021-08-24 15:20:01 +08:00
|
|
|
} else {
|
2022-07-29 16:17:52 +08:00
|
|
|
$q.dialog({
|
|
|
|
title: $t.t("Confirm"),
|
|
|
|
message: $t.t("do you want to delete the item") + "?",
|
|
|
|
ok: {
|
|
|
|
label: $t.t("ok"),
|
|
|
|
noCaps: true,
|
|
|
|
flat: true,
|
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
label: $t.t("cancel"),
|
|
|
|
noCaps: true,
|
|
|
|
flat: true,
|
|
|
|
},
|
|
|
|
persistent: true,
|
|
|
|
}).onOk(async () => {
|
|
|
|
let success = false;
|
2021-08-24 15:20:01 +08:00
|
|
|
|
2022-07-29 16:17:52 +08:00
|
|
|
let response = await GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.deleteSignalSource(uuid);
|
|
|
|
if (response) {
|
|
|
|
success = response.success;
|
|
|
|
}
|
|
|
|
show_tooltip(success);
|
|
|
|
});
|
|
|
|
}
|
2022-05-12 20:48:22 +08:00
|
|
|
},
|
2022-07-29 16:17:52 +08:00
|
|
|
updateContextMenu() {},
|
2022-05-12 20:48:22 +08:00
|
|
|
async setHdmiInDecodeType(index: number, type: string) {
|
|
|
|
let success = false;
|
|
|
|
|
|
|
|
const response = await GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.setHdmiInDecodeType(index, type);
|
|
|
|
|
|
|
|
if (response) {
|
|
|
|
success = response.success;
|
|
|
|
}
|
|
|
|
|
|
|
|
$q.notify({
|
|
|
|
color: success ? "positive" : "negative",
|
|
|
|
icon: success ? "done" : "warning",
|
|
|
|
message:
|
|
|
|
$t.t("set") + (success ? $t.t("success") : $t.t("fail")) + "!",
|
|
|
|
position: "top",
|
|
|
|
timeout: 1500,
|
|
|
|
});
|
|
|
|
},
|
2021-08-24 15:20:01 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|