2024-10-12 23:14:12 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import CodeExecutionModal from './CodeExecutionModal.svelte';
|
|
|
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
|
|
|
|
2024-10-14 06:16:51 +00:00
|
|
|
export let codeExecutions = [];
|
2024-10-12 23:14:12 +00:00
|
|
|
|
|
|
|
|
let selectedCodeExecution = null;
|
|
|
|
|
let showCodeExecutionModal = false;
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-10-14 06:16:51 +00:00
|
|
|
<CodeExecutionModal bind:show={showCodeExecutionModal} codeExecution={selectedCodeExecution} />
|
2024-10-12 23:14:12 +00:00
|
|
|
|
2024-10-14 06:16:51 +00:00
|
|
|
{#if codeExecutions.length > 0}
|
2024-10-12 23:14:12 +00:00
|
|
|
<div class="mt-1 mb-2 w-full flex gap-1 items-center flex-wrap">
|
2024-10-14 06:16:51 +00:00
|
|
|
{#each codeExecutions.map((execution) => {
|
|
|
|
|
let error = null;
|
|
|
|
|
let output = null;
|
|
|
|
|
let files = [];
|
|
|
|
|
let status = 'PENDING';
|
|
|
|
|
|
|
|
|
|
if (execution.result) {
|
|
|
|
|
output = execution.result.output;
|
|
|
|
|
if (execution.result.error) {
|
|
|
|
|
status = 'ERROR';
|
|
|
|
|
error = execution.result.error;
|
|
|
|
|
} else {
|
|
|
|
|
status = 'OK';
|
|
|
|
|
}
|
|
|
|
|
if (execution.result.files) {
|
|
|
|
|
files = execution.result.files;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { id: execution.id, name: execution.name, code: execution.code, language: execution.language || '', status: status, error: error, output: output, files: files };
|
|
|
|
|
}) as execution (execution.id)}
|
2024-10-12 23:14:12 +00:00
|
|
|
<div class="flex gap-1 text-xs font-semibold">
|
|
|
|
|
<button
|
|
|
|
|
class="flex dark:text-gray-300 py-1 px-1 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-xl max-w-96"
|
|
|
|
|
on:click={() => {
|
2024-10-14 06:16:51 +00:00
|
|
|
selectedCodeExecution = execution;
|
2024-10-12 23:14:12 +00:00
|
|
|
showCodeExecutionModal = true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class="bg-white dark:bg-gray-700 rounded-full size-4">
|
2024-10-14 06:16:51 +00:00
|
|
|
{#if execution.status == 'OK'}
|
2024-10-12 23:14:12 +00:00
|
|
|
✅ <!-- Checkmark -->
|
2024-10-14 06:16:51 +00:00
|
|
|
{:else if execution.status == 'ERROR'}
|
2024-10-12 23:14:12 +00:00
|
|
|
❌ <!-- X mark -->
|
2024-10-14 06:16:51 +00:00
|
|
|
{:else if execution.status == 'PENDING'}
|
2024-10-12 23:14:12 +00:00
|
|
|
<Spinner className="size-4" />
|
|
|
|
|
{:else}
|
|
|
|
|
⁉️ <!-- Interrobang -->
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
2024-10-14 06:16:51 +00:00
|
|
|
class="flex-1 mx-2 line-clamp-1 code-execution-name {execution.status == 'PENDING'
|
2024-10-12 23:14:12 +00:00
|
|
|
? 'pulse'
|
|
|
|
|
: ''}"
|
|
|
|
|
>
|
2024-10-14 06:16:51 +00:00
|
|
|
{execution.name}
|
2024-10-12 23:14:12 +00:00
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
@keyframes pulse {
|
|
|
|
|
0%,
|
|
|
|
|
100% {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
50% {
|
|
|
|
|
opacity: 0.6;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pulse {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
animation: pulse 1.5s ease;
|
|
|
|
|
}
|
|
|
|
|
</style>
|