WIP: Add light/dark theme with toggle in navbar (dark theme styling incomplete - dont care for now)
This commit is contained in:
@@ -3,26 +3,29 @@
|
||||
{% for name, children in functions.items() %}
|
||||
{% if children['_is_function'] is not defined %}
|
||||
<details class="group" {% if path_prefix=='' %}open{% endif %}>
|
||||
<summary class="flex items-center gap-2 py-2 cursor-pointer text-gray-700 hover:text-gray-900 font-medium">
|
||||
<summary
|
||||
class="flex items-center gap-2 py-2 cursor-pointer text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white font-medium">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5 text-gray-400 group-open:rotate-90 transition-transform">
|
||||
stroke="currentColor"
|
||||
class="w-5 h-5 text-gray-400 dark:text-gray-500 group-open:rotate-90 transition-transform">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
||||
</svg>
|
||||
<span>{{ name }}</span>
|
||||
</summary>
|
||||
<div class="ml-4 border-l border-gray-200">
|
||||
<div class="ml-4 border-l border-gray-200 dark:border-gray-700">
|
||||
{{ render_functions(children, path_prefix + name + '/') }}
|
||||
</div>
|
||||
</details>
|
||||
{% else %}
|
||||
{% set function = children %}
|
||||
<div class="flex items-center gap-2 py-2 pl-5 text-gray-800 hover:bg-gray-50 rounded-md">
|
||||
<div
|
||||
class="flex items-center gap-2 py-2 pl-5 text-gray-800 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md">
|
||||
<div class="flex-grow flex items-center gap-2 cursor-pointer"
|
||||
hx-get="{{ url_for('http.editor', function_id=function['id']) }}" hx-target="#container" hx-swap="innerHTML"
|
||||
hx-push-url="true">
|
||||
{% if function.is_public %}
|
||||
<span
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300">
|
||||
<svg class="w-2 h-2 mr-1.5 fill-current" viewBox="0 0 8 8">
|
||||
<circle cx="4" cy="4" r="3" />
|
||||
</svg>
|
||||
@@ -30,18 +33,21 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
<span class="font-medium">{{ function.name.split('/')[-1] }}</span>
|
||||
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
||||
<span
|
||||
class="bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
||||
v{{ function.version_number }}
|
||||
</span>
|
||||
<span class="bg-purple-100 text-purple-800 text-xs font-medium px-2.5 py-0.5 rounded-full uppercase">
|
||||
<span
|
||||
class="bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300 text-xs font-medium px-2.5 py-0.5 rounded-full uppercase">
|
||||
{{ function.runtime }}
|
||||
</span>
|
||||
<span class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
||||
<span
|
||||
class="bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
||||
{{ function.invoked_count }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex-shrink-0 flex items-center gap-2">
|
||||
<button class="p-1 text-gray-400 hover:text-gray-600"
|
||||
<button class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
hx-get="{{ url_for('http.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" fill="none" viewBox="0 0 24 24"
|
||||
@@ -50,7 +56,7 @@
|
||||
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>
|
||||
</button>
|
||||
<button class="p-1 text-gray-400 hover:text-gray-600"
|
||||
<button class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
hx-get="{{ url_for('http.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" fill="none" viewBox="0 0 24 24"
|
||||
@@ -62,7 +68,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
<a href="{{ url_for('execute_http_function', user_id=function.user_id, function=function.name) }}"
|
||||
target="_blank" class="p-1 text-gray-400 hover:text-gray-600">
|
||||
target="_blank" class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
|
||||
<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>
|
||||
|
||||
@@ -16,6 +16,54 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
<div class="mx-auto w-full pt-4" id="client-u{{ user_id }}-f{{ function_id }}">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function formatTime(milliseconds) {
|
||||
if (milliseconds < 1000) {
|
||||
return `${milliseconds.toFixed(2)} ms`; // Display milliseconds directly if less than 1 second
|
||||
}
|
||||
|
||||
const seconds = milliseconds / 1000;
|
||||
if (seconds < 60) {
|
||||
return `${seconds.toFixed(2)} s`; // Display seconds if less than 1 minute
|
||||
}
|
||||
|
||||
const minutes = seconds / 60;
|
||||
if (minutes < 60) {
|
||||
return `${minutes.toFixed(2)} min`; // Display minutes if less than 1 hour
|
||||
}
|
||||
|
||||
const hours = minutes / 60;
|
||||
return `${hours.toFixed(2)} h`; // Display hours for longer durations
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (bytes < 1024) {
|
||||
return `${bytes} bytes`;
|
||||
} else if (bytes < 1024 * 1024) {
|
||||
return `${(bytes / 1024).toFixed(2)} KB`;
|
||||
} else if (bytes < 1024 * 1024 * 1024) {
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{% block page %}
|
||||
|
||||
{
|
||||
{
|
||||
render_partial('dashboard/http_functions/header.html', user_id = user_id, function_id = function_id,
|
||||
active_tab = 'client',
|
||||
show_edit_form = True,
|
||||
show_logs = True,
|
||||
show_client = True,
|
||||
show_history = True,
|
||||
edit_url = url_for('http.editor', function_id = function_id),
|
||||
cancel_url = url_for('http.overview'),
|
||||
logs_url = url_for('http.logs', function_id = function_id),
|
||||
history_url = url_for('http.history', function_id = function_id))
|
||||
}
|
||||
}
|
||||
|
||||
<div class="mx-auto w-full pt-4" id="client-u{{ user_id }}-f{{ function_id }}">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function formatTime(milliseconds) {
|
||||
if (milliseconds < 1000) {
|
||||
@@ -51,24 +99,24 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
var KeyValueList = (initialVnode) => {
|
||||
return {
|
||||
view: (vnode) => {
|
||||
return m("div.px-4.py-4.rounded-b-lg.border.border-t-0.border-gray-300", [
|
||||
return m("div.px-4.py-4.rounded-b-lg.border.border-t-0.border-gray-300.dark:border-gray-700.bg-white.dark:bg-gray-800", [
|
||||
m("div", [
|
||||
m("div.flex-col.space-y-2.mb-3", vnode.attrs.list.map(({ key, value }, index) => m('div.flex', [
|
||||
m("input.px-4.py-1.5.w-full.border.border-gray-300.rounded-md.hover:border-orange-500.focus:outline-orange-500", {
|
||||
m("input.px-4.py-1.5.w-full.border.border-gray-300.dark:border-gray-600.rounded-md.hover:border-orange-500.focus:outline-orange-500.bg-white.dark:bg-gray-700.text-gray-900.dark:text-white", {
|
||||
placeholder: "Key",
|
||||
value: key,
|
||||
oninput: (e) => vnode.attrs.list[index].key = e.target.value
|
||||
}),
|
||||
m("input.ml-3.px-4.py-1.5.w-full.border.border-gray-300.rounded-md.hover:border-orange-500.focus:outline-orange-500", {
|
||||
m("input.ml-3.px-4.py-1.5.w-full.border.border-gray-300.dark:border-gray-600.rounded-md.hover:border-orange-500.focus:outline-orange-500.bg-white.dark:bg-gray-700.text-gray-900.dark:text-white", {
|
||||
placeholder: "Value",
|
||||
value: value,
|
||||
oninput: (e) => vnode.attrs.list[index].value = e.target.value
|
||||
}),
|
||||
m("button.ml-4.px-4.rounded-md.text-red-500.border.border-red-300.hover:bg-red-100", {
|
||||
m("button.ml-4.px-4.rounded-md.text-red-500.border.border-red-300.hover:bg-red-100.dark:border-red-800.dark:hover:bg-red-900/30", {
|
||||
onclick: () => vnode.attrs.list.splice(index, 1)
|
||||
}, "Remove")
|
||||
]))),
|
||||
m("button.px-6.py-1.rounded-md.text-orange-600.border.border-orange-400.hover:bg-orange-100", {
|
||||
m("button.px-6.py-1.rounded-md.text-orange-600.border.border-orange-400.hover:bg-orange-100.dark:text-orange-400.dark:border-orange-500.dark:hover:bg-orange-900/30", {
|
||||
onclick: () => vnode.attrs.list.push({ key: '', value: '' })
|
||||
}, "Add")
|
||||
])
|
||||
@@ -85,7 +133,7 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
oninput: (e) => this.body = e.target.value,
|
||||
value: this.body,
|
||||
rows: 4,
|
||||
class: "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300"
|
||||
class: "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
|
||||
})
|
||||
}
|
||||
return tabMappings[this.activeTab];
|
||||
@@ -150,13 +198,13 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
view: function () {
|
||||
return m("div.mx-auto.w-full.pt-4", [
|
||||
m("form.flex", [
|
||||
m("select.px-4.py-2.border.rounded-md.border-gray-300.hover:border-orange-500.focus:outline-none.bg-gray-100", {
|
||||
m("select.px-4.py-2.border.rounded-md.border-gray-300.hover:border-orange-500.focus:outline-none.bg-gray-100.dark:bg-gray-700.dark:border-gray-600.dark:text-white", {
|
||||
onchange: (e) => this.method = e.target.value,
|
||||
value: this.method
|
||||
}, ["GET", "POST", "PUT", "PATCH", "DELETE"].map(method =>
|
||||
m("option", { value: method }, method)
|
||||
)),
|
||||
m("input.ml-3.w-full.px-4.py-2.border.rounded-md.border-gray-300.hover:border-orange-500.focus:outline-orange-500", {
|
||||
m("input.ml-3.w-full.px-4.py-2.border.rounded-md.border-gray-300.hover:border-orange-500.focus:outline-orange-500.bg-white.dark:bg-gray-700.dark:border-gray-600.dark:text-white", {
|
||||
onchange: (e) => this.url = e.target.value,
|
||||
value: this.url,
|
||||
placeholder: "URL"
|
||||
@@ -175,14 +223,14 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
// Tabs for query params, headers, and body
|
||||
m("div", [
|
||||
// Tab headers
|
||||
m("ul.flex.mt-5.border.border-gray-300.rounded-t-lg", [
|
||||
m("ul.flex.mt-5.border.border-gray-300.dark:border-gray-700.rounded-t-lg.bg-gray-50.dark:bg-gray-800", [
|
||||
[
|
||||
{ name: "Query Params", count: this.queryParams.filter(p => p.key && p.value).length },
|
||||
{ name: "Headers", count: this.headers.filter(p => p.key && p.value).length },
|
||||
{ name: "Body", count: null }
|
||||
].map(({ name, count }, index) =>
|
||||
m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer", {
|
||||
class: this.activeTab === name ? "border-b-2 text-orange-600" : "",
|
||||
m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer.text-gray-700.dark:text-gray-300", {
|
||||
class: this.activeTab === name ? "border-b-2 text-orange-600 dark:text-orange-400" : "",
|
||||
onclick: () => this.activeTab = name
|
||||
}, `${name}${count ? ` (${count})` : ``}`))
|
||||
]),
|
||||
@@ -193,17 +241,17 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
oninput: (e) => this.body = e.target.value,
|
||||
value: this.body,
|
||||
rows: 4,
|
||||
class: "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300"
|
||||
class: "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
|
||||
}) : ''
|
||||
]),
|
||||
this.response ? m("div.my-4.p-4.shadow.rounded-lg", [
|
||||
this.response ? m("div.my-4.p-4.shadow.rounded-lg.bg-white.dark:bg-gray-800.border.border-gray-200.dark:border-gray-700", [
|
||||
m("div.flex.items-center.mb-4.justify-between", [
|
||||
m("ul.flex.border.border-gray-300.rounded-t-lg", [{ name: 'Browser Preview', count: null }, { name: 'Headers', count: this.responseHeaders.length }, { name: 'Body', count: null }].map(({ name, count }) =>
|
||||
m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer", {
|
||||
class: this.activeResponseTab === name ? "border-b-2 text-orange-600" : "",
|
||||
m("ul.flex.border.border-gray-300.dark:border-gray-700.rounded-t-lg.bg-gray-50.dark:bg-gray-800", [{ name: 'Browser Preview', count: null }, { name: 'Headers', count: this.responseHeaders.length }, { name: 'Body', count: null }].map(({ name, count }) =>
|
||||
m("li.mr-3.py-2.px-4.border-orange-400.focus:outline-none.hover:text-orange-500.cursor-pointer.text-gray-700.dark:text-gray-300", {
|
||||
class: this.activeResponseTab === name ? "border-b-2 text-orange-600 dark:text-orange-400" : "",
|
||||
onclick: () => this.activeResponseTab = name
|
||||
}, `${name}${count ? ` (${count})` : ``}`))),
|
||||
m("svg", { class: "h-6 w-6 cursor-pointer", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", onclick: () => this.response = '' },
|
||||
m("svg", { class: "h-6 w-6 cursor-pointer text-gray-500 dark:text-gray-400", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", onclick: () => this.response = '' },
|
||||
m("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" })
|
||||
)
|
||||
]),
|
||||
@@ -225,15 +273,15 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
)
|
||||
])
|
||||
]) : null,
|
||||
this.activeResponseTab == 'Body' ? m("div.overflow-auto.max-h-64.bg-gray-100.p-2.rounded-lg", [
|
||||
m("pre.text-sm", this.response)
|
||||
this.activeResponseTab == 'Body' ? m("div.overflow-auto.max-h-64.bg-gray-100.dark:bg-gray-900.p-2.rounded-lg", [
|
||||
m("pre.text-sm.text-gray-900.dark:text-gray-300", this.response)
|
||||
]) : null,
|
||||
this.activeResponseTab == 'Browser Preview' ? m("div.p-2.rounded-lg", m.trust(this.response)) : null,
|
||||
this.activeResponseTab == 'Browser Preview' ? m("div.p-2.rounded-lg.bg-white", m.trust(this.response)) : null,
|
||||
m("div.flex", [
|
||||
m("div.grow", ""),
|
||||
m("div.flex.space-x-2.pt-1", [{ key: 'Status', value: this.status }, { key: 'Time', value: formatTime(this.duration) }, { key: 'Size', value: formatSize(this.responseSize) }].map(({ key, value }) =>
|
||||
m("div.flex.items-center.justify-between", [
|
||||
m("span.text-gray-600", `${key}:`),
|
||||
m("span.text-gray-600.dark:text-gray-400", `${key}:`),
|
||||
m("span.font-semibold.pl-1.text-green-400", value)
|
||||
])))
|
||||
])
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', user_id=user_id, function_id=function_id,
|
||||
active_tab='logs',
|
||||
show_edit_form=True,
|
||||
show_logs=True,
|
||||
show_client=True,
|
||||
{% extends 'dashboard.html' %}
|
||||
|
||||
{% block page %}
|
||||
|
||||
{{ render_partial('dashboard/http_functions/header.html', user_id=user_id, function_id=function_id,
|
||||
active_tab='logs',
|
||||
show_edit_form=True,
|
||||
@@ -15,23 +24,25 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
{{ render_partial('dashboard/analytics.html', invocations=http_function_invocations) }}
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
|
||||
<!-- Headers -->
|
||||
<div class="grid md:grid-cols-4 gap-4 bg-gray-50 p-4 border-b border-gray-200">
|
||||
<div class="font-semibold text-gray-600 md:block hidden">Timestamp</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
|
||||
class="grid md:grid-cols-4 gap-4 bg-gray-50 dark:bg-gray-700 p-4 border-b border-gray-200 dark:border-gray-600">
|
||||
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Timestamp</div>
|
||||
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Request</div>
|
||||
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Response</div>
|
||||
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Logs</div>
|
||||
</div>
|
||||
|
||||
<!-- Data Rows -->
|
||||
{% for invocation in http_function_invocations %}
|
||||
<div
|
||||
class="log-row grid md:grid-cols-4 gap-4 p-4 hover:bg-gray-50 transition-colors duration-150 border-b border-gray-200">
|
||||
class="log-row grid md:grid-cols-4 gap-4 p-4 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors duration-150 border-b border-gray-200 dark:border-gray-700">
|
||||
<!-- Timestamp and Status -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<div
|
||||
class="{{ 'bg-green-100 text-green-700' if invocation.status == 'SUCCESS' else 'bg-red-100 text-red-700' }} p-2 rounded-full">
|
||||
class="{{ 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300' if invocation.status == 'SUCCESS' else 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300' }} p-2 rounded-full">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="{{ 'M5 13l4 4L19 7' if invocation.status == 'SUCCESS' else 'M6 18L18 6M6 6l12 12' }}">
|
||||
@@ -39,28 +50,31 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
</svg>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<span class="text-sm text-gray-900">{{ invocation.invocation_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
<span class="text-sm text-gray-900 dark:text-gray-200">{{
|
||||
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">
|
||||
class="inline-flex items-center w-fit px-2 py-1 text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 rounded-full">
|
||||
v{{ invocation.version_number }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Request Data -->
|
||||
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.request_data }}</pre>
|
||||
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre
|
||||
class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{{ invocation.request_data }}</pre>
|
||||
</div>
|
||||
|
||||
<!-- Response Data -->
|
||||
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.response_data }}</pre>
|
||||
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre
|
||||
class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{{ invocation.response_data }}</pre>
|
||||
</div>
|
||||
|
||||
<!-- Logs -->
|
||||
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
|
||||
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
|
||||
<pre class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
|
||||
{{- invocation.logs | map('join', ' ') | join('\n') -}}
|
||||
{%- elif invocation.logs is iterable and invocation.logs is not string -%}
|
||||
{{- invocation.logs | join('\n') -}}
|
||||
@@ -68,7 +82,7 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
{{- invocation.logs | string -}}
|
||||
{%- endif -%}</pre>
|
||||
{% if not invocation.logs %}
|
||||
<div class="text-sm text-gray-400 italic">No logs available</div>
|
||||
<div class="text-sm text-gray-400 dark:text-gray-500 italic">No logs available</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -76,14 +90,14 @@ history_url=url_for('http.history', function_id=function_id)) }}
|
||||
|
||||
{% if not http_function_invocations %}
|
||||
<div class="p-8 text-center">
|
||||
<div class="text-gray-400">
|
||||
<div class="text-gray-400 dark:text-gray-500">
|
||||
<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>
|
||||
<h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No logs found</h3>
|
||||
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No function invocations have been recorded yet.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -1,82 +1,25 @@
|
||||
{% extends 'dashboard.html' %}
|
||||
const isExpanding = btn.textContent.trim() === 'Expand All';
|
||||
|
||||
{% block page %}
|
||||
details.forEach(detail => {
|
||||
if (isExpanding) {
|
||||
detail.setAttribute('open', '');
|
||||
} else {
|
||||
detail.removeAttribute('open');
|
||||
}
|
||||
});
|
||||
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div class="flex items-center mb-6" data-id="51">
|
||||
<h1 class="text-2xl font-bold text-gray-900">HTTP Functions</h1>
|
||||
<button
|
||||
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-get="{{ url_for('http.new') }}" hx-target="#container" hx-swap="innerHTML" 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" class="w-5 h-5 mr-2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"></path>
|
||||
</svg>
|
||||
Add Function
|
||||
</button>
|
||||
</div>
|
||||
btn.textContent = isExpanding ? 'Collapse All' : 'Expand All';
|
||||
}
|
||||
|
||||
<div class="mb-6 flex gap-4">
|
||||
<input type="text" name="q" placeholder="Search functions..."
|
||||
class="flex-grow px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500"
|
||||
value="{{ search_query }}" hx-get="{{ url_for('http.overview') }}" hx-trigger="keyup changed delay:500ms"
|
||||
hx-target="#function-list" hx-headers='{"HX-Target": "function-list"}' hx-push-url="true">
|
||||
|
||||
<button onclick="toggleAllDetails()" id="toggle-btn"
|
||||
class="px-4 py-2 bg-white border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 font-medium transition-colors duration-200 whitespace-nowrap">
|
||||
Expand All
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="function-list">
|
||||
{% block function_list %}
|
||||
{% from 'dashboard/http_functions/_function_list.html' import render_functions %}
|
||||
{{ render_functions(http_functions) }}
|
||||
|
||||
{% if http_functions|length == 0 %}
|
||||
<div class="py-12">
|
||||
<div class="text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"
|
||||
aria-hidden="true">
|
||||
<path vector-effect="non-scaling-stroke" stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
|
||||
</svg>
|
||||
<h3 class="mt-2 text-lg font-medium text-gray-900">No functions found</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">Get started by creating a new function.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleAllDetails() {
|
||||
const details = document.querySelectorAll('#function-list details');
|
||||
const btn = document.getElementById('toggle-btn');
|
||||
const isExpanding = btn.textContent.trim() === 'Expand All';
|
||||
|
||||
details.forEach(detail => {
|
||||
if (isExpanding) {
|
||||
detail.setAttribute('open', '');
|
||||
} else {
|
||||
detail.removeAttribute('open');
|
||||
}
|
||||
});
|
||||
|
||||
btn.textContent = isExpanding ? 'Collapse All' : 'Expand All';
|
||||
}
|
||||
|
||||
// Reset button state when HTMX updates the list
|
||||
document.body.addEventListener('htmx:afterSwap', function (evt) {
|
||||
if (evt.detail.target.id === 'function-list') {
|
||||
const btn = document.getElementById('toggle-btn');
|
||||
if (btn) {
|
||||
btn.textContent = 'Expand All';
|
||||
}
|
||||
}
|
||||
});
|
||||
// Reset button state when HTMX updates the list
|
||||
document.body.addEventListener('htmx:afterSwap', function (evt) {
|
||||
if (evt.detail.target.id === 'function-list') {
|
||||
const btn = document.getElementById('toggle-btn');
|
||||
if (btn) {
|
||||
btn.textContent = 'Expand All';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user