Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/base-locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
"quest_condition": "Quest Condition",
"always_show_labels": "Always Show Labels",
"scan_areas_options": "Scan Areas Options",
"poi": "Points of Interest",
"300m_range": "300m Range",
"lure_range": "Lure Range"
}
12 changes: 12 additions & 0 deletions server/src/configs/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,18 @@
"enabled": {
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_ENABLED",
"__format": "boolean"
},
"rings": {
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_RINGS",
"__format": "boolean"
},
"s17Cells": {
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_S17CELLS",
"__format": "boolean"
},
"s14Cells": {
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_S14CELLS",
"__format": "boolean"
}
},
"weather": {
Expand Down
5 changes: 4 additions & 1 deletion server/src/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@
"enabled": false
},
"submissionCells": {
"enabled": false
"enabled": false,
"rings": true,
"s17Cells": true,
"s14Cells": true
},
"weather": {
"enabled": true
Expand Down
7 changes: 5 additions & 2 deletions server/src/graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,13 @@ module.exports = {
return [
{
placementCells:
args.zoom >= config.map.submissionZoom
args.zoom >= config.map.submissionZoom &&
args.filters.onlyS17Cells
? Utility.getPlacementCells(args, pokestops, gyms)
: [],
typeCells: Utility.getTypeCells(args, pokestops, gyms),
typeCells: args.filters.onlyS14Cells
? Utility.getTypeCells(args, pokestops, gyms)
: [],
},
]
}
Expand Down
3 changes: 3 additions & 0 deletions server/src/services/defaultFilters/buildDefaultFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ module.exports = function buildDefault(perms, available) {
submissionCells: perms.submissionCells
? {
enabled: defaultFilters.submissionCells.enabled,
rings: defaultFilters.submissionCells.rings,
s17Cells: defaultFilters.submissionCells.s17Cells,
s14Cells: defaultFilters.submissionCells.s14Cells,
filter: { global: new GenericFilter() },
}
: undefined,
Expand Down
4 changes: 3 additions & 1 deletion server/src/services/functions/getPlacementCells.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ module.exports = function getPlacementCells(bounds, pokestops, gyms) {
cell.blocked = true
}
}
const rings = allCoords.map((poi) => new Ring(poi.id, poi.lat, poi.lon))
const rings = bounds.filters.onlyRings
? allCoords.map((poi) => new Ring(poi.id, poi.lat, poi.lon))
: []

return {
cells: Object.values(indexedCells),
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/ui/clientOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function clientOptions(perms) {
clustering: { type: 'bool', perm: ['gyms', 'raids'] },
raidTimers: { type: 'bool', perm: ['raids'] },
interactionRanges: { type: 'bool', perm: ['gyms', 'raids'] },
"300mRange": { type: 'bool', perm: ['raids'] },
'300mRange': { type: 'bool', perm: ['raids'] },
showExBadge: { type: 'bool', perm: ['gyms'] },
showArBadge: { type: 'bool', perm: ['gyms'] },
raidLevelBadges: { type: 'bool', perm: ['raids'] },
Expand Down
169 changes: 84 additions & 85 deletions server/src/services/ui/primary.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,98 @@
/* eslint-disable no-restricted-syntax */
const {
api: {
pvp: { leagues },
},
defaultFilters: {
nests: { avgSliderStep },
nests: { avgSliderStep, avgFilter },
},
} = require('../config')

const refSliders = {
pokemon: {
primary: [
{
name: 'iv',
label: '%',
min: 0,
max: 100,
perm: 'iv',
color: 'secondary',
},
],
secondary: [
{
name: 'level',
label: '',
min: 1,
max: 35,
perm: 'iv',
},
{
name: 'atk_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
{
name: 'def_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
{
name: 'sta_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
],
},
nests: {
secondary: [
{
name: 'avgFilter',
i18nKey: 'spawns_per_hour',
label: '',
min: avgFilter[0],
max: avgFilter[1],
perm: 'nests',
step: avgSliderStep,
},
],
},
}

leagues.forEach((league) =>
refSliders.pokemon.primary.push({
name: league.name,
label: 'rank',
min: league.minRank || 1,
max: league.maxRank || 100,
perm: 'pvp',
color: 'primary',
}),
)

const ignoredKeys = [
'enabled',
'filter',
'showQuestSet',
'badge',
'avgFilter',
'raidTier',
]

module.exports = function generateUi(filters, perms) {
const ui = {}
const ignoredKeys = [
'enabled',
'filter',
'showQuestSet',
'badge',
'avgFilter',
'raidTier',
]

// builds the initial categories
for (const [key, value] of Object.entries(filters)) {
Object.entries(filters).forEach(([key, value]) => {
let sliders
if (value) {
switch (key) {
case 'nests':
ui[key] = {}
sliders = {
secondary: [
{
name: 'avgFilter',
i18nKey: 'spawns_per_hour',
label: '',
min: filters.nests.avgFilter[0],
max: filters.nests.avgFilter[1],
perm: 'nests',
step: avgSliderStep,
},
],
}
break
case 'pokemon':
ui[key] = {}
sliders = {
primary: [
{
name: 'iv',
label: '%',
min: 0,
max: 100,
perm: 'iv',
color: 'secondary',
},
],
secondary: [
{
name: 'level',
label: '',
min: 1,
max: 35,
perm: 'iv',
},
{
name: 'atk_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
{
name: 'def_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
{
name: 'sta_iv',
label: '',
min: 0,
max: 15,
perm: 'iv',
},
],
}
leagues.forEach((league) =>
sliders.primary.push({
name: league.name,
label: 'rank',
min: league.minRank || 1,
max: league.maxRank || 100,
perm: 'pvp',
color: 'primary',
}),
)
break
case 'submissionCells':
case 'portals':
if (!ui.wayfarer) ui.wayfarer = {}
Expand All @@ -108,10 +106,11 @@ module.exports = function generateUi(filters, perms) {
break
default:
ui[key] = {}
sliders = refSliders[key]
break
}
// builds each subcategory
for (const [subKey, subValue] of Object.entries(value)) {
Object.entries(value).forEach(([subKey, subValue]) => {
if (
(!ignoredKeys.includes(subKey) && subValue !== undefined) ||
key === 'weather' ||
Expand All @@ -136,7 +135,7 @@ module.exports = function generateUi(filters, perms) {
break
}
}
}
})
// adds any sliders present
if (sliders) {
ui[key].sliders = sliders
Expand All @@ -150,7 +149,7 @@ module.exports = function generateUi(filters, perms) {
})
}
}
}
})

// deletes any menus that do not have any items/perms
Object.keys(ui).forEach((category) => {
Expand Down
38 changes: 36 additions & 2 deletions src/components/layout/drawer/WithSubItems.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import React, { Fragment } from 'react'
import { Grid, Typography, Switch, Select, MenuItem } from '@material-ui/core'
import { useTranslation } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'

import Utility from '@services/Utility'

Expand Down Expand Up @@ -148,6 +148,40 @@ export default function WithSubItems({
</Grid>
</>
)}
{category === 'wayfarer' && subItem === 'submissionCells' && (
<>
{['rings', 's14Cells', 's17Cells'].map((item, i) => (
<Fragment key={item}>
<Grid item xs={8}>
<Typography>
{i ? (
<Trans i18nKey="s2_cell_level">
{{ level: item.substring(1, 3) }}
</Trans>
) : (
t('poi')
)}
</Typography>
</Grid>
<Grid item xs={4} style={{ textAlign: 'right' }}>
<Switch
checked={filters[subItem][item]}
onChange={() => {
setFilters({
...filters,
[subItem]: {
...filters[subItem],
[item]: !filters[subItem][item],
},
})
}}
disabled={!filters[subItem].enabled}
/>
</Grid>
</Fragment>
))}
</>
)}
</>
)
}