← Back
Editing: smtp-dashboard-widget-email-sources.min.js
export default function(t,a,e,r){let o=r.el,l={selectors:{widget:'[data-widget="email_sources"]',root:".wpms-dashboard-email-sources",donut:".wpms-dashboard-widget-email-sources-donut",chartTotal:".wpms-dashboard-widget-email-sources-chart-total"},chart:null,init(){o.$document.on("wpMailSmtpDashboardDataReceived",l.onDataReceived),l.draw()},draw(){l.chart?.destroy(),l.chart=null;var t=o.$main.find(l.selectors.root).first(),a=t.find(l.selectors.donut).get(0);if(a&&"undefined"!=typeof WPMailSMTPChart){let e=l.readConfig(t);e&&(l.chart=new WPMailSMTPChart(a.getContext("2d"),{type:"doughnut",data:{labels:e.all.map(t=>t.name),datasets:[{data:e.all.map(t=>t.total),backgroundColor:e.all.map((t,a)=>e.palette[a%e.palette.length]),borderColor:"#f6f6f6",borderWidth:1<e.all.length?2:0}]},options:{cutout:"50%",animation:!1,maintainAspectRatio:!1,responsive:!0,plugins:{legend:{display:!1}}}}),t.find(l.selectors.chartTotal).text((new Intl.NumberFormat).format(e.donutTotal)))}},readConfig(t){if(!t.length)return null;try{return JSON.parse(t.attr("data-config"))}catch(t){return a.console?.error?.("WP Mail SMTP Dashboard: invalid Email Sources config.",t),null}},onDataReceived(t,a){var e;a?.email_sources_html&&(e=o.$main.find(l.selectors.widget).first()).length&&(e.replaceWith(a.email_sources_html),l.draw())}};return l}
Save File
Cancel