@ -5,7 +5,7 @@ import ListReport from '../reports/list'
import * as api from '../../api'
import * as url from '../../util/url'
function Browsers ( { query , site } ) {
function Browsers ( { query , site } ) {
function fetchData ( ) {
return api . get ( url . apiPath ( site , '/browsers' ) , query )
}
@ -13,29 +13,34 @@ function Browsers({query, site}) {
return (
< ListReport
fetchData = { fetchData }
filter = { { browser : 'name' } }
filter = { { browser : 'name' } }
keyLabel = "Browser"
query = { query }
/ >
)
}
function BrowserVersions ( { query , site } ) {
function BrowserVersions ( { query , site } ) {
function fetchData ( ) {
return api . get ( url . apiPath ( site , '/browser-versions' ) , query )
}
const isNotSet = query . filters . browser === '(not set)'
const browserName = isNotSet ? 'Browser' : query . filters . browser
const filter = isNotSet ? { } : { browser _version : 'name' }
return (
< ListReport
fetchData = { fetchData }
filter = { { browser _version : 'name' } }
keyLabel = { query. filters . browser + ' version' }
filter = { filter }
keyLabel = { browserName + ' version' }
query = { query }
/ >
)
}
function OperatingSystems ( { query , site } ) {
function OperatingSystems ( { query , site } ) {
function fetchData ( ) {
return api . get ( url . apiPath ( site , '/operating-systems' ) , query )
}
@ -43,29 +48,34 @@ function OperatingSystems({query, site}) {
return (
< ListReport
fetchData = { fetchData }
filter = { { os : 'name' } }
filter = { { os : 'name' } }
keyLabel = "Operating system"
query = { query }
/ >
)
}
function OperatingSystemVersions ( { query , site } ) {
function OperatingSystemVersions ( { query , site } ) {
function fetchData ( ) {
return api . get ( url . apiPath ( site , '/operating-system-versions' ) , query )
}
const isNotSet = query . filters . os === '(not set)'
const osName = isNotSet ? 'Operating System' : query . filters . os
const filter = isNotSet ? { } : { os _version : 'name' }
return (
< ListReport
fetchData = { fetchData }
filter = { { os _version : 'name' } }
keyLabel = { query. filters . os + ' version' }
filter = { filter }
keyLabel = { osName + ' version' }
query = { query }
/ >
)
}
function ScreenSizes ( { query , site } ) {
function ScreenSizes ( { query , site } ) {
function fetchData ( ) {
return api . get ( url . apiPath ( site , '/screen-sizes' ) , query )
}
@ -81,7 +91,7 @@ function ScreenSizes({query, site}) {
return (
< ListReport
fetchData = { fetchData }
filter = { { screen : 'name' } }
filter = { { screen : 'name' } }
keyLabel = "Screen size"
query = { query }
renderIcon = { renderIcon }
@ -100,38 +110,39 @@ const EXPLANATION = {
function iconFor ( screenSize ) {
if ( screenSize === 'Mobile' ) {
return (
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "5" y = "2" width = "14" height = "20" rx = "2" ry = "2" / > < line x1 = "12" y1 = "18" x2 = "12" y2 = "18" / > < / s v g >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "5" y = "2" width = "14" height = "20" rx = "2" ry = "2" / > < line x1 = "12" y1 = "18" x2 = "12" y2 = "18" / > < / s v g >
)
} else if ( screenSize === 'Tablet' ) {
return (
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "4" y = "2" width = "16" height = "20" rx = "2" ry = "2" transform = "rotate(180 12 12)" / > < line x1 = "12" y1 = "18" x2 = "12" y2 = "18" / > < / s v g >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "4" y = "2" width = "16" height = "20" rx = "2" ry = "2" transform = "rotate(180 12 12)" / > < line x1 = "12" y1 = "18" x2 = "12" y2 = "18" / > < / s v g >
)
} else if ( screenSize === 'Laptop' ) {
return (
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "2" y = "3" width = "20" height = "14" rx = "2" ry = "2" / > < line x1 = "2" y1 = "20" x2 = "22" y2 = "20" / > < / s v g >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "2" y = "3" width = "20" height = "14" rx = "2" ry = "2" / > < line x1 = "2" y1 = "20" x2 = "22" y2 = "20" / > < / s v g >
)
} else if ( screenSize === 'Desktop' ) {
return (
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "2" y = "3" width = "20" height = "14" rx = "2" ry = "2" / > < line x1 = "8" y1 = "21" x2 = "16" y2 = "21" / > < line x1 = "12" y1 = "17" x2 = "12" y2 = "21" / > < / s v g >
< svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "-mt-px feather" > < rect x = "2" y = "3" width = "20" height = "14" rx = "2" ry = "2" / > < line x1 = "8" y1 = "21" x2 = "16" y2 = "21" / > < line x1 = "12" y1 = "17" x2 = "12" y2 = "21" / > < / s v g >
)
} else if ( screenSize === '(not set)' ) {
return null
}
}
export default class Devices extends React . Component {
constructor ( props ) {
super ( props )
this . tabKey = ` deviceTab__ ${ props . site . domain } `
this . tabKey = ` deviceTab__ ${ props . site . domain } `
const storedTab = storage . getItem ( this . tabKey )
this . state = {
mode : storedTab || 'size'
}
}
setMode ( mode ) {
return ( ) => {
storage . setItem ( this . tabKey , mode )
this . setState ( { mode } )
this . setState ( { mode } )
}
}
@ -189,12 +200,12 @@ export default class Devices extends React.Component {
< div className = "flex justify-between w-full" >
< h3 className = "font-bold dark:text-gray-100" > Devices < / h 3 >
< div className = "flex text-xs font-medium text-gray-500 dark:text-gray-400 space-x-2" >
{ this . renderPill ( 'Size' , 'size' ) }
{ this . renderPill ( 'Browser' , 'browser' ) }
{ this . renderPill ( 'OS' , 'os' ) }
{ this . renderPill ( 'Size' , 'size' ) }
{ this . renderPill ( 'Browser' , 'browser' ) }
{ this . renderPill ( 'OS' , 'os' ) }
< / d i v >
< / d i v >
{ this . renderContent ( ) }
{ this . renderContent ( ) }
< / d i v >
< / d i v >
)