diff --git a/timeliner/app/Http/Controllers/TimelineController.php b/timeliner/app/Http/Controllers/TimelineController.php index 3c8e9f1..6166697 100644 --- a/timeliner/app/Http/Controllers/TimelineController.php +++ b/timeliner/app/Http/Controllers/TimelineController.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Illuminate\View\View; +use Illuminate\Support\Facades\DB; use function Psy\debug; @@ -22,11 +23,6 @@ public function index() return view('index', ['timelines' => $timelines]); } - public function timelinelist() - { - return view('timeline.timelinelist'); - } - public function show($id) { $timeline = Timeline::findOrFail($id); @@ -37,8 +33,6 @@ public function show($id) ->with('milestones') ->get(); - Log::info('nodes: '.$nodes->count()); - $comments = Comment::where('timeline_id', '=', $timeline->id) ->with('user') ->get(); @@ -56,6 +50,21 @@ public function show($id) ->withErrors(["You don't have access."]); } + public function showDashboard() + { + $user = Auth::user(); + + $timelines = DB::select(" + SELECT timelines.* + FROM timelines + JOIN ownerships + ON CAST(SUBSTR(ownerships.id, 1, LENGTH(ownerships.id) - LENGTH(?)) AS INTEGER) = timelines.id + WHERE CAST(SUBSTR(ownerships.id, -LENGTH(?)) AS INTEGER) = ? + ", [$user->id, $user->id, $user->id]); + + return view('dashboard',['timelines' => $timelines]); + } + public function create() { return view('timeline.create'); diff --git a/timeliner/app/Models/User.php b/timeliner/app/Models/User.php index def621f..3da1945 100644 --- a/timeliner/app/Models/User.php +++ b/timeliner/app/Models/User.php @@ -44,4 +44,9 @@ protected function casts(): array 'password' => 'hashed', ]; } + + public function ownerships() + { + return $this->hasMany(Ownership::class, 'id', 'id'); + } } diff --git a/timeliner/resources/js/createformfunctions.js b/timeliner/resources/js/createformfunctions.js index 4e0d469..91e8f2a 100644 --- a/timeliner/resources/js/createformfunctions.js +++ b/timeliner/resources/js/createformfunctions.js @@ -95,7 +95,7 @@ if (nodeCreateButton) { let row_id = "node-" + ni; let ms_table_id = "ms-table-" + ni; tr_node_form.setAttribute("id", row_id); - tr_node_form.setAttribute("class", "form-row mt-3"); + tr_node_form.setAttribute("class", "form-row mt-3 border-4 border-blue-100 rounded-md p-2"); tr_milestone_table.setAttribute("id", ms_table_id); tr_milestone_table.setAttribute("class", "form-group col-9"); diff --git a/timeliner/resources/views/dashboard.blade.php b/timeliner/resources/views/dashboard.blade.php index 4024c64..a6da339 100644 --- a/timeliner/resources/views/dashboard.blade.php +++ b/timeliner/resources/views/dashboard.blade.php @@ -13,5 +13,21 @@ + +
+ +
+
+
+

Your timelines

+ + @if ($timelines) + @include("timeline.partials.timelinelist", $timelines) + @else + You did not create any timelines yet + @endif +
+
+
diff --git a/timeliner/resources/views/timeline/partials/nodecreate.blade.php b/timeliner/resources/views/timeline/partials/nodecreate.blade.php index 9c992b5..a7ec529 100644 --- a/timeliner/resources/views/timeline/partials/nodecreate.blade.php +++ b/timeliner/resources/views/timeline/partials/nodecreate.blade.php @@ -2,7 +2,8 @@ @csrf
- + +

Nodes

@@ -82,5 +83,8 @@
+ + +
diff --git a/timeliner/resources/views/timeline/partials/nodeedit.blade.php b/timeliner/resources/views/timeline/partials/nodeedit.blade.php index cb73cf9..9b77711 100644 --- a/timeliner/resources/views/timeline/partials/nodeedit.blade.php +++ b/timeliner/resources/views/timeline/partials/nodeedit.blade.php @@ -1,6 +1,8 @@
- -
+
+ +

Nodes

+
@@ -19,7 +21,7 @@ window.nodeMilestoneCounts = @json($nodeMilestoneCounts); @foreach ($currentNodes as $nodeIndex => $node) - + @@ -78,5 +80,7 @@
+ +
diff --git a/timeliner/resources/views/timeline/timeline.blade.php b/timeliner/resources/views/timeline/timeline.blade.php index be723f0..546e865 100644 --- a/timeliner/resources/views/timeline/timeline.blade.php +++ b/timeliner/resources/views/timeline/timeline.blade.php @@ -28,31 +28,34 @@ 100 + + +
- -
-

Comments

- - - - - - - - @foreach ($comments as $comment) - @include("timeline.partials.comment", ["comment"=>$comment]) - @endforeach -
+
+ +
+

Comments

+ + + + + + + + @foreach ($comments as $comment) + @include("timeline.partials.comment", ["comment"=>$comment]) + @endforeach
diff --git a/timeliner/routes/web.php b/timeliner/routes/web.php index afcb1d8..cc4772b 100644 --- a/timeliner/routes/web.php +++ b/timeliner/routes/web.php @@ -11,9 +11,7 @@ return view('about'); })->name('about'); -Route::get('/dashboard', function () { - return view('dashboard'); -})->middleware(['auth', 'verified'])->name('dashboard'); +Route::get('/dashboard', [TimelineController::class, 'showDashboard'])->middleware(['auth', 'verified'])->name('dashboard'); @@ -35,4 +33,4 @@ Route::post('comment', [CommentController::class, 'store'])->middleware(['auth', 'verified'])->name('comment.store'); Route::delete('comment/{comment}', [CommentController::class, 'destroy'])->middleware(['auth', 'verified'])->name('comment.destroy'); -Route::put('comment/{comment}', [CommentController::class, 'update'])->middleware(['auth', 'verified'])->name('comment.update'); \ No newline at end of file +Route::put('comment/{comment}', [CommentController::class, 'update'])->middleware(['auth', 'verified'])->name('comment.update');