Further refactor, still need to cleanup db.py
This commit is contained in:
@@ -270,7 +270,7 @@
|
||||
class="inline-flex items-center justify-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors duration-200">
|
||||
View Timer Functions
|
||||
</a>
|
||||
<a href="{{ url_for('http.dashboard_http_functions') }}"
|
||||
<a href="{{ url_for('http.overview') }}"
|
||||
class="inline-flex items-center justify-center px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition-colors duration-200">
|
||||
View HTTP Functions
|
||||
</a>
|
||||
|
||||
@@ -8,10 +8,10 @@ show_edit_form=True,
|
||||
show_logs=True,
|
||||
show_client=True,
|
||||
show_history=True,
|
||||
edit_url=url_for('http.http_function_editor', function_id=function_id),
|
||||
cancel_url=url_for('http.dashboard_http_functions'),
|
||||
logs_url=url_for('http.get_http_function_logs', function_id=function_id),
|
||||
history_url=url_for('http.get_http_function_history', function_id=function_id)) }}
|
||||
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>
|
||||
|
||||
@@ -10,8 +10,8 @@ show_client=True,
|
||||
show_history=True,
|
||||
edit_url=edit_url,
|
||||
cancel_url=cancel_url,
|
||||
logs_url=url_for('http.get_http_function_logs', function_id=function_id),
|
||||
history_url=url_for('http.get_http_function_history', function_id=function_id)) }}
|
||||
logs_url=url_for('http.logs', function_id=function_id),
|
||||
history_url=url_for('http.history', function_id=function_id)) }}
|
||||
|
||||
|
||||
<div id="app" class="p-1">
|
||||
@@ -33,8 +33,9 @@ history_url=url_for('http.get_http_function_history', function_id=function_id))
|
||||
logResponse: {{ log_response | tojson }},
|
||||
versionNumber: {{ version_number }},
|
||||
executeUrl: "{{ url_for('execute_code', playground='true') }}",
|
||||
saveUrl: "{{ url_for('http.api_update_http_function', function_id=id) if id else url_for('http.api_create_http_function') }}",
|
||||
deleteUrl: "{{ url_for('http.api_delete_http_function', function_id=id) if id else '' }}",
|
||||
saveUrl: "{{ url_for('http.edit', function_id=id) if id else url_for('http.new') }}",
|
||||
deleteUrl: "{{ url_for('http.delete', function_id=id) if id else '' }}",
|
||||
cancelUrl: "{{ url_for('http.overview') }}",
|
||||
showDeleteButton: true
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,196 +8,17 @@ show_edit_form=True,
|
||||
show_logs=True,
|
||||
show_client=True,
|
||||
show_history=True,
|
||||
edit_url=url_for('http.http_function_editor', function_id=function_id),
|
||||
cancel_url=url_for('http.dashboard_http_functions'),
|
||||
logs_url=url_for('http.get_http_function_logs', function_id=function_id),
|
||||
history_url=url_for('http.get_http_function_history', function_id=function_id)) }}
|
||||
|
||||
<!-- Timeline -->
|
||||
<div>
|
||||
{% if http_function.version_number > 1 %}
|
||||
{% for entry in http_function_history %}
|
||||
<!-- Item -->
|
||||
<div class="flex gap-x-3">
|
||||
<!-- Left Content -->
|
||||
<div class="w-24 text-end">
|
||||
<span class="text-xs text-gray-500">{{ entry.updated_at.strftime('%b %d %Y %I:%M %p').lstrip("0").replace("
|
||||
0", " ") }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- End Left Content -->
|
||||
|
||||
<!-- Icon -->
|
||||
<div
|
||||
class="relative last:after:hidden after:absolute after:top-7 after:bottom-0 after:start-3.5 after:w-px after:-translate-x-[0.5px] after:bg-gray-200">
|
||||
<div class="relative z-10 size-7 flex justify-center items-center">
|
||||
<div class="size-2 rounded-full bg-gray-400"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Icon -->
|
||||
|
||||
<!-- Right Content -->
|
||||
<div class="grow pt-0.5 pb-4 cursor-pointer">
|
||||
<h3 class="flex gap-x-1.5 font-semibold text-gray-800">
|
||||
v{{ entry.version_number }}
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-gray-600">
|
||||
</p>
|
||||
|
||||
<button type="button"
|
||||
class="mt-1 -ms-1 p-1 inline-flex items-center gap-x-2 text-xs rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">
|
||||
Revert
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<!-- End Right Content -->
|
||||
</div>
|
||||
<div class="block">
|
||||
<div id="diff_{{ entry.version_id }}" class="relative h-80"></div>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
// Assigning JSON content to a JavaScript variable
|
||||
var preContent = '{{ entry.pre | tojson | safe }}';
|
||||
var postContent = '{{ entry.post | tojson | safe }}';
|
||||
|
||||
var aceDiffer = new AceDiff({
|
||||
element: '#diff_{{ entry.version_id }}',
|
||||
mode: "ace/mode/javascript",
|
||||
left: {
|
||||
content: preContent,
|
||||
editable: false,
|
||||
},
|
||||
right: {
|
||||
content: postContent,
|
||||
editable: false,
|
||||
},
|
||||
});
|
||||
|
||||
// Retrieve the individual editors
|
||||
var editors = aceDiffer.getEditors();
|
||||
|
||||
// Set the maxLines property on each editor
|
||||
editors.left.setOptions({
|
||||
maxLines: 20, // Set the maximum number of lines
|
||||
autoScrollEditorIntoView: true,
|
||||
});
|
||||
editors.left.session.setOption("useWorker", false);
|
||||
|
||||
editors.right.setOptions({
|
||||
maxLines: 20, // Set the maximum number of lines
|
||||
autoScrollEditorIntoView: true,
|
||||
});
|
||||
editors.right.session.setOption("useWorker", false);
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- End Item -->
|
||||
{% endfor %}
|
||||
<!-- Item -->
|
||||
<div class="flex gap-x-3">
|
||||
<!-- Left Content -->
|
||||
<div class="w-24 text-end">
|
||||
<span class="text-xs text-gray-500">{{ http_function.created_at.strftime('%b %d %Y %I:%M
|
||||
%p').lstrip("0").replace("
|
||||
0", " ") }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- End Left Content -->
|
||||
|
||||
<!-- Icon -->
|
||||
<div
|
||||
class="relative last:after:hidden after:absolute after:top-7 after:bottom-0 after:start-3.5 after:w-px after:-translate-x-[0.5px] after:bg-gray-200">
|
||||
<div class="relative z-10 size-7 flex justify-center items-center">
|
||||
<div class="size-2 rounded-full bg-gray-400"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Icon -->
|
||||
|
||||
<!-- Right Content -->
|
||||
<div class="grow pt-0.5 pb-4 cursor-pointer">
|
||||
<h3 class="flex gap-x-1.5 font-semibold text-gray-800">
|
||||
v1
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-gray-600">
|
||||
</p>
|
||||
<button type="button"
|
||||
class="mt-1 -ms-1 p-1 inline-flex items-center gap-x-2 text-xs rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">
|
||||
Revert
|
||||
</button>
|
||||
</div>
|
||||
<!-- End Right Content -->
|
||||
</div>
|
||||
|
||||
<div id="diff_1_editor" class="relative rounded-lg shadow-lg p-4 text-opacity-0">{{ original_script }}</div>
|
||||
<script>
|
||||
var editor = ace.edit("diff_1_editor");
|
||||
editor.setOptions({
|
||||
maxLines: 100
|
||||
});
|
||||
editor.setTheme("ace/theme/github_dark");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
|
||||
editor.session.$worker.send("changeOptions", [{ asi: true }]);
|
||||
</script>
|
||||
<!-- End Item -->
|
||||
{% else %}
|
||||
|
||||
<!-- Item -->
|
||||
<div class="flex gap-x-3">
|
||||
<!-- Left Content -->
|
||||
<div class="w-24 text-end">
|
||||
<span class="text-xs text-gray-500">{{ http_function.created_at.strftime('%b %d %Y %I:%M
|
||||
%p').lstrip("0").replace("
|
||||
0", " ") }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- End Left Content -->
|
||||
|
||||
<!-- Icon -->
|
||||
<div
|
||||
class="relative last:after:hidden after:absolute after:top-7 after:bottom-0 after:start-3.5 after:w-px after:-translate-x-[0.5px] after:bg-gray-200">
|
||||
<div class="relative z-10 size-7 flex justify-center items-center">
|
||||
<div class="size-2 rounded-full bg-gray-400"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Icon -->
|
||||
|
||||
<!-- Right Content -->
|
||||
<div class="grow pt-0.5 pb-4 cursor-pointer">
|
||||
<h3 class="flex gap-x-1.5 font-semibold text-gray-800">
|
||||
v1
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-gray-600">
|
||||
</p>
|
||||
<button type="button"
|
||||
class="mt-1 -ms-1 p-1 inline-flex items-center gap-x-2 text-xs rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">
|
||||
Revert
|
||||
</button>
|
||||
</div>
|
||||
<!-- End Right Content -->
|
||||
|
||||
</div>
|
||||
|
||||
<div id="diff_1_editor" class="relative rounded-lg shadow-lg p-4 text-opacity-0">{{ original_script }}</div>
|
||||
<script>
|
||||
var editor = ace.edit("diff_1_editor");
|
||||
editor.setOptions({
|
||||
maxLines: 100,
|
||||
readOnly: true, // Disable editing
|
||||
highlightActiveLine: false, // Optionally, disable highlighting the active line
|
||||
highlightGutterLine: false // Optionally, disable highlighting the gutter line
|
||||
});
|
||||
editor.setTheme("ace/theme/github_dark");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
</script>
|
||||
|
||||
<!-- End Item -->
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<!-- End Timeline -->
|
||||
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 id="version-diff"></div>
|
||||
|
||||
<script>
|
||||
// Mount the Mithril component with versions as an attribute
|
||||
m.mount(document.getElementById("version-diff"), {
|
||||
view: () => m(DiffView, { versions: {{ versions| tojson }} })
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -8,10 +8,10 @@ show_edit_form=True,
|
||||
show_logs=True,
|
||||
show_client=True,
|
||||
show_history=True,
|
||||
edit_url=url_for('http.http_function_editor', function_id=function_id),
|
||||
cancel_url=url_for('http.dashboard_http_functions'),
|
||||
logs_url=url_for('http.get_http_function_logs', function_id=function_id),
|
||||
history_url=url_for('http.get_http_function_history', function_id=function_id)) }}
|
||||
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="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
|
||||
@@ -9,8 +9,8 @@ show_refresh=False,
|
||||
show_logs=False,
|
||||
show_client=False,
|
||||
show_link=False,
|
||||
dashboardUrl=url_for('http.dashboard_http_functions'),
|
||||
cancel_url=url_for('http.dashboard_http_functions'),
|
||||
dashboardUrl=url_for('http.overview'),
|
||||
cancel_url=url_for('http.overview'),
|
||||
title='New HTTP Function')
|
||||
}}
|
||||
|
||||
@@ -32,9 +32,9 @@ title='New HTTP Function')
|
||||
logRequest: {{ log_request | tojson }},
|
||||
logResponse: {{ log_response | tojson }},
|
||||
executeUrl: "{{ url_for('execute_code', playground='true') }}",
|
||||
saveUrl: "{{ url_for('http.api_create_http_function') }}",
|
||||
saveUrl: "{{ url_for('http.new') }}",
|
||||
showDeleteButton: false,
|
||||
dashboardUrl: "{{ url_for('http.dashboard_http_functions') }}"
|
||||
dashboardUrl: "{{ url_for('http.overview') }}"
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
<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.get_http_function_add_form') }}" hx-target="#container" hx-swap="innerHTML"
|
||||
hx-push-url="true">
|
||||
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>
|
||||
@@ -34,8 +33,8 @@
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center gap-2 cursor-pointer"
|
||||
hx-get="{{ url_for('http.http_function_editor', function_id=function.id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
hx-get="{{ url_for('http.editor', function_id=function.id) }}" hx-target="#container"
|
||||
hx-swap="innerHTML" hx-push-url="true">
|
||||
<span class="font-medium text-gray-900">{{ function.name }}</span>
|
||||
<span
|
||||
class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
||||
@@ -76,8 +75,8 @@
|
||||
<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('http.get_http_function_logs', function_id=function.id) }}"
|
||||
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
||||
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 mr-1.5" fill="none"
|
||||
viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
|
||||
Reference in New Issue
Block a user