Continue MMC

This commit is contained in:
Александр Бабкин
2022-07-14 11:01:44 +03:00
parent 30950a120e
commit 97bacd4423
10 changed files with 158 additions and 24 deletions

View File

@@ -147,6 +147,8 @@ class AUKController extends Controller
$auks = array(); $auks = array();
$MMC_PATH = $project->mmc_path; $MMC_PATH = $project->mmc_path;
if(is_dir($MMC_PATH))
{
$mmc_dir = scandir($MMC_PATH); $mmc_dir = scandir($MMC_PATH);
foreach ($mmc_dir as $entry) { foreach ($mmc_dir as $entry) {
@@ -170,6 +172,7 @@ class AUKController extends Controller
} }
} }
} }
}
return view('auks.scan', ['project' => $project, 'auks' => $auks]); return view('auks.scan', ['project' => $project, 'auks' => $auks]);
} }
@@ -199,7 +202,7 @@ class AUKController extends Controller
'auk_name' => $auk_name, 'auk_name' => $auk_name,
'auk_path' => $auk_path, 'auk_path' => $auk_path,
'image_dir' => $image_dir, 'image_dir' => $image_dir,
'parent_id' => null, 'parent_id' => 0,
]); ]);
$i++; $i++;
} }

View File

@@ -4,6 +4,9 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Project; use App\Models\Project;
use App\Models\AUK;
use App\Models\Document;
class MMCController extends Controller class MMCController extends Controller
{ {
@@ -17,7 +20,12 @@ class MMCController extends Controller
{ {
$project_id = $request->session()->get('project_id'); $project_id = $request->session()->get('project_id');
$project = Project::find($project_id); $project = Project::find($project_id);
return view('mmc.list', ['project' => $project]); $top_auks = $project->auks()->where('parent_id', 0)->get()->sortBy('auk_name');
if(count($top_auks))
{
$mmc = $top_auks[0]->mmcs;
}
return view('mmc.list', ['project' => $project, 'top_auks' => $top_auks]);
} }
/** /**

View File

@@ -23,5 +23,11 @@ class AUK extends Model
{ {
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');
}
} }

View File

@@ -17,4 +17,9 @@ class MMC extends Model
'mtime', 'mtime',
'atime', 'atime',
]; ];
public function auks()
{
return $this->belongsToMany(AUK::class);
}
} }

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAukMmcTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('auk_mmc', function (Blueprint $table) {
$table->id();
$table->integer('auk_id')->unsigned()->references('id')->on('auks');
$table->integer('mmc_id')->unsigned()->references('id')->on('mmcs');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('auk_mmc');
}
}

View File

@@ -17,7 +17,7 @@ class ProjectTableSeeder extends Seeder
DB::table('projects')->insert([ DB::table('projects')->insert([
'name' => 'Ил-76МД90А', 'name' => 'Ил-76МД90А',
'description' => 'АОС Ил-76МД90А', 'description' => 'АОС Ил-76МД90А',
'mmc_path' => '/Docs/Project/643 Россия/IL-76MD-90А_ru/2_MMC', 'mmc_path' => '/home/shurick/tmp/mmc',
]); ]);
} }

View File

@@ -38,7 +38,7 @@
@empty @empty
<tr> <tr>
<td colspan="3" class="p-2 border border-gray-200 text-center">No Documents! <td colspan="3" class="p-2 border border-gray-200 text-center">No AUKs!
</td> </td>
</tr> </tr>
@endforelse @endforelse

View File

@@ -13,7 +13,7 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg"> <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200"> <div class="p-6 bg-white border-b border-gray-200">
<div class="flex flex-row"> {{-- <div class="flex flex-row">
<div class="basis-1/2"> <div class="basis-1/2">
<a href="{{ route('mmc.create') }}"> <a href="{{ route('mmc.create') }}">
<button <button
@@ -32,11 +32,67 @@
</div> </div>
</div> </div>
<div align="center" class="pt-4"> <div align="center" class="pt-4"> --}}
TODO: MMC table {{-- <div class="w-96 mx-auto">
<div>
<x-label for="auk_id" :value="__('Select AUK')" />
<x-select id="auk_id" class="block mt-1 w-full" name="auk_id" required>
@foreach ($top_auks as $auks)
<option value="{{ $auks->id }}">{{ $auks->auk_name }}
({{ $auks->auk_path }})
</option>
@if (count($auks->childs))
@include('mmc.optionChild', [
'childs' => $auks->childs,
'level' => 1,
])
@endif
@endforeach
</x-select>
</div>
</div> --}}
<div align="center">
<h3>Выберите АУК:</h3>
<table class="table table-sm border-b border-gray-200"> <table class="table table-sm border-b border-gray-200">
<tr class="p-2 border border-gray-200 text-center">
<th class="p-2 border border-gray-200 text-center">AUK Title</th>
<th class="p-2 border border-gray-200 text-center">MMC</th>
</tr>
@forelse ($top_auks as $top_auk)
<tr class="p-2 border border-gray-200 text-center">
<td>{{ $top_auk->auk_name }}</td>
<td>
<table>
{{-- @forelse ($top_auk->mmcs as $mmc)
<tr>
<td>{{ $mmc->filename }}</td>
</tr>
@empty
<tr>
<td>No MMC</td>
</tr>
@endforelse --}}
</table>
</td>
</tr>
@if (count($top_auk->childs))
@include('mmc.tableAukChild', [
'childs' => $top_auk->childs,
'level' => 1,
])
@endif
@empty
<tr class="p-2 border border-gray-200 text-center">
<td colspan="2">No AUK</td>
</tr>
@endforelse
</table> </table>
</div> </div>
{{-- </div> --}}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,10 @@
@foreach ($childs as $child)
<option value="{{ $child->id }}">{{ str_pad('', $level, '-') . ' ' . $child->auk_name }}
({{ $child->auk_path }})</option>
@if (count($child->childs))
@include('mmc.optionChild', [
'childs' => $child->childs,
'level' => $level + 1,
])
@endif
@endforeach

View File

@@ -0,0 +1,13 @@
@foreach ($childs as $child)
<tr class="p-2 border border-gray-200 text-center">
<td>
{{ str_pad('', $level, '-') . ' ' . $child->auk_name }}
</td>
</tr>
@if (count($child->childs))
@include('mmc.tableAukChild', [
'childs' => $top_auk->childs,
'level' => $level + 1,
])
@endif
@endforeach