Skip to content

Commit

Permalink
Dashboard completed + minor design tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
theory-of-evrth committed Dec 18, 2024
1 parent 346c1ba commit a2ca903
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 39 deletions.
23 changes: 16 additions & 7 deletions timeliner/app/Http/Controllers/TimelineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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');
Expand Down
5 changes: 5 additions & 0 deletions timeliner/app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ protected function casts(): array
'password' => 'hashed',
];
}

public function ownerships()
{
return $this->hasMany(Ownership::class, 'id', 'id');
}
}
2 changes: 1 addition & 1 deletion timeliner/resources/js/createformfunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
16 changes: 16 additions & 0 deletions timeliner/resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,21 @@
</div>
</div>
</div>

<br>

<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2>Your timelines</h2>

@if ($timelines)
@include("timeline.partials.timelinelist", $timelines)
@else
You did not create any timelines yet
@endif
</div>
</div>
</div>
</div>
</x-app-layout>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@csrf
<div class="form-group ">

<button id="node-create-button" type="button" class="btn btn-primary mt-3 bi bi-node-plus"> Add Node</button>

<h3>Nodes</h3>

<div class="col-12">
<table>
Expand Down Expand Up @@ -82,5 +83,8 @@
</table>
</div>
</table>

<button id="node-create-button" type="button" class="btn btn-primary mt-3 bi bi-node-plus"> Add Node</button>

</div>
</div>
10 changes: 7 additions & 3 deletions timeliner/resources/views/timeline/partials/nodeedit.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div class="form-group ">
<button id="node-create-button" type="button" class="btn btn-primary mt-3 bi bi-node-plus"> Add Node</button>
<div class="col-12">
<div class="col-12">

<h3>Nodes</h3>

<table>
<div id="node-list">
<table>
Expand All @@ -19,7 +21,7 @@
window.nodeMilestoneCounts = @json($nodeMilestoneCounts);
</script>
@foreach ($currentNodes as $nodeIndex => $node)
<tr id="node-{{ $nodeIndex }}" class="form-row mt-3" data-index="{{ $nodeIndex }}">
<tr id="node-{{ $nodeIndex }}" class="form-row mt-3 border-4 border-blue-100 rounded-md p-2" data-index="{{ $nodeIndex }}">
<td>
<label for="nodeTitle-{{ $nodeIndex }}">Description</label>
</td>
Expand Down Expand Up @@ -78,5 +80,7 @@
</table>
</div>
</table>
<button id="node-create-button" type="button" class="btn btn-primary mt-3 bi bi-node-plus"> Add Node</button>

</div>
</div>
49 changes: 26 additions & 23 deletions timeliner/resources/views/timeline/timeline.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,34 @@
<input type="range" id="timelineSlider" min="30" max="200" value="100" step="1">
<span id="timelineWidthValue">100</span>
</div>
</div>
</div>

<br>

<!-- Comments to this timeline section -->
<div>
<h2>Comments</h2>

<!-- Add comment to this timeline section -->
<button class="btn btn-primary bi bi-plus-lg toggle-button" data-target="addComment"> Add comment</button>

<form id="addComment" class ="hidden" action="{{ route("comment.store") }}" method="POST">
@csrf
<input type="hidden" name="timeline_id" value="{{ $timeline->id }}">
<input type="hidden" name="user_id" value="{{ Auth::id() }}">
<div class="form-group">
<label for="inputComment">New comment</label>
<textarea name="comment" rows="5" class="form-control" id="inputComment">{{ old('comment') }}</textarea>
</div>
<button type="submit" class="btn btn-primary bi bi-plus-lg"> Add</button>
</form>

<!-- Show comments to this timeline section -->
@foreach ($comments as $comment)
@include("timeline.partials.comment", ["comment"=>$comment])
@endforeach
</div>
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<!-- Comments to this timeline section -->
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2>Comments</h2>

<!-- Add comment to this timeline section -->
<button class="btn btn-primary bi bi-plus-lg toggle-button" data-target="addComment"> Post comment</button>

<form id="addComment" class ="hidden" action="{{ route("comment.store") }}" method="POST">
@csrf
<input type="hidden" name="timeline_id" value="{{ $timeline->id }}">
<input type="hidden" name="user_id" value="{{ Auth::id() }}">
<div class="form-group">
<label for="inputComment">New comment</label>
<textarea name="comment" rows="5" class="form-control" id="inputComment">{{ old('comment') }}</textarea>
</div>
<button type="submit" class="btn btn-primary bi bi-plus-lg"> Add</button>
</form>

<!-- Show comments to this timeline section -->
@foreach ($comments as $comment)
@include("timeline.partials.comment", ["comment"=>$comment])
@endforeach
</div>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions timeliner/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');



Expand All @@ -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');
Route::put('comment/{comment}', [CommentController::class, 'update'])->middleware(['auth', 'verified'])->name('comment.update');

0 comments on commit a2ca903

Please sign in to comment.