Additional Progress
This commit is contained in:
parent
13756de3a8
commit
7951b8c84c
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\MaintenanceHistory;
|
use App\Models\MaintenanceHistory;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class MaintenanceController extends BaseController
|
class MaintenanceController extends BaseController
|
||||||
{
|
{
|
||||||
@ -22,4 +23,12 @@ public function plannedDetail(MaintenanceHistory $maintenance_history)
|
|||||||
'maintenance_history' => $maintenance_history,
|
'maintenance_history' => $maintenance_history,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function plannedDetailPut(Request $request, MaintenanceHistory $maintenance_history)
|
||||||
|
{
|
||||||
|
return view('maintenance.planned-detail-done', [
|
||||||
|
'maintenance_history' => $maintenance_history,
|
||||||
|
'maintenance_state' => $request->input('test'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,17 @@ public function mount($model = null)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatedHosts($value)
|
||||||
|
{
|
||||||
|
foreach ($this->hosts_tasks as $host_id => $tasks) {
|
||||||
|
if (in_array($host_id, $this->hosts)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->hosts_tasks[$host_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
$validatedData = $this->validate();
|
$validatedData = $this->validate();
|
||||||
@ -62,7 +73,7 @@ public function store()
|
|||||||
$hosts = Host::whereIn('id', $this->hosts)->get();
|
$hosts = Host::whereIn('id', $this->hosts)->get();
|
||||||
foreach ($hosts as $key => $host) {
|
foreach ($hosts as $key => $host) {
|
||||||
$maintenance->hosts()->attach($host);
|
$maintenance->hosts()->attach($host);
|
||||||
$tasks = Host::whereIn('id', $this->hosts_tasks[$host->id])->get();
|
$tasks = Task::whereIn('id', $this->hosts_tasks[$host->id])->get();
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$maintenance->tasks()->create([
|
$maintenance->tasks()->create([
|
||||||
'task_id' => $task->id,
|
'task_id' => $task->id,
|
||||||
|
@ -4,12 +4,11 @@
|
|||||||
<x-form::quill group-class="mb-3" type="text" wire:model="description" id="description" label="description" />
|
<x-form::quill group-class="mb-3" type="text" wire:model="description" id="description" label="description" />
|
||||||
<x-form::input group-class="mb-3" type="text" wire:model="schedule" id="schedule" label="schedule" />
|
<x-form::input group-class="mb-3" type="text" wire:model="schedule" id="schedule" label="schedule" />
|
||||||
<x-form::select group-class="mb-3" wire:model.live="hosts" label="Livewire Select" :options="$hosts_available" placeholder="Select value..." multiple />
|
<x-form::select group-class="mb-3" wire:model.live="hosts" label="Livewire Select" :options="$hosts_available" placeholder="Select value..." multiple />
|
||||||
|
|
||||||
@foreach($hosts as $key => $host_id)
|
@foreach($hosts as $key => $host_id)
|
||||||
<x-form::select group-class="mb-3" wire:model="hosts_tasks.{{ $host_id }}" label="Select Tasks for Host {{ $hosts_available[$host_id] }}" :options="$hosts_tasks_available" placeholder="Select value..." multiple />
|
<x-form::select group-class="mb-3" wire:key="{{ $host_id }}" wire:model="hosts_tasks.{{ $host_id }}" label="Select Tasks for Host {{ $hosts_available[$host_id] }}" :options="$hosts_tasks_available" placeholder="Select value..." multiple />
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
<x-form::button class="btn-primary" type="submit">Create</x-form::button>
|
<x-form::button class="btn-primary" type="submit">Create</x-form::button>
|
||||||
@dump($hosts_tasks)
|
|
||||||
</x-form::form>
|
</x-form::form>
|
||||||
</div>
|
</div>
|
||||||
|
14
resources/views/maintenance/planned-detail-done.blade.php
Normal file
14
resources/views/maintenance/planned-detail-done.blade.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<x-layout-app>
|
||||||
|
<div class="container-xl">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>{{ __('Planned Maintenance') }}</h1>
|
||||||
|
</div>
|
||||||
|
<p>{!! $maintenance_history->maintenance->description !!}</p>
|
||||||
|
@foreach ($maintenance_history->historyHosts as $historyHost)
|
||||||
|
<b>{{ $historyHost->host->hostname }}</b>
|
||||||
|
@foreach ($historyHost->historyTasks as $historyTasks)
|
||||||
|
<x-form::checkbox onclick="return false" checked="{{ isset($maintenance_state[$historyHost->id][$historyTasks->id]) ? 'checked' : '' }}" label="{{ $historyTasks->maintenanceTask->task->name }}" name="test-{{ $historyHost->id }}-{{ $historyTasks->id }}" />
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</x-layout-app>
|
@ -4,23 +4,23 @@
|
|||||||
<h1>{{ __('Planned Maintenance') }}</h1>
|
<h1>{{ __('Planned Maintenance') }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<p>{!! $maintenance_history->maintenance->description !!}</p>
|
<p>{!! $maintenance_history->maintenance->description !!}</p>
|
||||||
<x-form::form action="save" method="PUT">
|
<x-form::form action="{{ route('maintenance.planned.detail.put', ['maintenance_history' => $maintenance_history->id]) }}" method="PUT">
|
||||||
@foreach ($maintenance_history->historyHosts as $historyHost)
|
@foreach ($maintenance_history->historyHosts as $historyHost)
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="btn-toggle btn py-3 w-100 bg-primary text-start" style="--bs-bg-opacity: .2;" data-bs-toggle="collapse" data-bs-target="#collapse{{ $historyHost->id }}">
|
<div class="btn-toggle btn py-3 w-100 bg-primary text-start" style="--bs-bg-opacity: .2;" data-bs-toggle="collapse" data-bs-target="#collapse{{ $historyHost->id }}">
|
||||||
<b>{{ $historyHost->host->hostname }}</b>
|
<b>{{ $historyHost->host->hostname }}</b>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse" id="collapse{{ $historyHost->id }}">
|
<div class="collapse" id="collapse{{ $historyHost->id }}">
|
||||||
<div class="card card-body mt-2">
|
<div class="card card-body mt-2">
|
||||||
@foreach ($historyHost->historyTasks as $historyTasks)
|
@foreach ($historyHost->historyTasks as $historyTasks)
|
||||||
<x-form::checkbox wire:model="test" label="{{$historyTasks->maintenanceTask->task->name}}" />
|
<x-form::checkbox name="test[{{ $historyHost->id }}][{{ $historyTasks->id }}]" id="test-{{ $historyHost->id }}-{{ $historyTasks->id }}" label="{{ $historyTasks->maintenanceTask->task->name }}" />
|
||||||
<p>{!! $historyTasks->maintenanceTask->task->description !!}</p>
|
<p>{!! $historyTasks->maintenanceTask->task->description !!}</p>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@endforeach
|
@endforeach
|
||||||
<x-form::button class="btn-primary" type="submit">{{ __('Ukončit')}}</x-form::button>
|
<x-form::button class="btn-primary" type="submit">{{ __('Ukončit') }}</x-form::button>
|
||||||
</x-form::form>
|
</x-form::form>
|
||||||
</div>
|
</div>
|
||||||
</x-layout-app>
|
</x-layout-app>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||||
Route::get('/maintenance/planned', [App\Http\Controllers\MaintenanceController::class, 'planned'])->name('maintenance.planned');
|
Route::get('/maintenance/planned', [App\Http\Controllers\MaintenanceController::class, 'planned'])->name('maintenance.planned');
|
||||||
Route::get('/maintenance/planned/{maintenance_history}', [App\Http\Controllers\MaintenanceController::class, 'plannedDetail'])->name('maintenance.planned.detail');
|
Route::get('/maintenance/planned/{maintenance_history}', [App\Http\Controllers\MaintenanceController::class, 'plannedDetail'])->name('maintenance.planned.detail');
|
||||||
|
Route::put('/maintenance/planned/{maintenance_history}', [App\Http\Controllers\MaintenanceController::class, 'plannedDetailPut'])->name('maintenance.planned.detail.put');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/host', [App\Http\Controllers\HostController::class, 'index'])->name('host');
|
Route::get('/host', [App\Http\Controllers\HostController::class, 'index'])->name('host');
|
||||||
|
Loading…
Reference in New Issue
Block a user