Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Show regions when filtering by country etc
Uku Tahtdcf31502c277
diff --git a/assets/js/dashboard/stats/locations/index.js b/assets/js/dashboard/stats/locations/index.jsindex 2327d95075..d8a277ee6a 100644--- a/assets/js/dashboard/stats/locations/index.js+++ b/assets/js/dashboard/stats/locations/index.js@@ -7,7 +7,7 @@ import * as api from '../../api'import {apiPath, sitePath} from '../../util/url'import ListReport from '../reports/list'-function Countries({query, site}) {+function Countries({query, site, onClick}) {function fetchData() {return api.get(apiPath(site, '/countries'), query, {limit: 9}).then((res) => {return res.map(row => Object.assign({}, row, {percentage: undefined}))@@ -22,6 +22,7 @@ function Countries({query, site}) {<ListReportfetchData={fetchData}filter={{country: 'code', country_name: 'name'}}+ onClick={onClick}keyLabel="Country"detailsLink={sitePath(site, '/countries')}query={query}@@ -31,7 +32,7 @@ function Countries({query, site}) {)}-function Regions({query, site}) {+function Regions({query, site, onClick}) {function fetchData() {return api.get(apiPath(site, '/regions'), query, {country_name: query.filters.country, limit: 9})}@@ -44,6 +45,7 @@ function Regions({query, site}) {<ListReportfetchData={fetchData}filter={{region: 'code', region_name: 'name'}}+ onClick={onClick}keyLabel="Region"detailsLink={sitePath(site, '/regions')}query={query}@@ -85,6 +87,8 @@ const labelFor = {export default class Locations extends React.Component {constructor(props) {super(props)+ this.onCountryFilter = this.onCountryFilter.bind(this)+ this.onRegionFilter = this.onRegionFilter.bind(this)this.tabKey = `geoTab__${ props.site.domain}`const storedTab = storage.getItem(this.tabKey)this.state = {@@ -99,14 +103,22 @@ export default class Locations extends React.Component {}}+ onCountryFilter() {+ this.setMode('regions')()+ }++ onRegionFilter() {+ this.setMode('cities')()+ }+renderContent() {switch(this.state.mode) {case "cities":return <Cities site={this.props.site} query={this.props.query} timer={this.props.timer}/>case "regions":- return <Regions site={this.props.site} query={this.props.query} timer={this.props.timer}/>+ return <Regions onClick={this.onRegionFilter} site={this.props.site} query={this.props.query} timer={this.props.timer}/>case "countries":- return <Countries site={this.props.site} query={this.props.query} timer={this.props.timer}/>+ return <Countries onClick={this.onCountryFilter} site={this.props.site} query={this.props.query} timer={this.props.timer}/>case "map":default:return <CountriesMap site={this.props.site} query={this.props.query} timer={this.props.timer}/>diff --git a/assets/js/dashboard/stats/reports/list.js b/assets/js/dashboard/stats/reports/list.jsindex 63de8c737f..b52194fd13 100644--- a/assets/js/dashboard/stats/reports/list.js+++ b/assets/js/dashboard/stats/reports/list.js@@ -81,6 +81,7 @@ export default class ListReport extends React.Component {const maxWidthDeduction = this.showConversionRate() ? "10rem" : "5rem"const lightBackground = this.props.color || 'bg-green-50'+ const noop = () => {}return (<div className="flex items-center justify-between my-1 text-sm" key={listItem.name}>@@ -92,7 +93,7 @@ export default class ListReport extends React.Component {plot={this.valueKey()}><span className="flex px-2 py-1.5 group dark:text-gray-300 relative z-9 break-all" tooltip={this.props.tooltipText && this.props.tooltipText(listItem)}>- <Link className="md:truncate block hover:underline" to={{search: query.toString()}}>+ <Link onClick={this.props.onClick || noop} className="md:truncate block hover:underline" to={{search: query.toString()}}>{this.props.renderIcon && this.props.renderIcon(listItem)}{this.props.renderIcon && ' '}{listItem.name}diff --git a/mix.lock b/mix.lockindex 9251ccf209..9ce499c13c 100644--- a/mix.lock+++ b/mix.lock@@ -54,7 +54,7 @@"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},"kaffy": {:hex, :kaffy, "0.9.0", "bef34c9729f6a3af4d0dea8eede8bcb9e11371a83ac9a8b393991bce81839517", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "d18ff57b8e68feb433aed11e71510cd357abc7034e75358af5deff7d0d4c6ed3"},- "location": {:git, "https://github.com/plausible/location.git", "898e918d7094605b781a140001a746164691967c", []},+ "location": {:git, "https://github.com/plausible/location.git", "fe8b43d9dc52fb2bbc2dc79319b6888adada8d4c", []},"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},"mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"},"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},