3
0
Fork 0

Redesign + Fixes

This commit is contained in:
thomas 2021-06-29 22:05:00 +02:00
parent 7718ed6c32
commit 7fe8056e35
67 changed files with 1898 additions and 2799 deletions

View file

@ -27,9 +27,9 @@ class HomeController extends Controller
public function index()
{
$users = User::count();
$regions = DB::table('region')->count();
$attractions = DB::table('attraction')->where('type', '!=', 'GLOBAL')->count();
$shows = Show::count();
$regions = DB::table('regions')->count();
$attractions = DB::table('attractions')->count();
$shows = env('SHOWS', false) ? Show::count() : 0;
return view('panel.home')->with([
'users' => $users,
'regions' => $regions,

View file

@ -0,0 +1,111 @@
<?php
namespace App\Http\Controllers\Panel;
use App\Http\Controllers\Controller;
use App\Show;
use App\ShowDate;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
class ToolController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware(['auth', 'verified', '2fa', 'admin']);
}
/**
* Show the operator tool.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function operator()
{
return view('panel.operator');
}
//Default values for cssTags
private $cssDefaults = [
'banner' => 'url("../img/banner.png") center center',
'bg' => '#f2f2f2',
'light' => '#2ecc71',
'dark' => "#27ae60",
'text' => '#fff',
];
//Tags that can be changed in root.css
private $cssTags = [
'banner' => 'banner',
"bg" => "bg",
"light" => "color-light",
"dark" => "color-dark",
"text" => "color-text",
];
public function css() {
$styles = $this->cssDefaults;
if(file_exists(storage_path('app/public/css.json'))) {
$json = file_get_contents(storage_path('app/public/css.json'));
$json = json_decode($json);
if(json_last_error() != JSON_ERROR_NONE && !empty($json))
$styles = $json;
}
return view('panel.css')->with([
'styles' => $styles,
]);
}
public function cssPost(Request $request) {
$rules = [];
foreach($this->cssTags as $key => $value)
$rules[$key] = ['required'];
$validator = Validator::make($request->all(), $rules);
if(!$validator->passes())
return Redirect::back()->withErrors($validator->errors());
$styles = [];
foreach($request->all() as $key => $value)
if(array_key_exists($key, $this->cssTags))
$styles[$key] = $value;
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
$str = ":root {\n";
foreach($styles as $key => $value)
$str .= "\t--".$this->cssTags[$key].': '.$value.";\n";
file_put_contents(public_path('assets/css/root.css'), $str.'}');
return view('panel.css')->with([
'styles' => $styles,
]);
}
public function cssReset() {
$styles = $this->cssDefaults;
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
$str = ":root {\n";
foreach($styles as $key => $value)
$str .= '--'.$this->cssTags[$key].': '.$value.";\n";
file_put_contents(public_path('assets/css/root.css'), $str.'}');
return Redirect::back();
}
}