downloading the file to flash

This commit is contained in:
2025-11-26 22:36:20 +00:00
parent 139b198d54
commit 326540671b
4 changed files with 120 additions and 111 deletions

View File

@@ -5,15 +5,34 @@ import updater from "@/utils/updater";
import {IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle} from "@ionic/vue";
import { onBeforeMount, ref } from "vue";
const emit = defineEmits<{(e:"back"):void}>();
const emit = defineEmits<{(e:"back"):void, (e: "home"):void}>();
const archive = useArchiveStore();
const view = ref<number>(0);
const version = ref<string>("");
const logValue = ref<string>("");
const back = () => {
emit("back");
}
async function flash() {
view.value = 1;
logValue.value = "Downloading file";
await updater.obj.getFirmware( archive.getArchive[archive.getShownI]);
logValue.value = "File recieved";
logValue.value = "Starting to flash (0%)";
const fileSize = updater.obj.getFileSize();
logValue.value = `FileSize: ${fileSize}`;
// await updater.obj.flashFirmware();
// logValue.value = "Flash complete!";
view.value = 2;
}
function home() {
emit("home");
}
onBeforeMount(async () => {
version.value = await updater.obj.getBoardVersion();
});
@@ -35,9 +54,21 @@ onBeforeMount(async () => {
<ion-card-content>
<p>{{ version }} -> {{ archive.getArchive[archive.getShownI].title }}</p> <br>
<ion-button>Flash</ion-button>
<!-- BEFORE FLASHING -->
<ion-button @click="flash" v-if="view==0">Flash</ion-button>
<ion-button @click="back" v-if="view==0">Cancel</ion-button>
<!-- DURING FLASHING -->
<p v-if="view!=0">Status info</p><br />
<p v-if="view!=0">{{ logValue }}</p>
<!-- AFTER FLASHING -->
<ion-button @click="home" v-if="view==2">Finish</ion-button>
<ion-button @click="back">Cancel</ion-button>
</ion-card-content>
</ion-card>
</template>