Files
dragonroll/frontend/app/components/viewer/statusbar/FetchStatus.vue
Aran Roig 1ec29121e1
Some checks failed
Test / test (push) Failing after 2s
Build and Deploy Nuxt / build (push) Successful in 1m51s
Deploy deepseek 2
2026-10-19 19:04:28 +02:00

44 lines
1.1 KiB
Vue

<script setup>
import { ref,onMounted,onUnmounted } from 'vue';
import { emitter } from '~/services/Emitter';
const statusIcon = ref(null);
const statusMessage = ref(null);
const handleStatusUpdate = (state) => {
var preloadImage = new Image();
preloadImage.src = '/icons/Pixelarticons/black/' + state.icon + ".svg";
preloadImage.onload = function() {
// The update can arrive (or finish loading) while the bar is not mounted.
if (statusIcon.value) statusIcon.value.src = this.src;
};
if (statusMessage.value) statusMessage.value.innerText = state.text;
};
emitter.on("status-bar-update", handleStatusUpdate);
onMounted(() => {
emitter.emit("status-bar-update", {text: "Hola", icon: "check"})
});
onUnmounted(() => emitter.off("status-bar-update", handleStatusUpdate));
</script>
<template>
<span class="status-text">
<img class="icon" ref="statusIcon" src=""/>
<span class="status-message" ref="statusMessage"></span>
</span>
</template>
<style scoped>
.status-text {
margin-left: 10px;
flex-direction: column;
justify-content: center;
}
.status-message {
margin-left: 5px;
}
</style>