feat: initial datalist

This commit is contained in:
Andras Bacsai
2024-04-26 10:33:55 +02:00
parent 83a29f8d85
commit 3e0440ba53
6 changed files with 157 additions and 52 deletions

View File

@@ -0,0 +1,44 @@
<div class="w-full">
<label>
@if ($label)
{{ $label }}
@if ($required)
<x-highlighted text="*" />
@endif
@if ($helper)
<x-helper :helper="$helper" />
@endif
@endif
<input list={{ $id }} {{ $attributes->merge(['class' => $defaultClass]) }} @required($required)
wire:dirty.class.remove='dark:text-white' wire:dirty.class="text-black bg-warning" wire:loading.attr="disabled"
name={{ $id }}
@if ($attributes->whereStartsWith('wire:model')->first()) {{ $attributes->whereStartsWith('wire:model')->first() }} @else wire:model={{ $id }} @endif
@if ($attributes->whereStartsWith('onUpdate')->first()) wire:change={{ $attributes->whereStartsWith('onUpdate')->first() }} wire:keydown.enter={{ $attributes->whereStartsWith('onUpdate')->first() }} wire:blur={{ $attributes->whereStartsWith('onUpdate')->first() }} @else wire:change={{ $id }} wire:blur={{ $id }} wire:keydown.enter={{ $id }} @endif>
<datalist id={{ $id }}>
{{ $slot }}
</datalist>
</label>
@error($id)
<label class="label">
<span class="text-red-500 label-text-alt">{{ $message }}</span>
</label>
@enderror
{{-- <script>
const input = document.querySelector(`input[list={{ $id }}]`);
input.addEventListener('focus', function(e) {
const input = e.target.value;
const datalist = document.getElementById('{{ $id }}');
if (datalist.options) {
for (let option of datalist.options) {
// change background color to red on all options
option.style.display = "none";
if (option.value.includes(input)) {
option.style.display = "block";
}
}
}
});
</script> --}}
</div>

View File

@@ -0,0 +1,28 @@
<div wire:poll.1000ms="get_deployments" class="grid grid-cols-1">
@forelse ($deployments_per_tag_per_server as $server_name => $deployments)
<h4 class="py-4">{{ $server_name }}</h4>
<div class="grid grid-cols-1 gap-2 lg:grid-cols-3">
@foreach ($deployments as $deployment)
<div @class([
'box-without-bg dark:bg-coolgray-100 bg-white gap-2 cursor-pointer group border-l-2 border-dotted',
'dark:border-coolgray-300' => data_get($deployment, 'status') === 'queued',
'border-yellow-500' => data_get($deployment, 'status') === 'in_progress',
])>
<a href="{{ data_get($deployment, 'deployment_url') }}">
<div class="flex flex-col mx-6">
<div class="box-title">
{{ data_get($deployment, 'application_name') }}
</div>
<div class="box-description">
{{ str(data_get($deployment, 'status'))->headline() }}
</div>
</div>
<div class="flex-1"></div>
</a>
</div>
@endforeach
</div>
@empty
<div>No deployments running.</div>
@endforelse
</div>

View File

@@ -6,12 +6,11 @@
@if ($tags->count() === 0)
<div>No tags yet defined yet. Go to a resource and add a tag there.</div>
@else
<x-forms.select wire:model.live="tag">
<option value="null" disabled selected>Select a tag</option>
<x-forms.datalist wire:model="tag" onUpdate='tag_updated'>
@foreach ($tags as $oneTag)
<option value="{{ $oneTag->name }}">{{ $oneTag->name }}</option>
@endforeach
</x-forms.select>
</x-forms.datalist>
@if ($tag)
<div class="pt-5">
<div class="flex items-end gap-2 ">
@@ -51,34 +50,7 @@
<x-loading />
@endif
</div>
<div wire:poll.1000ms="get_deployments" class="grid grid-cols-1">
@forelse ($deployments_per_tag_per_server as $server_name => $deployments)
<h4 class="py-4">{{ $server_name }}</h4>
<div class="grid grid-cols-1 gap-2 lg:grid-cols-3">
@foreach ($deployments as $deployment)
<div @class([
'box-without-bg dark:bg-coolgray-100 bg-white gap-2 cursor-pointer group border-l-2 border-dotted',
'dark:border-coolgray-300' => data_get($deployment, 'status') === 'queued',
'border-yellow-500' => data_get($deployment, 'status') === 'in_progress',
])>
<a href="{{ data_get($deployment, 'deployment_url') }}">
<div class="flex flex-col mx-6">
<div class="box-title">
{{ data_get($deployment, 'application_name') }}
</div>
<div class="box-description">
{{ str(data_get($deployment, 'status'))->headline() }}
</div>
</div>
<div class="flex-1"></div>
</a>
</div>
@endforeach
</div>
@empty
<div>No deployments running.</div>
@endforelse
</div>
<livewire:tags.deployments :deployments_per_tag_per_server="$deployments_per_tag_per_server" :resource_ids="$applications->pluck('id')" />
</div>
@endif
@endif