-
-
Notifications
You must be signed in to change notification settings - Fork 77
Add config to select source directories #2319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+739
−406
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e038644
Add config to select source directories
artonge bc85b66
Use store to manage user config
artonge d96558f
use userConfig store in all components
artonge e3c3926
Update photosLocationFolder when photosLocation change
artonge 8f16b06
Restrict source folder selection to 1
artonge aec5811
Use photosSourceFolder in photos search
artonge 2cebaf0
Run lint:fix
artonge c357cb2
Update root folder icon and label for upload location
artonge 3e0a2d3
Fix lint errors
artonge 1cbfa65
Upload test images in the /Photos directory
artonge 289c4b8
Remove warning during compilation
artonge 57aea9b
Improve errors handling
artonge b110ae7
Compile assets
artonge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add config to select source directories
Signed-off-by: Louis Chemineau <[email protected]>
- Loading branch information
commit e038644eb1691a48fd1a553accb64cbeecebb2fe
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| <template> | ||
| <div class="folder"> | ||
| <FolderMultiple v-if="path === '/'" /> | ||
| <Folder v-else /> | ||
| <span class="folder__info"> | ||
| <div class="folder__path">{{ folderName }}</div> | ||
| <div v-if="subname !== ''"> | ||
| {{ subname }} | ||
| </div> | ||
| </span> | ||
| <NcButton v-if="canDelete" | ||
| type="tertiary" | ||
| :aria-label="t('photos', 'Delete source directory')" | ||
| @click="emitRemoveSourceFolder"> | ||
| <template #icon> | ||
| <Close :size="20" /> | ||
| </template> | ||
| </NcButton> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { defineComponent } from 'vue' | ||
|
|
||
| import Folder from 'vue-material-design-icons/Folder.vue' | ||
| import FolderMultiple from 'vue-material-design-icons/FolderMultiple.vue' | ||
| import Close from 'vue-material-design-icons/Close.vue' | ||
|
|
||
| import { NcButton } from '@nextcloud/vue' | ||
| import { translate as t } from '@nextcloud/l10n' | ||
|
|
||
| export default defineComponent({ | ||
| name: 'PhotosFolder', | ||
|
|
||
| components: { | ||
| NcButton, | ||
| Folder, | ||
| FolderMultiple, | ||
| Close, | ||
| }, | ||
|
|
||
| props: { | ||
| path: { | ||
| type: String, | ||
| required: true, | ||
| }, | ||
| canDelete: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| }, | ||
|
|
||
| emits: ['remove-folder'], | ||
|
|
||
| computed: { | ||
| folderName() { | ||
| if (this.path === '/') { | ||
| return t('photos', 'All folders') | ||
| } else { | ||
| return this.path.split('/').pop() | ||
| } | ||
| }, | ||
|
|
||
| /** | ||
| * Return the summary path of the folder | ||
| * Examples: | ||
| * - / ==> Home | ||
| * - /a ==> nothing | ||
| * - /a/b ==> /a | ||
| * - /a/b/c ==> /a/b | ||
| * - /a/b/c/d ==> /a/b | ||
| */ | ||
| subname() { | ||
| const slashesCount = (this.path.match(/\//g) ?? []).length | ||
|
|
||
| switch (slashesCount) { | ||
| case 1: | ||
| return '' | ||
| case 2: | ||
| return this.path.split('/').splice(0, 2).join('/') | ||
| default: | ||
| return this.path.split('/').splice(0, 3).join('/') | ||
| } | ||
| }, | ||
| }, | ||
|
|
||
| methods: { | ||
| emitRemoveSourceFolder() { | ||
| this.$emit('remove-folder') | ||
| }, | ||
|
|
||
| t, | ||
| }, | ||
| }) | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .folder { | ||
| display: flex; | ||
| gap: 16px; | ||
| min-width: 300px; | ||
|
|
||
| &__info { | ||
| display: flex; | ||
| flex-direction: column; | ||
| flex-grow: 1; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| &__path { | ||
| font-weight: bold; | ||
| } | ||
| } | ||
| </style> | ||
114 changes: 114 additions & 0 deletions
114
src/components/Settings/PhotosSourceLocationsSettings.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license AGPL-3.0-or-later | ||
| - | ||
| - This program is free software: you can redistribute it and/or modify | ||
| - it under the terms of the GNU Affero General Public License as | ||
| - published by the Free Software Foundation, either version 3 of the | ||
| - License, or (at your option) any later version. | ||
| - | ||
| - This program is distributed in the hope that it will be useful, | ||
| - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| - GNU Affero General Public License for more details. | ||
| - | ||
| - You should have received a copy of the GNU Affero General Public License | ||
| - along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| - | ||
| --> | ||
|
|
||
| <template> | ||
| <div class="photos-locations"> | ||
| <ul> | ||
| <li v-for="(source, index) in photosSourceFolders" | ||
| :key="index"> | ||
| <PhotosFolder :path="source" :can-delete="photosSourceFolders.length !== 1" @remove-folder="removeSourceFolder(index)" /> | ||
| </li> | ||
| </ul> | ||
|
|
||
| <NcButton :aria-label="t('photos', 'Add source directory')" | ||
| @click="debounceAddSourceFolder"> | ||
| <template #icon> | ||
| <Plus :size="20" /> | ||
| </template> | ||
| {{ t('photos', 'Add folder') }} | ||
| </NcButton> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import debounce from 'debounce' | ||
| import { defineComponent } from 'vue' | ||
|
|
||
| import Plus from 'vue-material-design-icons/Plus.vue' | ||
|
|
||
| import { NcButton } from '@nextcloud/vue' | ||
| import { getFilePickerBuilder } from '@nextcloud/dialogs' | ||
| import { translate as t } from '@nextcloud/l10n' | ||
|
|
||
| import UserConfig from '../../mixins/UserConfig.js' | ||
| import PhotosFolder from './PhotosFolder.vue' | ||
|
|
||
| export default defineComponent({ | ||
| name: 'PhotosSourceLocationsSettings', | ||
artonge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| components: { | ||
| NcButton, | ||
| Plus, | ||
| PhotosFolder, | ||
| }, | ||
|
|
||
| mixins: [ | ||
| UserConfig, | ||
| ], | ||
|
|
||
| methods: { | ||
| debounceAddSourceFolder: debounce(function(...args) { | ||
| this.addSourceFolder(...args) | ||
| }, 200, false), | ||
|
|
||
| async openFilePicker(title) { | ||
| const picker = getFilePickerBuilder(title) | ||
| .setMultiSelect(false) | ||
| .setModal(true) | ||
| .setType(1) | ||
| .addMimeTypeFilter('httpd/unix-directory') | ||
| .allowDirectories() | ||
| .build() | ||
|
|
||
| return picker.pick() | ||
| }, | ||
|
|
||
| async addSourceFolder() { | ||
| const pickedFolder = await this.openFilePicker(t('photos', 'Select a source folder for your media')) | ||
| if (this.photosSourceFolders.includes(pickedFolder)) { | ||
| return | ||
| } | ||
| this.photosSourceFolders.push(pickedFolder) | ||
| this.updateSetting('photosSourceFolders') | ||
| }, | ||
|
|
||
| removeSourceFolder(index) { | ||
| this.photosSourceFolders.splice(index, 1) | ||
| this.updateSetting('photosSourceFolders') | ||
| }, | ||
|
|
||
| t, | ||
| }, | ||
| }) | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .photos-locations { | ||
| display: flex; | ||
| flex-direction: column; | ||
| width: fit-content; | ||
|
|
||
| ul { | ||
| margin-bottom: 16px; | ||
| } | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this sorcery? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To properly display the path of the folder. Let me add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments the better :)