chore: add insights banner (#20487)
* chore: add insights banner * chore: cleanup message and title [skip ci] --------- Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
parent
6bda014406
commit
e756d41790
1 changed files with 41 additions and 0 deletions
|
|
@ -38,6 +38,8 @@ frappe.views.ListSidebar = class ListSidebar {
|
|||
this.reload_stats();
|
||||
});
|
||||
}
|
||||
|
||||
this.add_insights_banner();
|
||||
}
|
||||
|
||||
setup_views() {
|
||||
|
|
@ -239,4 +241,43 @@ frappe.views.ListSidebar = class ListSidebar {
|
|||
this.sidebar.find(".stat-no-records").remove();
|
||||
this.get_stats();
|
||||
}
|
||||
|
||||
add_insights_banner() {
|
||||
try {
|
||||
if (this.list_view.view != "Report") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (localStorage.getItem("show_insights_banner") == "false") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.insights_banner) {
|
||||
this.insights_banner.remove();
|
||||
}
|
||||
|
||||
const message = "Get more insights from your data with Frappe Insights.";
|
||||
const link = "https://frappe.io/s/insights";
|
||||
const cta = "Get Frappe Insights";
|
||||
|
||||
this.insights_banner = $(`
|
||||
<div style="position: relative;">
|
||||
<div class="">
|
||||
${message}
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<a href="${link}" target="_blank" style="color: var(--primary-color)">${cta} -> </a>
|
||||
</div>
|
||||
<div style="position: absolute; top: 0px; right: 0px; cursor: pointer;" title="Dismiss"
|
||||
onclick="localStorage.setItem('show_insights_banner', 'false') || this.parentElement.remove()">
|
||||
<svg class="icon icon-sm" style="">
|
||||
<use class="" href="#icon-close"></use>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
`).appendTo(this.sidebar);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue