diff --git a/app/Http/Controllers/AUKController.php b/app/Http/Controllers/AUKController.php
index 3675682..df0ecf1 100644
--- a/app/Http/Controllers/AUKController.php
+++ b/app/Http/Controllers/AUKController.php
@@ -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,
diff --git a/app/Http/Controllers/MMCController.php b/app/Http/Controllers/MMCController.php
index 7559626..f591686 100644
--- a/app/Http/Controllers/MMCController.php
+++ b/app/Http/Controllers/MMCController.php
@@ -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,61 +137,70 @@ 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;
- if (is_file($image_file_path)) {
- if (strncmp($entry, $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['size'] = filesize($image_file_path);
- $tmp_array['mtime'] = filemtime($image_file_path);
- $tmp_array['atime'] = fileatime($image_file_path);
+ foreach ($mmc_dir as $image) {
+ $image_file_path = $MMC_PATH . '/' . $image;
+ if (is_file($image_file_path)) {
+ 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
+ ) {
+ $tmp_array = array();
+ $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++;
- }
- }
- }
- }
- }
- }
- // ^^^ Images ^^^
+ $total_size += $tmp_array['size'];
+ $total_count++;
}
}
}
}
- return view('mmc.scan', ['project' => $project, 'MMC' => $MMC]);
+ return view('mmc.scan', ['project' => $project, 'AUK' => $auk, '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'));
}
}
diff --git a/app/Models/AUK.php b/app/Models/AUK.php
index 4f26512..59f68e6 100644
--- a/app/Models/AUK.php
+++ b/app/Models/AUK.php
@@ -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');
}
-
}
-
diff --git a/app/Models/MMC.php b/app/Models/MMC.php
index 71cd1d2..5431a73 100644
--- a/app/Models/MMC.php
+++ b/app/Models/MMC.php
@@ -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');
}
}
diff --git a/database/migrations/2022_07_13_161318_create_mmcs_table.php b/database/migrations/2022_07_13_161318_create_mmcs_table.php
index 890a606..b717063 100644
--- a/database/migrations/2022_07_13_161318_create_mmcs_table.php
+++ b/database/migrations/2022_07_13_161318_create_mmcs_table.php
@@ -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();
});
diff --git a/public/css/app.css b/public/css/app.css
index eaf6095..473d195 100644
--- a/public/css/app.css
+++ b/public/css/app.css
@@ -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));
diff --git a/resources/views/mmc/list.blade.php b/resources/views/mmc/list.blade.php
index efa277c..a14e7b2 100644
--- a/resources/views/mmc/list.blade.php
+++ b/resources/views/mmc/list.blade.php
@@ -62,7 +62,7 @@
@forelse ($top_auks as $top_auk)
- | {{ $top_auk->auk_name }} |
+ {{ $top_auk->auk_name }} |
+ @if (count($MMC))
+
+
+ @endif
+
diff --git a/resources/views/mmc/tableAukChild.blade.php b/resources/views/mmc/tableAukChild.blade.php
index 1310121..10ceb7b 100644
--- a/resources/views/mmc/tableAukChild.blade.php
+++ b/resources/views/mmc/tableAukChild.blade.php
@@ -1,9 +1,29 @@
@foreach ($childs as $child)
- |
+
|
{{ str_pad('', $level, '-') . ' ' . $child->auk_name }}
|
+
|
diff --git a/routes/web.php b/routes/web.php
index 890a847..885d6bc 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -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');