Skip to content

Commit

Permalink
Add new menu stop presentation processing, Remove route, add lang
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecraank committed Feb 26, 2024
1 parent 948123a commit 287458c
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 11 deletions.
19 changes: 19 additions & 0 deletions app/Http/Controllers/PresentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ public function index()
return view('presentations.index', compact('presentations', 'countUsed', 'countUnused'));
}

public function ongoing() {
$presentations = Presentation::where('processed', false)->latest()->get();

return view('presentations.ongoing', compact('presentations'));
}

public function stopOngoingProcessing(Request $request, $id) {
$presentation = Presentation::whereId($id)->first();

if(!$presentation) {
return redirect()->back()->withErrors(['message' => __('Presentation not found')]);
}

$presentation->processed = true;
$presentation->save();

return redirect()->route('presentations.ongoing')->with('success', __('Presentation processing stopped'));
}

/**
* Show the form for creating a new resource.
*/
Expand Down
4 changes: 3 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,7 @@
"Go to presentation": "Gehe zu Präsentation",
"Delete presentation after schedule ends": "Präsentation nach Ablauf des Zeitplans löschen",
"Start date": "Startdatum",
"End date": "Enddatum"
"End date": "Enddatum",
"Ongoing processing": "Laufende Verarbeitung",
"Are you sure to stop this processing?" : "Sind Sie sicher, dass Sie diese Verarbeitung stoppen möchten?"
}
6 changes: 6 additions & 0 deletions resources/views/layouts/menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class="nav-link @if (str_contains(\Request::route()->getName(), 'schedules.')) a
</a>
</li>
@endcan
@can('read logs')
<li><a href="{{ route('presentations.ongoing') }}" class="dropdown-item">
{{ __('Ongoing processing') }}
</a>
</li>
@endcan
</ul>
</li>
@endcan
Expand Down
59 changes: 59 additions & 0 deletions resources/views/presentations/ongoing.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@extends('layouts.app')

@section('content')
@can('read logs')
<h3>{{ __('Ongoing processing') }}</h3>
<div class="card">
<h5 class="card-header">
{{ __('Overview') }}
</h5>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('Preview') }}</th>
<th>{{ __('Description') }}</th>
<th>{{ __('Slides') }}</th>
<th>{{ __('Slides updated') }}</th>
<th>{{ __('Created by') }}</th>
<th>{{ __('Actions') }}</th>
</tr>
</thead>

<tbody>
@foreach ($presentations as $presentation)
<tr>
<td>
<a href="{{ route('presentations.show', ['id' => $presentation->id]) }}">
<img src="{{ $presentation->slides->first()?->publicpreviewpath ?? config('app.placeholder_image') }}"
class="img-thumbnail" style="max-height: 100px;">
</a>
</td>
<td>{{ $presentation->name }}</td>
<td>{{ $presentation->slides->count() }}</td>
<td>{{ $presentation->slides->first()?->created_at?->format('d.m.Y H:i') ?? 'N/A' }}</td>
<td>{{ $presentation->author }}</td>
<td class="actions-cell">

<form action="{{ route('presentations.ongoing.stop', $presentation->id) }}" method="POST" onsubmit="return confirm('{{ __('Are you sure to stop this processing?') }}')">
@csrf
<button class="btn btn-sm btn-danger" type="submit"><i class="bi-trash"></i></button>
</form>
</td>
</tr>
@endforeach
@if ($presentations->count() == 0)
<tr>
<td colspan="7" class="text-center">
{{ __('No templates found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
@endcan
@cannot('read presentations')
@include('unauthorized')
@endcannot
@endsection
24 changes: 18 additions & 6 deletions resources/views/presentations/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@extends('layouts.app')

@section('content')
<h3 class="mb-3">{{ __('Template') }}: {{ $presentation->name }}</h3>
<h3 class="mb-3">
{{ __('Template') }}: {{ $presentation->name }}</h3>
<div class="card">
<h5 class="card-header">
{{ __('Edit template') }}
Expand Down Expand Up @@ -44,27 +45,38 @@
</div>


<div class="mb-3">
<div class="mb-3 mt-4">
<label class="form-label">{{ __('Upload file') }}<span class="text-danger">*</span></label>
<div id="drop_zone" ondrop="window.dropHandler(event)" ondragover="window.dragOverHandler(event)">
<div id="drop_zone" ondrop="window.dropHandler(event)"
ondragover="window.dragOverHandler(event)">
<div id="file-upload">
<input class="form-control file-input" type="file" name="file" required
accept="application/pdf,video/mp4" id="formFile">
<p class="mt-4" style="display: inline-block">{{ __('or drag and drop to upload') }}</p>
<p class="mt-4" style="display: inline-block">
{{ __('or drag and drop to upload') }}</p>
</div>
</div>
</div>

<hr>

@if ($presentation->processed)
<button @if (!$presentation->processed) disabled @endif type="submit" class="btn btn-primary">{{ __('Save') }} @if (!$presentation->processed) ({{ __('In process') }}) @endif</button>
<button @if (!$presentation->processed) disabled @endif type="submit"
class="btn btn-primary">{{ __('Save') }} @if (!$presentation->processed)
({{ __('In process') }})
@endif
</button>
@else
<button disabled type="submit" class="btn btn-primary">{{ __('Save') }} @if (!$presentation->processed)
({{ __('In process') }})
@endif
</button>
@endif
</form>
@endcan
</div>

<hr>
<hr style="margin-top: 20px">

<div class="p-3">
<h5 class="pt-1">{{ __('Devices') }} ({{ $presentation->devices->count() }})</h5>
Expand Down
6 changes: 2 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

Route::prefix('presentations')->group(function () {
Route::get('/', [PresentationController::class, 'index'])->name('presentations.index');
Route::post('/ongoing/{id}', [PresentationController::class, 'stopOngoingProcessing'])->name('presentations.ongoing.stop');
Route::get('/ongoing', [PresentationController::class, 'ongoing'])->name('presentations.ongoing');
Route::get('/create', [PresentationController::class, 'create'])->middleware('can:create presentations')->name('presentations.create');
Route::post('/', [PresentationController::class, 'store'])->middleware('can:create presentations')->name('presentations.store');
Route::get('/{id}', [PresentationController::class, 'show'])->middleware('can:read presentations')->name('presentations.show');
Expand Down Expand Up @@ -110,10 +112,6 @@
});
});

Route::get('/test', function() {
dd(ScheduleController::checkForExpiredSchedules());
})->name('test');

Auth::routes();


0 comments on commit 287458c

Please sign in to comment.