11<template >
22 <div >
3- <div class =" code-editor" >
3+ <div class =" overflow-y-hidden code-editor" >
44 <code-editor :code =" parsedCode" @keyup.ctrl.enter =" runTheCode()" lang =" python" @edit =" updateCode($event)"
55 :hljs =" hljs" ></code-editor >
66 </div >
77 <div v-if =" controls == true" >
8- <button class =" border code-exec-btn btn neuro" :class = " (canRun && !isExecuting) ? 'cursor-pointer' : 'cursor-wait' "
9- @click =" runTheCode()" >
8+ <button class =" border code-exec-btn btn neuro focus:ring-0 "
9+ :class = " (canRun && !isExecuting) ? 'cursor-pointer' : 'cursor-wait' " @click =" runTheCode()" >
1010 <template v-if =" ! canRun " >
1111 <app-icon name =" play" class =" inline-block text-xl txt-lighter" ></app-icon >
1212 </template >
1515 <app-icon name =" play" class =" inline-block text-xl txt-success" ></app-icon >
1616 </template >
1717 <template v-else >
18- <app-icon name =" python" class =" inline-block text-xl txt-danger" ></app-icon >
18+ <template v-if =" log .id == id " >
19+ <app-icon name =" python" class =" inline-block text-xl txt-danger" ></app-icon >
20+ </template >
21+ <template v-else >
22+ <app-icon name =" play" class =" inline-block text-xl txt-lighter" ></app-icon >
23+ </template >
1924 </template >
2025 </template >
2126   ; Execute
2227 </button >
28+ <!-- button class="ml-2 cursor-pointer neuro btn" v-if="namespace && controlsClear" @click="clear()">Clear</button -->
2329 </div >
24- <div class =" flex flex-col code-output" >
25- <div v-if =" stdout == true && outputHtml " >
30+ <div class =" flex flex-col code-output" :class = " bottomMargin " >
31+ <div v-if =" stdout == true && log.stdOut.length > 0 " >
2632 <pre v-for =" row in log.stdOut" v-html =" row" ></pre >
2733 </div >
28- <div v-if =" stderr == true" >
34+ <div v-if =" stderr == true && log.stdErr.length > 0 " >
2935 <pre v-for =" row in log.stdErr" v-html =" row" ></pre >
3036 </div >
31- <div v-if =" exception == true && log.exception" v-html =" log.exception" ></div >
37+ <div v-if =" exception == true && log.exception" >
38+ <pre v-html =" log.exception" ></pre >
39+ </div >
3240 <div v-if =" output == true && outputHtml" v-html =" outputHtml" ></div >
3341 </div >
3442 </div >
@@ -59,10 +67,18 @@ const props = defineProps({
5967 type: String ,
6068 required: true ,
6169 },
70+ namespace: {
71+ type: String ,
72+ default: null ,
73+ },
6274 controls: {
6375 type: Boolean ,
6476 default: true ,
6577 },
78+ /* controlsClear: {
79+ type: Boolean,
80+ default: false,
81+ },*/
6682 output: {
6783 type: Boolean ,
6884 default: true ,
@@ -106,7 +122,7 @@ async function runTheCode() {
106122 if (! canRun ) {
107123 return
108124 }
109- const { results, error } = await props .py .run (parsedCode .value , props .id );
125+ const { results, error } = await props .py .run (parsedCode .value , props .namespace , props . id );
110126 if (results ) {
111127 // console.log("RES TYPE", typeof results, results);
112128 let res = " " ;
@@ -128,6 +144,11 @@ async function runTheCode() {
128144 }
129145};
130146
147+ function clear() {
148+ props .py .clear (props .namespace );
149+ outputHtml .value = " " ;
150+ }
151+
131152const canRun = computed <Boolean >(() => {
132153 // return isReady.value == true && isExecuting.value == false
133154 return isReady .value == true
@@ -142,19 +163,17 @@ const unbindLog = props.py.log.listen((val) => {
142163 }
143164});
144165
166+ const bottomMargin = computed <string >(() => {
167+ let m = " " ;
168+ if (outputHtml || (outputHtml || log .stdOut .length > 0 || log .stdErr .length > 0 )) {
169+ m = " filled"
170+ }
171+ return m
172+ })
173+
145174onBeforeUnmount (() => unbindLog ())
146175watchEffect (() => {
147176 parsedCode .value = props .code
148177 outputHtml .value = " " ;
149178})
150179 </script >
151-
152- <style lang="sass" scoped>
153- .code-exec-btn
154- @apply mt-2
155- .code-output
156- @apply pl-8 space-y-2
157- .btn.neuro
158- @apply rounded-lg block-background shadow-[-2px_-2px_10px_rgba(255,255,255,1),3px_3px_10px_rgba(0,0,0,0.2 )] active:shadow-[inset_-2px_-2px_5px_rgba(255,255,255,0.7 ),inset_3px_3px_5px_rgba(0,0,0,0.1 )]
159- @apply dark:shadow-[-2px_-2px_10px_rgba(155,155,155,0.3 ),3px_3px_10px_rgba(10,10,10,1)]
160- </style >
0 commit comments