Skip to content

Commit

Permalink
Add drag and drop support for verify tab
Browse files Browse the repository at this point in the history
  • Loading branch information
luk1337 committed Dec 26, 2023
1 parent d6728b6 commit c2cb7c2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/components/verify-main/VerifyTabPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="tab-page verify-tab-page">
<div class="tab-page verify-tab-page" ondragover="event.preventDefault()" v-on:drop="fileDropped">
<a href="#" class="verify-icon" v-on:click="verifyClicked">Verify OTA package signature</a>
<form ref="form">
<input type="file" ref="input" style="display: none;" />
Expand All @@ -14,7 +14,18 @@ export default {
name: 'ErrorMain',
mounted() {
const input = this.$refs.input;
input.onchange = () => {
input.onchange = () => this.verifyFile(input.files[0]);
},
methods: {
fileDropped(event) {
event.preventDefault();
this.verifyFile(event.dataTransfer.files[0]);
},
verifyClicked() {
const input = this.$refs.input;
input.click();
},
verifyFile(blob) {
const fileReader = new FileReader();
fileReader.onload = async () => {
const result = await CryptoService.verifyPackage(await fileReader.result);
Expand All @@ -23,14 +34,8 @@ export default {
const form = this.$refs.form;
form.reset();
};
fileReader.readAsArrayBuffer(input.files[0]);
};
},
methods: {
verifyClicked() {
const input = this.$refs.input;
input.click();
},
fileReader.readAsArrayBuffer(blob);
}
}
}
</script>
Expand Down

0 comments on commit c2cb7c2

Please sign in to comment.