Refactor HTTP functions overview and logs pages with improved UI and responsiveness

- Modernize the design of HTTP functions overview and logs pages
- Add more detailed styling with Tailwind CSS
- Improve layout and readability with better typography and spacing
- Add empty state handling for both logs and functions lists
- Enhance visual hierarchy and interaction states
This commit is contained in:
Peter Stockings
2025-02-14 22:22:27 +11:00
parent 5ec8bba9e8
commit 9d48bbd285
2 changed files with 170 additions and 135 deletions

View File

@@ -11,47 +11,75 @@ show_history=True,
edit_url=url_for('http_function_editor', function_id=function_id), edit_url=url_for('http_function_editor', function_id=function_id),
cancel_url=url_for('dashboard_http_functions')) }} cancel_url=url_for('dashboard_http_functions')) }}
<div class="block md:grid md:grid-cols-4 md:gap-4 p-4"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Headers --> <div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
<div class="font-medium text-muted-foreground md:block hidden">Timestamp</div> <!-- Headers -->
<div class="font-medium text-muted-foreground md:block hidden">Request</div> <div class="grid md:grid-cols-4 gap-4 bg-gray-50 p-4 border-b border-gray-200">
<div class="font-medium text-muted-foreground md:block hidden">Response</div> <div class="font-semibold text-gray-600 md:block hidden">Timestamp</div>
<div class="font-medium text-muted-foreground md:block hidden">Logs</div> <div class="font-semibold text-gray-600 md:block hidden">Request</div>
<div class="font-semibold text-gray-600 md:block hidden">Response</div>
<div class="font-semibold text-gray-600 md:block hidden">Logs</div>
</div>
<!-- Data Rows --> <!-- Data Rows -->
{% for invocation in http_function_invocations %} {% for invocation in http_function_invocations %}
<!-- Timestamp and Status for Mobile and Desktop --> <div
<div class="flex items-center md:col-span-1 py-2 border-b"> class="grid md:grid-cols-4 gap-4 p-4 hover:bg-gray-50 transition-colors duration-150 border-b border-gray-200">
<button <!-- Timestamp and Status -->
class="{{ 'bg-green-400' if invocation.status == 'SUCCESS' else 'bg-red-400' }} hover:bg-opacity-75 text-white font-bold rounded-full h-fit p-2 mr-2"> <div class="flex items-center space-x-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <div
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="{{ 'bg-green-100 text-green-700' if invocation.status == 'SUCCESS' else 'bg-red-100 text-red-700' }} p-2 rounded-full">
d="{{ 'M5 13l4 4L19 7' if invocation.status == 'SUCCESS' else 'M6 18L18 6M6 6l12 12' }}"></path> <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
</svg> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
</button> d="{{ 'M5 13l4 4L19 7' if invocation.status == 'SUCCESS' else 'M6 18L18 6M6 6l12 12' }}">
<span>{{ invocation.invocation_time.strftime('%Y-%m-%d %H:%M:%S') }}</span> </path>
<span class="bg-blue-500 text-white text-xs font-semibold px-2 py-1 rounded"> </svg>
v{{ invocation.version_number }} </div>
</span> <div class="flex flex-col">
</div> <span class="text-sm text-gray-900">{{ invocation.invocation_time.strftime('%Y-%m-%d %H:%M:%S')
}}</span>
<span
class="inline-flex items-center w-fit px-2 py-1 text-xs font-medium bg-blue-100 text-blue-700 rounded-full">
v{{ invocation.version_number }}
</span>
</div>
</div>
<!-- Request Data for Mobile and Desktop --> <!-- Request Data -->
<div class="font-mono text-gray-400 overflow-auto md:col-span-1 py-2 border-b"> <div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
{{ invocation.request_data }} <pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.request_data }}</pre>
</div> </div>
<!-- Response Data for Mobile and Desktop --> <!-- Response Data -->
<div class="font-mono text-gray-400 overflow-auto md:col-span-1 py-2 border-b"> <div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
{{ invocation.response_data }} <pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.response_data }}</pre>
</div> </div>
<!-- Logs for Mobile and Desktop --> <!-- Logs -->
<div class="space-y-1 md:col-span-1 py-2 border-b"> <div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
{% for log in invocation.logs %} {% for log in invocation.logs %}
<div class="font-mono text-gray-400">{{ log[0] }}</div> <div class="text-sm font-mono text-gray-600 py-0.5">{{ log[0] }}</div>
{% endfor %}
{% if not invocation.logs %}
<div class="text-sm text-gray-400 italic">No logs available</div>
{% endif %}
</div>
</div>
{% endfor %} {% endfor %}
{% if not http_function_invocations %}
<div class="p-8 text-center">
<div class="text-gray-400">
<svg class="mx-auto h-12 w-12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
</div>
<h3 class="mt-2 text-sm font-medium text-gray-900">No logs found</h3>
<p class="mt-1 text-sm text-gray-500">No function invocations have been recorded yet.</p>
</div>
{% endif %}
</div> </div>
{% endfor %}
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -2,110 +2,117 @@
{% block page %} {% block page %}
<div class="flex items-center" data-id="51"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<h1 class="leading-normal text-gray-800 text-base md:text-xl lg:text-2xl">HTTP functions</h1> <div class="flex items-center mb-6" data-id="51">
<button <h1 class="text-2xl font-bold text-gray-900">HTTP Functions</h1>
class="bg-transparent hover:bg-green-500 text-green-700 font-semibold hover:text-white py-2 px-4 border border-green-500 hover:border-transparent rounded flex mr-2 items-center ml-auto" <button
hx-get="{{ url_for('get_http_function_add_form') }}" hx-target="#container" hx-swap="innerHTML" class="inline-flex items-center px-4 py-2 ml-auto bg-green-600 hover:bg-green-700 text-white font-medium rounded-lg transition-colors duration-200"
hx-push-url="true"> hx-get="{{ url_for('get_http_function_add_form') }}" hx-target="#container" hx-swap="innerHTML"
<span class="sr-only" data-id="4">Bold</span> hx-push-url="true">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
class="w-5 h-5" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: currentColor;"> stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"></path> <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"></path>
</svg> </svg>
<span class="ml-1">Add Function</span> Add Function
</button> </button>
</div> </div>
<div class="border shadow-sm rounded-lg" data-id="54">
<div class="relative w-full overflow-auto">
<table class="w-full caption-bottom text-sm" data-id="55">
<thead class="[&amp;_tr]:border-b" data-id="56">
<tr class="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" data-id="57">
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground text-gray-800"
data-id="59">Name</th>
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground text-gray-800 hidden md:table-cell"
data-id="60">URL</th>
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground text-gray-800"
data-id="61">Actions</th>
</tr>
</thead>
<tbody class="[&amp;_tr:last-child]:border-0" data-id="62">
{% for function in http_functions %}
<tr class="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" data-id="63">
<td
class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0 font-medium flex items-center space-x-1">
<span class="text-gray-800 text-base text-md">{{ function.name }}</span>
<span class="bg-green-500 text-white text-xs font-semibold px-2 py-1 rounded flex items-center">
#{{ function.invoked_count }}
</span>
<span class="bg-blue-500 text-white text-xs font-semibold px-2 py-1 rounded">
v{{ function.version_number }}
</span>
{% if function.is_public %}
<span class="ml-1">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" data-slot="icon" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round"
d="M13.5 10.5V6.75a4.5 4.5 0 1 1 9 0v3.75M3.75 21.75h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H3.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" />
</svg>
</span> <div class="bg-white border border-gray-200 rounded-lg shadow-sm overflow-hidden">
{% endif %} <div class="overflow-x-auto">
<table class="w-full">
</td> <thead>
<td class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0 hidden md:table-cell" data-id="67"> <tr class="bg-gray-50 border-b border-gray-200">
<a <th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Name</th>
href="{{ url_for('execute_http_function', user_id=function.user_id, function=function.name) }}">{{ <th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">URL
url_for('execute_http_function', user_id=function.user_id, function=function.name) }}</a> </th>
<button <th class="px-6 py-4 text-left text-sm font-semibold text-gray-900 hidden md:table-cell">Actions
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground pl-1 text-gray-600 dark:text-gray-400" </th>
data-id="24"><span class="sr-only" data-id="25">Add Link</span><svg </tr>
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" </thead>
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" <tbody class="divide-y divide-gray-200">
stroke-linejoin="round" class="w-4 h-4" data-id="26" data-darkreader-inline-stroke="" {% for function in http_functions %}
style="--darkreader-inline-stroke: currentColor;"> <tr class="hover:bg-gray-50">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"> <td class="px-6 py-4">
</path> <div class="flex items-center gap-2 cursor-pointer"
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71">
</path>
</svg></button>
</td>
<td class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0" data-id="68">
<div class="flex gap-1">
<button
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800"
hx-get="{{ url_for('get_http_function_logs', function_id=function.id) }}"
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
Logs
</button>
<button
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800"
hx-get="{{ url_for('http_function_editor', function_id=function.id) }}" hx-get="{{ url_for('http_function_editor', function_id=function.id) }}"
hx-target="#container" hx-swap="innerHTML" hx-push-url="true"> hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
Edit <span class="font-medium text-gray-900">{{ function.name }}</span>
</button> <span
<button class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
class="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 rounded-md px-3 text-gray-800" #{{ function.invoked_count }}
hx-get="{{ url_for('client', function_id=function.id) }}" hx-target="#container" </span>
hx-swap="innerHTML" hx-push-url="true"> <span class="bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
Try v{{ function.version_number }}
</button> </span>
</div> {% if function.is_public %}
</td> <span class="text-gray-500">
</tr> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
{% endfor %} stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round"
d="M13.5 10.5V6.75a4.5 4.5 0 1 1 9 0v3.75M3.75 21.75h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H3.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" />
</svg>
</span>
{% endif %}
</div>
</td>
<td class="px-6 py-4">
<div class="flex items-center">
<a href="{{ url_for('execute_http_function', user_id=function.user_id, function=function.name) }}"
class="text-blue-600 hover:text-blue-800">
{{ url_for('execute_http_function', user_id=function.user_id,
function=function.name) }}
</a>
<button class="ml-2 text-gray-400 hover:text-gray-600">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
</button>
</div>
</td>
<td class="px-6 py-4 hidden md:table-cell">
<div class="flex gap-3">
<button
class="inline-flex items-center px-3 py-1.5 text-sm font-medium text-indigo-700 bg-indigo-50 rounded-md hover:bg-indigo-100 transition-colors duration-200"
hx-get="{{ url_for('get_http_function_logs', function_id=function.id) }}"
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 mr-1.5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
Logs
</button>
<button
class="inline-flex items-center px-3 py-1.5 text-sm font-medium text-indigo-700 bg-indigo-50 rounded-md hover:bg-indigo-100 transition-colors duration-200"
hx-get="{{ url_for('client', function_id=function.id) }}" hx-target="#container"
hx-swap="innerHTML" hx-push-url="true">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 mr-1.5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
Try
</button>
</div>
</td>
</tr>
{% endfor %}
{% if http_functions|length == 0 %} {% if http_functions|length == 0 %}
<div class="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" data-id="63"> <tr>
<td class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0 font-medium flex items-center" <td colspan="3" class="px-6 py-8 text-center">
colspan="3"> <p class="text-gray-500 text-lg">No functions found</p>
<span class="text-lg">No functions found</span> </td>
</td> </tr>
</div> {% endif %}
{% endif %} </tbody>
</table>
</tbody> </div>
</table>
</div> </div>
</div> </div>