Skip to content

Commit 9d59284

Browse files
committed
commented out electron functionality
1 parent bd7b9e8 commit 9d59284

File tree

1 file changed

+71
-18
lines changed

1 file changed

+71
-18
lines changed

src/components/UploadImage.vue

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@
33
<q-list>
44
<q-expansion-item dense dense-toggle expand-separator label="Upload Mockup Image">
55
<div class="upload">
6-
<q-btn class="upload-btn" color="secondary" label="Upload Mockup" @click="importMockup" />
6+
<!-- for electron, below is for browser usage
7+
<q-btn class="upload-btn" color="secondary" label="Upload Mockup" @click="importMockup" />-->
8+
<form enctype="multipart/form-data" action="/upload/image" method="post">
9+
<input
10+
type="file"
11+
class="browser-btn"
12+
ref="myFiles"
13+
accept="image/*"
14+
@change="importMockupBrowser"
15+
/>
16+
</form>
717
<q-btn
818
v-if="imageExists"
919
class="upload-btn"
1020
color="secondary"
1121
label="Clear Image"
12-
@click="removeImage"
22+
@click="removeImageBrowser"
1323
/>
24+
<!-- for electron
25+
<q-btn
26+
v-if="imageExists"
27+
class="upload-btn"
28+
color="secondary"
29+
label="Clear Image"
30+
@click="removeImage"
31+
/>-->
1432
<q-btn v-else disable class="upload-btn" color="secondary" label="Clear Image" />
1533
</div>
1634
<div class="file-path">
@@ -29,56 +47,91 @@
2947
</template>
3048

3149
<script>
32-
import { mapState, mapActions } from 'vuex'
33-
import uploadImage from '../utils/uploadImage.util'
34-
import clearImageDialog from '../utils/clearImage.util'
50+
import { mapState, mapActions } from "vuex";
51+
/**
52+
* Electron functionality
53+
*/
54+
// import uploadImage from '../utils/uploadImage.util'
55+
// import clearImageDialog from '../utils/clearImage.util'
3556
3657
export default {
37-
name: 'upload-image',
58+
name: "upload-image",
59+
data() {
60+
return {
61+
files: []
62+
};
63+
},
3864
computed: {
39-
...mapState(['imagePath']),
40-
imageExists () {
41-
return this.imagePath.length
65+
...mapState(["imagePath"]),
66+
imageExists() {
67+
return this.imagePath.length;
4268
}
4369
},
4470
methods: {
45-
...mapActions(['importImage', 'clearImage']),
46-
importMockup () {
47-
const img = uploadImage()
48-
this.importImage(img)
71+
...mapActions(["importImage", "clearImage"]),
72+
/**
73+
* @description: for use with electron
74+
*/
75+
importMockup() {
76+
// const img = uploadImage()
77+
// this.importImage(img)
78+
},
79+
removeImage() {
80+
// const res = clearImageDialog()
81+
// if (res === 0) this.clearImage()
82+
},
83+
/**
84+
* @description: for use with the browser
85+
* currently needs an approach for storing the file on the browser..
86+
* also, needs async functionality to update state in store (yet we cant even save the file so its useless, gonna check out local storage)
87+
*/
88+
async importMockupBrowser() {
89+
console.log(`importMockupBrowser: ${this.$refs.myFiles.files}`);
90+
this.files = this.$refs.myFiles.files[0];
91+
await this.importImage(this.files.name);
92+
await console.log(this.files.name);
4993
},
50-
removeImage () {
51-
const res = clearImageDialog()
52-
if (res === 0) this.clearImage()
94+
removeImageBrowser() {
95+
this.clearImage();
5396
}
5497
}
55-
}
98+
};
5699
</script>
57100

58-
<style>
101+
<style lang="stylus">
59102
.home-sidebar {
60103
margin: 1rem;
61104
justify-content: center;
62105
border-radius: 5px;
63106
}
107+
64108
.upload-btn {
65109
text-transform: capitalize;
66110
font-size: 12px;
67111
}
112+
68113
.upload {
69114
margin: 0.5rem;
70115
display: flex;
71116
justify-content: space-evenly;
72117
}
118+
73119
.file-path {
74120
padding-bottom: 1rem;
75121
margin: 1rem;
76122
font-size: 11px;
77123
}
124+
78125
.file-header {
79126
padding-left: 0.4em;
80127
}
128+
81129
.file-content {
82130
padding: 0em 1em 1em 1em;
83131
}
132+
133+
.browser-btn {
134+
width: 90px;
135+
background: $secondary;
136+
}
84137
</style>

0 commit comments

Comments
 (0)