diff options
author | Corentin Mors <corentin.mors@dashlane.com> | 2020-10-24 00:07:07 +0200 |
---|---|---|
committer | Corentin Mors <corentin.mors@dashlane.com> | 2020-10-24 00:07:07 +0200 |
commit | 901d7d99b228459a2c4fb951f8999db39846bf83 (patch) | |
tree | 64e8afce753d30634390df4bc7fdeeecb998c577 | |
parent | b6007deb7d68500977b0d56df59425835d9169a5 (diff) |
Select root folder for timelinefeature/select-root-folder-timeline
Signed-off-by: Corentin Mors <corentin.mors@dashlane.com>
-rw-r--r-- | lib/Controller/PageController.php | 3 | ||||
-rw-r--r-- | package-lock.json | 31 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/Photos.vue | 3 | ||||
-rw-r--r-- | src/components/Settings/CroppedLayoutSettings.vue | 7 | ||||
-rw-r--r-- | src/components/Settings/TimelineSettings.vue | 73 | ||||
-rw-r--r-- | src/mixins/UserConfig.js | 2 | ||||
-rw-r--r-- | src/services/PhotoSearch.js | 22 | ||||
-rw-r--r-- | src/views/Timeline.vue | 4 |
9 files changed, 133 insertions, 13 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 4fbc9599..97c60e87 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -86,7 +86,10 @@ class PageController extends Controller { $this->initialStateService->provideInitialState($this->appName, 'image-mimes', Application::IMAGE_MIMES); $this->initialStateService->provideInitialState($this->appName, 'video-mimes', Application::VIDEO_MIMES); $this->initialStateService->provideInitialState($this->appName, 'maps', $this->appManager->isEnabledForUser('maps') === true); + + // User Settings $this->initialStateService->provideInitialState($this->appName, 'croppedLayout', $this->config->getUserValue($user->getUid(), Application::APP_ID, 'croppedLayout', 'false')); + $this->initialStateService->provideInitialState($this->appName, 'timelineRootFolder', $this->config->getUserValue($user->getUid(), Application::APP_ID, 'timelineRootFolder', '/')); Util::addScript(Application::APP_ID, 'photos-main'); Util::addStyle(Application::APP_ID, 'icons'); diff --git a/package-lock.json b/package-lock.json index 85946a84..382f4507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2554,14 +2554,24 @@ } }, "@nextcloud/dialogs": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-2.0.1.tgz", - "integrity": "sha512-Bme8vcs8n4XT5spBgkDEv1z9zNOE23AIbr5jF1WJ1A2XNMNj5Zvy29RosIh0k7H+1lN0PlU38u+eMV1Ets3E4A==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-3.0.0.tgz", + "integrity": "sha512-5FVP0RSxIpKTKdSUlQ4osDDz/oCx2/4+InliB5MX2EcrjDe6q3fZMabSGnFTnIAu0CXRTzBk7RpneaIFGv+d5A==", "requires": { "@nextcloud/l10n": "^1.3.0", - "@nextcloud/typings": "^0.2.2", + "@nextcloud/typings": "^1.0.0", "core-js": "^3.6.4", "toastify-js": "^1.9.1" + }, + "dependencies": { + "@nextcloud/typings": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.0.0.tgz", + "integrity": "sha512-r8SRvXszWTyKWEhVd3gx7eBAcCKwdoLlr+ZrR8hrSxs2nfH00de/QoGdo0n/Rcv/9mMtX/haJNd71KwODM2+uQ==", + "requires": { + "@types/jquery": "2.0.54" + } + } } }, "@nextcloud/eslint-config": { @@ -2655,6 +2665,19 @@ "vue-multiselect": "^2.1.6", "vue-visible": "^1.0.2", "vue2-datepicker": "^3.6.2" + }, + "dependencies": { + "@nextcloud/dialogs": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-2.0.1.tgz", + "integrity": "sha512-Bme8vcs8n4XT5spBgkDEv1z9zNOE23AIbr5jF1WJ1A2XNMNj5Zvy29RosIh0k7H+1lN0PlU38u+eMV1Ets3E4A==", + "requires": { + "@nextcloud/l10n": "^1.3.0", + "@nextcloud/typings": "^0.2.2", + "core-js": "^3.6.4", + "toastify-js": "^1.9.1" + } + } } }, "@nextcloud/webpack-vue-config": { diff --git a/package.json b/package.json index 3eaef24f..e8ace038 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@essentials/request-timeout": "^1.3.0", "@nextcloud/auth": "^1.3.0", "@nextcloud/axios": "^1.4.0", + "@nextcloud/dialogs": "^3.0.0", "@nextcloud/event-bus": "^1.2.0", "@nextcloud/initial-state": "^1.2.0", "@nextcloud/l10n": "^1.4.1", diff --git a/src/Photos.vue b/src/Photos.vue index 5b3f241b..b00704c0 100644 --- a/src/Photos.vue +++ b/src/Photos.vue @@ -41,6 +41,7 @@ </template> <template #footer> <AppNavigationSettings :title="t('photos', 'Settings')"> + <TimelineSettings /> <CroppedLayoutSettings /> </AppNavigationSettings> </template> @@ -70,6 +71,7 @@ import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem' import AppNavigationSettings from '@nextcloud/vue/dist/Components/AppNavigationSettings' import CroppedLayoutSettings from './components/Settings/CroppedLayoutSettings' +import TimelineSettings from './components/Settings/TimelineSettings' import svgplaceholder from './assets/file-placeholder.svg' import imgplaceholder from './assets/image.svg' import videoplaceholder from './assets/video.svg' @@ -80,6 +82,7 @@ export default { components: { Content, CroppedLayoutSettings, + TimelineSettings, AppContent, AppNavigation, AppNavigationItem, diff --git a/src/components/Settings/CroppedLayoutSettings.vue b/src/components/Settings/CroppedLayoutSettings.vue index ecafd3a8..37a7e3b1 100644 --- a/src/components/Settings/CroppedLayoutSettings.vue +++ b/src/components/Settings/CroppedLayoutSettings.vue @@ -46,3 +46,10 @@ export default { ], } </script> + +<style scoped> +.section { + padding: 10px; + margin-bottom: 5px; +} +</style> diff --git a/src/components/Settings/TimelineSettings.vue b/src/components/Settings/TimelineSettings.vue new file mode 100644 index 00000000..f8f743e0 --- /dev/null +++ b/src/components/Settings/TimelineSettings.vue @@ -0,0 +1,73 @@ +<!-- + - @copyright Copyright (c) 2020 Corentin Mors + - + - @license GNU AGPL version 3 or any later version + - + - @author Corentin Mors <medias@pixelswap.fr> + - + - 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="section"> + <h2>{{ t('photos', 'Timeline') }}</h2> + + <p>{{ t('photos', 'Folder for the timeline') }} : {{ timelineRootFolder }}/</p> + <button + @click="pickRootFolder"> + {{ t('photos', 'Choose folder') }} + </button> + </div> +</template> + +<script> +import { getFilePickerBuilder } from '@nextcloud/dialogs' +import UserConfig from '../../mixins/UserConfig' + +export default { + name: 'TimelineSettings', + + mixins: [ + UserConfig, + ], + + methods: { + pickRootFolder() { + const picker = getFilePickerBuilder(t('photos', 'Choose a folder to display in the timeline')) + .setMultiSelect(false) + .addMimeTypeFilter('httpd/unix-directory') + .setModal(true) + .setType(1) + .allowDirectories(true) + .build() + + return picker + .pick() + .then((dest) => { + this.timelineRootFolder = dest + this.updateSetting('timelineRootFolder') + location.reload() + }) + }, + }, +} +</script> + +<style scoped> +.section { + padding: 10px; + margin-bottom: 5px; +} +</style> diff --git a/src/mixins/UserConfig.js b/src/mixins/UserConfig.js index efa123dc..2bfde207 100644 --- a/src/mixins/UserConfig.js +++ b/src/mixins/UserConfig.js @@ -30,7 +30,9 @@ const eventName = 'photos:user-config-changed' export default { data() { const croppedLayoutLocalStorage = localStorage.getItem('photos:croppedLayout') + const timelineRootFolderLocalStorage = localStorage.getItem('photos:timelineRootFolder') return { + timelineRootFolder: timelineRootFolderLocalStorage || loadState('photos', 'timelineRootFolder'), croppedLayout: croppedLayoutLocalStorage !== null ? croppedLayoutLocalStorage === 'true' : loadState('photos', 'croppedLayout') === 'true', diff --git a/src/services/PhotoSearch.js b/src/services/PhotoSearch.js index 477addb1..621f7d55 100644 --- a/src/services/PhotoSearch.js +++ b/src/services/PhotoSearch.js @@ -44,9 +44,11 @@ export default async function(onlyFavorites = false, options = {}) { page: 0, // start at the first page perPage: sizes.max.count * 10, // ten rows of the max width mimesType: allMimes, // all mimes types + rootFolder: '', }, options) - const prefixPath = `/files/${getCurrentUser().uid}` + const davPath = `/files/${getCurrentUser().uid}` + const prefixPath = `${davPath}${options.rootFolder}` // generating the search or condition // based on the allowed mimetypes @@ -68,6 +70,15 @@ export default async function(onlyFavorites = false, options = {}) { </d:eq>` : '' + const eqOwner = options.rootFolder === '' + ? `<d:eq> + <d:prop> + <oc:owner-id/> + </d:prop> + <d:literal>${getCurrentUser().uid}</d:literal> + </d:eq>` + : '' + options = Object.assign({ method: 'SEARCH', headers: { @@ -97,12 +108,7 @@ export default async function(onlyFavorites = false, options = {}) { ${orMime} </d:or> ${eqFavorites} - <d:eq> - <d:prop> - <oc:owner-id/> - </d:prop> - <d:literal>${getCurrentUser().uid}</d:literal> - </d:eq> + ${eqOwner} </d:and> </d:where> <d:orderby> @@ -126,6 +132,6 @@ export default async function(onlyFavorites = false, options = {}) { return response.data .map(data => genFileInfo(data)) // remove prefix path from full file path - .map(data => Object.assign({}, data, { filename: data.filename.replace(prefixPath, '') })) + .map(data => Object.assign({}, data, { filename: data.filename.replace(davPath, '') })) } diff --git a/src/views/Timeline.vue b/src/views/Timeline.vue index 8eb90698..ffbf7aa5 100644 --- a/src/views/Timeline.vue +++ b/src/views/Timeline.vue @@ -71,6 +71,7 @@ import Loader from '../components/Loader' import cancelableRequest from '../utils/CancelableRequest' import GridConfigMixin from '../mixins/GridConfig' +import UserConfig from '../mixins/UserConfig' import { allMimes } from '../services/AllowedMimes' export default { @@ -80,7 +81,7 @@ export default { VirtualGrid, Navigation, }, - mixins: [GridConfigMixin], + mixins: [GridConfigMixin, UserConfig], props: { loading: { type: Boolean, @@ -237,6 +238,7 @@ export default { page: this.page, perPage: numberOfImagesPerBatch, mimesType: this.mimesType, + rootFolder: this.timelineRootFolder, }) // If we get less files than requested that means we got to the end |