信号源组的增删改
This commit is contained in:
parent
e5ef89c939
commit
f008433166
|
@ -302,6 +302,36 @@ export default class ClientConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async editSignalSourceGroup(uuid: string, name: string) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.EditSignalSourcesGroupResponseEntity>(
|
||||||
|
new Protocol.EditSignalSourcesGroupRequestEntity(0, uuid, name)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteSignalSourceGroup(uuid: string) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.DeleteSignalSourcesGroupResponseEntity>(
|
||||||
|
new Protocol.DeleteSignalSourcesGroupRequestEntity(0, uuid)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteSignalSource(uuid: string) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.DeleteSignalSourcesGroupResponseEntity>(
|
||||||
|
new Protocol.DeleteSignalSourcesGroupRequestEntity(0, uuid)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _destoryed = false;
|
private _destoryed = false;
|
||||||
public destory() {
|
public destory() {
|
||||||
this._destoryed = true;
|
this._destoryed = true;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<q-dialog v-model="show_dialog" @before-hide="resetData">
|
<q-dialog v-model="show_dialog" @before-hide="resetData">
|
||||||
<q-card class="overflow-hidden" style="overflow-y: scroll">
|
<q-card class="overflow-hidden" style="overflow-y: scroll; width: 45vw">
|
||||||
<q-card-section class="q-ma-none q-pa-sm">
|
<q-card-section class="q-ma-none q-pa-sm">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-11 text-h6">
|
<div class="col-11 text-h6">
|
||||||
|
@ -15,7 +15,14 @@
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<q-btn flat round icon="close" color="red" v-close-popup>
|
<q-btn
|
||||||
|
:loading="loading"
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
icon="close"
|
||||||
|
color="red"
|
||||||
|
v-close-popup
|
||||||
|
>
|
||||||
<q-tooltip>
|
<q-tooltip>
|
||||||
{{ $t("close") }}
|
{{ $t("close") }}
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
|
@ -28,10 +35,10 @@
|
||||||
|
|
||||||
<q-card-section style="max-height: 50vh; width: 45vw" class="scroll">
|
<q-card-section style="max-height: 50vh; width: 45vw" class="scroll">
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item>
|
<q-item v-if="type != 2">
|
||||||
<q-item-label>{{ $t("parent group") }}:</q-item-label>
|
<q-item-label>{{ $t("parent group") }}:</q-item-label>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item class="q-pa-none q-ma-none">
|
<q-item v-if="type != 2" class="q-pa-none q-ma-none">
|
||||||
<q-item-section style="padding-right: 10px">
|
<q-item-section style="padding-right: 10px">
|
||||||
<q-tree
|
<q-tree
|
||||||
ref="tree"
|
ref="tree"
|
||||||
|
@ -42,6 +49,8 @@
|
||||||
default-expand-all
|
default-expand-all
|
||||||
node-key="uuid"
|
node-key="uuid"
|
||||||
labelKey="name"
|
labelKey="name"
|
||||||
|
filter="group filter"
|
||||||
|
:filter-method="treeNodesFilter"
|
||||||
>
|
>
|
||||||
<template v-slot:default-header="prop">
|
<template v-slot:default-header="prop">
|
||||||
<q-item
|
<q-item
|
||||||
|
@ -107,11 +116,18 @@
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn flat :label="$t('Cancel')" color="primary" v-close-popup />
|
<q-btn
|
||||||
|
:loading="loading"
|
||||||
|
flat
|
||||||
|
:label="$t('Cancel')"
|
||||||
|
color="primary"
|
||||||
|
v-close-popup
|
||||||
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
ref="accept"
|
ref="accept"
|
||||||
flat
|
flat
|
||||||
:label="$t('Accept')"
|
:label="$t('Accept')"
|
||||||
|
:loading="loading"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="onSubmit"
|
@click="onSubmit"
|
||||||
/>
|
/>
|
||||||
|
@ -129,11 +145,19 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, watch, onUnmounted, computed } from "vue";
|
import {
|
||||||
|
defineComponent,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
reactive,
|
||||||
|
onUnmounted,
|
||||||
|
computed,
|
||||||
|
} from "vue";
|
||||||
import { useStore } from "src/store";
|
import { useStore } from "src/store";
|
||||||
import GlobalData from "src/common/GlobalData";
|
import GlobalData from "src/common/GlobalData";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { SignalSourceTreeItemEntity } from "src/entities/SignalSourceEntity";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "ComponentGroupDialog",
|
name: "ComponentGroupDialog",
|
||||||
|
@ -146,13 +170,13 @@ export default defineComponent({
|
||||||
let show_dialog = ref(false);
|
let show_dialog = ref(false);
|
||||||
let type = ref(1);
|
let type = ref(1);
|
||||||
let name = ref(null);
|
let name = ref(null);
|
||||||
|
let uuid = ref("");
|
||||||
const selected: any = ref(null);
|
const selected: any = ref(null);
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
|
|
||||||
const tree_nodes = computed({
|
const tree_nodes = computed({
|
||||||
get: () =>
|
get: () => $store.state.signal_source_tree,
|
||||||
$store.state.signal_source_tree.filter((item) => item && item.is_group),
|
set: (val) => {},
|
||||||
set: (val) => $store.commit("setSignalSourceTree", val),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -164,18 +188,58 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const requestAddSignalSourceGroup = async () => {
|
||||||
|
let response = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.addSignalSourceGroup(selected.value, name.value ?? "");
|
||||||
|
if (response) {
|
||||||
|
$q.notify({
|
||||||
|
color: response.success ? "positive" : "negative",
|
||||||
|
icon: response.success ? "done" : "warning",
|
||||||
|
message:
|
||||||
|
$t.t("add group") +
|
||||||
|
(response.success ? $t.t("success") : $t.t("fail")) +
|
||||||
|
"!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const requestEditSignalSourceGroup = async () => {
|
||||||
|
let response = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.editSignalSourceGroup(uuid.value, name.value ?? "");
|
||||||
|
if (response) {
|
||||||
|
$q.notify({
|
||||||
|
color: response.success ? "positive" : "negative",
|
||||||
|
icon: response.success ? "done" : "warning",
|
||||||
|
message:
|
||||||
|
$t.t("edit group") +
|
||||||
|
(response.success ? $t.t("success") : $t.t("fail")) +
|
||||||
|
"!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show_dialog,
|
show_dialog,
|
||||||
type,
|
type,
|
||||||
name,
|
name,
|
||||||
|
uuid,
|
||||||
selected,
|
selected,
|
||||||
loading,
|
loading,
|
||||||
tree_nodes,
|
tree_nodes,
|
||||||
showDialog(options: any) {
|
showDialog(options: any) {
|
||||||
if (options) {
|
if (options) {
|
||||||
type.value = options.type ?? 1;
|
type.value = options.type ?? 1;
|
||||||
name.value = options.name ?? null;
|
if (type.value == 2) {
|
||||||
selected.value = options.parent ?? null;
|
name.value = options.data?.name ?? null;
|
||||||
|
}
|
||||||
|
selected.value = options.data?.uuid ?? null;
|
||||||
|
uuid.value = options.data?.uuid ?? null;
|
||||||
}
|
}
|
||||||
show_dialog.value = true;
|
show_dialog.value = true;
|
||||||
},
|
},
|
||||||
|
@ -183,27 +247,17 @@ export default defineComponent({
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
(selected.value = null), (name.value = null);
|
(selected.value = null), (name.value = null);
|
||||||
type.value = 1;
|
type.value = 1;
|
||||||
console.log("reset dialog data");
|
},
|
||||||
|
treeNodesFilter(node: any, filter: any) {
|
||||||
|
return node.is_group && !node.item_data?.system_default;
|
||||||
},
|
},
|
||||||
|
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
let response = await GlobalData.getInstance()
|
await (type.value == 2
|
||||||
.getCurrentClient()
|
? requestEditSignalSourceGroup()
|
||||||
?.addSignalSourceGroup(selected.value, name.value ?? "");
|
: requestAddSignalSourceGroup());
|
||||||
if (response) {
|
|
||||||
$q.notify({
|
|
||||||
color: response.success ? "positive" : "negative",
|
|
||||||
icon: response.success ? "done" : "warning",
|
|
||||||
message:
|
|
||||||
$t.t("add group") +
|
|
||||||
(response.success ? $t.t("success") : $t.t("fail")) +
|
|
||||||
"!",
|
|
||||||
position: "top",
|
|
||||||
timeout: 1000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
show_dialog.value = false;
|
show_dialog.value = false;
|
||||||
} catch {}
|
} catch {}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
|
@ -69,6 +69,14 @@ export namespace Protocol {
|
||||||
return Commands.PROTOCOL_PREFIX + "RpcAddSignalSourceGroup";
|
return Commands.PROTOCOL_PREFIX + "RpcAddSignalSourceGroup";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static get kRpcDeleteSignalSourceGroup() {
|
||||||
|
return Commands.PROTOCOL_PREFIX + "RpcDeleteSignalSourceGroup";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static get kRpcEditSignalSourceGroup() {
|
||||||
|
return Commands.PROTOCOL_PREFIX + "RpcEditSignalSourceGroup";
|
||||||
|
}
|
||||||
|
|
||||||
static _all_commands = new Set([
|
static _all_commands = new Set([
|
||||||
Commands.kUnKnowCommand,
|
Commands.kUnKnowCommand,
|
||||||
Commands.kSearchDevice,
|
Commands.kSearchDevice,
|
||||||
|
@ -86,6 +94,8 @@ export namespace Protocol {
|
||||||
Commands.kCloseWindow,
|
Commands.kCloseWindow,
|
||||||
Commands.kWindowOtherStateChanged,
|
Commands.kWindowOtherStateChanged,
|
||||||
Commands.kRpcAddSignalSourceGroup,
|
Commands.kRpcAddSignalSourceGroup,
|
||||||
|
Commands.kRpcDeleteSignalSourceGroup,
|
||||||
|
Commands.kRpcEditSignalSourceGroup,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
public static get AllCommands() {
|
public static get AllCommands() {
|
||||||
|
@ -316,4 +326,46 @@ export namespace Protocol {
|
||||||
this.command = Protocol.Commands.kRpcAddSignalSourceGroup;
|
this.command = Protocol.Commands.kRpcAddSignalSourceGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class EditSignalSourcesGroupRequestEntity extends Protocol.PacketEntity {
|
||||||
|
uuid = "";
|
||||||
|
name = "";
|
||||||
|
|
||||||
|
constructor(rcp_id?: number, uuid?: string, name?: string) {
|
||||||
|
super();
|
||||||
|
this.rpc_id = rcp_id ?? 0;
|
||||||
|
this.command = Protocol.Commands.kRpcEditSignalSourceGroup;
|
||||||
|
this.uuid = uuid ?? "";
|
||||||
|
this.name = name ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditSignalSourcesGroupResponseEntity extends Protocol.PacketEntity {
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.command = Protocol.Commands.kRpcEditSignalSourceGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DeleteSignalSourcesGroupRequestEntity extends Protocol.PacketEntity {
|
||||||
|
uuid = "";
|
||||||
|
|
||||||
|
constructor(rcp_id?: number, uuid?: string) {
|
||||||
|
super();
|
||||||
|
this.rpc_id = rcp_id ?? 0;
|
||||||
|
this.command = Protocol.Commands.kRpcDeleteSignalSourceGroup;
|
||||||
|
this.uuid = uuid ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DeleteSignalSourcesGroupResponseEntity extends Protocol.PacketEntity {
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.command = Protocol.Commands.kRpcDeleteSignalSourceGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
export default {
|
export default {
|
||||||
title: "MediaPlayerWebAPP",
|
title: "MediaPlayerWebAPP",
|
||||||
failed: "失败",
|
failed: "失败",
|
||||||
|
fail: "失败",
|
||||||
success: "成功",
|
success: "成功",
|
||||||
Cancel: "取消",
|
Cancel: "取消",
|
||||||
Accept: "确认",
|
Accept: "确认",
|
||||||
|
|
|
@ -28,7 +28,17 @@
|
||||||
<q-popup-proxy context-menu>
|
<q-popup-proxy context-menu>
|
||||||
<q-popup-proxy context-menu />
|
<q-popup-proxy context-menu />
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item clickable v-close-popup v-ripple>
|
<q-item
|
||||||
|
v-if="
|
||||||
|
prop.node.name == $t('root') ||
|
||||||
|
(prop.node.is_group &&
|
||||||
|
prop.node.item_data &&
|
||||||
|
!prop.node.item_data.system_default)
|
||||||
|
"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
v-ripple
|
||||||
|
>
|
||||||
<q-item-section avatar><q-icon name="add" /></q-item-section>
|
<q-item-section avatar><q-icon name="add" /></q-item-section>
|
||||||
<q-item-section>{{
|
<q-item-section>{{
|
||||||
$t("add signal source item")
|
$t("add signal source item")
|
||||||
|
@ -37,13 +47,18 @@
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-if="prop.node.is_group"
|
v-if="
|
||||||
|
prop.node.name == $t('root') ||
|
||||||
|
(prop.node.is_group &&
|
||||||
|
prop.node.item_data &&
|
||||||
|
!prop.node.item_data.system_default)
|
||||||
|
"
|
||||||
v-ripple
|
v-ripple
|
||||||
@click="
|
@click="
|
||||||
() =>
|
() =>
|
||||||
$refs.group_dialog.showDialog({
|
$refs.group_dialog.showDialog({
|
||||||
type: 1,
|
type: 1,
|
||||||
parent: prop.node.uuid,
|
data: prop.node,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -56,7 +71,16 @@
|
||||||
clickable
|
clickable
|
||||||
v-ripple
|
v-ripple
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-if="prop.node.uuid != '' && prop.node.name != $t('root')"
|
v-if="
|
||||||
|
prop.node.item_data && !prop.node.item_data.system_default
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
() =>
|
||||||
|
$refs.group_dialog.showDialog({
|
||||||
|
type: 2,
|
||||||
|
data: prop.node,
|
||||||
|
})
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<q-item-section avatar><q-icon name="edit" /></q-item-section>
|
<q-item-section avatar><q-icon name="edit" /></q-item-section>
|
||||||
<q-item-section>{{ $t("edit") }}</q-item-section>
|
<q-item-section>{{ $t("edit") }}</q-item-section>
|
||||||
|
@ -66,7 +90,12 @@
|
||||||
clickable
|
clickable
|
||||||
v-ripple
|
v-ripple
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-if="prop.node.uuid != '' && prop.node.name != $t('root')"
|
v-if="
|
||||||
|
prop.node.item_data && !prop.node.item_data.system_default
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
(evt) => deleteItem(evt, prop.node.is_group, prop.node.uuid)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<q-item-section avatar
|
<q-item-section avatar
|
||||||
><q-icon color="red" name="delete"
|
><q-icon color="red" name="delete"
|
||||||
|
@ -88,6 +117,9 @@ import { useStore } from "src/store";
|
||||||
import { SignalSourceTreeItemEntity } from "src/entities/SignalSourceEntity";
|
import { SignalSourceTreeItemEntity } from "src/entities/SignalSourceEntity";
|
||||||
import GroupDialog from "src/components/GroupDialog.vue";
|
import GroupDialog from "src/components/GroupDialog.vue";
|
||||||
import { Common } from "src/common/Common";
|
import { Common } from "src/common/Common";
|
||||||
|
import GlobalData from "src/common/GlobalData";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "PageLeftToolBar",
|
name: "PageLeftToolBar",
|
||||||
|
@ -96,6 +128,8 @@ export default defineComponent({
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const $store = useStore();
|
const $store = useStore();
|
||||||
|
const $q = useQuasar();
|
||||||
|
const $t = useI18n();
|
||||||
|
|
||||||
const tree_nodes = computed({
|
const tree_nodes = computed({
|
||||||
get: () => $store.state.signal_source_tree,
|
get: () => $store.state.signal_source_tree,
|
||||||
|
@ -117,6 +151,37 @@ export default defineComponent({
|
||||||
getItemIcon(item_type: string) {
|
getItemIcon(item_type: string) {
|
||||||
return Common.getSignalSourceIcon(item_type);
|
return Common.getSignalSourceIcon(item_type);
|
||||||
},
|
},
|
||||||
|
async deleteItem(
|
||||||
|
evt: PointerEvent | null,
|
||||||
|
is_group: boolean,
|
||||||
|
uuid: string
|
||||||
|
) {
|
||||||
|
let success = false;
|
||||||
|
if (is_group) {
|
||||||
|
let response = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.deleteSignalSourceGroup(uuid);
|
||||||
|
if (response) {
|
||||||
|
success = response.success;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let response = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.deleteSignalSource(uuid);
|
||||||
|
if (response) {
|
||||||
|
success = response.success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$q.notify({
|
||||||
|
color: success ? "positive" : "negative",
|
||||||
|
icon: success ? "done" : "warning",
|
||||||
|
message:
|
||||||
|
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1000,
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -183,6 +183,7 @@ export default store(function (/* { ssrContext } */) {
|
||||||
item.name,
|
item.name,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
node_item.item_data = item;
|
||||||
parent.children.push(node_item);
|
parent.children.push(node_item);
|
||||||
buildGroup(node_item, group_array, item_array);
|
buildGroup(node_item, group_array, item_array);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue