Skip to content

Commit

Permalink
add search_spec_map_center to config (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv authored Sep 18, 2022
1 parent c010c38 commit 8341df3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/Http/Controllers/SwitcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ private function getServerInfo($request): BaseJsonResponse
'versionInt' => strval((intval($versionArray[0]) * 1000000) + (intval($versionArray[1]) * 1000) + intval($versionArray[2])),
'langs' => collect(scandir(base_path('lang')))->reject(fn ($dir) => $dir == '.' || $dir == '..')->sort()->join(','),
'nativeLang' => config('app.locale'),
'centerLongitude' => strval(legacy_config('search_spec_map_center_longitude')),
'centerLatitude' => strval(legacy_config('search_spec_map_center_latitude')),
'centerZoom' => strval(legacy_config('search_spec_map_center_zoom')),
'defaultDuration' => legacy_config('default_duration_time'),
'regionBias' => legacy_config('region_bias'),
'charSet' => 'UTF-8',
Expand Down
4 changes: 3 additions & 1 deletion src/app/LegacyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ private static function loadConfig()
$config['meeting_states_and_provinces'] = $meeting_states_and_provinces ?? [];
$config['meeting_counties_and_sub_provinces'] = $meeting_counties_and_sub_provinces ?? [];
$config['meeting_time_zones_enabled'] = isset($meeting_time_zones_enabled) && $meeting_time_zones_enabled;

$config['search_spec_map_center_longitude'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['longitude']) ? $search_spec_map_center['longitude'] : -118.563659;
$config['search_spec_map_center_latitude'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['latitude']) ? $search_spec_map_center['latitude'] : 34.235918;
$config['search_spec_map_center_zoom'] = isset($search_spec_map_center) && is_array($search_spec_map_center) && isset($search_spec_map_center['zoom']) ? $search_spec_map_center['zoom'] : 6;

self::$config = $config;
self::$configLoaded = true;
Expand Down
63 changes: 63 additions & 0 deletions src/tests/Feature/GetServerInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,67 @@ public function testMeetingTimeZonesEnabled()
LegacyConfig::reset();
}
}

public function testCenterLongitude()
{
LegacyConfig::remove('search_spec_map_center_longitude');
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerLongitude' => '']);
} finally {
LegacyConfig::reset();
}

LegacyConfig::set('search_spec_map_center_longitude', -79.793701171875);
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerLongitude' => '-79.793701171875']);
} finally {
LegacyConfig::reset();
}
}

public function testCenterLatitude()
{
LegacyConfig::remove('search_spec_map_center_latitude');
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerLatitude' => '']);
} finally {
LegacyConfig::reset();
}

LegacyConfig::set('search_spec_map_center_latitude', 36.065752051707);
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerLatitude' => '36.065752051707']);
} finally {
LegacyConfig::reset();
}
}

public function testCenterZoom()
{
LegacyConfig::remove('search_spec_map_center_zoom');
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerZoom' => '']);
} finally {
LegacyConfig::reset();
}

LegacyConfig::set('search_spec_map_center_zoom', 10);
try {
$this->get('/client_interface/json/?switcher=GetServerInfo')
->assertStatus(200)
->assertJsonFragment(['centerZoom' => '10']);
} finally {
LegacyConfig::reset();
}
}
}

0 comments on commit 8341df3

Please sign in to comment.