Add voxtelesys_integration/doctype/voxtelesys_settings/voxtelesys_settings.js
This commit is contained in:
parent
9a17384cd2
commit
f507e90484
1 changed files with 29 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
frappe.ui.form.on("Voxtelesys Settings", {
|
||||
refresh(frm) {
|
||||
frm.set_df_property("webhook_url_display", "read_only", 1);
|
||||
if (!frm.doc.webhook_url_display) {
|
||||
const base = frm.doc.voxml_base_url || `${window.location.protocol}//${window.location.host}`;
|
||||
frm.set_value("webhook_url_display",
|
||||
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
|
||||
}
|
||||
frm.add_custom_button(__("Test API Connection"), () => {
|
||||
frappe.call({
|
||||
method: "voxtelesys_integration.api.voxtelesys.test_connection",
|
||||
callback(r) {
|
||||
if (r.message && r.message.ok) {
|
||||
frappe.msgprint({ title: __("Connection Successful"),
|
||||
message: __("Voxtelesys API responded correctly."), indicator: "green" });
|
||||
} else {
|
||||
frappe.msgprint({ title: __("Connection Failed"),
|
||||
message: r.message?.error || __("Could not reach Voxtelesys API."), indicator: "red" });
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
voxml_base_url(frm) {
|
||||
const base = (frm.doc.voxml_base_url || "").replace(/\/$/, "");
|
||||
frm.set_value("webhook_url_display",
|
||||
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
|
||||
},
|
||||
});
|
||||
Loading…
Reference in a new issue