From e6e50a1253fe329f82f0f3df4941e9649ec17df1 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 31 Jan 2018 10:40:26 -0800 Subject: [PATCH] added basic asset preview --- react/components/AssetPreview/index.js | 49 ++++++++++++++++++++++---- react/components/ShowChannel/index.js | 7 ++-- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/react/components/AssetPreview/index.js b/react/components/AssetPreview/index.js index b00275de..79eefb3c 100644 --- a/react/components/AssetPreview/index.js +++ b/react/components/AssetPreview/index.js @@ -1,11 +1,48 @@ import React from 'react'; -const AssetPreview = ({ name, claimId, contentType }) => { - return ( -
-

name: {name}, claimId: {claimId}, contentType: {contentType}

-
- ); +const AssetPreview = ({ name, claimId, fileExt, contentType }) => { + const directSourceLink = `${claimId}/${name}.${fileExt}`; + const previewHolderStyle = { + clear: 'both', + display: 'inline-block', + width: '31%', + padding: '0px', + margin: '1%', + backgroundColor: 'black', + }; + const assetStyle = { + width: '100%', + padding: '0px', + margin: '0px', + }; + switch (contentType) { + case 'image/jpeg': + case 'image/jpg': + case 'image/png': + return ( +
+ {name} +
+ ); + case 'image/gif': + return ( +
+ {name} +
+ ); + case 'video/mp4': + return ( +
+ +
+ ); + default: + return ( +

unsupported file type

+ ); + } }; export default AssetPreview; diff --git a/react/components/ShowChannel/index.js b/react/components/ShowChannel/index.js index c86168c8..1e51f353 100644 --- a/react/components/ShowChannel/index.js +++ b/react/components/ShowChannel/index.js @@ -21,19 +21,18 @@ class ShowChannel extends React.Component { this.updateChannelData = this.updateChannelData.bind(this); } componentDidMount () { - console.log(this.props); this.updateChannelData(1); } updateChannelData (page) { - const that = this; const channelName = this.props.channelName; const channelClaimId = this.props.channelClaimId || 'none'; const url = `/api/channel-get-content/${channelName}/${channelClaimId}/${page}`; + const that = this; return request(url) .then(({ success, message, data }) => { console.log('get channel data response:', data); if (!success) { - return this.setState({error: message}); + return that.setState({error: message}); } that.setState({ channelName : data.channelName, @@ -67,7 +66,7 @@ class ShowChannel extends React.Component {

channel name: {this.props.channelName}

full channel id: {this.state.longChannelClaimId ? this.state.longChannelClaimId : 'loading...'}

short channel id: {this.state.shortChannelClaimId ? this.state.shortChannelClaimId : 'loading...'}

-

# of claims in channel: {this.state.totalResults ? this.state.totalResults : 'loading...' }

+

# of claims in channel: {this.state.totalResults >= 0 ? this.state.totalResults : 'loading...' }