Add tags to show and index views

This commit is contained in:
Andras Bacsai 2024-02-05 09:51:44 +01:00
parent 8c60ef5bd6
commit 8b58c8f856
3 changed files with 33 additions and 14 deletions

View File

@ -9,6 +9,7 @@ use Livewire\Component;
class Show extends Component
{
public $tags;
public Tag $tag;
public $applications;
public $services;
@ -17,7 +18,8 @@ class Show extends Component
public function mount()
{
$tag = Tag::ownedByCurrentTeam()->where('name', request()->tag_name)->first();
$this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name');
$tag = $this->tags->where('name', request()->tag_name)->first();
if (!$tag) {
return redirect()->route('tags.index');
}

View File

@ -1,11 +1,14 @@
<div>
<h1>Tags</h1>
<div>Here you can see all the tags here</div>
<div class="flex gap-2 pt-10 flex-wrap">
@forelse ($tags as $tag)
<a class="box" href="{{ route('tags.show', ['tag_name' => $tag->name]) }}">{{ $tag->name }}</a>
@empty
<div>No tags yet defined yet. Go to a resource and add a tag there.</div>
@endforelse
<div class="flex flex-col gap-2 pb-6 ">
<div>Available tags: </div>
<div class="flex flex-wrap gap-2">
@forelse ($tags as $oneTag)
<a class="flex items-center justify-center h-6 text-white min-w-14 w-fit hover:no-underline hover:bg-coolgray-200 bg-coolgray-100"
href="{{ route('tags.show', ['tag_name' => $oneTag->name]) }}">{{ $oneTag->name }}</a>
@empty
<div>No tags yet defined yet. Go to a resource and add a tag there.</div>
@endforelse
</div>
</div>
</div>

View File

@ -1,30 +1,44 @@
<div>
<div class="flex items-start gap-2">
<div>
<h1>Tag: {{ $tag->name }}</h1>
<div class="pt-2">Tag details</div>
<h1>Tags</h1>
</div>
</div>
<div class="pt-4">
<div class="flex flex-col gap-2 pb-6 ">
<div>Available tags: </div>
<div class="flex flex-wrap gap-2 ">
@forelse ($tags as $oneTag)
<a :class="{{ $tag->id == $oneTag->id }} && 'bg-coollabs hover:bg-coollabs-100'"
class="flex items-center justify-center h-6 text-white min-w-14 w-fit hover:no-underline hover:bg-coolgray-200 bg-coolgray-100"
href="{{ route('tags.show', ['tag_name' => $oneTag->name]) }}">{{ $oneTag->name }}</a>
@empty
<div>No tags yet defined yet. Go to a resource and add a tag there.</div>
@endforelse
</div>
</div>
<div>
<h3 class="py-4">Details</h3>
<div class="flex items-end gap-2 ">
<div class="w-[500px]">
<x-forms.input readonly label="Deploy Webhook URL" id="webhook" />
</div>
<x-new-modal buttonTitle="Redeploy All" action="redeploy_all" class="mt-1">
<x-new-modal isHighlighted buttonTitle="Redeploy All" action="redeploy_all">
All resources will be redeployed.
</x-new-modal>
</div>
<div class="grid grid-cols-1 gap-2 pt-4 lg:grid-cols-2 xl:grid-cols-3">
@foreach ($applications as $application)
<a href="{{ $application->link() }}" class="flex flex-col box group">
<span class="font-bold text-white">{{ $application->project()->name }}/{{$application->environment->name}}</span>
<span
class="font-bold text-white">{{ $application->project()->name }}/{{ $application->environment->name }}</span>
<span class="text-white ">{{ $application->name }}</span>
<span class="description">{{ $application->description }}</span>
</a>
@endforeach
@foreach ($services as $service)
<a href="{{ $service->link() }}" class="flex flex-col box group">
<span class="font-bold text-white">{{ $service->project()->name }}/{{$service->environment->name}}</span>
<span
class="font-bold text-white">{{ $service->project()->name }}/{{ $service->environment->name }}</span>
<span class="text-white ">{{ $service->name }}</span>
<span class="description">{{ $service->description }}</span>
</a>