Skip to content

Commit

Permalink
Admin Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPJunior committed Aug 1, 2021
1 parent 0d69a81 commit 0e35103
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Frontend/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function home()
*/
public function watch(Request $request)
{
$video = Video::where('media_id', $request->get('v'))->first();
$video = Video::withoutBanned()->where('media_id', $request->get('v'))->firstOrFail();
if (auth()->check())
{
auth()->user()->hasSubscribed($video->channel);
Expand All @@ -48,7 +48,7 @@ public function watch(Request $request)
*/
public function download(Request $request)
{
$video = Video::where('media_id', $request->get('v'))->first();
$video = Video::withoutBanned()->where('media_id', $request->get('v'))->firstOrFail();
if ($video->settings()->get('allow_download', false))
{
$headers = [
Expand All @@ -68,7 +68,7 @@ public function download(Request $request)
public function channel($slug, Request $request)
{
return view('frontend.page.channel')->with([
'channel' => Channel::where('slug', $slug)->first()
'channel' => Channel::where('slug', $slug)->firstOrFail()
]);
}
}
28 changes: 28 additions & 0 deletions app/Http/Livewire/Backend/Channel/Modal/ViewVideo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Livewire\Backend\Channel\Modal;

use App\Models\Channel\Video;
use Livewire\Component;
use LivewireUI\Modal\ModalComponent;

class ViewVideo extends ModalComponent
{
public $video_id;
public $video;

public static function closeModalOnClickAway(): bool
{
return false;
}

public function mount()
{
$this->video = Video::find($this->video_id);
}

public function render()
{
return view('livewire.backend.channel.modal.view-video');
}
}
53 changes: 53 additions & 0 deletions app/Http/Livewire/Backend/Settings/FilesystemSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Http\Livewire\Backend\Settings;

use Livewire\Component;

class FilesystemSettings extends Component
{
public $aws_access_key_id;
public $aws_secret_access_key;
public $aws_default_region;
public $aws_bucket;
public $aws_url;
public $aws_endpoint;

public $success;

protected $listeners = ['settingsUpdated' => '$refresh'];

public function mount()
{
$this->aws_access_key_id = setting('aws_access_key_id');
$this->aws_secret_access_key = setting('aws_secret_access_key');
$this->aws_default_region = setting('aws_default_region');
$this->aws_bucket = setting('aws_bucket');
$this->aws_url = setting('aws_url');
$this->aws_endpoint = setting('aws_endpoint');
}

public function submit()
{
$validated = $this->validate([
'aws_access_key_id' => 'required',
'aws_secret_access_key' => 'required',
'aws_default_region' => 'required',
'aws_bucket' => 'required',
'aws_url' => 'required',
'aws_endpoint' => 'required',
]);
foreach ($validated as $key => $value)
{
setting()->set($key, $value);
}

$this->success = __('Filesystem Settings Updated');
$this->emit('settingsUpdated');
}

public function render()
{
return view('livewire.backend.settings.filesystem-settings');
}
}
44 changes: 44 additions & 0 deletions app/Http/Livewire/Backend/Settings/TranscodingSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Http\Livewire\Backend\Settings;

use Livewire\Component;

class TranscodingSettings extends Component
{
public $converted_file_driver;
public $hls_segment_size;
public $frame_from_seconds;

public $success;

protected $listeners = ['settingsUpdated' => '$refresh'];

public function mount()
{
$this->converted_file_driver = setting('converted_file_driver', config('site.converted_file_driver'));
$this->hls_segment_size = setting('hls_segment_size', config('site.hls_segment_size'));
$this->frame_from_seconds = setting('frame_from_seconds', config('site.frame_from_seconds'));
}

public function submit()
{
$validated = $this->validate([
'converted_file_driver' => 'required',
'hls_segment_size' => 'required',
'frame_from_seconds' => 'required',
]);
foreach ($validated as $key => $value)
{
setting()->set($key, $value);
}

$this->success = __('Transcoding Settings Updated');
$this->emit('settingsUpdated');
}

public function render()
{
return view('livewire.backend.settings.transcoding-settings');
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Frontend/Video/ChannelVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function mount()
public function render()
{
return view('livewire.frontend.video.channel-video')->with([
'videos' => $this->channel->videos()->where('name', 'like', '%'.$this->search.'%')->where('status', 'ready')->orderBy('created_at', 'desc')->paginate($this->perPage)
'videos' => $this->channel->videos()->withoutBanned()->where('name', 'like', '%'.$this->search.'%')->where('status', 'ready')->orderBy('created_at', 'desc')->paginate($this->perPage)
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Frontend/Video/LatestVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function loadMore()
public function render()
{
return view('livewire.frontend.video.latest-video', [
'videos' => Video::where('name', 'like', '%'.$this->search.'%')->where('status', 'ready')->orderBy('created_at', 'desc')->paginate($this->perPage)
'videos' => Video::withoutBanned()->where('name', 'like', '%'.$this->search.'%')->where('status', 'ready')->orderBy('created_at', 'desc')->paginate($this->perPage)
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Frontend/Video/WatchVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function updatedAutoplay($value)

public function render()
{
$upcoming_videos = Video::where('id', '!=', $this->video->id)->where('status', 'ready')->inRandomOrder()->paginate($this->perPage);
$upcoming_videos = Video::withoutBanned()->where('id', '!=', $this->video->id)->where('status', 'ready')->inRandomOrder()->paginate($this->perPage);
$this->next_video = $upcoming_videos->first();
$this->autoplay = request()->get('autoplay', null) ? 1 : null ;
$this->view = views($this->video)->unique()->count();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"laravel/framework": "^8.40",
"laravel/tinker": "^2.5",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.1",
"league/flysystem-cached-adapter": "~1.0",
"livewire-ui/modal": "^0.1.7",
"livewire/livewire": "^2.5",
"overtrue/laravel-like": "^4.0",
Expand Down
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
'services.mailgun.domain' => 'mailgun_domain',
'services.mailgun.secret' => 'mailgun_secret',
'services.mailgun.endpoint' => 'mailgun_endpoint',

'site.converted_file_driver' => 'converted_file_driver',
'site.hls_segment_size' => 'hls_segment_size',
'site.frame_from_seconds' => 'frame_from_seconds',

'filesystems.disks.s3.key' => 'aws_access_key_id',
'filesystems.disks.s3.secret' => 'aws_secret_access_key',
'filesystems.disks.s3.region' => 'aws_default_region',
'filesystems.disks.s3.bucket' => 'aws_bucket',
'filesystems.disks.s3.url' => 'aws_url',
'filesystems.disks.s3.endpoint' => 'aws_endpoint',
],

/*
Expand Down
24 changes: 23 additions & 1 deletion resources/views/backend/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div class="w-full md:w-1/3">
<div class="px-4 md:px-0">
<h3 class="text-lg font-medium leading-6 text-gray-900">{{ __('Mail Settings') }}</h3>
<p class="mt-1 text-sm leading-5 text-gray-600">{{ __("Please be careful when you are configuring SMTP. For incorrect configuration you will get error at the time of new registration, sending newsletter.") }}</p>
</div>
</div>
<div class="mt-4 md:mt-0 w-full md:w-2/3 pl-0 md:pl-2">
Expand All @@ -20,5 +19,28 @@
<div class="py-8">
<div class="border-t border-transparent md:border-gray-200"></div>
</div>
<div class="flex flex-row flex-wrap">
<div class="w-full md:w-1/3">
<div class="px-4 md:px-0">
<h3 class="text-lg font-medium leading-6 text-gray-900">{{ __('Transcoding Settings') }}</h3>
</div>
</div>
<div class="mt-4 md:mt-0 w-full md:w-2/3 pl-0 md:pl-2">
@livewire('backend.settings.transcoding-settings')
</div>
</div>
<div class="py-8">
<div class="border-t border-transparent md:border-gray-200"></div>
</div>
<div class="flex flex-row flex-wrap">
<div class="w-full md:w-1/3">
<div class="px-4 md:px-0">
<h3 class="text-lg font-medium leading-6 text-gray-900">{{ __('Filesystem Settings') }}</h3>
</div>
</div>
<div class="mt-4 md:mt-0 w-full md:w-2/3 pl-0 md:pl-2">
@livewire('backend.settings.filesystem-settings')
</div>
</div>
</div>
@endsection
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<x-modal>
<x-slot name="title">
<h3 class="text-lg font-medium text-gray-900">{{ __('Video Details') }}</h3>
</x-slot>
<x-slot name="content">
<div class="p-3">
<div id="player"></div>
</div>
<div class="w-full p-3">
<h2 class="text-md font-bold leading-5 text-gray-900 sm:text-3xl sm:truncate">{{ $video->name }}</h2>
<p class="mt-2">{{ $video->description }}</p>
</div>
<div class="w-full p-3 flex justify-between items-center">
<h2 class="font-medium">{{ __('Video Link') }}</h2>
<a id="video_link mt-1" href="{{ route('watch', ['v' => $video->media_id]) }}" class="text-indigo-500" target="_blank">{{ route('watch', ['v' => $video->media_id]) }}</a>
</div>
</x-slot>
</x-modal>

<script>
function renderVideoPlayer() {
let playerElement = document.getElementById("player");
let aspectRatio = 9/16, newWidth = playerElement.parentElement.offsetWidth, newHeight = 2 * Math.round(newWidth * aspectRatio/2);
let player = new Clappr.Player({
source: '{{ \Illuminate\Support\Facades\Storage::disk($video->disk)->url($video->streaming_url) }}',
plugins: [HlsjsPlayback],
poster: '{{ \Illuminate\Support\Facades\Storage::disk($video->disk)->url($video->thumbnail_url) }}'
});
player.attachTo(playerElement);
}
renderVideoPlayer();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class="object-contain md:object-scale-down w-24"
</x-livewire-tables::table.cell>
<x-livewire-tables::table.cell class="md:table-cell flex justify-end items-center">
<div>
<a wire:click="$emit('openModal', 'backend.channel.modal.view-video', {{ json_encode(["video_id" => $row->id]) }})" class="cursor-pointer font-medium mr-2">View</a>
@if($row->isBanned())
<a wire:click="$emit('openModal', 'backend.channel.modal.un-ban-video', {{ json_encode(["video_id" => $row->id]) }})" class="cursor-pointer font-medium mr-2">UnBan</a>
@else
Expand Down
Loading

0 comments on commit 0e35103

Please sign in to comment.