[Delete] Doesn't use Bounding Boxes in code.
This commit is contained in:
parent
8e143badc5
commit
a4f48d04a4
|
|
@ -36,14 +36,12 @@ public function __construct(ProjectDownload $download, Carbon $date,)
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
logger(json_encode($this->download->project->getBoundingBoxesAsArray()));
|
|
||||||
|
|
||||||
$command = [
|
$command = [
|
||||||
sprintf('%srunpython.sh', base_path('../')),
|
sprintf('%srunpython.sh', base_path('../')),
|
||||||
sprintf('--date=%s', $this->date->format('Y-m-d')),
|
sprintf('--date=%s', $this->date->format('Y-m-d')),
|
||||||
sprintf('--days=%d', $this->days),
|
sprintf('--days=%d', $this->days),
|
||||||
sprintf('--project_dir=%s', $this->download->project->download_path),
|
sprintf('--project_dir=%s', $this->download->project->download_path),
|
||||||
sprintf('--bbox=%s', json_encode($this->download->project->getBoundingBoxesAsArray())),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$process = new Process($command);
|
$process = new Process($command);
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
namespace App\Livewire\Projects;
|
namespace App\Livewire\Projects;
|
||||||
|
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectBoundingBox;
|
|
||||||
use App\Models\ProjectEmailRecipient;
|
use App\Models\ProjectEmailRecipient;
|
||||||
use App\Rules\HarvestFile;
|
use App\Rules\HarvestFile;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
@ -27,9 +25,9 @@ class ProjectManager extends Component
|
||||||
public $showMailSettingsModal = false;
|
public $showMailSettingsModal = false;
|
||||||
|
|
||||||
public $projectIdBeingDeleted;
|
public $projectIdBeingDeleted;
|
||||||
public $span_json_path;
|
// public $span_json_path;
|
||||||
public $pivot_json_path;
|
// public $pivot_json_path;
|
||||||
public $harvest_json_path;
|
// public $harvest_json_path;
|
||||||
|
|
||||||
public array $pivotFiles;
|
public array $pivotFiles;
|
||||||
public array $spanFiles;
|
public array $spanFiles;
|
||||||
|
|
@ -58,19 +56,19 @@ public function editMailSettings(Project $project)
|
||||||
$this->loadFormData($project);
|
$this->loadFormData($project);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadFormData(Project $project)
|
private function loadFormData(Project $project)
|
||||||
{
|
{
|
||||||
$this->formData = $project->toArray();
|
$this->formData = $project->toArray();
|
||||||
$this->pivot_json_path = $this->formData['pivot_json_path'];
|
// $this->pivot_json_path = $this->formData['pivot_json_path'];
|
||||||
$this->span_json_path = $this->formData['span_json_path'];
|
// $this->span_json_path = $this->formData['span_json_path'];
|
||||||
$this->harvest_json_path = $this->formData['harvest_json_path'];
|
// $this->harvest_json_path = $this->formData['harvest_json_path'];
|
||||||
$this->formData['pivot_json_path'] = null;
|
// $this->formData['pivot_json_path'] = null;
|
||||||
$this->formData['span_json_path'] = null;
|
// $this->formData['span_json_path'] = null;
|
||||||
$this->formData['harvest_json_path'] = null;
|
// $this->formData['harvest_json_path'] = null;
|
||||||
$this->formData['boundingBoxes'] = $project->boundingBoxes->toArray();
|
// $this->formData['boundingBoxes'] = $project->boundingBoxes->toArray();
|
||||||
$this->formData['mail_recipients'] = $project->emailRecipients->toArray() ?: [
|
$this->formData['mail_recipients'] = $project->emailRecipients->toArray() ?: [
|
||||||
[
|
[
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
@ -82,10 +80,11 @@ public function openCreateProjectModal()
|
||||||
$this->showProjectModal = true;
|
$this->showProjectModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveProject(Request $request)
|
public function saveProject()
|
||||||
{
|
{
|
||||||
$this->resetErrorBag();
|
$this->resetErrorBag();
|
||||||
dd($this->validateForm());
|
$this->mergeFormData();
|
||||||
|
$this->validateForm();
|
||||||
Project::saveWithFormData($this->formData);
|
Project::saveWithFormData($this->formData);
|
||||||
$this->resetFormData();
|
$this->resetFormData();
|
||||||
$this->showProjectModal = false;
|
$this->showProjectModal = false;
|
||||||
|
|
@ -102,38 +101,15 @@ public function saveMailSettings()
|
||||||
$this->dispatch('saved');
|
$this->dispatch('saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addBoundingBox()
|
|
||||||
{
|
|
||||||
$this->formData['boundingBoxes'][] =
|
|
||||||
[
|
|
||||||
'name' => '',
|
|
||||||
'top_left_latitude' => '',
|
|
||||||
'top_left_longitude' => '',
|
|
||||||
'bottom_right_latitude' => '',
|
|
||||||
'bottom_right_longitude' => '',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addEmailRecipient()
|
public function addEmailRecipient()
|
||||||
{
|
{
|
||||||
$this->formData['mail_recipients'][] =
|
$this->formData['mail_recipients'][] =
|
||||||
[
|
[
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function deleteBoundingBox($index)
|
|
||||||
{
|
|
||||||
if (array_key_exists('id', $this->formData['boundingBoxes'][$index])) {
|
|
||||||
ProjectBoundingBox::whereId($this->formData['boundingBoxes'][$index]['id'])->delete();
|
|
||||||
}
|
|
||||||
unset($this->formData['boundingBoxes'][$index]);
|
|
||||||
$this->formData['boundingBoxes'] = array_values($this->formData['boundingBoxes']);
|
|
||||||
$this->dispatch('saved');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteEmailRecipient($index)
|
public function deleteEmailRecipient($index)
|
||||||
{
|
{
|
||||||
if (array_key_exists('id', $this->formData['mail_recipients'][$index])) {
|
if (array_key_exists('id', $this->formData['mail_recipients'][$index])) {
|
||||||
|
|
@ -148,7 +124,7 @@ public function deleteEmailRecipient($index)
|
||||||
/**
|
/**
|
||||||
* Confirm that the given Project should be deleted.
|
* Confirm that the given Project should be deleted.
|
||||||
*
|
*
|
||||||
* @param int $reportId
|
* @param int $reportId
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function confirmReportDeletion($reportId)
|
public function confirmReportDeletion($reportId)
|
||||||
|
|
@ -189,21 +165,16 @@ public function render()
|
||||||
private function resetFormData()
|
private function resetFormData()
|
||||||
{
|
{
|
||||||
$this->formData = [
|
$this->formData = [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'pivot_json_path' => '',
|
'mail_subject' => '',
|
||||||
'span_json_path' => '',
|
'mail_template' => '',
|
||||||
'harvest_json_path' => '',
|
'mail_frequency' => '',
|
||||||
'boundingBoxes' => [],
|
'mail_day' => '',
|
||||||
'mail_subject' => '',
|
|
||||||
'mail_template' => '',
|
|
||||||
'mail_frequency' => '',
|
|
||||||
'mail_day' => '',
|
|
||||||
'mail_recipients' => [],
|
'mail_recipients' => [],
|
||||||
];
|
];
|
||||||
$this->pivotFiles = [];
|
$this->pivotFiles = [];
|
||||||
$this->spanFiles = [];
|
$this->spanFiles = [];
|
||||||
$this->harvestDataFiles = [];
|
$this->harvestDataFiles = [];
|
||||||
$this->addBoundingBox();
|
|
||||||
$this->addEmailRecipient();
|
$this->addEmailRecipient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,55 +183,58 @@ private function validateForm()
|
||||||
$projectIdentifier = $this->formData['id'] ?? null;
|
$projectIdentifier = $this->formData['id'] ?? null;
|
||||||
|
|
||||||
return Validator::make([
|
return Validator::make([
|
||||||
'name' => $this->formData['name'],
|
'name' => $this->formData['name'],
|
||||||
'pivot_file' => $this->pivotFiles[0] ?? null,
|
'pivot_file' => $this->formData['pivot_file'],
|
||||||
'span_file' => $this->spanFiles[0] ?? null,
|
'span_file' => $this->formData['span_file'],
|
||||||
'harvest_file' => $this->harvestDataFiles[0] ?? null,
|
'harvest_file' => $this->formData['harvest_file'],
|
||||||
'boundingBoxes' => $this->formData['boundingBoxes'],
|
|
||||||
], [
|
], [
|
||||||
'name' => [
|
'name' => [
|
||||||
'required',
|
'required',
|
||||||
Rule::unique('projects')->ignore($projectIdentifier),
|
Rule::unique('projects')->ignore($projectIdentifier),
|
||||||
'string',
|
'string',
|
||||||
'max:255'
|
'max:255'
|
||||||
],
|
],
|
||||||
'pivot_file.extension' => ['sometimes',function ($attribute, $value, $fail) {
|
'pivot_file.extension' => ['sometimes', function ($attribute, $value, $fail) {
|
||||||
if($value && $value != 'json'){
|
if ($value && $value != 'json') {
|
||||||
|
|
||||||
$fail('Not a json file');
|
$fail('Not a json file');
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
'span_file.extension' => ['sometimes',function ($attribute, $value, $fail) {
|
'span_file.extension' => ['sometimes', function ($attribute, $value, $fail) {
|
||||||
if($value && $value != 'json'){
|
if ($value && $value != 'json') {
|
||||||
$fail('Not a json file');
|
$fail('Not a json file');
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
'harvest_file' => ['sometimes',new HarvestFile],
|
'harvest_file' => ['sometimes', new HarvestFile],
|
||||||
'boundingBoxes' => ['required', 'array', 'min:1'],
|
|
||||||
'boundingBoxes.*.name' => ['required', 'string', 'max:255'],
|
|
||||||
'boundingBoxes.*.top_left_latitude' => ['required', 'string'],
|
|
||||||
'boundingBoxes.*.top_left_longitude' => ['required', 'string'],
|
|
||||||
'boundingBoxes.*.bottom_right_latitude' => ['required', 'string'],
|
|
||||||
'boundingBoxes.*.bottom_right_longitude' => ['required', 'string'],
|
|
||||||
])->validate();
|
])->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateEmailSettingsForm()
|
private function validateEmailSettingsForm()
|
||||||
{
|
{
|
||||||
Validator::make([
|
Validator::make([
|
||||||
'mail_template' => $this->formData['mail_template'],
|
'mail_template' => $this->formData['mail_template'],
|
||||||
'mail_subject' => $this->formData['mail_subject'],
|
'mail_subject' => $this->formData['mail_subject'],
|
||||||
'mail_frequency' => $this->formData['mail_frequency'],
|
'mail_frequency' => $this->formData['mail_frequency'],
|
||||||
'mail_day' => $this->formData['mail_day'],
|
'mail_day' => $this->formData['mail_day'],
|
||||||
'mail_recipients' => $this->formData['mail_recipients'],
|
'mail_recipients' => $this->formData['mail_recipients'],
|
||||||
], [
|
], [
|
||||||
'mail_template' => ['required', 'string',],
|
'mail_template' => ['required', 'string',],
|
||||||
'mail_subject' => ['required', 'string',],
|
'mail_subject' => ['required', 'string',],
|
||||||
'mail_frequency' => ['required', 'string',],
|
'mail_frequency' => ['required', 'string',],
|
||||||
'mail_day' => ['required', 'string',],
|
'mail_day' => ['required', 'string',],
|
||||||
'mail_recipients' => ['required', 'array', 'min:1'],
|
'mail_recipients' => ['required', 'array', 'min:1'],
|
||||||
'mail_recipients.*.name' => ['required', 'string', 'max:255'],
|
'mail_recipients.*.name' => ['required', 'string', 'max:255'],
|
||||||
'mail_recipients.*.email' => ['required', 'email'],
|
'mail_recipients.*.email' => ['required', 'email'],
|
||||||
])->validateWithBag('saveEmailSettingsForm');
|
])->validateWithBag('saveEmailSettingsForm');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function mergeFormData(): void
|
||||||
|
{
|
||||||
|
$this->formData['pivot_file'] = $this->pivotFiles[0] ?? null;
|
||||||
|
$this->formData['span_file'] = $this->spanFiles[0] ?? null;
|
||||||
|
$this->formData['harvest_file'] = $this->harvestDataFiles[0] ?? null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
use App\Jobs\ProjectDownloadTiffJob;
|
use App\Jobs\ProjectDownloadTiffJob;
|
||||||
use App\Jobs\ProjectMosiacGeneratorJob;
|
use App\Jobs\ProjectMosiacGeneratorJob;
|
||||||
use App\Jobs\ProjectReportGeneratorJob;
|
use App\Jobs\ProjectReportGeneratorJob;
|
||||||
use App\Livewire\Forms\MailingForm;
|
|
||||||
use Carbon\CarbonPeriod;
|
use Carbon\CarbonPeriod;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
@ -28,52 +27,28 @@ class Project extends Model
|
||||||
'download_path',
|
'download_path',
|
||||||
'pivot_json_path',
|
'pivot_json_path',
|
||||||
'span_json_path',
|
'span_json_path',
|
||||||
'harvest_json_data'
|
'harvest_json_path'
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function saveWithFormData(mixed $formData)
|
public static function saveWithFormData(mixed $formData)
|
||||||
{
|
{
|
||||||
$uniqueIdentifier = ['id' => $formData['id'] ?? null];
|
$uniqueIdentifier = ['id' => $formData['id'] ?? null];
|
||||||
$project = Project::updateOrCreate($uniqueIdentifier, $formData);
|
$project = Project::updateOrCreate($uniqueIdentifier, $formData);
|
||||||
if ($formData['pivot_json_path']) {
|
$baseFrom = 'livewire-tmp/';
|
||||||
$path = $formData['pivot_json_path']->storeAs($project->download_path .'/Data', 'pivot.geojson');
|
$baseTo = $project->download_path.'/Data/';
|
||||||
$project->update(['pivot_json_path' => $path]);
|
if ($formData['pivot_file']) {
|
||||||
|
Storage::copy($baseFrom.$formData['pivot_file']['tmpFilename'],$baseTo.'pivot.geojson');
|
||||||
|
$project->update(['pivot_json_path' => $baseTo.'pivot.geojson']);
|
||||||
}
|
}
|
||||||
if ($formData['span_json_path']) {
|
if ($formData['span_file']) {
|
||||||
$path = $formData['span_json_path']->storeAs($project->download_path .'/Data', 'span.geojson');
|
Storage::copy($baseFrom.$formData['span_file']['tmpFilename'],$baseTo.'span.geojson');
|
||||||
$project->update(['span_json_path' => $path]);
|
$project->update(['span_json_path' => $baseTo.'span.geojson']);
|
||||||
}
|
}
|
||||||
if ($formData['harvest_json_data']) {
|
if ($formData['harvest_file']) {
|
||||||
$path = $formData['harvest_json_path']->storeAs($project->download_path .'/Data', 'harvest.xlsx');
|
Storage::copy($baseFrom.$formData['harvest_file']['tmpFilename'],$baseTo.'harvest.'.$formData['harvest_file']['extension']);
|
||||||
$project->update(['harvest_json_path' => $path]);
|
$project->update(['harvest_json_path' => $baseTo.'harvest.'.$formData['harvest_file']['extension']]);
|
||||||
}
|
}
|
||||||
$project->upsertBoundingBox($formData);
|
|
||||||
$project->upsertMailRecipients($formData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function upsertBoundingBox($formData)
|
|
||||||
{
|
|
||||||
$boundingBoxesData = array_map(function ($boundingBox) {
|
|
||||||
$boundingBox['project_id'] = $this->id;
|
|
||||||
unset($boundingBox['created_at']);
|
|
||||||
unset($boundingBox['updated_at']);
|
|
||||||
$boundingBox['id'] ??= null;
|
|
||||||
return $boundingBox;
|
|
||||||
}, $formData['boundingBoxes'] ?? []);
|
|
||||||
|
|
||||||
ProjectBoundingBox::upsert(
|
|
||||||
$boundingBoxesData,
|
|
||||||
['id', 'project_id'],
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
'top_left_latitude',
|
|
||||||
'top_left_longitude',
|
|
||||||
'bottom_right_latitude',
|
|
||||||
'bottom_right_longitude'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function upsertMailRecipients($formData)
|
private function upsertMailRecipients($formData)
|
||||||
{
|
{
|
||||||
$mailRecipientsData = array_map(function ($mailRecipient) {
|
$mailRecipientsData = array_map(function ($mailRecipient) {
|
||||||
|
|
@ -95,7 +70,7 @@ public function getMosaicPath()
|
||||||
return sprintf('%s/%s', $this->download_path, 'weekly_mosaic');
|
return sprintf('%s/%s', $this->download_path, 'weekly_mosaic');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMosaicList(): \Illuminate\Support\Collection
|
public function getMosaicList(): Collection
|
||||||
{
|
{
|
||||||
return collect(Storage::files($this->getMosaicPath()))
|
return collect(Storage::files($this->getMosaicPath()))
|
||||||
->filter(fn($file) => Str::endsWith($file, '.tif'))
|
->filter(fn($file) => Str::endsWith($file, '.tif'))
|
||||||
|
|
@ -113,7 +88,6 @@ protected static function boot()
|
||||||
parent::boot(); // TODO: Change the autogenerated stub
|
parent::boot(); // TODO: Change the autogenerated stub
|
||||||
|
|
||||||
static::deleting(function ($project) {
|
static::deleting(function ($project) {
|
||||||
$project->boundingBoxes()->delete();
|
|
||||||
$project->emailRecipients()->delete();
|
$project->emailRecipients()->delete();
|
||||||
$project->mailings()->each(function ($mailing) {
|
$project->mailings()->each(function ($mailing) {
|
||||||
$mailing->attachments()->delete();
|
$mailing->attachments()->delete();
|
||||||
|
|
@ -135,11 +109,6 @@ public function getAttachmentPathAttribute()
|
||||||
return '/storage/'.$this->download_path.'/attachments';
|
return '/storage/'.$this->download_path.'/attachments';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boundingBoxes()
|
|
||||||
{
|
|
||||||
return $this->hasMany(ProjectBoundingBox::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function emailRecipients()
|
public function emailRecipients()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProjectEmailRecipient::class);
|
return $this->hasMany(ProjectEmailRecipient::class);
|
||||||
|
|
@ -184,7 +153,7 @@ public function allMosaicsPresent(Carbon $endDate): bool
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMosaicFilenameListByEndDate(Carbon $endDate): \Illuminate\Support\Collection
|
public function getMosaicFilenameListByEndDate(Carbon $endDate): Collection
|
||||||
{
|
{
|
||||||
$result = collect([]);
|
$result = collect([]);
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
|
@ -370,10 +339,4 @@ public function getMosaicsFor($year, $startWeekNumber)
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundingBoxesAsArray() {
|
|
||||||
return $this->boundingBoxes->map(function ($boundingBox) {
|
|
||||||
return $boundingBox->toArrayCustom();
|
|
||||||
})->toArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ProjectBoundingBox extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'name',
|
|
||||||
'top_left_latitude',
|
|
||||||
'top_left_longitude',
|
|
||||||
'bottom_right_latitude',
|
|
||||||
'bottom_right_longitude',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function project()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Project::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toArrayCustom()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
(float) $this->top_left_latitude,
|
|
||||||
(float) $this->top_left_longitude,
|
|
||||||
(float) $this->bottom_right_latitude,
|
|
||||||
(float) $this->bottom_right_longitude
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
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::dropIfExists('project_bounding_boxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::create('project_bounding_boxes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignIdFor(Project::class);
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('top_left_latitude');
|
||||||
|
$table->string('top_left_longitude');
|
||||||
|
$table->string('bottom_right_latitude');
|
||||||
|
$table->string('bottom_right_longitude');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -60,76 +60,12 @@
|
||||||
<span class="bg-red-100 text-red-400 p-1 rounded">{{ $message }}</span>
|
<span class="bg-red-100 text-red-400 p-1 rounded">{{ $message }}</span>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
@foreach($projectManager->formData['boundingBoxes'] as $key => $boundingBox)
|
|
||||||
{{-- <div wire:key="bounding_box_{{ $key }}">--}}
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
|
||||||
{{ __('Bounding box') }}
|
|
||||||
@if( count($projectManager->formData['boundingBoxes']) > 1)
|
|
||||||
<button
|
|
||||||
class="cursor-pointer ml-6 text-sm text-red-500"
|
|
||||||
type="button"
|
|
||||||
wire:click="deleteBoundingBox({{ $key }})"
|
|
||||||
wire:confirm="{{ __('Are you sure you want to delete this BoundingBox?') }}"
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</button>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
|
||||||
<x-label for="bounding_box_{{ $key }}_name" value="{{ __('Name') }}"/>
|
|
||||||
<x-input id="bounding_box_{{ $key }}_name" type="text" class="mt-1 block w-full"
|
|
||||||
wire:model="formData.boundingBoxes.{{ $key }}.name" autofocus/>
|
|
||||||
<x-input-error for="boundingBoxes.{{ $key }}.name" class="mt-2"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-6 grid grid-cols-6 gap-1">
|
|
||||||
<div class="col-span-3">
|
|
||||||
<x-label for="bounding_box_{{ $key }}_top_left_latitude"
|
|
||||||
value="{{ __('Top left Latitude') }}"/>
|
|
||||||
<x-input id="bounding_box_{{ $key }}_top_left_latitude" type="text"
|
|
||||||
class="block w-full"
|
|
||||||
wire:model="formData.boundingBoxes.{{ $key }}.top_left_latitude"
|
|
||||||
autofocus/>
|
|
||||||
<x-input-error for="boundingBoxes.{{ $key }}.top_left_latitude" class="mt-2"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-3">
|
|
||||||
<x-label for="bounding_box_{{ $key }}_top_left_longitude" value="{{ __('Longitude') }}"/>
|
|
||||||
<x-input id="name" type="text" class="block w-full"
|
|
||||||
wire:model="formData.boundingBoxes.{{ $key }}.top_left_longitude"
|
|
||||||
autofocus/>
|
|
||||||
<x-input-error for="boundingBoxes.{{ $key }}.top_left_longitude" class="mt-2"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-3">
|
|
||||||
<x-label for="bounding_box_{{ $key }}_bottom_right_latitude"
|
|
||||||
value="{{ __('Bottom right Latitude') }}"/>
|
|
||||||
<x-input id="bounding_box_{{ $key }}_bottom_right_latitude" type="text"
|
|
||||||
class="block w-full"
|
|
||||||
wire:model="formData.boundingBoxes.{{ $key }}.bottom_right_latitude"
|
|
||||||
autofocus/>
|
|
||||||
<x-input-error for="boundingBoxes.{{ $key }}.bottom_right_latitude" class="mt-2"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-3">
|
|
||||||
<x-label for="boundingBox_{{ $key }}_bottom_right_longitude" value="{{ __('Longitude') }}"/>
|
|
||||||
<x-input id="boundingBox_{{ $key }}_bottom_right_longitude" type="text"
|
|
||||||
class="block w-full"
|
|
||||||
wire:model="formData.boundingBoxes.{{ $key }}.bottom_right_longitude"
|
|
||||||
autofocus/>
|
|
||||||
<x-input-error for="boundingBoxes.{{ $key }}.bottom_right_longitude" class="mt-2"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{-- </div>--}}
|
|
||||||
@endforeach
|
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
<x-slot name="actions">
|
<x-slot name="actions">
|
||||||
<x-action-message class="mr-3" on="saved">
|
<x-action-message class="mr-3" on="saved">
|
||||||
{{ __('Saved.') }}
|
{{ __('Saved.') }}
|
||||||
</x-action-message>
|
</x-action-message>
|
||||||
<x-secondary-button class="mr-3"
|
|
||||||
type="button"
|
|
||||||
wire:click="addBoundingBox"
|
|
||||||
>
|
|
||||||
{{ __('Add Bounding box') }}
|
|
||||||
</x-secondary-button>
|
|
||||||
<x-secondary-button class="mr-3"
|
<x-secondary-button class="mr-3"
|
||||||
type="button"
|
type="button"
|
||||||
x-on:click="$wire.showProjectModal = false"
|
x-on:click="$wire.showProjectModal = false"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue