删除资源时添加对话框确认

This commit is contained in:
fangxiang 2022-07-29 16:17:52 +08:00
parent cf98b9ba08
commit f645d98b02
6 changed files with 254 additions and 112 deletions

View File

@ -217,36 +217,69 @@ export default defineComponent({
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
async deleteItem( deleteItem(evt: PointerEvent | null, is_group: boolean, uuid: string) {
evt: PointerEvent | null, const show_tooltip = (success: boolean) => {
is_group: boolean, $q.notify({
uuid: string color: success ? "positive" : "negative",
) { icon: success ? "done" : "warning",
message:
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
position: "top",
timeout: 1500,
});
};
let success = false; let success = false;
if (is_group) { if (is_group) {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deleteModeGroup(uuid); message: $t.t(
if (response) { "delete group should be delete all child! do you want to delete this group?"
success = response.success; ),
} ok: {
label: $t.t("ok"),
noCaps: true,
flat: true,
},
cancel: {
label: $t.t("cancel"),
noCaps: true,
flat: true,
},
persistent: true,
}).onOk(async () => {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteModeGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else { } else {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deleteMode(uuid); message: $t.t("do you want to delete the item") + "?",
if (response) { ok: {
success = response.success; label: $t.t("ok"),
} noCaps: true,
flat: true,
},
cancel: {
label: $t.t("cancel"),
noCaps: true,
flat: true,
},
persistent: true,
}).onOk(async () => {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteMode(uuid);
if (response) {
success = response.success;
}
show_tooltip(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: 1500,
});
}, },
callMode(item: ModeEntity) { callMode(item: ModeEntity) {
GlobalData.getInstance().getCurrentClient()?.callMode(item.uuid); GlobalData.getInstance().getCurrentClient()?.callMode(item.uuid);

View File

@ -224,36 +224,70 @@ export default defineComponent({
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
async deleteItem( deleteItem(evt: MouseEvent | null, is_group: boolean, uuid: string) {
evt: MouseEvent | null, const show_tooltip = (success: boolean) => {
is_group: boolean, $q.notify({
uuid: string color: success ? "positive" : "negative",
) { icon: success ? "done" : "warning",
let success = false; message:
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
position: "top",
timeout: 1500,
});
};
if (is_group) { if (is_group) {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deletePlanGroup(uuid); message: $t.t(
if (response) { "delete group should be delete all child! do you want to delete this group?"
success = response.success; ),
} 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()
?.deletePlanGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else { } else {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deletePlan(uuid); message: $t.t("do you want to delete the item") + "?",
if (response) { ok: {
success = response.success; 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()
?.deletePlan(uuid);
if (response) {
success = response.success;
}
show_tooltip(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: 1500,
});
}, },
runPlan(item: PlanEntity) { runPlan(item: PlanEntity) {
if (!$store.state.power_state) { if (!$store.state.power_state) {

View File

@ -177,35 +177,72 @@ export default defineComponent({
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
async deleteItem( deleteItem(evt: PointerEvent | null, is_group: boolean, uuid: string) {
evt: PointerEvent | null, const show_tooltip = (success: boolean) => {
is_group: boolean, $q.notify({
uuid: string color: success ? "positive" : "negative",
) { icon: success ? "done" : "warning",
let success = false; message:
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
position: "top",
timeout: 1500,
});
};
if (is_group) { if (is_group) {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deletePollingGroup(uuid); message: $t.t(
if (response) { "delete group should be delete all child! do you want to delete this group?"
success = response.success; ),
} 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()
?.deletePollingGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else { } else {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deletePolling(uuid); message: $t.t("do you want to delete the item") + "?",
if (response) { ok: {
success = response.success; 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()
?.deletePolling(uuid);
if (response) {
success = response.success;
}
show_tooltip(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: 1500,
});
}, },
onDragStart(e: DragEvent, node: PollingTreeItemEntity) { onDragStart(e: DragEvent, node: PollingTreeItemEntity) {
e.dataTransfer?.setData("uuid", node.uuid); e.dataTransfer?.setData("uuid", node.uuid);

View File

@ -318,42 +318,74 @@ export default defineComponent({
getItemIcon(item_type: string) { getItemIcon(item_type: string) {
return Common.getSignalSourceIcon(item_type); return Common.getSignalSourceIcon(item_type);
}, },
async deleteItem( deleteItem(evt: PointerEvent | null, is_group: boolean, uuid: string) {
evt: PointerEvent | null, const show_tooltip = (success: boolean) => {
is_group: boolean, $q.notify({
uuid: string color: success ? "positive" : "negative",
) { icon: success ? "done" : "warning",
let success = false; message:
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!",
position: "top",
timeout: 1500,
});
};
if (is_group) { if (is_group) {
let response = await GlobalData.getInstance() $q.dialog({
.getCurrentClient() title: $t.t("Confirm"),
?.deleteSignalSourceGroup(uuid); message: $t.t(
if (response) { "delete group should be delete all child! do you want to delete this group?"
success = response.success; ),
} ok: {
} else { label: $t.t("ok"),
let response = await GlobalData.getInstance() noCaps: true,
.getCurrentClient() flat: true,
?.deleteSignalSource(uuid); },
if (response) { cancel: {
success = response.success; label: $t.t("cancel"),
} noCaps: true,
} flat: true,
},
persistent: true,
}).onOk(async () => {
let success = false;
$q.notify({ let response = await GlobalData.getInstance()
color: success ? "positive" : "negative", .getCurrentClient()
icon: success ? "done" : "warning", ?.deleteSignalSourceGroup(uuid);
message: if (response) {
$t.t("delete") + (success ? $t.t("success") : $t.t("fail")) + "!", success = response.success;
position: "top", }
timeout: 1500, show_tooltip(success);
}); });
}, } else {
updateContextMenu() { $q.dialog({
lossy_pic.value = title: $t.t("Confirm"),
(GlobalData.getInstance().applicationConfig?.hdmi_in_decode_type_1 ?? message: $t.t("do you want to delete the item") + "?",
"NV12") == "NV12"; 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()
?.deleteSignalSource(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
}
}, },
updateContextMenu() {},
async setHdmiInDecodeType(index: number, type: string) { async setHdmiInDecodeType(index: number, type: string) {
let success = false; let success = false;

View File

@ -332,4 +332,7 @@ export default {
"send power off command": "Send Power Off Command", "send power off command": "Send Power Off Command",
"set subtitle success": "Set OSD Success", "set subtitle success": "Set OSD Success",
"stop polling": "Stop Signal Loop", "stop polling": "Stop Signal Loop",
"delete group should be delete all child! do you want to delete this group?":
"Delete Group Should Be Delete All Child! Do You Want To Delete This Group?",
"do you want to delete the item": "Do You Want To Delete The Item",
}; };

View File

@ -609,4 +609,7 @@ export default {
real: "实际", real: "实际",
"current real": "当前实际", "current real": "当前实际",
"the port number must be between 0 and 65535": "端口号只能在0~65535之间", "the port number must be between 0 and 65535": "端口号只能在0~65535之间",
"delete group should be delete all child! do you want to delete this group?":
"删除组会删除组里面所有的子项目! 确定要删除该组吗?",
"do you want to delete the item": "确定删除该项目吗",
}; };