mirror of
				https://github.com/linuxserver/Heimdall.git
				synced 2025-10-31 13:07:50 +09:00 
			
		
		
		
	get background switching working
This commit is contained in:
		| @@ -4,6 +4,7 @@ namespace App\Http\Controllers; | ||||
|  | ||||
| use Illuminate\Http\Request; | ||||
| use App\Item; | ||||
| use App\Setting; | ||||
| use App\SupportedApps\Nzbget; | ||||
| use Illuminate\Support\Facades\Storage; | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,7 @@ | ||||
|  | ||||
| namespace App\Http\Controllers; | ||||
|  | ||||
| use Illuminate\Http\Request; | ||||
| use App\Setting; | ||||
| use App\SettingGroup; | ||||
| use App\Http\Controllers\Controller; | ||||
| @@ -47,7 +48,7 @@ class SettingsController extends Controller | ||||
|      * | ||||
|      * @return \Illuminate\Http\RedirectResponse | ||||
|      */ | ||||
|     public function update($id) | ||||
|     public function update(Request $request, $id) | ||||
|     { | ||||
|         $setting = Setting::find($id); | ||||
|  | ||||
| @@ -55,24 +56,26 @@ class SettingsController extends Controller | ||||
|             $data = Setting::getInput(); | ||||
|  | ||||
|             if ($setting->type == 'image') { | ||||
|                 if (!is_null($data->image) && $data->image->isValid()) { | ||||
|                     $destinationPath = uploads_path().'/settings/'; | ||||
|                     $extension = $data->image->getClientOriginalExtension(); | ||||
|                     $fileName = rand(11111111, 99999999).'.'.$extension; | ||||
|                     $data->image->move($destinationPath, $fileName); | ||||
|                     $setting->value = $fileName; | ||||
|  | ||||
|  | ||||
|                 if($request->hasFile('value')) { | ||||
|                     $path = $request->file('value')->store('backgrounds'); | ||||
|                     $setting->value = $path; | ||||
|                 } | ||||
|              | ||||
|  | ||||
|  | ||||
|             } else { | ||||
|                 $setting->value = $data->value; | ||||
|             } | ||||
|  | ||||
|             $setting->save(); | ||||
|  | ||||
|             return redirect()->route('settings.list')->with([ | ||||
|             return redirect()->route('settings.index')->with([ | ||||
|                 'success' => 'You have successfully edited this Setting!', | ||||
|             ]); | ||||
|         } else { | ||||
|             return redirect()->route('settings.list')->with([ | ||||
|             return redirect()->route('settings.index')->with([ | ||||
|                 'error' => 'This Setting does not exist.', | ||||
|             ]); | ||||
|         } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ namespace App\Providers; | ||||
|  | ||||
| use Illuminate\Support\ServiceProvider; | ||||
| use Artisan; | ||||
| use App\Setting; | ||||
|  | ||||
| class AppServiceProvider extends ServiceProvider | ||||
| { | ||||
| @@ -23,6 +24,12 @@ class AppServiceProvider extends ServiceProvider | ||||
|             //Artisan::call('config:cache'); | ||||
|             //Artisan::call('route:cache'); | ||||
|         } | ||||
|         $alt_bg = ''; | ||||
|         if($bg_image = Setting::fetch('background_image')) { | ||||
|             $alt_bg = ' style="background-image: url('.asset('storage/'.$bg_image).')"'; | ||||
|         } | ||||
|         view()->share('alt_bg', $alt_bg); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
|  | ||||
|     </head> | ||||
|     <body> | ||||
|         <div id="app"> | ||||
|         <div id="app"{!! $alt_bg !!}> | ||||
|             <nav class="sidenav"> | ||||
|                 <a class="close-sidenav" href=""><i class="fas fa-times-circle"></i></a> | ||||
|                 @if(isset($all_apps)) | ||||
|   | ||||
							
								
								
									
										9
									
								
								resources/views/settings/edit.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								resources/views/settings/edit.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| @extends('app') | ||||
|  | ||||
| @section('content') | ||||
|  | ||||
|     {!! Form::model($setting, ['method' => 'PATCH', 'files' => true, 'route' => ['settings.edit', $setting->id]]) !!} | ||||
|     @include('settings.form') | ||||
|     {!! Form::close() !!} | ||||
|  | ||||
| @endsection | ||||
							
								
								
									
										43
									
								
								resources/views/settings/form.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								resources/views/settings/form.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| <section class="module-container"> | ||||
|         <header> | ||||
|             <div class="section-title">{{ $setting->label }}</div> | ||||
|             <div class="module-actions"> | ||||
|                 <button type="submit"class="button"><i class="fa fa-save"></i><span>Save</span></button> | ||||
|                 <a href="{{ route('settings.index') }}" class="button"><i class="fa fa-ban"></i><span>Cancel</span></a> | ||||
|             </div> | ||||
|         </header> | ||||
|         <div class="create"> | ||||
|             {!! csrf_field() !!} | ||||
|             <!--<div class="input"> | ||||
|                 <label>Application name</label> | ||||
|                 {!! Form::select('supported', \App\Item::supportedOptions(), array('placeholder' => 'Title','class' => 'form-control')) !!} | ||||
|             </div>--> | ||||
|  | ||||
|             <div class="input"> | ||||
|                     @php($type = explode('|', $setting->type)[0]) | ||||
|                     {!! Form::label('value', 'Value') !!} | ||||
|                     @if ($type == 'image') | ||||
|                     {!! Form::file('value', ['class' => 'form-control']) !!} | ||||
|                     @elseif ($type == 'select') | ||||
|                     @php($options = explode('|', $setting->type)[1]) | ||||
|                     @php($options = explode(',', $options)) | ||||
|                     {!! Form::select('value', $options, null, ['class' => 'form-control']) !!} | ||||
|                     @elseif ($type == 'textarea') | ||||
|                     {!! Form::textarea('value', Request::get('value'), ['class' => 'form-control trumbowyg', 'placeholder' => 'FAQ contents']) !!} | ||||
|                     @else | ||||
|                     {!! Form::text('value', null, ['class' => 'form-control']) !!} | ||||
|                     @endif | ||||
|  | ||||
|             </div> | ||||
|  | ||||
|              | ||||
|         </div> | ||||
|         <footer> | ||||
|             <div class="section-title"> </div> | ||||
|             <div class="module-actions"> | ||||
|                 <button type="submit"class="button"><i class="fa fa-save"></i><span>Save</span></button> | ||||
|                 <a href="{{ route('settings.index') }}" class="button"><i class="fa fa-ban"></i><span>Cancel</span></a> | ||||
|             </div> | ||||
|         </footer> | ||||
|  | ||||
|     </section> | ||||
| @@ -28,7 +28,7 @@ | ||||
|                                     @php($type = explode('|', $setting->type)[0]) | ||||
|                                     @if ($type == 'image') | ||||
|                                         @if(!empty($setting->value)) | ||||
|                                         <a href="/uploads/settings/{{ $setting->value }}" title="View" target="_blank">View</a> | ||||
|                                         <a href="{{ asset('storage/'.$setting->value) }}" title="View" target="_blank">View</a> | ||||
|                                         @else | ||||
|                                         - not set - | ||||
|                                         @endif | ||||
|   | ||||
| @@ -36,6 +36,6 @@ Route::group([ | ||||
|         ->name('edit'); | ||||
|  | ||||
|  | ||||
|     Route::post('edit/{id}', 'SettingsController@update'); | ||||
|     Route::patch('edit/{id}', 'SettingsController@update'); | ||||
|  | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user