MMC alpha ready
This commit is contained in:
@@ -184,18 +184,18 @@ class AUKController extends Controller
|
||||
*/
|
||||
public function load(Request $request)
|
||||
{
|
||||
Log::alert("In load");
|
||||
// Log::alert("In load");
|
||||
$project_id = $request->session()->get('project_id');
|
||||
|
||||
$i = 0;
|
||||
while ($request->input('auk_name_' . $i) !== null) {
|
||||
Log::alert("Loading " . $i);
|
||||
// Log::alert("Loading " . $i);
|
||||
$auk_name = $request->input('auk_name_' . $i);
|
||||
$auk_path = $request->input('auk_path_' . $i);
|
||||
$image_dir = $request->input('image_dir_' . $i);
|
||||
Log::alert("auk_name \"" . $auk_name . "\"");
|
||||
Log::alert("auk_path \"" . $auk_path . "\"");
|
||||
Log::alert("image_dir \"" . $image_dir . "\"");
|
||||
// Log::alert("auk_name \"" . $auk_name . "\"");
|
||||
// Log::alert("auk_path \"" . $auk_path . "\"");
|
||||
// Log::alert("image_dir \"" . $image_dir . "\"");
|
||||
|
||||
AUK::create([
|
||||
'project_id' => $project_id,
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Project;
|
||||
use App\Models\AUK;
|
||||
use App\Models\Document;
|
||||
use App\Models\MMC;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
|
||||
class MMCController extends Controller
|
||||
@@ -21,8 +23,7 @@ class MMCController extends Controller
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
$top_auks = $project->auks()->where('parent_id', 0)->get()->sortBy('auk_name');
|
||||
if(count($top_auks))
|
||||
{
|
||||
if (count($top_auks)) {
|
||||
$mmc = $top_auks[0]->mmcs;
|
||||
}
|
||||
return view('mmc.list', ['project' => $project, 'top_auks' => $top_auks]);
|
||||
@@ -136,46 +137,30 @@ class MMCController extends Controller
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
|
||||
|
||||
$auk = AUK::find($auk_id);
|
||||
$MMC = array();
|
||||
$total_size = 0;
|
||||
$total_count = 0;
|
||||
$MMC_PATH = $project->mmc_path;
|
||||
$MMC_PATH = $project->mmc_path . '/' . $auk->auk_path . '/' . $auk->image_dir;
|
||||
$mmc_dir = scandir($MMC_PATH);
|
||||
|
||||
|
||||
foreach ($mmc_dir as $entry) {
|
||||
$course_path = $MMC_PATH . '/' . $entry;
|
||||
if (is_dir($course_path)) {
|
||||
if (intval($entry) > 0 && intval($entry) < 99) {
|
||||
// $MMC[] = $entry;
|
||||
// echo ($entry . "\n");
|
||||
$mmc_course_dir = scandir($course_path);
|
||||
foreach ($mmc_course_dir as $course_entry) {
|
||||
// VVV Images VVV
|
||||
if (strcasecmp($course_entry, 'images') == 0) {
|
||||
$course_image_path = $course_path . '/' . $course_entry;
|
||||
if (is_dir($course_image_path)) {
|
||||
// echo ($course_image_path . "\n");
|
||||
$MMC[$entry]['image_dir'] = $course_entry;
|
||||
$course_images = scandir($course_image_path);
|
||||
foreach ($course_images as $image) {
|
||||
$image_file_path = $course_image_path . '/' . $image;
|
||||
foreach ($mmc_dir as $image) {
|
||||
$image_file_path = $MMC_PATH . '/' . $image;
|
||||
if (is_file($image_file_path)) {
|
||||
if (strncmp($entry, $image, 2) == 0) {
|
||||
if (strncmp($auk->auk_path, $image, 2) == 0) {
|
||||
if (
|
||||
strcasecmp(substr($image, -3, 3), 'jpg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'svg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'swf') == 0
|
||||
) {
|
||||
// $MMC[$entry][] = $image;
|
||||
$tmp_array = array();
|
||||
$tmp_array['file'] = $image;
|
||||
$tmp_array['filename'] = $image;
|
||||
$tmp_array['size'] = filesize($image_file_path);
|
||||
$tmp_array['mtime'] = filemtime($image_file_path);
|
||||
$tmp_array['atime'] = fileatime($image_file_path);
|
||||
|
||||
$MMC[$entry]['images'][] = $tmp_array;
|
||||
$MMC[] = $tmp_array;
|
||||
|
||||
$total_size += $tmp_array['size'];
|
||||
$total_count++;
|
||||
@@ -183,14 +168,39 @@ class MMCController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ^^^ Images ^^^
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('mmc.scan', ['project' => $project, 'AUK' => $auk, 'MMC' => $MMC]);
|
||||
}
|
||||
|
||||
return view('mmc.scan', ['project' => $project, 'MMC' => $MMC]);
|
||||
/**
|
||||
* Load Images from file system
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function load(Request $request, $auk_id)
|
||||
{
|
||||
// Log::alert("In load");
|
||||
$project_id = $request->session()->get('project_id');
|
||||
|
||||
$i = 0;
|
||||
while ($request->input('filename_' . $i) !== null) {
|
||||
$filename = $request->input('filename_' . $i);
|
||||
$size = $request->input('size_' . $i);
|
||||
$mtime= $request->input('mtime_' . $i);
|
||||
// Log::alert("filename \"" . $filename . "\"");
|
||||
// Log::alert("size \"" . $size . "\"");
|
||||
// Log::alert("mtime \"" . $mtime . "\"");
|
||||
// $atime= $request->input('atime_' . $i);
|
||||
|
||||
MMC::create([
|
||||
'filename' => $filename,
|
||||
'size' => $size,
|
||||
'mtime' => $mtime,
|
||||
// 'atime' => $atime,
|
||||
])->auks()->attach($auk_id);
|
||||
$i++;
|
||||
}
|
||||
return redirect(route('mmc.index'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,11 @@ class AUK extends Model
|
||||
|
||||
public function childs()
|
||||
{
|
||||
return $this->hasMany('App\Models\AUK','parent_id','id');
|
||||
return $this->hasMany('App\Models\AUK', 'parent_id', 'id');
|
||||
}
|
||||
|
||||
public function mmcs()
|
||||
{
|
||||
return $this->belongsToMany(MMC::class,'auk_mmc','auk_id','mmc_id');
|
||||
return $this->belongsToMany(MMC::class, 'auk_mmc', 'auk_id', 'mmc_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ class MMC extends Model
|
||||
|
||||
public function auks()
|
||||
{
|
||||
return $this->belongsToMany(AUK::class);
|
||||
return $this->belongsToMany(AUK::class, 'auk_mmc', 'mmc_id', 'auk_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class CreateMMCSTable extends Migration
|
||||
$table->string('filename');
|
||||
$table->string('size');
|
||||
$table->string('mtime');
|
||||
$table->string('atime');
|
||||
// $table->string('atime');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -707,6 +707,9 @@ select {
|
||||
.-ml-px {
|
||||
margin-left: -1px;
|
||||
}
|
||||
.mt-4 {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.ml-1 {
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
@@ -719,9 +722,6 @@ select {
|
||||
.ml-2 {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
.mt-4 {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.ml-4 {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
@@ -734,6 +734,9 @@ select {
|
||||
.-mt-px {
|
||||
margin-top: -1px;
|
||||
}
|
||||
.mt-1 {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
.-mr-2 {
|
||||
margin-right: -0.5rem;
|
||||
}
|
||||
@@ -743,15 +746,9 @@ select {
|
||||
.mt-6 {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
.mt-1 {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
.mb-4 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.-mb-px {
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
@@ -800,12 +797,18 @@ select {
|
||||
.w-5 {
|
||||
width: 1.25rem;
|
||||
}
|
||||
.w-96 {
|
||||
width: 24rem;
|
||||
}
|
||||
.w-8 {
|
||||
width: 2rem;
|
||||
}
|
||||
.w-auto {
|
||||
width: auto;
|
||||
}
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.w-4 {
|
||||
width: 1rem;
|
||||
}
|
||||
@@ -815,12 +818,6 @@ select {
|
||||
.w-48 {
|
||||
width: 12rem;
|
||||
}
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.w-96 {
|
||||
width: 24rem;
|
||||
}
|
||||
.w-20 {
|
||||
width: 5rem;
|
||||
}
|
||||
@@ -879,9 +876,6 @@ select {
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.flex-wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
@@ -927,10 +921,6 @@ select {
|
||||
border-top-right-radius: 0.375rem;
|
||||
border-bottom-right-radius: 0.375rem;
|
||||
}
|
||||
.rounded-t-lg {
|
||||
border-top-left-radius: 0.5rem;
|
||||
border-top-right-radius: 0.5rem;
|
||||
}
|
||||
.border {
|
||||
border-width: 1px;
|
||||
}
|
||||
@@ -977,22 +967,18 @@ select {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-gray-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-gray-500 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(107 114 128 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-gray-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-indigo-50 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(238 242 255 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-gray-50 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
|
||||
}
|
||||
.fill-current {
|
||||
fill: currentColor;
|
||||
}
|
||||
@@ -1002,9 +988,6 @@ select {
|
||||
.p-2 {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.p-4 {
|
||||
padding: 1rem;
|
||||
}
|
||||
.px-4 {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
@@ -1047,6 +1030,12 @@ select {
|
||||
.pt-4 {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
.pb-2 {
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
.pl-2 {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
.pt-8 {
|
||||
padding-top: 2rem;
|
||||
}
|
||||
@@ -1059,23 +1048,23 @@ select {
|
||||
.pb-1 {
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
.pb-4 {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
.pt-6 {
|
||||
padding-top: 1.5rem;
|
||||
}
|
||||
.pt-1 {
|
||||
padding-top: 0.25rem;
|
||||
}
|
||||
.pl-2 {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
.pl-3 {
|
||||
padding-left: 0.75rem;
|
||||
}
|
||||
.pr-4 {
|
||||
padding-right: 1rem;
|
||||
}
|
||||
.pb-4 {
|
||||
padding-bottom: 1rem;
|
||||
.text-left {
|
||||
text-align: left;
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
@@ -9086,14 +9075,14 @@ readers do not read off random characters that represent icons */
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
||||
}
|
||||
.hover\:bg-gray-100:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(243 244 246 / var(--tw-bg-opacity));
|
||||
}
|
||||
.hover\:bg-gray-700:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
||||
}
|
||||
.hover\:bg-gray-100:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(243 244 246 / var(--tw-bg-opacity));
|
||||
}
|
||||
.hover\:bg-gray-50:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</tr>
|
||||
@forelse ($top_auks as $top_auk)
|
||||
<tr class="p-2 border border-gray-200 text-center">
|
||||
<td class="p-2 border border-gray-200 text-center">{{ $top_auk->auk_name }}</td>
|
||||
<td class="p-2 border border-gray-200 text-left">{{ $top_auk->auk_name }}</td>
|
||||
<td class="p-2 border border-gray-200 text-center">
|
||||
<table>
|
||||
@forelse ($top_auk->mmcs as $mmc)
|
||||
@@ -73,7 +73,7 @@
|
||||
@empty
|
||||
<tr>
|
||||
<td>No MMC
|
||||
<a href="{{ route('mmc.scan') }}">
|
||||
<a href="{{ route('mmc.scan',$top_auk->id) }}" class="pl-2">
|
||||
<button
|
||||
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-search pr-2"></i>{{ __('Scan mmc') }}
|
||||
|
||||
@@ -10,37 +10,7 @@
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 bg-white border-b border-gray-200">
|
||||
<div class="w-96 mx-auto">
|
||||
<div class="panel-group">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" target="_blank" rel="nofollow noreferrer"
|
||||
target="_blank" rel="nofollow noreferrer" href="#collapse1">123</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse1" class="panel-collapse collapse">
|
||||
<div class="panel-body">123123123</div>
|
||||
<div class="panel-footer">123</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div class="mb-4 border-b border-gray-200 dark:border-gray-700">
|
||||
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center" id="aukTab" data-tabs-toggle="#aukTabContent" role="tablist">
|
||||
@foreach ($MMC as $key => $value)
|
||||
<li class="mr-2" role="presentation">
|
||||
<button class="inline-block p-4 rounded-t-lg border-b-2" id="auk{{ $key }}-tab" data-tabs-target="#auk{{ $key }}" type="button" role="tab" aria-controls="auk{{ $key }}" aria-selected="false">AUK {{ $key }}</button>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
<div id="aukTabContent">
|
||||
@foreach ($MMC as $key => $value)
|
||||
<div class="hidden p-4 bg-gray-50 rounded-lg dark:bg-gray-800" id="auk{{ $key }}" role="tabpanel" aria-labelledby="auk{{ $key }}-tab">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400">This is some placeholder content the <strong class="font-medium text-gray-800 dark:text-white">Profile tab's associated content</strong>. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling.</p>
|
||||
</div>
|
||||
@endforeach
|
||||
</div> --}}
|
||||
{{-- <h3 class="font-bold text-l text-gray-800 leading-tight">АУК {{ $key }}</h3>
|
||||
<h3 class="font-bold text-l text-gray-800 leading-tight pb-2">{{ $AUK->auk_name }}</h3>
|
||||
<table class="table table-sm border-b border-gray-200">
|
||||
<tr class="border border-gray-200">
|
||||
<th class="p-2 border border-gray-200">
|
||||
@@ -52,30 +22,52 @@
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('MTime') }}
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{-- <th class="p-2 border border-gray-200">
|
||||
{{ __('ATime') }}
|
||||
</th>
|
||||
<th class="p-2 border border-gray-200">
|
||||
{{ __('Actions') }}
|
||||
</th>
|
||||
</th> --}}
|
||||
</tr>
|
||||
@forelse ($value['images'] as $image)
|
||||
@forelse ($MMC as $image)
|
||||
<tr class="border border-gray-200">
|
||||
<td class="p-2 border border-gray-200">{{ $image['file'] }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $image['filename'] }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $image['size'] }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $image['mtime'] }}</td>
|
||||
<td class="p-2 border border-gray-200">{{ $image['atime'] }}</td>
|
||||
<td class="p-2 border border-gray-200"> </td>
|
||||
{{-- <td class="p-2 border border-gray-200">{{ $image['atime'] }}</td> --}}
|
||||
</tr>
|
||||
|
||||
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="p-2 border border-gray-200 text-center">No Documents!
|
||||
<td colspan="4" class="p-2 border border-gray-200 text-center">No Images!
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</table> --}}
|
||||
</table>
|
||||
@if (count($MMC))
|
||||
|
||||
<form method="POST" action="{{ route('mmc.load',$AUK->id) }}">
|
||||
@csrf
|
||||
<input type="hidden" name="auk_id" id="auk_id" value="{{ $AUK->id }}">
|
||||
@for($i = 0; $i < count($MMC); $i++)
|
||||
<input type="hidden" name="filename_{{$i}}" id="filename_{{$i}}" value="{{ $MMC[$i]['filename'] }}">
|
||||
<input type="hidden" name="size_{{$i}}" id="size_{{$i}}" value="{{ $MMC[$i]['size'] }}">
|
||||
<input type="hidden" name="mtime_{{$i}}" id="mtime_{{$i}}" value="{{ $MMC[$i]['mtime'] }}">
|
||||
{{-- <input type="hidden" name="atime_{{$i}}" id="atime_{{$i}}" value="{{ $image['atime'] }}"> --}}
|
||||
@endfor
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<button
|
||||
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-add pr-2"></i>{{ __('Insert Images') }}
|
||||
</button>
|
||||
<div class="pl-2">
|
||||
<a href="{{ route('mmc.index') }}"
|
||||
class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-cancel pr-2"></i>{{ __('Cancel') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,29 @@
|
||||
@foreach ($childs as $child)
|
||||
<tr class="p-2 border border-gray-200 text-center">
|
||||
<tr class="p-2 border border-gray-200 text-left">
|
||||
<td class="p-2 border border-gray-200 text-center">
|
||||
{{ str_pad('', $level, '-') . ' ' . $child->auk_name }}
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
@forelse ($child->mmcs as $mmc)
|
||||
<tr>
|
||||
<td>{{ $mmc->filename }}</td>
|
||||
</tr>
|
||||
|
||||
@empty
|
||||
<tr>
|
||||
<td>No MMC
|
||||
<a href="{{ route('mmc.scan',$top_auk->id) }}" class="pl-2">
|
||||
<button
|
||||
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
|
||||
<i class="fa fa-search pr-2"></i>{{ __('Scan mmc') }}
|
||||
</button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforelse
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -39,6 +39,7 @@ Route::post('/project/{project}/select',SelectProjectController::class)->middlew
|
||||
|
||||
Route::resource('/mmc', MMCController::class)->middleware(['auth'])->only(['index','create']);
|
||||
Route::get('/mmc/scan/{auk}', [MMCController::class, 'scan'])->middleware(['auth'])->name('mmc.scan');
|
||||
Route::post('/mmc/load/{auk}', [MMCController::class, 'load'])->middleware(['auth'])->name('mmc.load');
|
||||
Route::resource('/documents', DocumentController::class)->except('show')->middleware(['auth']);
|
||||
Route::resource('/auks', AUKController::class)->except('show')->middleware(['auth']);
|
||||
Route::get('/auks/scan', [AUKController::class, 'scan'])->middleware(['auth'])->name('auks.scan');
|
||||
|
||||
Reference in New Issue
Block a user