upgraded to laravel 11 and added search to
This commit is contained in:
parent
d2fa24fc6c
commit
50aae2abc8
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Livewire\Projects;
|
||||
|
||||
use App\Livewire\Searchable;
|
||||
use App\Models\Project;
|
||||
use App\Rules\DownloadDateRangeRule;
|
||||
use Carbon\Carbon;
|
||||
|
|
@ -13,7 +12,7 @@
|
|||
|
||||
class DownloadManager extends Component
|
||||
{
|
||||
use WithPagination, Searchable;
|
||||
use WithPagination;
|
||||
|
||||
|
||||
public $project;
|
||||
|
|
@ -22,6 +21,10 @@ class DownloadManager extends Component
|
|||
|
||||
public $showDownloadModal = false;
|
||||
|
||||
public $search = '';
|
||||
|
||||
|
||||
|
||||
public function mount(Project $project)
|
||||
{
|
||||
$this->path = $project->download_path;
|
||||
|
|
@ -33,6 +36,13 @@ public function mount(Project $project)
|
|||
];
|
||||
}
|
||||
|
||||
public function update($property)
|
||||
{
|
||||
if ($property === 'search') {
|
||||
$this->resetPage('downloadPage');
|
||||
}
|
||||
}
|
||||
|
||||
public function openDownloadModal()
|
||||
{
|
||||
$this->showDownloadModal = true;
|
||||
|
|
@ -61,6 +71,14 @@ public function saveDownloads()
|
|||
$this->showDownloadModal = false;
|
||||
}
|
||||
|
||||
private function applySearch($query)
|
||||
{
|
||||
if ($this->search) {
|
||||
$query->where('name', 'like', '%' . $this->search . '%');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,21 +19,16 @@ class MosaicManager extends Component
|
|||
];
|
||||
public $showCreateModal = false;
|
||||
|
||||
public function mount(Project $project) {
|
||||
public $search = "";
|
||||
|
||||
public function mount(Project $project)
|
||||
{
|
||||
$this->path = $project->download_path;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.projects.mosaic-manager', [
|
||||
'mosaics' => $this->project->mosaics()
|
||||
->orderBy('year','desc')
|
||||
->orderBy('week', 'desc')
|
||||
->paginate(10, pageName: 'mosaicPage')
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveMosaic(){
|
||||
public function saveMosaic()
|
||||
{
|
||||
$this->validate([
|
||||
'formData.year' => 'required',
|
||||
'formData.week' => 'required',
|
||||
|
|
@ -43,7 +38,7 @@ public function saveMosaic(){
|
|||
'name' => sprintf('Week %s, %s', $this->formData['week'], $this->formData['year']),
|
||||
'year' => $this->formData['year'],
|
||||
'week' => $this->formData['week'],
|
||||
],[
|
||||
], [
|
||||
'path' => $this->project->getMosaicPath(),
|
||||
]);
|
||||
|
||||
|
|
@ -52,7 +47,8 @@ public function saveMosaic(){
|
|||
$this->showCreateModal = false;
|
||||
}
|
||||
|
||||
public function openCreateMosiacsModal(){
|
||||
public function openCreateMosiacsModal()
|
||||
{
|
||||
$this->showCreateModal = true;
|
||||
}
|
||||
|
||||
|
|
@ -69,4 +65,34 @@ public function getDateRangeProperty()
|
|||
->endOfWeek();
|
||||
return $begin->format('Y-m-d').' - '.$end->format('Y-m-d');
|
||||
}
|
||||
|
||||
private function applySearch($query)
|
||||
{
|
||||
if ($this->search) {
|
||||
$query->where('name', 'like', '%' . $this->search . '%');
|
||||
$query->orWhere('year', 'like', '%' . $this->search . '%');
|
||||
$query->orWhere('week', 'like', '%' . $this->search . '%');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function update($property)
|
||||
{
|
||||
if ($property === 'search') {
|
||||
$this->resetPage('mosaicPage');
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = $this->project->mosaics()
|
||||
->orderBy('year', 'desc')
|
||||
->orderBy('week', 'desc');
|
||||
$query = $this->applySearch($query);
|
||||
$mosaics = $query->paginate(10, pageName: 'mosaicPage');
|
||||
|
||||
return view('livewire.projects.mosaic-manager', [
|
||||
'mosaics' => $mosaics
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class ReportManager extends Component
|
|||
public $formData = [];
|
||||
public $project_id;
|
||||
|
||||
public $search = "";
|
||||
|
||||
public $showReportModal = false;
|
||||
|
||||
public $listeners = ['refresh' => '$refresh'];
|
||||
|
|
@ -31,15 +33,6 @@ public function mount(Project $project)
|
|||
$this->project_id = $project->id;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$reports = Project::find($this->project_id)
|
||||
->reports()
|
||||
->orderBy('year', 'desc')
|
||||
->orderBy('week', 'desc')
|
||||
->paginate(10, pageName: 'reportPage');
|
||||
return view('livewire.projects.report-manager')->with(compact('reports'));
|
||||
}
|
||||
|
||||
private function resetFormData()
|
||||
{
|
||||
|
|
@ -50,9 +43,9 @@ private function resetFormData()
|
|||
public function saveProjectReport()
|
||||
{
|
||||
$this->validate([
|
||||
'formData.week' => ['required', 'integer', 'min:1', 'max:53' ],
|
||||
'formData.week' => ['required', 'integer', 'min:1', 'max:53'],
|
||||
'formData.year' => 'required|integer|min:2020|max:'.now()->addYear()->year,
|
||||
'formData' => [new AllMosaicsPresentRule($this->project_id)],
|
||||
'formData' => [new AllMosaicsPresentRule($this->project_id)],
|
||||
]);
|
||||
|
||||
$newReport = Project::find($this->project_id)
|
||||
|
|
@ -83,11 +76,34 @@ public function getDateRangeProperty()
|
|||
->setISODate($this->formData['year'], $this->formData['week'])
|
||||
->endOfWeek();
|
||||
return $begin->format('Y-m-d').' - '.$end->format('Y-m-d');
|
||||
|
||||
}
|
||||
|
||||
public function deleteReport(ProjectReport $report) {
|
||||
public function deleteReport(ProjectReport $report)
|
||||
{
|
||||
$report->deleteMe();
|
||||
$this->dispatch('refresh');
|
||||
}
|
||||
|
||||
private function applySearch($query)
|
||||
{
|
||||
if ($this->search) {
|
||||
$query->where('name', 'like', '%'.$this->search.'%');
|
||||
$query->orWhere('year', 'like', '%'.$this->search.'%');
|
||||
$query->orWhere('week', 'like', '%'.$this->search.'%');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Project::find($this->project_id)
|
||||
->reports()
|
||||
->orderBy('year', 'desc')
|
||||
->orderBy('week', 'desc');
|
||||
$query = $this->applySearch($query);
|
||||
$reports = $query->paginate(10, pageName: 'reportPage');
|
||||
|
||||
return view('livewire.projects.report-manager')
|
||||
->with(compact('reports'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
trait Searchable
|
||||
{
|
||||
public $search = '';
|
||||
|
||||
public function updatedSearchable($property)
|
||||
{
|
||||
if ($property === 'search') {
|
||||
$this->resetPage();
|
||||
}
|
||||
}
|
||||
|
||||
protected function applySearch($query)
|
||||
{
|
||||
return $this->search === ''
|
||||
? $query
|
||||
: $query
|
||||
->where('email', 'like', '%'.$this->search.'%')
|
||||
->orWhere('number', 'like', '%'.$this->search.'%');
|
||||
}
|
||||
}
|
||||
|
|
@ -5,24 +5,24 @@
|
|||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"php": "^8.2",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/jetstream": "^4.0",
|
||||
"laravel/sanctum": "^3.2",
|
||||
"laravel/telescope": "^4.17",
|
||||
"laravel/tinker": "^2.8",
|
||||
"laravel/framework": "^v11.0.7",
|
||||
"laravel/jetstream": "^5.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/telescope": "^5.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"livewire/livewire": "^3.0",
|
||||
"queueworker/sansdaemon": "^1.2"
|
||||
"queueworker/sansdaemon": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.18",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pint": "^1.13",
|
||||
"laravel/sail": "^1.26",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.0",
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"spatie/laravel-ignition": "^2.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
|||
1470
laravel_app/composer.lock
generated
1470
laravel_app/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Get the migration connection name.
|
||||
*/
|
||||
public function getConnection(): string|null
|
||||
{
|
||||
return config('telescope.storage.database.connection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
$schema->create('telescope_entries', function (Blueprint $table) {
|
||||
$table->bigIncrements('sequence');
|
||||
$table->uuid('uuid');
|
||||
$table->uuid('batch_id');
|
||||
$table->string('family_hash')->nullable();
|
||||
$table->boolean('should_display_on_index')->default(true);
|
||||
$table->string('type', 20);
|
||||
$table->longText('content');
|
||||
$table->dateTime('created_at')->nullable();
|
||||
|
||||
$table->unique('uuid');
|
||||
$table->index('batch_id');
|
||||
$table->index('family_hash');
|
||||
$table->index('created_at');
|
||||
$table->index(['type', 'should_display_on_index']);
|
||||
});
|
||||
|
||||
$schema->create('telescope_entries_tags', function (Blueprint $table) {
|
||||
$table->uuid('entry_uuid');
|
||||
$table->string('tag');
|
||||
|
||||
$table->primary(['entry_uuid', 'tag']);
|
||||
$table->index('tag');
|
||||
|
||||
$table->foreign('entry_uuid')
|
||||
->references('uuid')
|
||||
->on('telescope_entries')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
$schema->create('telescope_monitoring', function (Blueprint $table) {
|
||||
$table->string('tag')->primary();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
$schema->dropIfExists('telescope_entries_tags');
|
||||
$schema->dropIfExists('telescope_entries');
|
||||
$schema->dropIfExists('telescope_monitoring');
|
||||
}
|
||||
};
|
||||
2
laravel_app/public/vendor/telescope/app.js
vendored
2
laravel_app/public/vendor/telescope/app.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"/app.js": "/app.js?id=613c227dfb4d6e1fc4db1b1a90513610",
|
||||
"/app.js": "/app.js?id=7049e92a398e816f8cd53a915eaea592",
|
||||
"/app-dark.css": "/app-dark.css?id=b11fa9a28e9d3aeb8c92986f319b3c44",
|
||||
"/app.css": "/app.css?id=b3ccfbe68f24cff776f83faa8dead721"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,17 @@
|
|||
@endif
|
||||
>
|
||||
<div class="px-4 sm:px-6 lg:px-8">
|
||||
<div class="sm:flex sm:items-center">
|
||||
<div class="sm:flex-auto">
|
||||
<div class="sm:flex sm:flex-col sm:items-center">
|
||||
<div class="w-full">
|
||||
<h1 class="text-base font-semibold leading-6 text-gray-900">Mosaics</h1>
|
||||
<p class="mt-2 text-sm text-gray-700"></p>
|
||||
<p class="mt-2 text-sm text-gray-700">
|
||||
@if ($project->hasPendingDownload())
|
||||
Pending mosaics for this project: {{ $project->mosaics()->statusPending()->count() }}
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-4 sm:ml-16 sm:mt-0 sm:flex-none">
|
||||
<div class="mt-4 sm:mt-0 sm:flex sm:justify-between w-full">
|
||||
<x-search></x-search>
|
||||
<x-button wire:click="openCreateMosiacsModal"
|
||||
class="block rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
|
||||
Create Mosaic
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<p class="mt-2 text-sm text-gray-700"></p>
|
||||
</div>
|
||||
<div class="mt-4 sm:ml-16 sm:mt-0 sm:flex-none">
|
||||
<x-search></x-search>
|
||||
<x-button wire:click="openCreateReportModal"
|
||||
class="block rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
|
||||
Create Report
|
||||
|
|
|
|||
Loading…
Reference in a new issue