This commit is contained in:
JonatanRek 2024-08-16 13:28:14 +02:00
parent 2d5cb8cdc6
commit 84ef42382a
10 changed files with 67 additions and 395 deletions

View File

@ -9,5 +9,5 @@ class AuthController
{ {
use Authentication; use Authentication;
protected string $redirectTo = "dashboard"; protected string $redirectTo = "maintenance.planned";
} }

View File

@ -1,11 +0,0 @@
<?php
namespace App\Http\Controllers;
class DashboardController extends BaseController
{
public function index()
{
return view('home');
}
}

View File

@ -25,7 +25,7 @@ public function plannedDetail(MaintenanceHistory $maintenance_history)
} }
return view('maintenance.planned-detail', [ return view('maintenance.planned-detail', [
'maintenance_history' => $maintenance_history, 'maintenance_history' => $maintenance_history ?? [],
]); ]);
} }
@ -37,8 +37,8 @@ public function plannedDetailPut(Request $request, MaintenanceHistory $maintenan
return view('maintenance.planned-detail-done', [ return view('maintenance.planned-detail-done', [
'maintenance_history' => $maintenance_history, 'maintenance_history' => $maintenance_history,
'maintenance_task_status' => $request->input('maintenance_task_status'), 'maintenance_task_status' => $request->input('maintenance_task_status') ?? [],
'maintenance_host_skipped' => $request->input('maintenance_host_skipped'), 'maintenance_host_skipped' => $request->input('maintenance_host_skipped') ?? [],
]); ]);
} }
@ -48,19 +48,29 @@ public function plannedDetailFinishPost(Request $request, MaintenanceHistory $ma
abort(404); abort(404);
} }
$request->validate([
"skippedHostsSummary.*.*" => 'required|string'
]);
// if ($request->has('skippedHostsSummary') || $request->has('skippedHostTasksSummary'))
// {
// return redirect()->back()->with('error', __('boilerplate::ui.incorect.old.password'));
// }
foreach ($request->input('skippedHostsSummary') as $history_host_id => $summary) { foreach ($request->input('skippedHostsSummary') as $history_host_id => $summary) {
$maintenance_history->historyHosts->find($history_host_id)->update([ $maintenance_history->historyHosts->find($history_host_id)->update([
'summary' => $summary, 'summary' => $summary,
]); ]);
} }
if (!$request->has('skippedHostsTasksSummary')) { if ($request->has('skippedHostTasksSummary')) {
foreach ($maintenance_history->historyHosts as $history_host) { foreach ($maintenance_history->historyHosts as $history_host) {
if (!isset($request->input('skippedHostsTasksSummary')[$history_host->id])) if (!isset($request->input('skippedHostTasksSummary')[$history_host->id]))
continue; continue;
foreach ($request->input('skippedHostsTasksSummary')[$history_host->id] as $history_task_id => $task_summary) { foreach ($request->input('skippedHostTasksSummary')[$history_host->id] as $history_task_id => $task_summary) {
$history_host->find($history_task_id)->update([ $history_host->historyTasks->find($history_task_id)->update([
'summary' => $task_summary, 'summary' => $task_summary,
]); ]);
} }
@ -80,6 +90,8 @@ public function history(Request $request)
public function historyDetail(Request $request, MaintenanceHistory $maintenance_history) public function historyDetail(Request $request, MaintenanceHistory $maintenance_history)
{ {
dd($maintenance_history->historyHosts); return view('maintenance.history-detail-done', [
'maintenance_history' => $maintenance_history ?? []
]);
} }
} }

View File

@ -26,7 +26,6 @@ public function handle(Request $request, Closure $next): Response
Menu::make('main-menu', function ($menu) { Menu::make('main-menu', function ($menu) {
$systemRoutes = [ $systemRoutes = [
'ui.dashboard' => [' fas fa-home', 'dashboard'],
'ui.planned' => [' fas fa-home', 'maintenance.planned'], 'ui.planned' => [' fas fa-home', 'maintenance.planned'],
'ui.history' => [' fas fa-home', 'maintenance.history'], 'ui.history' => [' fas fa-home', 'maintenance.history'],
]; ];

View File

@ -24,13 +24,13 @@ protected function rules()
public function mount ($model = null){ public function mount ($model = null){
if (!empty($model)) { if (!empty($model)) {
$maintenance-history = MaintenanceHistory::find($model); $maintenanceHistory = MaintenanceHistory::find($model);
$this->model = $model; $this->model = $model;
$this->maintenance_id = $maintenance-history->maintenance_id; $this->maintenance_id = $maintenanceHistory->maintenance_id;
$this->start_at = $maintenance-history->start_at; $this->start_at = $maintenanceHistory->start_at;
$this->finished_at = $maintenance-history->finished_at; $this->finished_at = $maintenanceHistory->finished_at;
$this->action = 'update'; $this->action = 'update';
} }
@ -46,9 +46,9 @@ public function store()
public function update() public function update()
{ {
$validatedData = $this->validate(); $validatedData = $this->validate();
$maintenance-history = MaintenanceHistory::find($this->model); $maintenanceHistory = MaintenanceHistory::find($this->model);
if (!empty($maintenance-history)) { if (!empty($maintenanceHistory)) {
$maintenance-history->update($validatedData); $maintenanceHistory->update($validatedData);
} }
$this->dispatch('closeModal'); $this->dispatch('closeModal');
} }

View File

@ -1,189 +0,0 @@
<x-layout-app>
<div class="container-xl">
<div class="page-header">
<h1>Welcolm Back !</h1>
<a class="btn btn-primary" href="{{ url('home') }}"><i class="fa fa-plus me-2"></i> Page Action</a>
</div>
</div>
<div class="container-xl">
<h1>head 1</h1>
<h2>head 2</h2>
<h3>head 3</h3>
<h4>head 4</h4>
<h5>head 5</h5>
<h6>head 6</h6>
<div class="my-4">
<h4>Tabs</h4>
<ul class="nav nav-tabs mb-4">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
<div class="my-4 d-flex">
<div class="app-nav-profile random-bg-1">
PS
</div>
<div class="app-nav-profile random-bg-2">
PS
</div>
<div class="app-nav-profile random-bg-3">
PS
</div>
<div class="app-nav-profile random-bg-4">
PS
</div>
<div class="app-nav-profile random-bg-5">
PS
</div>
<div class="app-nav-profile random-bg-6">
PS
</div>
</div>
<div class="my-4">
<h4>Buttons</h4>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn">Button</button>
<button type="button" class="btn btn-link">Link</button>
</div>
<div class="my-4">
<h4>Badges</h4>
<span class="badge text-bg-primary">Primary</span>
<span class="badge text-bg-secondary">Secondary</span>
<span class="badge text-bg-success">Success</span>
<span class="badge text-bg-danger">Danger</span>
<span class="badge text-bg-warning">Warning</span>
<span class="badge text-bg-info">Info</span>
<span class="badge text-bg-light">Light</span>
<span class="badge text-bg-dark">Dark</span>
<br>
<span class="badge rounded-pill text-bg-primary">Primary</span>
<span class="badge rounded-pill text-bg-secondary">Secondary</span>
<span class="badge rounded-pill text-bg-success">Success</span>
<span class="badge rounded-pill text-bg-danger">Danger</span>
<span class="badge rounded-pill text-bg-warning">Warning</span>
<span class="badge rounded-pill text-bg-info">Info</span>
<span class="badge rounded-pill text-bg-light">Light</span>
<span class="badge rounded-pill text-bg-dark">Dark</span>
<br>
</div>
<div class="my-4">
<h4>Breadcrumbs</h4>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">Home</li>
</ol>
</nav>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Library</li>
</ol>
</nav>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="#">Library</a></li>
<li class="breadcrumb-item active" aria-current="page">Data</li>
</ol>
</nav>
</div>
<div class="my-4">
<h4>Alerts</h4>
<div class="alert alert-primary" role="alert">
A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
A simple danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
A simple warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
A simple info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
A simple light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
A simple dark alert—check it out!
</div>
</div>
<div class="my-4">
<h4>Pagination</h4>
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active" aria-current="page">
<a class="page-link" href="#">2</a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
</div>
<div class="my-4">
<h4>Colors</h4>
<div class="text-bg-primary p-3">Primary with contrasting color</div>
<div class="text-bg-secondary p-3">Secondary with contrasting color</div>
<div class="text-bg-success p-3">Success with contrasting color</div>
<div class="text-bg-danger p-3">Danger with contrasting color</div>
<div class="text-bg-warning p-3">Warning with contrasting color</div>
<div class="text-bg-info p-3">Info with contrasting color</div>
<div class="text-bg-light p-3">Light with contrasting color</div>
<div class="text-bg-dark p-3">Dark with contrasting color</div>
</div>
</div>
</x-layout-app>

View File

@ -0,0 +1,37 @@
<x-layout-app>
<div class="container-xl">
<div class="page-header">
<h1>{{ $maintenance_history->maintenance->name }}</h1>
</div>
<p>{!! $maintenance_history->maintenance->description !!}</p>
@foreach ($maintenance_history->historyHosts as $historyHost)
<h2>
@if (empty($historyHost->summary))
<i class="fas fa-check text-success"></i>
@else
<i class="fas fa-times text-danger"></i>
@endif{{ $historyHost->host->hostname }}
</h2>
@if (!empty($historyHost->summary))
<b>{{ __('Oduvodnění') }}</b>
<p>{!! $historyHost->summary !!}</p>
@endif
@foreach ($historyHost->historyTasks as $historyTask)
<h3>
@if (empty($historyTask->summary))
<i class="fas fa-check text-success"></i>
@else
<i class="fas fa-times text-danger"></i>
@endif
{{ $historyTask->maintenanceTask->task->name }}
</h3>
@if (!empty($historyTask->summary))
<b>{{ __('Oduvodnění') }}</b>
<p>{!! $historyTask->summary !!}</p>
@endif
@endforeach
<hr>
@endforeach
</div>
</x-layout-app>

View File

@ -7,11 +7,11 @@
<x-form::form action="{{ route('maintenance.planned.finished', ['maintenance_history' => $maintenance_history->id]) }}" method="POST"> <x-form::form action="{{ route('maintenance.planned.finished', ['maintenance_history' => $maintenance_history->id]) }}" method="POST">
@foreach ($maintenance_history->historyHosts as $historyHost) @foreach ($maintenance_history->historyHosts as $historyHost)
@if (in_array($historyHost->id, array_keys($maintenance_host_skipped))) @if (in_array($historyHost->id, array_keys($maintenance_host_skipped)))
<x-form::quill label="{{ __('Reason for Skipping Host: ') . $historyHost->host->hostname}}" id="skipped-host-{{ $historyHost->id }}-summary" name="skippedHostsSummary[{{ $historyHost->id }}]" help="{{ _('Describe why did you skipped the host') }}" /> <x-form::quill required label="{{ __('Reason for Skipping Host: ') . $historyHost->host->hostname}}" id="skipped-host-{{ $historyHost->id }}-summary" name="skippedHostsSummary[{{ $historyHost->id }}]" help="{{ __('Describe why did you skipped the host') }}" />
@else @else
@foreach ($historyHost->historyTasks as $historyTask) @foreach ($historyHost->historyTasks as $historyTask)
@if (!isset($maintenance_task_status[$historyHost->id][$historyTask->id])) @if (!isset($maintenance_task_status[$historyHost->id][$historyTask->id]))
<x-form::quill label="{{ __('Reason for Skipping Task: ') . $historyTask->maintenanceTask->name}}" id="skipped-host-{{ $historyHost->id }}-task-{{ $historyTask->id }}-summary" name="skippedHostTasksSummary[{{ $historyHost->id }}][{{ $historyTask->id }}]" help="{{ _('Describe why did you not finished the task') }}" /> <x-form::quill required label="{{ __('Reason for Skipping Task: ') . $historyTask->maintenanceTask->name}}" id="skipped-host-{{ $historyHost->id }}-task-{{ $historyTask->id }}-summary" name="skippedHostTasksSummary[{{ $historyHost->id }}][{{ $historyTask->id }}]" help="{{ __('Describe why did you not finished the task') }}" />
@else @else
<x-form::checkbox onclick="return false" checked="{{ isset($maintenance_task_status[$historyHost->id][$historyTask->id]) ? 'checked' : '' }}" label="{{ $historyTask->maintenanceTask->task->name }}" name="test-{{ $historyHost->id }}-{{ $historyTask->id }}" /> <x-form::checkbox onclick="return false" checked="{{ isset($maintenance_task_status[$historyHost->id][$historyTask->id]) ? 'checked' : '' }}" label="{{ $historyTask->maintenanceTask->task->name }}" name="test-{{ $historyHost->id }}-{{ $historyTask->id }}" />
@endif @endif

File diff suppressed because one or more lines are too long

View File

@ -3,11 +3,7 @@
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::auth(); Route::auth();
Route::get('/', function () {
return view('welcome');
});
Route::get('/dashboard', [App\Http\Controllers\DashboardController::class, 'index'])->name('dashboard');
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::put('/maintenance/planned/{maintenance_history}', [App\Http\Controllers\MaintenanceController::class, 'plannedDetailPut'])->name('maintenance.planned.detail.put');