-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3187 from owncloud/filelist-previews
Added file previews
- Loading branch information
Showing
22 changed files
with
410 additions
and
41 deletions.
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 => { | ||
// 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.