[ SYSTEM ]: Linux wordpress 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
presto-player
/
src
/
admin
/
analytics
/
components
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 DataTable.js
1,235 B
SET
[ EDIT ]
|
[ DEL ]
📄 DatePicker.js
1,421 B
SET
[ EDIT ]
|
[ DEL ]
📄 TopUsers.js
1,992 B
SET
[ EDIT ]
|
[ DEL ]
📄 TopVideos.js
2,633 B
SET
[ EDIT ]
|
[ DEL ]
📄 TotalVideoViewsByUser.js
790 B
SET
[ EDIT ]
|
[ DEL ]
📄 TotalViewsGraph.js
3,001 B
SET
[ EDIT ]
|
[ DEL ]
📄 TotalWatchGraph.js
2,949 B
SET
[ EDIT ]
|
[ DEL ]
📄 VideoAverageWatchTime.js
847 B
SET
[ EDIT ]
|
[ DEL ]
📄 VideoAverageWatchTimeByUser.js
861 B
SET
[ EDIT ]
|
[ DEL ]
📄 VideoTimeline.js
2,670 B
SET
[ EDIT ]
|
[ DEL ]
📄 VideoTotalWatchTimeByUser.js
857 B
SET
[ EDIT ]
|
[ DEL ]
📄 VideoViews.js
818 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: TotalViewsGraph.js
import { __, sprintf } from "@wordpress/i18n"; const { Card, CardBody } = wp.components; const { useState, useEffect, useRef } = wp.element; import Loading from "@/admin/settings/components/Loading"; import apiFetch from "@/shared/services/fetch"; import Chart from "react-apexcharts"; import { convertDateTimeToAbsoluteDate } from "../util"; export default (props) => { const [loading, setLoading] = useState(true); const [totalViews, setTotalViews] = useState(0); const { startDate, endDate } = props; const [series, setSeries] = useState([ { name: "Views", data: [], }, ]); const chart = { options: { chart: { toolbar: { show: false, }, }, yaxis: { min: 0, labels: { formatter: function (num) { if (num < 1) { return 0; } return Math.abs(num) > 999 ? Math.sign(num) * (Math.abs(num) / 1000).toFixed(1) + "k" : Math.sign(num) * Math.abs(num).toFixed(0); }, }, }, colors: ["#7c3aed"], xaxis: { type: "datetime", min: new Date(startDate).setHours(0, 0, 0, 0), max: new Date(endDate).setHours(23, 59, 59, 999), }, dataLabels: { enabled: false, }, stroke: { curve: "smooth" }, fill: { type: "gradient", gradient: { shadeIntensity: 1, opacityFrom: 0.7, opacityTo: 0.9, stops: [0, 90, 100], }, }, }, }; // fetch only if we already mounted useEffect(() => { fetchViews(); }, [props]); const fetchViews = () => { setLoading(true); apiFetch({ path: "/presto-player/v1/analytics/views?" + jQuery.param({ ...(startDate ? { start: convertDateTimeToAbsoluteDate(startDate) } : {}), ...(endDate ? { end: convertDateTimeToAbsoluteDate(endDate) } : {}), }), parse: false, }) .then(async (res) => { setTotalViews(res.headers && res.headers.get("X-WP-Total")); const data = await res.json(); let series = []; if (data.length) { data.forEach((item) => { series.push({ x: item.date_time, y: item.total, }); }); } setSeries([ { name: "Views", data: series, }, ]); }) .catch((e) => { console.error(e); }) .finally(() => { setLoading(false); }); }; if (loading) { return ( <CardBody> <Loading /> </CardBody> ); } return ( <CardBody className="presto-flow"> <div className="presto-card__title"> {sprintf(__("%d Unique Views", "presto-player"), totalViews)} </div> <Chart options={chart.options} series={series} type="area" height={280} /> </CardBody> ); };