-
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.
Added new component FileItem wrapped around oc-file to better encapsulated the formatting methods as computed properties instead of using the mixin. Added preview support in file list loaded using mediaSource.
- Loading branch information
Vincent Petry
committed
Mar 18, 2020
1 parent
d115983
commit 1c419d9
Showing
11 changed files
with
247 additions
and
17 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,88 @@ | ||
<template> | ||
<oc-file | ||
:name="fileName" | ||
:extension="item.extension" | ||
:icon="fileTypeIcon" | ||
:iconUrl="previewUrl" | ||
:filename="item.name" | ||
/> | ||
</template> | ||
<script> | ||
import queryString from 'query-string' | ||
import fileTypeIconMappings from '../fileTypeIconMappings.json' | ||
export default { | ||
name: 'FileItem', | ||
props: { | ||
/** | ||
* The html element used for the avatar container. | ||
* `div, span` | ||
*/ | ||
item: { | ||
type: Object | ||
}, | ||
davUrl: { | ||
type: String | ||
}, | ||
showPath: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
data: function () { | ||
return { | ||
previewUrl: this.item.previewUrl | ||
} | ||
}, | ||
computed: { | ||
fileName () { | ||
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 | ||
}, | ||
// FIXME: duplicate in mixin | ||
fileTypeIcon () { | ||
if (this.item.type === 'folder') { | ||
return 'folder' | ||
} | ||
const icon = fileTypeIconMappings[this.item.extension] | ||
if (icon) return `${icon}` | ||
return 'x-office-document' | ||
} | ||
}, | ||
mounted () { | ||
this.loadPreview() | ||
}, | ||
methods: { | ||
loadPreview () { | ||
if (this.item.previewUrl) { | ||
this.previewUrl = this.item.previewUrl | ||
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)) { | ||
return | ||
} | ||
const query = queryString.stringify({ | ||
x: this.thumbDimensions, | ||
y: this.thumbDimensions, | ||
c: this.item.etag, | ||
scalingup: 0, | ||
preview: 1, | ||
a: 1 | ||
}) | ||
const previewUrl = this.davUrl + '/' + this.item.path + '?' + query | ||
this.mediaSource(previewUrl, 'url', this.requestHeaders).then(dataUrl => { | ||
// cache inside item | ||
this.previewUrl = this.item.previewUrl = dataUrl | ||
}) | ||
} | ||
} | ||
} | ||
</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
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
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