-
Notifications
You must be signed in to change notification settings - Fork 159
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
Added file previews #3187
Merged
Merged
Added file previews #3187
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e380514
Added file preview in file list
78f76b8
Wait for preview call to end in file list
fb8eef6
Add fetch API to ajax counters in tests code
6518128
Still wait for ajax calls in case there's another one
27f643f
[Tests-only] Skip thumbnail tests in ocis
dpakach 8eeae76
[Tests-only] Wait for thumbnails to load after loggin in
dpakach 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
There are no files selected for viewing
This file contains 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 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 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,111 @@ | ||
<template> | ||
<oc-file | ||
:name="fileName" | ||
:extension="item.extension" | ||
:icon="previewIcon" | ||
:iconUrl="previewUrl" | ||
:filename="item.name" | ||
:data-preview-loaded="previewLoaded" | ||
/> | ||
</template> | ||
<script> | ||
import queryString from 'query-string' | ||
import Mixins from '../mixins' | ||
|
||
export default { | ||
name: 'FileItem', | ||
mixins: [ | ||
Mixins | ||
], | ||
props: { | ||
item: { | ||
type: Object | ||
}, | ||
// override for file name | ||
name: { | ||
type: String | ||
}, | ||
davUrl: { | ||
type: String | ||
}, | ||
showPath: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
data: function () { | ||
return { | ||
previewUrl: this.item.previewUrl, | ||
// 'false' while the preview is loading (needs string for Vue.js to render the attribute) | ||
// true when the preview loading process is done, | ||
// even if we fell back to the mime type icon | ||
previewLoaded: 'false' | ||
} | ||
}, | ||
computed: { | ||
fileName () { | ||
if (this.name) { | ||
return this.name | ||
} | ||
if (this.showPath) { | ||
const pathSplit = this.item.path.substr(1).split('/') | ||
if (pathSplit.length === 2) return `${pathSplit[pathSplit.length - 2]}/${this.item.basename}` | ||
if (pathSplit.length > 2) return `…/${pathSplit[pathSplit.length - 2]}/${this.item.basename}` | ||
} | ||
return this.item.basename | ||
}, | ||
previewIcon () { | ||
return this.fileTypeIcon(this.item) | ||
} | ||
}, | ||
mounted () { | ||
this.loadPreview() | ||
}, | ||
methods: { | ||
loadPreview () { | ||
if (this.item.previewUrl) { | ||
this.previewUrl = this.item.previewUrl | ||
this.previewLoaded = true | ||
return | ||
} | ||
|
||
// TODO: check if previews are globally enabled (requires capability entry) | ||
// don't load previews for pending or rejected shares (status) | ||
if (!this.davUrl || this.item.type === 'folder' || (typeof this.item.status !== 'undefined' && this.item.status !== 0)) { | ||
this.previewLoaded = true | ||
return | ||
} | ||
|
||
const query = { | ||
x: this.thumbDimensions, | ||
y: this.thumbDimensions, | ||
scalingup: 0, | ||
preview: 1, | ||
a: 1 | ||
} | ||
|
||
if (this.item.etag) { | ||
// add etag for URL based caching | ||
// strip double quotes from etag | ||
query.c = this.item.etag.substr(2, this.item.etag.length - 2) | ||
} | ||
|
||
let itemPath = this.item.path | ||
if (itemPath.charAt(0) === '/') { | ||
itemPath = itemPath.substr(1) | ||
} | ||
|
||
const previewUrl = this.davUrl + '/' + this.encodePath(itemPath) + '?' + queryString.stringify(query) | ||
|
||
this.mediaSource(previewUrl, 'url', this.requestHeaders).then(dataUrl => { | ||
PVince81 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// cache inside item | ||
this.previewUrl = this.item.previewUrl = dataUrl | ||
this.previewLoaded = true | ||
}).catch((e) => { | ||
this.previewUrl = null | ||
this.previewLoaded = true | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains 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 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 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 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 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,7 @@ | ||
Enhancement: Added thumbnails in file list | ||
|
||
Thumbnails are now displayed in the file list for known file types. | ||
When no thumbnail was returned, fall back to the file type icon. | ||
|
||
https://github.com/owncloud/phoenix/issues/276 | ||
https://github.com/owncloud/phoenix/pull/3187 |
This file contains 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 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 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.
@LukasHirt, oh no here is a bug..
the
substr
should besubstr(1, this.item.etag.length - 2)
or else it will cut of the first character. :/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.
Thanks for catching that! I'll open a PR with fix and ping you for review 😉