Skip to content

Commit 592d66c

Browse files
committed
[#28] add loading on change metric
1 parent 7224b3a commit 592d66c

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

components/ProfilerPageCallGraph/ProfilerPageCallGraph.vue

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
class="profiler-page-call-graph"
44
:class="{ 'profiler-page-call-graph--fullscreen': isFullscreen }"
55
>
6+
<div v-if="metricLoading" class="profiler-page-call-graph__loading-wr">
7+
<div class="profiler-page-call-graph__loading">
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
</div>
12+
</div>
13+
614
<div ref="graphviz" class="profiler-page-call-graph__graphviz"></div>
15+
716
<div class="profiler-page-call-graph__toolbar">
817
<button title="Full screen" @click="isFullscreen = !isFullscreen">
918
<IconSvg
@@ -14,21 +23,21 @@
1423
<button
1524
class="profiler-page-call-graph__toolbar-action"
1625
:class="{ 'font-bold': metric === 'cpu' }"
17-
@click="metric = 'cpu'"
26+
@click="setMetric('cpu')"
1827
>
1928
CPU
2029
</button>
2130
<button
2231
class="profiler-page-call-graph__toolbar-action"
2332
:class="{ 'font-bold': metric === 'pmu' }"
24-
@click="metric = 'pmu'"
33+
@click="setMetric('pmu')"
2534
>
2635
Memory change
2736
</button>
2837
<button
2938
class="profiler-page-call-graph__toolbar-action"
3039
:class="{ 'font-bold': metric === 'mu' }"
31-
@click="metric = 'mu'"
40+
@click="setMetric('mu')"
3241
>
3342
Memory usage
3443
</button>
@@ -60,16 +69,14 @@ export default defineComponent({
6069
return {
6170
isFullscreen: false,
6271
metric: "cpu",
72+
metricLoading: false,
6373
threshold: 1,
6474
};
6575
},
6676
watch: {
6777
threshold(): void {
6878
this.renderGraph();
6979
},
70-
metric(): void {
71-
this.renderGraph();
72-
},
7380
},
7481
created(): void {
7582
this.renderGraph();
@@ -78,6 +85,15 @@ export default defineComponent({
7885
this.graph.destroy();
7986
},
8087
methods: {
88+
setMetric(metric: string): void {
89+
this.metricLoading = true;
90+
91+
setTimeout(() => {
92+
this.metric = metric;
93+
this.renderGraph();
94+
this.metricLoading = false;
95+
}, 0);
96+
},
8197
buildDigraph(): string {
8298
const builder = new DigraphBuilder(this.event.edges);
8399
@@ -131,6 +147,8 @@ export default defineComponent({
131147
</script>
132148

133149
<style lang="scss" scoped>
150+
@import "assets/mixins";
151+
134152
.profiler-page-call-graph {
135153
@apply relative flex rounded border border-gray-900 h-full;
136154
}
@@ -153,6 +171,16 @@ export default defineComponent({
153171
@apply text-xs uppercase text-gray-600;
154172
}
155173
174+
.profiler-page-call-graph__loading-wr {
175+
@apply absolute m-auto top-0 left-0 right-0 bottom-0 flex justify-center items-center;
176+
}
177+
178+
.profiler-page-call-graph__loading {
179+
@apply z-50;
180+
181+
@include loading;
182+
}
183+
156184
.profiler-page-call-graph__graphviz {
157185
@apply flex-1 justify-items-stretch items-stretch bg-white;
158186

0 commit comments

Comments
 (0)