From 609996d1757bb48744f0c7f8c3fe44ed37214ccc Mon Sep 17 00:00:00 2001 From: constraintAutomaton Date: Sun, 30 Jan 2022 12:49:16 -0500 Subject: [PATCH] In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE --- .../download-settings/download-settings.js | 49 ++++++++ .../download-settings/download-settings.sass | 8 ++ .../download-settings/download-settings.vue | 37 ++++++ .../ft-icon-button/ft-icon-button.js | 24 +++- src/renderer/components/ft-toast/ft-toast.js | 8 +- .../ft-video-player/ft-video-player.js | 1 - .../watch-video-info/watch-video-info.js | 3 +- .../watch-video-info/watch-video-info.vue | 3 +- src/renderer/store/modules/settings.js | 3 +- src/renderer/store/modules/utils.js | 114 +++++++++++++++++- src/renderer/views/Settings/Settings.js | 4 +- src/renderer/views/Settings/Settings.vue | 2 + static/locales/en-US.yaml | 9 ++ static/locales/fr-FR.yaml | 10 ++ 14 files changed, 267 insertions(+), 8 deletions(-) create mode 100644 src/renderer/components/download-settings/download-settings.js create mode 100644 src/renderer/components/download-settings/download-settings.sass create mode 100644 src/renderer/components/download-settings/download-settings.vue diff --git a/src/renderer/components/download-settings/download-settings.js b/src/renderer/components/download-settings/download-settings.js new file mode 100644 index 00000000..96c67535 --- /dev/null +++ b/src/renderer/components/download-settings/download-settings.js @@ -0,0 +1,49 @@ +import Vue from 'vue' +import FtFlexBox from '../ft-flex-box/ft-flex-box.vue' +import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue' +import FtButton from '../ft-button/ft-button.vue' +import FtInput from '../ft-input/ft-input.vue' +import { mapActions } from 'vuex' +import { ipcRenderer } from 'electron' +import { IpcChannels } from '../../../constants' + +export default Vue.extend({ + name: 'DownloadSettings', + components: { + 'ft-toggle-switch': FtToggleSwitch, + 'ft-flex-box': FtFlexBox, + 'ft-button': FtButton, + 'ft-input': FtInput + }, + data: function () { + return { + askForDownloadPath: this.$store.getters.getDownloadFolderPath === '' + } + }, + computed: { + downloadPath: function() { + return this.$store.getters.getDownloadFolderPath + } + }, + methods: { + handleDownloadingSettingChange: function (value) { + this.askForDownloadPath = value + if (value === true) { + this.updateDownloadFolderPath('') + } + }, + chooseDownloadingFolder: async function() { + // only use with electron + const folder = await ipcRenderer.invoke( + IpcChannels.SHOW_OPEN_DIALOG, + { properties: ['openDirectory'] } + ) + + this.updateDownloadFolderPath(folder.filePaths[0]) + }, + ...mapActions([ + 'updateDownloadFolderPath' + ]) + } + +}) diff --git a/src/renderer/components/download-settings/download-settings.sass b/src/renderer/components/download-settings/download-settings.sass new file mode 100644 index 00000000..330bf087 --- /dev/null +++ b/src/renderer/components/download-settings/download-settings.sass @@ -0,0 +1,8 @@ +@use "../../sass-partials/settings" + +@media only screen and (max-width: 500px) + .downloadSettingsFlexBox + justify-content: flex-start + +.folderDisplay + width: 50vh diff --git a/src/renderer/components/download-settings/download-settings.vue b/src/renderer/components/download-settings/download-settings.vue new file mode 100644 index 00000000..c55e314e --- /dev/null +++ b/src/renderer/components/download-settings/download-settings.vue @@ -0,0 +1,37 @@ + + +