-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Select root folder for timeline #515
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,10 @@ export default { | |
], | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.section { | ||
padding: 10px; | ||
margin-bottom: 5px; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2020 Corentin Mors | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- @author Corentin Mors <[email protected]> | ||
- | ||
- 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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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>` | ||
: '' | ||
Comment on lines
+74
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed to not have the shares as results. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The owner filter is only allowed on the root. Dav throws this error if you try on subfolders. What do you think then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then it should be fixed on server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
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, '') })) | ||
|
||
} |
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.
We should probably limit the allowed keys here:
photos/lib/Controller/ApiController.php
Line 66 in 441f970
As a safety mesure 🤔
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.
I'm not sure what you mean
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.
setUserConfig allows anything, and will put it straight into the db.
Meaning we could override existing values. We should check if the $key is either
timelineRootFolder
orcroppedLayout
and throw otherwise as a safety measureThere 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.
ok gotcha