1
1
<script setup lang="ts">
2
- import { onMounted , ref , watch } from ' vue'
3
2
import { useStore } from ' @modules/script/store'
4
3
5
- import SOutput from ' ./SOutput.vue'
6
- import MEditor from ' @modules/monaco/components/MEditor.vue'
7
- import VChart from ' @/components/v-chart.vue'
8
4
import EvaluationOutput from ' @core/entities/evaluation-output'
9
5
6
+ import VChart from ' @components/VChart.vue'
7
+ import MEditor from ' @modules/monaco/components/MEditor.vue'
8
+ import SOutput from ' ./SOutput.vue'
9
+
10
10
// Props & Emits
11
11
12
12
defineProps ({
@@ -48,17 +48,17 @@ const current = ref<'chart' | 'debug' | 'raw'>('chart')
48
48
// execute script
49
49
const store = useStore ()
50
50
51
- const output = ref <EvaluationOutput >({
52
- error: null ,
53
- result: null ,
54
- logs: [],
55
- })
51
+ const output = ref (new EvaluationOutput ())
56
52
57
53
async function execute() {
58
- output . value = await store .execute ({
54
+ const response = await store .execute ({
59
55
content: content .value ,
60
56
})
61
57
58
+ output .value .error = response .error
59
+ output .value .result = response .result
60
+ output .value .logs = response .logs
61
+
62
62
if (output .value .error || ! output .value .result ) {
63
63
current .value = ' debug'
64
64
}
@@ -72,13 +72,16 @@ const chart = ref({
72
72
options: null ,
73
73
})
74
74
75
- watch (output , (value ) => {
76
- chart .value .loading = true
75
+ watch (
76
+ () => output .value .result ,
77
+ (value ) => {
78
+ chart .value .loading = true
77
79
78
- chart .value .options = value . result
80
+ chart .value .options = value
79
81
80
- setTimeout (() => (chart .value .loading = false ), 800 )
81
- })
82
+ setTimeout (() => (chart .value .loading = false ), 800 )
83
+ }
84
+ )
82
85
83
86
// refresh chart
84
87
const chartRef = ref <InstanceType <typeof VChart > | null >()
@@ -102,19 +105,24 @@ function refresh() {
102
105
{{ title }}
103
106
</v-card-title >
104
107
105
- <v-btn text size =" sm" class =" ml-auto text-t-secondary" @click =" current = 'chart'" >
108
+ <v-btn
109
+ mode =" text"
110
+ size =" xs"
111
+ class =" ml-auto text-t-secondary"
112
+ @click =" current = 'chart'"
113
+ >
106
114
<v-icon name =" chart-pie" />
107
115
</v-btn >
108
116
109
- <v-btn text size =" sm " class =" text-t-secondary" @click =" refresh" >
117
+ <v-btn mode = " text" size =" xs " class =" text-t-secondary" @click =" refresh" >
110
118
<v-icon name =" rotate" />
111
119
</v-btn >
112
120
113
- <v-btn text size =" sm " class =" text-t-secondary" @click =" current = 'raw'" >
121
+ <v-btn mode = " text" size =" xs " class =" text-t-secondary" @click =" current = 'raw'" >
114
122
<v-icon name =" code" />
115
123
</v-btn >
116
124
117
- <v-btn text size =" sm " class =" text-t-secondary" @click =" current = 'debug'" >
125
+ <v-btn mode = " text" size =" xs " class =" text-t-secondary" @click =" current = 'debug'" >
118
126
<v-icon name =" check-circle" />
119
127
</v-btn >
120
128
</v-card-head >
0 commit comments