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;
protected $list_duplicates = 20;
protected $list_deletes = 50;
public function delete(Photo $o)
{
$o->remove = TRUE;
$o->save();
return redirect()->action('PhotoController@info',[$o->id]);
return redirect()
->action('PhotoController@info',[$o->id]);
}
public function deletes($id=NULL)
{
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'),
'type'=>'photo',
]);
@ -32,7 +35,12 @@ class PhotoController extends Controller
public function duplicates($id=NULL)
{
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'),
'type'=>'photo',
]);

View File

@ -10,21 +10,24 @@ class VideoController extends Controller
{
use Multimedia;
protected $list_duplicates = 20;
protected $list_deletes = 50;
public function delete(Video $o)
{
$o->remove = TRUE;
$o->save();
return redirect()->action('VideoController@info',[$o->id]);
return redirect()
->action('VideoController@info',[$o->id]);
}
public function deletes($id=NULL)
{
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'),
'type'=>'video',
]);
@ -33,7 +36,12 @@ class VideoController extends Controller
public function duplicates($id=NULL)
{
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'),
'type'=>'video',
]);
@ -44,7 +52,8 @@ class VideoController extends Controller
$o->remove = NULL;
$o->save();
return redirect()->action('VideoController@info',[$o->id]);
return redirect()
->action('VideoController@info',[$o->id]);
}
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 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
*
@ -558,12 +497,6 @@ abstract class Catalog extends Model
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
*/

View File

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

View File

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

View File

@ -17,14 +17,17 @@
@section('main-content')
<div class="col-12">
@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">
@csrf
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
<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>
</form>

View File

@ -17,15 +17,17 @@
@section('main-content')
<div class="col-12">
@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">
@csrf
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
<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>
</form>

View File

@ -11,8 +11,8 @@
<tbody>
@foreach ($catalog as $o)
@continue($rendered->search($o))
@php($rendered->push($o))
@continue($rendered->contains($o->id))
@php($rendered->push($o->id))
<tr>
<td>
@ -28,8 +28,8 @@
@else
@foreach($d as $item)
@continue($rendered->search($item))
@php($rendered->push($item))
@continue($rendered->contains($item->id))
@php($rendered->push($item->id))
<td>
<input type="hidden" name="items[]" value="{{ $item->id }}">
@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->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->flag)<button class="btn btn-sm btn-primary">FLAG</button>@endif
</div>
<div class="dl-horizontal">
<dt>Signature</dt><dd>{{ $po->signature(TRUE) }}</dd>

View File

@ -5,10 +5,6 @@
'Filename'=>['filename','filename'],
'Filesize'=>['filesize','filesize'],
'Dimensions'=>['height','dimensions'],
'Duplicate'=>['duplicate','duplicatecheckbox'],
'Flagged'=>['flag','flagcheckbox'],
'Ignore Duplicate'=>['ignore','ignorecheckbox'],
'Delete'=>['remove','removecheckbox'],
];?>
<div class="card card-widget">
@ -38,6 +34,19 @@
<td>{!! $o->{$v[1]} !!}</td>
</tr>
@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>
</div>
</div>

View File

@ -31,6 +31,7 @@
@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->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 class="dl-horizontal">
<dt>Signature</dt><dd>{{ $vo->signature(TRUE) }}</dd>

View File

@ -1,43 +1,52 @@
<?php $data = [
'ID'=>['id','idlink'],
'Signature'=>['signature','signature'],
'File Signature'=>['file_signature','file_signature'],
'Date Created'=>['created','created'],
'Filename'=>['filename','filename'],
'Filesize'=>['filesize','filesize'],
'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-header">
<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>
<span class="description">{{ $o->created ? $o->created->toDateTimeString() : '-' }} [{{ $o->device() }}]</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() : '-' }} @if($o->device)[{{ $o->device }}]@else <small><strong>[No Device Info]</strong></small> @endif</span>
</div>
<!-- /.user-block -->
<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="remove"><i class="fa fa-times"></i></button>
</div>
<!-- /.card-tools -->
</div>
<!-- /.card-body -->
<div class="card-body">
{!! $o->getHtmlImageURL() !!}
<x-video.thumbnail :id="$o->id" :css="$css ?? NULL"/>
</div>
<!-- /.card-body -->
<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)
<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
<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>
</div>
</div>