Custom Maps: geo map and color backgrounds (#16020)

* Custom Maps: geo map and color background
tabs blade component
geo-map blade component and related script enhancements

* Update css/js

* style fixes

* update db_schema.yaml

* fix db_schema hand edit

* ignore phpstan being wrong

* Handle null

* another possible null spot

* Use standard file cache for custom map background images

* Create map->image as jpeg so we can compress it

* whitespace fix

* Fix background cancel button when other type is selected than the saved type

* Save and restore layer

* Map must exist before creating static image

* Don't show set as image button for Google and Bing.
Bing gives an odd error, but Google won't work.
This commit is contained in:
Tony Murray
2024-05-13 08:12:59 -05:00
committed by GitHub
parent 1e3e60d59b
commit 0d246a6ffc
29 changed files with 2082 additions and 863 deletions

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// check for existence if migration fails
if (! Schema::hasColumn('custom_maps', 'background_data')) {
Schema::table('custom_maps', function (Blueprint $table) {
$table->string('background_type', 16)->default('none');
$table->text('background_data')->nullable();
});
}
// migrate data
DB::table('custom_maps')->select(['custom_map_id', 'background_suffix', 'background_version'])->get()->map(function ($map) {
if ($map->background_suffix) {
DB::table('custom_maps')->where('custom_map_id', $map->custom_map_id)->update([
'background_type' => 'image',
'background_data' => json_encode([
'suffix' => $map->background_suffix,
'version' => $map->background_version,
]),
]);
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// migrate data
DB::table('custom_maps')->select(['custom_map_id', 'background_type', 'background_data'])->get()->map(function ($map) {
if ($map->background_type == 'image' && $map->background_data) {
$data = json_decode($map->background_data, true);
DB::table('custom_maps')->where('custom_map_id', $map->custom_map_id)->update([
'background_suffix' => $data['suffix'],
'background_version' => $data['version'],
]);
}
});
Schema::table('custom_maps', function (Blueprint $table) {
$table->dropColumn(['background_type', 'background_data']);
});
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('custom_maps', function (Blueprint $table) {
$table->dropColumn(['background_suffix', 'background_version']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('custom_maps', function (Blueprint $table) {
$table->string('background_suffix', 10)->nullable()->after('legend_hide_overspeed');
$table->integer('background_version')->unsigned()->after('background_suffix');
});
}
};