Updates to duplicate/remove displays, remove deprecated display functions

This commit is contained in:
Deon George 2024-09-30 22:56:08 +10:00
parent 7eb0379996
commit 7742b4289d
13 changed files with 103 additions and 117 deletions

View File

@ -9,21 +9,24 @@ class PhotoController extends Controller
{ {
use Multimedia; use Multimedia;
protected $list_duplicates = 20;
protected $list_deletes = 50;
public function delete(Photo $o) public function delete(Photo $o)
{ {
$o->remove = TRUE; $o->remove = TRUE;
$o->save(); $o->save();
return redirect()->action('PhotoController@info',[$o->id]); return redirect()
->action('PhotoController@info',[$o->id]);
} }
public function deletes($id=NULL) public function deletes($id=NULL)
{ {
return view('catalog.deletereview',[ return view('catalog.deletereview',[
'catalog'=>is_null($id) ? Photo::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Photo::where('id',$id)->paginate(1), 'catalog'=>is_null($id)
? Photo::where('remove',1)
->with(['software.model.make'])
->paginate(self::list_deletes)
: Photo::where('id',$id)
->paginate(1),
'return'=>url('p/deletes'), 'return'=>url('p/deletes'),
'type'=>'photo', 'type'=>'photo',
]); ]);
@ -32,7 +35,12 @@ class PhotoController extends Controller
public function duplicates($id=NULL) public function duplicates($id=NULL)
{ {
return view('catalog.duplicatereview',[ return view('catalog.duplicatereview',[
'catalog'=>is_null($id) ? Photo::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Photo::where('id',$id)->paginate(1), 'catalog'=>is_null($id)
? Photo::duplicates()
->with(['software.model.make'])
->paginate(self::list_duplicates)
: Photo::where('id',$id)
->paginate(1),
'return'=>url('p/duplicates'), 'return'=>url('p/duplicates'),
'type'=>'photo', 'type'=>'photo',
]); ]);

View File

@ -10,21 +10,24 @@ class VideoController extends Controller
{ {
use Multimedia; use Multimedia;
protected $list_duplicates = 20;
protected $list_deletes = 50;
public function delete(Video $o) public function delete(Video $o)
{ {
$o->remove = TRUE; $o->remove = TRUE;
$o->save(); $o->save();
return redirect()->action('VideoController@info',[$o->id]); return redirect()
->action('VideoController@info',[$o->id]);
} }
public function deletes($id=NULL) public function deletes($id=NULL)
{ {
return view('catalog.deletereview',[ return view('catalog.deletereview',[
'catalog'=>is_null($id) ? Video::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Video::where('id',$id)->paginate(1), 'catalog'=>is_null($id)
? Video::where('remove',1)
->with(['software.model.make'])
->paginate(self::list_deletes)
: Video::where('id',$id)
->paginate(1),
'return'=>url('v/deletes'), 'return'=>url('v/deletes'),
'type'=>'video', 'type'=>'video',
]); ]);
@ -33,7 +36,12 @@ class VideoController extends Controller
public function duplicates($id=NULL) public function duplicates($id=NULL)
{ {
return view('catalog.duplicatereview',[ return view('catalog.duplicatereview',[
'catalog'=>is_null($id) ? Video::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Video::where('id',$id)->paginate(1), 'catalog'=>is_null($id)
? Video::duplicates()
->with(['software.model.make'])
->paginate(self::list_duplicates)
: Video::where('id',$id)
->paginate(1),
'return'=>url('v/duplicates'), 'return'=>url('v/duplicates'),
'type'=>'video', 'type'=>'video',
]); ]);
@ -44,7 +52,8 @@ class VideoController extends Controller
$o->remove = NULL; $o->remove = NULL;
$o->save(); $o->save();
return redirect()->action('VideoController@info',[$o->id]); return redirect()
->action('VideoController@info',[$o->id]);
} }
public function view(Video $o) public function view(Video $o)

View File

@ -322,67 +322,6 @@ abstract class Catalog extends Model
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/'); return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
} }
/**
* Return HTML Checkbox for duplicate
* @deprecated use a component
*/
public function getDuplicateCheckboxAttribute()
{
return $this->HTMLCheckbox('duplicate',$this->id,$this->duplicate);
}
/**
* Return HTML Checkbox for flagged
* @deprecated use a component
*/
public function getFlagCheckboxAttribute()
{
return $this->HTMLCheckbox('flag',$this->id,$this->flag);
}
/**
* Return HTML Checkbox for ignore
* @deprecated use a component
*/
public function getIgnoreCheckboxAttribute()
{
return $this->HTMLCheckbox('ignore_duplicate',$this->id,$this->ignore_duplicate);
}
/**
* @deprecated use a component
*/
public function getDuplicateTextAttribute()
{
return $this->TextTrueFalse($this->duplicate);
}
/**
* @deprecated use a component
*/
public function getFlagTextAttribute()
{
return $this->TextTrueFalse($this->flag);
}
/**
* Return HTML Checkbox for remove
* @deprecated use a component
*/
public function getRemoveCheckboxAttribute()
{
return $this->HTMLCheckbox('remove',$this->id,$this->remove);
}
/**
* Return an HTML checkbox
* @deprecated use a component
*/
protected function HTMLCheckbox($name,$id,$value)
{
return sprintf('<input type="checkbox" name="%s[%s]" value="1"%s>',$name,$id,$value ? ' checked="checked"' : '');
}
/** /**
* Set values from the media object * Set values from the media object
* *
@ -558,12 +497,6 @@ abstract class Catalog extends Model
return $this->filename !== $this->file_name(); return $this->filename !== $this->file_name();
} }
/** @deprecated is this really needed? */
private function TextTrueFalse($value): string
{
return $value ? 'TRUE' : 'FALSE';
}
/** /**
* Find duplicate images based on some attributes of the current image * Find duplicate images based on some attributes of the current image
*/ */

View File

@ -5,6 +5,7 @@ namespace App\Providers;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Pagination\Paginator;
use App\Models\{Photo,Video}; use App\Models\{Photo,Video};
@ -31,5 +32,7 @@ class AppServiceProvider extends ServiceProvider
{ {
Route::model('po',Photo::class); Route::model('po',Photo::class);
Route::model('vo',Video::class); Route::model('vo',Video::class);
Paginator::useBootstrapFour();
} }
} }

View File

@ -17,6 +17,9 @@ trait Multimedia
{ {
use Type; use Type;
protected const list_duplicates = 20;
protected const list_deletes = 50;
private function controller(string $type): string private function controller(string $type): string
{ {
switch (strtolower($type)) { switch (strtolower($type)) {
@ -31,10 +34,11 @@ trait Multimedia
$class = $this->getModelType($request->input('type')); $class = $this->getModelType($request->input('type'));
$this->updatePostItems($request,$class,TRUE); $this->updatePostItems($request,$class,TRUE);
return redirect()->action( return redirect()
sprintf('%s@deletes',$this->controller($request->input('type'))), ->action(
sprintf('?page=%s',$request->input('page')) sprintf('%s@deletes',$this->controller($request->input('type'))),
); sprintf('?page=%s',$request->input('page'))
);
} }
public function duplicatesUpdate(Request $request) public function duplicatesUpdate(Request $request)
@ -42,10 +46,11 @@ trait Multimedia
$class = $this->getModelType($request->input('type')); $class = $this->getModelType($request->input('type'));
$this->updatePostItems($request,$class); $this->updatePostItems($request,$class);
return redirect()->action( return redirect()
sprintf('%s@duplicates',$this->controller($request->input('type'))), ->action(
sprintf('?page=%s',$request->input('page')) sprintf('%s@duplicates',$this->controller($request->input('type'))),
); sprintf('?page=%s',$request->input('page'))
);
} }
private function updatePostItems(Request $request,string $class,bool $delete=FALSE) private function updatePostItems(Request $request,string $class,bool $delete=FALSE)
@ -53,9 +58,11 @@ trait Multimedia
foreach ($request->input('items') as $id) { foreach ($request->input('items') as $id) {
try { try {
$o = $class::findOrFail($id); $o = $class::findOrFail($id);
} catch (ModelNotFoundException $e) { } catch (ModelNotFoundException $e) {
Log::alert('Object not found: '.$id); Log::alert('Object not found: '.$id);
continue; continue;
} catch (\Exception $e) { } catch (\Exception $e) {
dd($e); dd($e);
} }
@ -70,7 +77,7 @@ trait Multimedia
$o->flag = $request->input('flag.'.$id) ? 1 : NULL; $o->flag = $request->input('flag.'.$id) ? 1 : NULL;
// Set if delete // Set if delete
if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) { if ($delete && $o->remove && ($request->input('remove.'.$id) ? 1 : NULL)) {
switch (strtolower($request->input('type'))) { switch (strtolower($request->input('type'))) {
case 'photo': case 'photo':
$this->dispatch((new PhotoDelete($o))->onQueue('delete')); $this->dispatch((new PhotoDelete($o))->onQueue('delete'));

View File

@ -17,14 +17,17 @@
@section('main-content') @section('main-content')
<div class="col-12"> <div class="col-12">
@if ($catalog->count()) @if ($catalog->count())
<span class="pagination justify-content-center">{{ $catalog->links() }}</span> <span class="pagination justify-content-center">
{{ $catalog->links() }}
</span>
<form action="{{ $return }}" method="POST"> <form action="{{ $return }}" method="POST">
@csrf @csrf
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}"> <input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
<input type="hidden" name="type" value="{{ $type }}"> <input type="hidden" name="type" value="{{ $type }}">
@include('catalog.widgets.duplicates') @include('catalog.widgets.list')
<div class="pb-2"><button class="btn btn-sm btn-danger">Confirm Delete</button></div> <div class="pb-2"><button class="btn btn-sm btn-danger">Confirm Delete</button></div>
</form> </form>

View File

@ -17,15 +17,17 @@
@section('main-content') @section('main-content')
<div class="col-12"> <div class="col-12">
@if ($catalog->count()) @if ($catalog->count())
<span class="pagination justify-content-center">{{ $catalog->links() }}</span> <span class="pagination justify-content-center">
{{ $catalog->links() }}
</span>
<form action="{{ $return }}" method="POST"> <form action="{{ $return }}" method="POST">
@csrf @csrf
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
<input type="hidden" name="type" value="{{ $type }}"> <input type="hidden" name="type" value="{{ $type }}">
<input type="hidden" name="page" value="{{ $catalog->currentPage() }}">
@include('catalog.widgets.duplicates') @include('catalog.widgets.list')
<div class="pb-2"><button class="btn btn-sm btn-primary">Update</button></div> <div class="pb-2"><button class="btn btn-sm btn-primary">Update</button></div>
</form> </form>

View File

@ -11,8 +11,8 @@
<tbody> <tbody>
@foreach ($catalog as $o) @foreach ($catalog as $o)
@continue($rendered->search($o)) @continue($rendered->contains($o->id))
@php($rendered->push($o)) @php($rendered->push($o->id))
<tr> <tr>
<td> <td>
@ -28,8 +28,8 @@
@else @else
@foreach($d as $item) @foreach($d as $item)
@continue($rendered->search($item)) @continue($rendered->contains($item->id))
@php($rendered->push($item)) @php($rendered->push($item->id))
<td> <td>
<input type="hidden" name="items[]" value="{{ $item->id }}"> <input type="hidden" name="items[]" value="{{ $item->id }}">
@include($item::config.'.widgets.thumbnail',['o'=>$item,'reference'=>$o,'css'=>'thumbnail']) @include($item::config.'.widgets.thumbnail',['o'=>$item,'reference'=>$o,'css'=>'thumbnail'])

View File

@ -0,0 +1 @@
<input type="checkbox" name="{{ $name }}[{{ $id }}]" value="{{ $value ?? TRUE }}" @checked($checked)>

View File

@ -31,6 +31,7 @@
@if($po->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif @if($po->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif
@if($po->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif @if($po->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif
@if($po->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif @if($po->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
@if($po->flag)<button class="btn btn-sm btn-primary">FLAG</button>@endif
</div> </div>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Signature</dt><dd>{{ $po->signature(TRUE) }}</dd> <dt>Signature</dt><dd>{{ $po->signature(TRUE) }}</dd>

View File

@ -5,10 +5,6 @@
'Filename'=>['filename','filename'], 'Filename'=>['filename','filename'],
'Filesize'=>['filesize','filesize'], 'Filesize'=>['filesize','filesize'],
'Dimensions'=>['height','dimensions'], 'Dimensions'=>['height','dimensions'],
'Duplicate'=>['duplicate','duplicatecheckbox'],
'Flagged'=>['flag','flagcheckbox'],
'Ignore Duplicate'=>['ignore','ignorecheckbox'],
'Delete'=>['remove','removecheckbox'],
];?> ];?>
<div class="card card-widget"> <div class="card card-widget">
@ -38,6 +34,19 @@
<td>{!! $o->{$v[1]} !!}</td> <td>{!! $o->{$v[1]} !!}</td>
</tr> </tr>
@endforeach @endforeach
<tr>
<th>Flag</th><td><x-checkbox name="flag" :id="$o->id" :checked="$o->flag"/></td>
</tr>
<tr>
<th>Duplicate</th><td><x-checkbox name="duplicate" :id="$o->id" :checked="$o->duplicate"/></td>
</tr>
<tr>
<th>IGNORE Duplicate</th><td><x-checkbox name="ignore_duplicate" :id="$o->id" :checked="$o->ignore_duplicate"/></td>
</tr>
<tr>
<th>Delete</th><td><x-checkbox name="remove" :id="$o->id" :checked="$o->remove"/></td>
</tr>
</table> </table>
</div> </div>
</div> </div>

View File

@ -31,6 +31,7 @@
@if($vo->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif @if($vo->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif
@if($vo->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif @if($vo->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif
@if($vo->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif @if($vo->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
@if($po->flag)<button class="btn btn-sm btn-primary">FLAG</button>@endif
</div> </div>
<div class="dl-horizontal"> <div class="dl-horizontal">
<dt>Signature</dt><dd>{{ $vo->signature(TRUE) }}</dd> <dt>Signature</dt><dd>{{ $vo->signature(TRUE) }}</dd>

View File

@ -1,43 +1,52 @@
<?php $data = [ <?php $data = [
'ID'=>['id','idlink'],
'Signature'=>['signature','signature'], 'Signature'=>['signature','signature'],
'File Signature'=>['file_signature','file_signature'], 'File Signature'=>['file_signature','file_signature'],
'Date Created'=>['created','created'], 'Date Created'=>['created','created'],
'Filename'=>['filename','filename'], 'Filename'=>['filename','filename'],
'Filesize'=>['filesize','filesize'], 'Filesize'=>['filesize','filesize'],
'Dimensions'=>['height','dimensions'], 'Dimensions'=>['height','dimensions'],
'Length'=>['length','length'],
'Duplicate'=>['duplicate','duplicatecheckbox'],
'Flagged'=>['flag','flagcheckbox'],
'Ignore Duplicate'=>['ignore','ignorecheckbox'],
'Delete'=>['remove','removecheckbox'],
];?> ];?>
<div class="card card-widget"> <div class="card card-widget">
<div class="card-header"> <div class="card-header">
<div class="user-block"> <div class="user-block">
<i class="float-left fa fa-2x fa-camera"></i><span class="username"><a href="{{ url('v/info',$o->id) }}">#{{ $o->id }} - {{ \Illuminate\Support\Str::limit($o->filename,12).\Illuminate\Support\Str::substr($o->filename,-16) }}</a></span> <i class="fas fa-2x fa-camera float-left"></i><span class="username"><a href="{{ url('v/info',$o->id) }}">#{{ $o->id }} - {{ Str::limit($o->filename,12).Str::substr($o->filename,-16) }}</a></span>
<span class="description">{{ $o->created ? $o->created->toDateTimeString() : '-' }} [{{ $o->device() }}]</span> <span class="description">{{ $o->created ? $o->created->toDateTimeString() : '-' }} @if($o->device)[{{ $o->device }}]@else <small><strong>[No Device Info]</strong></small> @endif</span>
</div> </div>
<!-- /.user-block -->
<div class="card-tools"> <div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-minus"></i></button> <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fa fa-times"></i></button> <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fa fa-times"></i></button>
</div> </div>
<!-- /.card-tools -->
</div> </div>
<!-- /.card-body -->
<div class="card-body"> <div class="card-body">
{!! $o->getHtmlImageURL() !!} <x-video.thumbnail :id="$o->id" :css="$css ?? NULL"/>
</div> </div>
<!-- /.card-body -->
<div class="card-footer card-comments"> <div class="card-footer card-comments">
<table class="table table-striped table-sm table-hover"> <table class="table table-sm table-striped">
<tr><th>ID</th><td><x-info :id="$o->id"/></td></tr>
@foreach($data as $k=>$v) @foreach($data as $k=>$v)
<tr><th>{{$k}}</th><td>{!! $o->{$v[1]} !!}</td></tr> <tr @class(['bg-success'=>($reference->exists && ((string)$reference->{$v[1]} === (string)$o->{$v[1]}))])>
<th>{{$k}}</th>
<td>{!! $o->{$v[1]} !!}</td>
</tr>
@endforeach @endforeach
<tr>
<th>Flag</th><td><x-checkbox name="flag" :id="$o->id" :checked="$o->flag"/></td>
</tr>
<tr>
<th>Duplicate</th><td><x-checkbox name="duplicate" :id="$o->id" :checked="$o->duplicate"/></td>
</tr>
<tr>
<th>IGNORE Duplicate</th><td><x-checkbox name="ignore_duplicate" :id="$o->id" :checked="$o->ignore_duplicate"/></td>
</tr>
<tr>
<th>Delete</th><td><x-checkbox name="remove" :id="$o->id" :checked="$o->remove"/></td>
</tr>
</table> </table>
</div> </div>
</div> </div>