1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-21 23:42:10 +02:00

Refactor the trash controller, add custom error views (WIP)

This commit is contained in:
Kovah 2020-01-31 12:25:03 +01:00
parent 33f302799f
commit 1855d87715
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
12 changed files with 91 additions and 8 deletions

View File

@ -82,7 +82,7 @@ class TrashController extends Controller
break;
}
if (empty($entries)) {
if ($entries->isEmpty()) {
alert(trans('trash.delete_no_entries'), 'warning');
return redirect()->back();
}
@ -124,16 +124,16 @@ class TrashController extends Controller
}
if (empty($entry)) {
abort(404);
abort(404, trans('trash.restore.not_found'));
}
if ($entry->user_id !== auth()->id()) {
abort(403);
abort(403, trans('trash.restore.not_allowed'));
}
$entry->restore();
alert(trans('trash.delete_restore.' . $model), 'success');
alert(trans('trash.restore.' . $model), 'success');
return redirect()->route('get-trash');
}

View File

@ -46,6 +46,7 @@ server {
# Error pages
error_page 404 /index.php;
error_page 403 /index.php;
# PHP handling
location ~ \.php$ {

View File

@ -39,6 +39,7 @@ server {
# Error pages
error_page 404 /index.php;
error_page 403 /index.php;
# PHP handling
location ~ \.php$ {

View File

@ -20,9 +20,12 @@ return [
'delete_success.tags' => 'Permanently deleted all tags.',
'delete_success.notes' => 'Permanently deleted all notes.',
'delete_restore.link' => 'Restored the link from trash.',
'delete_restore.list' => 'Restored the list from trash.',
'delete_restore.tag' => 'Restored the tag from trash.',
'delete_restore.note' => 'Restored the note from trash.',
'restore.link' => 'Restored the link from trash.',
'restore.list' => 'Restored the list from trash.',
'restore.tag' => 'Restored the tag from trash.',
'restore.note' => 'Restored the note from trash.',
'restore.not_found' => 'The item to be restored could not be found.',
'restore.not_allowed' => 'You are not allowed to restore this item.',
];

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Unauthorized'))
@section('code', '401')
@section('message', __($exception->getMessage() ?: 'Unauthorized'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Forbidden'))
@section('code', '403')
@section('message', __($exception->getMessage() ?: 'Forbidden'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Not Found'))
@section('code', '404')
@section('message', __($exception->getMessage() ?: 'Page not Found'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Page Expired'))
@section('code', '419')
@section('message', __($exception->getMessage() ?: 'Page Expired'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Too Many Requests'))
@section('code', '429')
@section('message', __($exception->getMessage() ?: 'Too Many Requests'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Server Error'))
@section('code', '500')
@section('message', __($exception->getMessage() ?: 'Server Error'))

View File

@ -0,0 +1,5 @@
@extends('layouts.errors')
@section('title', __('Service Unavailable'))
@section('code', '503')
@section('message', __($exception->getMessage() ?: 'Service Unavailable'))

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config('app.name', 'LinkAce') }}</title>
<link href="{{ mix('assets/dist/css/app.css') }}" rel="stylesheet">
@include('partials.favicon')
</head>
<body class="setup">
<div id="app">
<main class="main container">
<div class="mb-5 text-center">
<img src="{{ asset('assets/img/logo_linkace.svg') }}" alt="@lang('linkace.linkace')"
width="150" height="55">
</div>
<div class="card border-danger text-danger mb-3">
<div class="card-header bg-danger text-white text-large">
@yield('code') - @yield('title')
</div>
<div class="card-body">
@yield('message')
</div>
</div>
<a href="{{ redirect()->back()->getTargetUrl() }}">Go back</a>
</main>
<script src="{{ mix('assets/dist/js/dependencies.js') }}"></script>
<script src="{{ mix('assets/dist/js/app.js') }}"></script>
<script src="{{ mix('assets/dist/js/fontawesome.js') }}"></script>
@stack('scripts')
</div>
<div id="loader"><div></div></div>
</body>
</html>