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

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) {
console.log(a);
},
async deleteItem(
evt: PointerEvent | null,
is_group: boolean,
uuid: string
) {
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,
});
};
let success = false;
if (is_group) {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteModeGroup(uuid);
if (response) {
success = response.success;
}
$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 response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteModeGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteMode(uuid);
if (response) {
success = response.success;
}
$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 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) {
GlobalData.getInstance().getCurrentClient()?.callMode(item.uuid);

View File

@ -224,36 +224,70 @@ export default defineComponent({
loga(a: any) {
console.log(a);
},
async deleteItem(
evt: MouseEvent | null,
is_group: boolean,
uuid: string
) {
let success = false;
deleteItem(evt: MouseEvent | 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,
});
};
if (is_group) {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deletePlanGroup(uuid);
if (response) {
success = response.success;
}
$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()
?.deletePlanGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deletePlan(uuid);
if (response) {
success = response.success;
}
$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;
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) {
if (!$store.state.power_state) {

View File

@ -177,35 +177,72 @@ export default defineComponent({
loga(a: any) {
console.log(a);
},
async deleteItem(
evt: PointerEvent | null,
is_group: boolean,
uuid: string
) {
let success = false;
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,
});
};
if (is_group) {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deletePollingGroup(uuid);
if (response) {
success = response.success;
}
$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()
?.deletePollingGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else {
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deletePolling(uuid);
if (response) {
success = response.success;
}
$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;
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) {
e.dataTransfer?.setData("uuid", node.uuid);

View File

@ -318,42 +318,74 @@ export default defineComponent({
getItemIcon(item_type: string) {
return Common.getSignalSourceIcon(item_type);
},
async deleteItem(
evt: PointerEvent | null,
is_group: boolean,
uuid: string
) {
let success = false;
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,
});
};
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.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;
$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,
});
},
updateContextMenu() {
lossy_pic.value =
(GlobalData.getInstance().applicationConfig?.hdmi_in_decode_type_1 ??
"NV12") == "NV12";
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteSignalSourceGroup(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
} else {
$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;
let response = await GlobalData.getInstance()
.getCurrentClient()
?.deleteSignalSource(uuid);
if (response) {
success = response.success;
}
show_tooltip(success);
});
}
},
updateContextMenu() {},
async setHdmiInDecodeType(index: number, type: string) {
let success = false;

View File

@ -332,4 +332,7 @@ export default {
"send power off command": "Send Power Off Command",
"set subtitle success": "Set OSD Success",
"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: "实际",
"current real": "当前实际",
"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": "确定删除该项目吗",
};