Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed Oct 27, 2023
1 parent d7e51d4 commit 14a5bd0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ Before you begin, make sure you have the following software installed:

- Node.js: [https://nodejs.org/](https://nodejs.org/)
- Vue CLI: [https://cli.vuejs.org/](https://cli.vuejs.org/)
```
> npm install -D sass
```

### Installation

To use this library, you can install it via npm:

```
npm install file-upload-frontend
> npm install file-upload-frontend
```

Make sure to check the library's documentation for any additional setup or configuration steps.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@canopassoftware/file-upload-ui",
"version": "1.0.0",
"version": "1.0.1",
"description": "Show the preview of file and manage files data to upload",
"main": "src/main.ts",
"repository": {
Expand Down
7 changes: 4 additions & 3 deletions src/components/SingleFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default {
}
},
uploadingFunction() {
this.$emit('file', this.file.previewUrl)
this.$emit('file', this.file)
this.$emit('uploading', true)
this.flag = 1
},
Expand Down Expand Up @@ -158,9 +158,10 @@ export default {
}
}
this.file.previewName = file.name
reader.onerror = (error) => {
console.error(`Error reading file ${file.name}: ${error}`)
}
reader.readAsDataURL(file)
this.$emit('file', file)
},
handleDragOver(event: any) {
if (this.isUploading) {
Expand Down
9 changes: 6 additions & 3 deletions src/examples/LongSquareView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</template>

<script lang="ts">
import placeHolderImage from '../assets/images/placeholder.png'
import placeHolderImage from '../assets/images/placeholder.png' // add placeholder image on this location or you can update file path
export default {
name: 'IndexView',
Expand All @@ -108,25 +108,28 @@ export default {
placeHolderImage,
received: {} as Object,
receivedArray: [],
// it's a required thing to pass in component
isSingleFileUploading: false,
isMultipleFileUploading: false
}
},
methods: {
receiveFile(file: any) {
this.received = file
this.received = file // here you will get the file from preview
},
receiveFilesArray(array: []) {
this.receivedArray = array
this.receivedArray = array // here you will get all the files from preview
},
singleFileUploadingStatus(isUploading: any) {
this.isSingleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isSingleFileUploading = !isUploading
}, 5000)
},
multipleFileUploadingStatus(isUploading: any) {
this.isMultipleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isMultipleFileUploading = !isUploading
}, 5000)
Expand Down
9 changes: 6 additions & 3 deletions src/examples/RoundView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</template>

<script lang="ts">
import placeHolderImage from '../assets/images/placeholder.png'
import placeHolderImage from '../assets/images/placeholder.png' // add placeholder image on this location or you can update file path
export default {
name: 'IndexView',
Expand All @@ -120,25 +120,28 @@ export default {
placeHolderImage,
received: {} as Object,
receivedArray: [],
// it's a required thing to pass in component
isSingleFileUploading: false,
isMultipleFileUploading: false
}
},
methods: {
receiveFile(file: any) {
this.received = file
this.received = file // here you will get the file from preview
},
receiveFilesArray(array: []) {
this.receivedArray = array
this.receivedArray = array // here you will get all the files from preview
},
singleFileUploadingStatus(isUploading: any) {
this.isSingleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isSingleFileUploading = !isUploading
}, 5000)
},
multipleFileUploadingStatus(isUploading: any) {
this.isMultipleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isMultipleFileUploading = !isUploading
}, 5000)
Expand Down
9 changes: 6 additions & 3 deletions src/examples/SquareView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</template>

<script lang="ts">
import placeHolderImage from '../assets/images/placeholder.png'
import placeHolderImage from '../assets/images/placeholder.png' // add placeholder image on this location or you can update file path
export default {
name: 'IndexView',
Expand All @@ -120,25 +120,28 @@ export default {
placeHolderImage,
received: {} as Object,
receivedArray: [],
// it's a required thing to pass in component
isSingleFileUploading: false,
isMultipleFileUploading: false
}
},
methods: {
receiveFile(file: any) {
this.received = file
this.received = file // here you will get the file from preview
},
receiveFilesArray(array: []) {
this.receivedArray = array
this.receivedArray = array // here you will get all the files from preview
},
singleFileUploadingStatus(isUploading: any) {
this.isSingleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isSingleFileUploading = !isUploading
}, 5000)
},
multipleFileUploadingStatus(isUploading: any) {
this.isMultipleFileUploading = isUploading
// remove setTimeout and add your uploading logic here, when you successfully uploaded all the files, update the value of isUploading = false
setTimeout(() => {
this.isMultipleFileUploading = !isUploading
}, 5000)
Expand Down

0 comments on commit 14a5bd0

Please sign in to comment.