PATH:
home
/
lab2454c
/
costbloc.com
/
public
/
dist
/
js
/
custom
"use strict";$.fn.isInViewport=function(){return 0!=this.length&&this[0].getBoundingClientRect().top<$(window).height()};class AjaxRequest{static async call(t,e={}){return await fetch(t,Object.assign({method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}},e)).then(t=>t.json()).then(t=>t.response)}}class Dashboard{element;fetched=!1;links=[];params={};static getObject(){return null==this.myself&&(this.myself=new this),this.myself}async update(t){this.fetched=!0;let e=await AjaxRequest.call(t,this.params);if(this.getStatus(e))this.renderData(this.element,e);else throw Error(this.getErrMessage(e))}dataAlreadyFetched(t){return void 0!=dashboardAjaxData[t]}getFromFetchedData(t){return dashboardAjaxData[t]}sliceData(t,e=5){return t.slice(0,e)}switchView(){this.element.find(".placeholder-data").addClass("d-none"),this.element.find(".original-data").removeClass("d-none")}sync(t){this.hasObject()&&!this.fetched&&this.element.isInViewport()&&t&&this.update(t)}hasObject(){return void 0!=this.element&&!(this.element.length<1)}renderData(){throw Error("Must implement renderData() method.")}getStatus(t){return!!t.status&&!!t.status.code&&200==t.status.code}getErrMessage(t){return t.status.message}formatString(t,e=20,s="..."){return t.length>e-s.length?t.substr(0,e)+s:t}formatUrl(t,e,s=null){return s?t.replace(s,e):t.replace("__id__",e)}addLink(t,e){return this.links[e]=t,this}getLink(t,e,s=null){return void 0==this.links[t]?"#":s?this.links[t].replace(s,e):this.links[t].replace("__id__",e)}setParams(t){return this.params=t,this}resetFetch(){return this.fetched=!1,this}}class DashReport extends Dashboard{static myself=null;constructor(){super(),super.element=$("#dashboard-reports")}renderData(t,e){e=super.sliceData(e.records);let s="";e.forEach(t=>{s+="<tr class='unread'><td><img></td>",s+="<td><h6>"+t.title.substr(0,20)+"</H6></td>",s+='<td class=""><h6>11 MAY 12:56</h6></td>',s+='<td class=""><a href="#!" class="label bg-c-blue text-white f-12">View</a></td>',s+="</tr>"}),t.find(".original-data").append(s),super.switchView()}}class VendorStats extends Dashboard{static myself=null;constructor(){super(),super.element=$("#vendor-stat")}renderData(t,e){e=super.sliceData(e.records);let s="";e.forEach(t=>{if(t.name){s+='<tr class="unread"><td><h6 class="mb-0" data-url="'+t.url+'">'+t.name.substr(0,20)+"</H6></td>",s+='<td class="text-center">';for(let e=1;e<=5;e++)t.ratings>0?s+='<span><i class="fa fa-star f-12 text-c-yellow"></i></span>':s+='<span"><i class="fa fa-star f-12 star-inactive"></i></a>',t.ratings--;s+="</td>",s+='<td><h6 class="text-center mb-0">'+t.orders+"</h6></td>",s+='<td><h6 class="text-center mb-0">'+t.sales+"</h6></td>",s+='<td class="text-center"><a href="'+super.getLink("edit",t.id)+'" class="label view-color-btn f-12 text-2c">'+jsLang("VIEW")+"</a></td>",s+="</tr>"}}),0==e.length&&(t.find(".original-data").siblings("thead").remove(),s=`<tr class="border-0"><td colspan="2" class="border-0">${jsLang("No data found.")}</td></tr>`),t.find(".original-data").append(s),super.switchView()}}class MostVisitedReport extends Dashboard{static myself=null;constructor(){super(),super.element=$("#most-visited-page")}renderData(t,e){e=super.sliceData(e.records);let s="";e.forEach(t=>{s+='<tr class="unread">',s+="<td><h6 class='mb-0'>"+t.title.substr(0,20)+"</h6></td>",s+='<td class="text-right"><h6 class="mb-0">'+Math.floor(100*Math.random()+50)+"</h6></td>",s+="</tr>"}),t.find(".original-data").append(s),super.switchView()}}class CustomerComplain extends Dashboard{static myself=null;constructor(){super(),super.element=$("#customer-complain")}renderData(t,e){super.switchView()}}class MostActiveUsers extends Dashboard{static myself=null;constructor(){super(),super.element=$("#most-active-users")}isVendor=document.getElementById("vendor_dashboard_container");admin(t){let e="";return t.forEach(t=>{e+=` <tr class='unread'> <td><a class="mb-0" target="_blank" href="${t.profile}">${super.formatString(t.name)}</a></td> <td class="text-right">${t.total}</td> </tr> `}),e}vendor(t){let e="";return t.forEach(t=>{e+=` <tr class='unread'> <td><span class=" mb-0">${super.formatString(t.name)}</span></td> <td class="text-right">${t.total}</td> </tr> `}),e}renderData(t,e){e=super.sliceData(e.records);let s="";s=this.isVendor?this.vendor(e):this.admin(e),0==e.length&&(t.find(".original-data").siblings("thead").remove(),s=`<tr class="border-0"><td colspan="2" class="border-0">${jsLang("No data found.")}</td></tr>`),t.find(".original-data").append(s),super.switchView()}}class MostSoldProducts extends Dashboard{static myself=null;constructor(){super(),super.element=$("#most-sold-products")}renderData(t,e){e=super.sliceData(e.records);let s="";e.forEach(t=>{s+="<tr class='unread'>",s+=`<td><a class='mb-0' href='${t.url}' target="${"javascript:void(0)"==t.url?"_self":"_blank"}">${super.formatString(t.name)}</a></td>`,s+='<td class="text-right">'+t.total+" </td>",s+="</tr>"}),0==e.length&&(t.find(".original-data").siblings("thead").remove(),s=`<tr class="border-0"><td colspan="2" class="border-0">${jsLang("No data found.")}</td></tr>`),t.find(".original-data").append(s),super.switchView()}}var ctx=$("#chart-area-2");ctx.height(335);class SaleOfThisMonth extends Dashboard{static myself=null;constructor(){super(),super.element=$("#sale-of-this-month")}renderData(t,e){this.lineChart(t,e),super.switchView()}lineChart=(t,e)=>{t.find(".placeholder").addClass("d-none");let s=t.find("#chart-area-2");s.removeClass("d-none"),this.updateChart(s[0],e.records)};dayMonth(t){let e=new Date;e.setMonth(t-1);let s=e.getFullYear().toLocaleString(localeString);return t<=0&&(t+=12),e.toLocaleString(localeString,{month:"short"})+" "+s}monthToColor(t){var e;return t%3==0?"rgba(252, 202, 25, 1)":t%3==1?"rgba(227, 147, 255, 1)":"rgba(0, 223, 255, 1)"}updateChart=(t,e)=>{var s=t.getContext("2d"),a=[];for(let r in e.values){var n=s.createLinearGradient(0,0,500,0);n.addColorStop(1,this.monthToColor(r));let l={label:this.dayMonth(r),data:e.values[r],borderWidth:4,borderColor:n,backgroundColor:n,hoverborderColor:n,hoverBackgroundColor:n,tension:.1};a.push(l)}var d={labels:e.dates,datasets:a},i=new Chart(s,{type:"line",data:d,responsive:!0,fill:!0,options:{scales:{y:{title:{display:!0,text:jsLang("Sales")}}}}})}}class VendorReq extends Dashboard{static myself=null;constructor(){super(),super.element=$("#vendor-request")}renderData(t,e){e=super.sliceData(e.records);let s="";e.forEach(t=>{s+='<tr class="unread">',s+='<td> <img class="rounded-circle w-30p" src="'+t.file_url+'" alt="activity-user"> </td>',s+='<td><h6 class="mb-0" data-url="'+t.url+'">'+t.name.substr(0,20)+"</h6></td>",s+='<td class="text-center"> <h6 class="text-muted mb-0">'+t.created_at+"</h6></td>",s+='<td class="text-right"> <a target="_blank" href="'+t.view+'" class="label view-color-btn text-2c f-12">'+jsLang("View")+'</a><a class="label f-12 text-white accept-color-btn" target="_blank" href="'+t.view+'">'+jsLang("Accept")+'</a><a class="label text-white f-12 reject-color-btn" target="_blank" href="'+t.view+'">'+jsLang("Reject")+"</a></td>",s+="</tr>"}),0==e.length&&(t.find(".original-data").siblings("thead").remove(),s=`<tr class="border-0"><td colspan="2" class="border-0">${jsLang("No data found.")}</td></tr>`),t.find(".original-data").append(s),super.switchView()}}$(document).ready(function(){let t=()=>{DashReport.getObject().sync(),MostVisitedReport.getObject().sync(),CustomerComplain.getObject().sync(),VendorStats.getObject().addLink(vendorEdiUrl,"edit").sync(vendorStatsUrl),MostActiveUsers.getObject().sync(mostActiveUsersUrl),MostSoldProducts.getObject().sync(mostSoldProductsUrl),SaleOfThisMonth.getObject().sync(salesOfThisMonth),"undefined"!=typeof vendorReqsUrl&&VendorReq.getObject().addLink(vendorReqsUrl,"edit").sync(vendorReqsUrl)};function e(){$(".placeholder-data-sta").removeClass("d-none"),$(".original-data-sta").addClass("d-none"),$(".original-data-sta").empty()}$(document).on("scroll",()=>{t()}),$(document).on("click",".daily",function(t){t.preventDefault(),e(),VendorStats.getObject().resetFetch().sync(vendorStatsUrlDaily)}),$(document).on("click",".weekly",function(t){t.preventDefault(),e(),VendorStats.getObject().resetFetch().sync(vendorStatsUrlWeekly)}),$(document).on("click",".monthly",function(t){t.preventDefault(),e(),VendorStats.getObject().resetFetch().sync(vendorStatsUrlMonthly)}),$(document).on("click",".yearly",function(t){t.preventDefault(),e(),VendorStats.getObject().resetFetch().sync(vendorStatsUrlYearly)}),$(document).on("click",".vendor-req",function(t){t.preventDefault();let e=$(this).attr("data-url");$(".placeholder-data-req").removeClass("d-none"),$(".original-data-req").addClass("d-none"),$(".original-data-req").empty(),VendorReq.getObject().resetFetch().sync(e)}),t()});
[-] create-product.min.js
[edit]
[-] refund.js
[edit]
[-] shops.js
[edit]
[-] commission.min.js
[edit]
[-] user.min.js
[edit]
[-] installer.js
[edit]
[-] category.min.js
[edit]
[+]
site
[-] jquery.blockUI.js
[edit]
[-] category.js
[edit]
[-] create-product.js
[edit]
[-] refund.min.js
[edit]
[+]
..
[-] shipping.min.js
[edit]
[-] user.js
[edit]
[-] jquery.blockUI.min.js
[edit]
[-] option.min.js
[edit]
[-] users-activity-list.js
[edit]
[-] attribute.min.js
[edit]
[-] email-configuration.min.js
[edit]
[-] dashboard.js
[edit]
[-] order.min.js
[edit]
[-] delete-modal.js
[edit]
[-] withdrawal.js
[edit]
[-] product-setting.js
[edit]
[-] validation.js
[edit]
[-] vendors.min.js
[edit]
[-] shops.min.js
[edit]
[-] roles.js
[edit]
[-] review.js
[edit]
[-] common.min.js
[edit]
[-] geolocale-suggestion.min.js
[edit]
[-] custom-category.js
[edit]
[-] product.js
[edit]
[-] order-invoice.min.js
[edit]
[-] common.js
[edit]
[-] product_list.js
[edit]
[-] settings.js
[edit]
[-] permission.min.js
[edit]
[-] coupon.js
[edit]
[-] export.js
[edit]
[-] yajra-custom.min.js
[edit]
[-] users-activity-list.min.js
[edit]
[-] finance.min.js
[edit]
[-] geolocale-suggestion.js
[edit]
[-] option.js
[edit]
[-] newsletter.min.js
[edit]
[-] order.js
[edit]
[-] role-permission.js
[edit]
[-] brand.min.js
[edit]
[-] transaction.js
[edit]
[-] popup.min.js
[edit]
[-] validation.min.js
[edit]
[-] templates.min.js
[edit]
[-] attribute.js
[edit]
[-] brand.js
[edit]
[-] app-layout.js
[edit]
[-] preference.js
[edit]
[-] invoice.js
[edit]
[-] order-invoice.js
[edit]
[-] yajra-export.js
[edit]
[-] product-setting.min.js
[edit]
[-] yajra-custom.js
[edit]
[-] installer.min.js
[edit]
[-] invoice.min.js
[edit]
[-] product_list.min.js
[edit]
[-] email-configuration.js
[edit]
[-] custom-category.min.js
[edit]
[-] settings.min.js
[edit]
[-] yajra-export.min.js
[edit]
[-] withdrawal.min.js
[edit]
[-] payment.js
[edit]
[-] preference.min.js
[edit]
[-] roles.min.js
[edit]
[-] finance.js
[edit]
[-] app-layout.min.js
[edit]
[-] permission.js
[edit]
[-] transaction.min.js
[edit]
[-] popup.js
[edit]
[-] order_status.min.js
[edit]
[-] commission.js
[edit]
[-] coupon.min.js
[edit]
[-] shipping.js
[edit]
[-] review.min.js
[edit]
[-] templates.js
[edit]
[-] delete-modal.min.js
[edit]
[-] vendors.js
[edit]
[-] order_status.js
[edit]
[-] dashboard.min.js
[edit]
[-] newsletter.js
[edit]
[-] product.min.js
[edit]
[-] export.min.js
[edit]