Merge pull request #37549 from sokumon/chat-popup
This commit is contained in:
commit
0d4ec69e64
2 changed files with 19 additions and 3 deletions
|
|
@ -89,13 +89,17 @@ function openFrappeCloudDashboard() {
|
|||
}
|
||||
|
||||
function addChatBubble() {
|
||||
if (checkBusinessHours()) {
|
||||
const all_apps = frappe.utils.get_installed_apps();
|
||||
const desk_apps = ["erpnext", "hrms"];
|
||||
|
||||
const apps_allowed = frappe.utils.is_sub_array(all_apps, desk_apps);
|
||||
if (checkBusinessHours && apps_allowed) {
|
||||
let chat_banner = document.createElement("script");
|
||||
chat_banner.innerHTML =
|
||||
'(function(d,t){var BASE_URL="https://chat.frappe.cloud";var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src=BASE_URL+"/packs/js/sdk.js";g.async=true;s.parentNode.insertBefore(g,s);g.onload=function(){window.chatwootSDK.run({websiteToken:"LdmfJzftdJGEcFjoTqk8CrSq",baseUrl:BASE_URL})}})(document,"script");';
|
||||
document.body.append(chat_banner);
|
||||
const root = document.documentElement;
|
||||
root.style.setProperty("--s-700", "var(--gray-50)");
|
||||
root.style.setProperty("--s-700", "var(--gray-500)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,5 +107,5 @@ function checkBusinessHours() {
|
|||
let currentTime = new Date();
|
||||
const istTime = new Date(currentTime.toLocaleString("en-US", { timeZone: "Asia/Kolkata" }));
|
||||
|
||||
return istTime.getHours() >= 11 && istTime.getHours() <= 18;
|
||||
return istTime.getHours() >= 11 && istTime.getHours() < 18;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2229,4 +2229,16 @@ Object.assign(frappe.utils, {
|
|||
}
|
||||
return value;
|
||||
},
|
||||
get_installed_apps() {
|
||||
return frappe.boot.app_data.map((app) => {
|
||||
return app.app_name;
|
||||
});
|
||||
},
|
||||
is_sub_array(big, small) {
|
||||
let i = 0;
|
||||
for (let num of big) {
|
||||
if (num === small[i]) i++;
|
||||
}
|
||||
return i === small.length;
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue