Tweak search sorting (#5464)
* Tweak search sorting * Tweak search sorting * fix ping impl * remove port field, add server regions * fix compile * fix tests * update frontend banner upload size limit * feat: use server project region instead of country * remove java and bedrock port in frontend * add helper text * allow filtering by if server is online * add server status online offline filter * use region in instance * pre-collapse status in app discovery * pnpm prepr * remove server discovery flag * add servers into mobile nav tabs * parse port from address if present --------- Co-authored-by: tdgao <mr.trumgao@gmail.com>
This commit is contained in:
@@ -55,25 +55,15 @@ const SERVER_CATEGORY_ICON_MAP: Record<string, string> = {
|
||||
'world-resets': 'refresh-ccw',
|
||||
}
|
||||
|
||||
export const SERVER_COUNTRIES = [
|
||||
{ code: 'US', name: 'United States' },
|
||||
{ code: 'GB', name: 'United Kingdom' },
|
||||
{ code: 'DE', name: 'Germany' },
|
||||
{ code: 'FR', name: 'France' },
|
||||
{ code: 'NL', name: 'Netherlands' },
|
||||
{ code: 'PL', name: 'Poland' },
|
||||
{ code: 'RU', name: 'Russia' },
|
||||
{ code: 'BR', name: 'Brazil' },
|
||||
{ code: 'CA', name: 'Canada' },
|
||||
{ code: 'AU', name: 'Australia' },
|
||||
{ code: 'SE', name: 'Sweden' },
|
||||
{ code: 'FI', name: 'Finland' },
|
||||
{ code: 'SG', name: 'Singapore' },
|
||||
{ code: 'JP', name: 'Japan' },
|
||||
{ code: 'KR', name: 'South Korea' },
|
||||
{ code: 'TR', name: 'Turkey' },
|
||||
{ code: 'IN', name: 'India' },
|
||||
{ code: 'ZA', name: 'South Africa' },
|
||||
export const SERVER_REGIONS = [
|
||||
{ code: 'us_east', name: 'US East' },
|
||||
{ code: 'us_west', name: 'US West' },
|
||||
{ code: 'europe', name: 'Europe' },
|
||||
{ code: 'asia', name: 'Asia' },
|
||||
{ code: 'australia', name: 'Australia' },
|
||||
{ code: 'south_america', name: 'South America' },
|
||||
{ code: 'middle_east', name: 'Middle East' },
|
||||
{ code: 'russia', name: 'Russia' },
|
||||
]
|
||||
|
||||
export const SERVER_LANGUAGES = [
|
||||
@@ -106,7 +96,8 @@ export const SERVER_SORT_TYPES: SortType[] = [
|
||||
const FILTER_FIELD_MAP: Record<string, string> = {
|
||||
server_content_type: 'minecraft_java_server.content.kind',
|
||||
server_game_version: 'minecraft_java_server.content.supported_game_versions',
|
||||
server_country: 'minecraft_server.country',
|
||||
server_status: 'minecraft_java_server.ping.data',
|
||||
server_region: 'minecraft_server.region',
|
||||
server_language: 'minecraft_server.languages',
|
||||
}
|
||||
|
||||
@@ -128,7 +119,7 @@ export function useServerSearch(opts: {
|
||||
const route = useRoute()
|
||||
|
||||
const serverCurrentSortType = ref<SortType>(SERVER_SORT_TYPES[0])
|
||||
const serverCurrentFilters = ref<FilterValue[]>([])
|
||||
const serverCurrentFilters = ref<FilterValue[]>([{ type: 'server_status', option: 'online' }])
|
||||
const serverToggledGroups = ref<string[]>([])
|
||||
|
||||
const serverFilterTypes = computed<FilterType[]>(() => {
|
||||
@@ -206,18 +197,18 @@ export function useServerSearch(opts: {
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: 'server_country',
|
||||
formatted_name: 'Country',
|
||||
id: 'server_region',
|
||||
formatted_name: 'Region',
|
||||
supported_project_types: ['server'],
|
||||
display: 'scrollable',
|
||||
query_param: 'sco',
|
||||
display: 'all',
|
||||
query_param: 'sr',
|
||||
supports_negative_filter: true,
|
||||
searchable: true,
|
||||
options: SERVER_COUNTRIES.map((c) => ({
|
||||
id: c.code,
|
||||
formatted_name: c.name,
|
||||
searchable: false,
|
||||
options: SERVER_REGIONS.map((r) => ({
|
||||
id: r.code,
|
||||
formatted_name: r.name,
|
||||
method: 'or' as const,
|
||||
value: c.code,
|
||||
value: r.code,
|
||||
})),
|
||||
},
|
||||
{
|
||||
@@ -235,6 +226,19 @@ export function useServerSearch(opts: {
|
||||
value: l.code,
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: 'server_status',
|
||||
formatted_name: 'Status',
|
||||
supported_project_types: ['server'],
|
||||
display: 'all',
|
||||
query_param: 'sst',
|
||||
supports_negative_filter: false,
|
||||
searchable: false,
|
||||
options: [
|
||||
{ id: 'online', formatted_name: 'Online', method: 'or', value: 'online' },
|
||||
{ id: 'offline', formatted_name: 'Offline', method: 'or', value: 'offline' },
|
||||
],
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
@@ -245,6 +249,18 @@ export function useServerSearch(opts: {
|
||||
const field = getFilterField(filterType.id)
|
||||
if (!field) continue
|
||||
const matched = serverCurrentFilters.value.filter((f) => f.type === filterType.id)
|
||||
if (matched.length === 0) continue
|
||||
|
||||
if (filterType.id === 'server_status') {
|
||||
const selected = matched[0]?.option
|
||||
if (selected === 'online') {
|
||||
parts.push(`${field} EXISTS`)
|
||||
} else if (selected === 'offline') {
|
||||
parts.push(`${field} NOT EXISTS`)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
const included = matched.filter((f) => !f.negative)
|
||||
const excluded = matched.filter((f) => f.negative)
|
||||
if (included.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user