Skip to content

Commit

Permalink
Merge events bus into a single one
Browse files Browse the repository at this point in the history
  • Loading branch information
BitK committed Jul 19, 2021
1 parent 72535ca commit edd65c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</template>

<script>
import { DownloaderBus, UploaderBus } from "src/eventBus.js";
import { GlobalBus } from "src/eventBus.js";
import api from "src/api";
export default {
props: {
Expand All @@ -47,21 +47,21 @@ export default {
}
},
methods: {
async downloadFile() {
downloadFile() {
const info = {
volume: this.volumeName,
path: this.node.fullpath,
file: this.node.file
};
await DownloaderBus.$emit("startDownload", info);
GlobalBus.$emit("startFileDownload", info);
},
async uploadFile() {
uploadFile() {
const info = {
volume: this.volumeName,
path: this.folderPath
};
UploaderBus.$emit("startUpload", info);
GlobalBus.$emit("startFileUpload", info);
},
async deleteFile() {
const input = {
Expand Down
7 changes: 5 additions & 2 deletions dockers/manager/front/src/components/Downloader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
</template>

<script>
import { DownloaderBus } from "src/eventBus.js";
import { GlobalBus } from "src/eventBus.js";
export default {
data: () => ({ value: 0, downloading: [] }),
created() {
DownloaderBus.$on("startDownload", (info) => this.downloadFile(info));
GlobalBus.$on("startFileDownload", this.downloadFile);
},
destroyed() {
GlobalBus.$off("startFileDownload", this.downloadFile);
},
methods: {
downloadBlob(blob, downloadInfo) {
Expand Down
11 changes: 7 additions & 4 deletions dockers/manager/front/src/components/Uploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</template>

<script>
import { UploaderBus } from "src/eventBus.js";
import { GlobalBus } from "src/eventBus.js";
export default {
props: {},
Expand All @@ -31,11 +31,14 @@ export default {
}
]
},
created() {
UploaderBus.$on("startUpload", info => this.startUpload(info));
created () {
GlobalBus.$on("startFileUpload", this.startUpload);
},
destroyed () {
GlobalBus.$off("startFileUpload", this.startUpload);
},
methods: {
startUpload({ volume, path }) {
startUpload ({ volume, path }) {
const params = new URLSearchParams({ volume, path });
this.url = `/file/upload?${params}`;
this.title = `Upload in ${path}`;
Expand Down

0 comments on commit edd65c2

Please sign in to comment.