React router #343

Merged
bones7242 merged 96 commits from react-router into master 2018-02-15 08:02:17 +01:00
6 changed files with 188 additions and 93 deletions
Showing only changes of commit f7e50597e6 - Show all commits

View file

@ -1,6 +1,6 @@
const db = require('../models');
const logger = require('winston');
const { returnPaginatedChannelViewData } = require('../helpers/channelPagination.js');
const { returnPaginatedChannelClaims } = require('../helpers/channelPagination.js');
const NO_CHANNEL = 'NO_CHANNEL';
const NO_CLAIM = 'NO_CLAIM';
@ -53,7 +53,7 @@ module.exports = {
});
});
},
getChannelViewData (channelName, channelClaimId, page) {
getChannelData (channelName, channelClaimId, page) {
return new Promise((resolve, reject) => {
// 1. get the long channel Id (make sure channel exists)
db.Certificate.getLongChannelId(channelName, channelClaimId)
@ -62,14 +62,41 @@ module.exports = {
return [null, null, null];
}
// 2. get the short ID and all claims for that channel
return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName), db.Claim.getAllChannelClaims(longChannelClaimId)]);
return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName)]);
})
.then(([longChannelClaimId, shortChannelClaimId, channelClaimsArray]) => {
.then(([longChannelClaimId, shortChannelClaimId]) => {
if (!longChannelClaimId) {
return resolve(NO_CHANNEL);
}
// 3. return all the channel information
resolve({
channelName,
longChannelClaimId,
shortChannelClaimId,
});
})
.catch(error => {
reject(error);
});
});
},
getChannelClaims (channelName, channelClaimId, page) {
return new Promise((resolve, reject) => {
// 1. get the long channel Id (make sure channel exists)
db.Certificate.getLongChannelId(channelName, channelClaimId)
.then(longChannelClaimId => {
if (!longChannelClaimId) {
return [null, null, null];
}
// 2. get the short ID and all claims for that channel
return Promise.all([longChannelClaimId, db.Claim.getAllChannelClaims(longChannelClaimId)]);
})
.then(([longChannelClaimId, channelClaimsArray]) => {
if (!longChannelClaimId) {
return resolve(NO_CHANNEL);
}
// 3. format the data for the view, including pagination
let paginatedChannelViewData = returnPaginatedChannelViewData(channelName, longChannelClaimId, shortChannelClaimId, channelClaimsArray, page);
let paginatedChannelViewData = returnPaginatedChannelClaims(channelName, longChannelClaimId, channelClaimsArray, page);
// 4. return all the channel information and contents
resolve(paginatedChannelViewData);
})

View file

@ -1,19 +1,18 @@
const CLAIMS_PER_PAGE = 10;
const CLAIMS_PER_PAGE = 12;
module.exports = {
returnPaginatedChannelViewData (channelName, longChannelClaimId, shortChannelClaimId, claims, page) {
returnPaginatedChannelClaims (channelName, longChannelClaimId, claims, page) {
const totalPages = module.exports.determineTotalPages(claims);
const paginationPage = module.exports.getPageFromQuery(page);
const viewData = {
channelName : channelName,
longChannelClaimId : longChannelClaimId,
shortChannelClaimId: shortChannelClaimId,
claims : module.exports.extractPageFromClaims(claims, paginationPage),
previousPage : module.exports.determinePreviousPage(paginationPage),
currentPage : paginationPage,
nextPage : module.exports.determineNextPage(totalPages, paginationPage),
totalPages : totalPages,
totalResults : module.exports.determineTotalClaims(claims),
channelName : channelName,
longChannelClaimId: longChannelClaimId,
claims : module.exports.extractPageFromClaims(claims, paginationPage),
previousPage : module.exports.determinePreviousPage(paginationPage),
currentPage : paginationPage,
nextPage : module.exports.determineNextPage(totalPages, paginationPage),
totalPages : totalPages,
totalResults : module.exports.determineTotalClaims(claims),
};
return viewData;
},
@ -30,7 +29,7 @@ module.exports = {
// logger.debug('claims is array?', Array.isArray(claims));
// logger.debug(`pageNumber ${pageNumber} is number?`, Number.isInteger(pageNumber));
const claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;
const claimEndIndex = claimStartIndex + 10;
const claimEndIndex = claimStartIndex + CLAIMS_PER_PAGE;
const pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);
return pageOfClaims;
},

View file

@ -1,52 +1,52 @@
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
import React from 'react';
import { Link } from 'react-router-dom';
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
import { Link } from 'react-router-dom'
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
const AssetPreview = ({ name, claimId, fileExt, contentType }) => {
const directSourceLink = `${claimId}/${name}.${fileExt}`;
const showUrlLink = `${claimId}/${name}`;
const previewHolderStyle = {
clear: 'both',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
display: 'inline-block',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
width: '31%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
padding: '0px',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
margin: '1%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
clear : 'both',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
display : 'inline-block',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
width : '31%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
padding : '0px',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
margin : '1%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
backgroundColor: 'black',
};
const assetStyle = {
width: '100%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
width : '100%',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
padding: '0px',
margin: '0px',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
margin : '0px',
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
};
switch (contentType) {
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/jpeg':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/jpg':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/png':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<div style={previewHolderStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<Link to={showUrlLink} >
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<img style={assetStyle} className={'asset-preview--image'} src={directSourceLink} alt={name} />
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</Link>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</div>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/gif':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<div style={previewHolderStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<img style={assetStyle} className={'asset-preview--gif'} src={directSourceLink} alt={name} />
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</div>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'video/mp4':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<div style={previewHolderStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<video style={assetStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<source src={directSourceLink} type={contentType} />
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</video>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</div>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
default:
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<p>unsupported file type</p>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
}
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<div style={previewHolderStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<Link to={showUrlLink} >
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
{(() => {
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
switch (contentType) {
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/jpeg':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/jpg':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/png':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<img style={assetStyle} className={'asset-preview--image'} src={directSourceLink} alt={name}/>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'image/gif':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<img style={assetStyle} className={'asset-preview--gif'} src={directSourceLink} alt={name}/>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
case 'video/mp4':
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<video style={assetStyle}>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<source src={directSourceLink} type={contentType}/>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</video>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
default:
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
return (
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
<p>unsupported file type</p>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
}
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
})()}
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</Link>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
</div>
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
);
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
};
export default AssetPreview;

neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops
neb-b commented 2018-02-05 20:38:50 +01:00 (Migrated from github.com)
Review

Any reason these aren't just css?

Any reason these aren't just css?
bones7242 commented 2018-02-07 07:28:57 +01:00 (Migrated from github.com)
Review

oops

oops

View file

@ -0,0 +1,72 @@
import React from 'react';
import NavBar from 'containers/NavBar';
import AssetPreview from 'components/AssetPreview';
import request from 'utils/request';
class ChannelClaimsDisplay extends React.Component {
constructor (props) {
super(props);
this.state = {
error: null,
page : 1,
};
this.getAndStoreChannelClaims = this.getAndStoreChannelClaims.bind(this);
}
componentDidMount () {
const channelName = this.props.channelName;
const channelClaimId = this.props.channelClaimId || 'none';
const page = this.state.page;
this.getAndStoreChannelClaims(channelName, channelClaimId, page);
}
getAndStoreChannelClaims (channelName, channelClaimId, page) {
const url = `/api/channel-claims/${channelName}/${channelClaimId}/${page}`;
const that = this;
return request(url)
.then(({ success, message, data }) => {
console.log('api/channel-claims response:', data);
if (!success) {
return that.setState({error: message});
}
that.setState({
claims : data.claims,
currentPage : data.currentPage,
nextPage : data.nextPage,
previousPage: data.previousPage,
totalPages : data.totalPages,
totalResults: data.totalResults,
});
})
.catch((error) => {
that.setState({error: error.message});
});
}
render () {
return (
<div>
{this.state.error ? (
<div className="row">
<div className="column column--10">
<p>{this.state.error}</p>
</div>
</div>
) : (
<div className="row row--tall">
<p># of claims in channel: {this.state.totalResults >= 0 ? this.state.totalResults : 'loading...' }</p>
{this.state.claims && this.state.claims.map((claim, index) => <AssetPreview
name={claim.name}
claimId={claim.claimId}
contentType={claim.contentType}
key={index}
/>)}
</div>
)}
</div>
);
}
};
// required props
// channelName
// channelClaimId
export default ChannelClaimsDisplay;

View file

@ -1,49 +1,34 @@
import React from 'react';
import NavBar from 'containers/NavBar';
import AssetPreview from 'components/AssetPreview';
import ChannelClaimsDisplay from 'components/ChannelClaimsDisplay';
import request from 'utils/request';
class ShowChannel extends React.Component {
constructor (props) {
super(props);
this.state = {
error : null,
channelName : null,
claims : null,
currentPage : null,
longChannelClaimId : null,
nextPage : null,
previousPage : null,
shortChannelClaimId: null,
totalPages : null,
totalResults : null,
error: null,
};
this.updateChannelData = this.updateChannelData.bind(this);
this.getAndStoreChannelData = this.getAndStoreChannelData.bind(this);
}
componentDidMount () {
this.updateChannelData(1);
}
updateChannelData (page) {
const channelName = this.props.channelName;
const channelClaimId = this.props.channelClaimId || 'none';
const url = `/api/channel-get-content/${channelName}/${channelClaimId}/${page}`;
this.getAndStoreChannelData(channelName, channelClaimId);
}
getAndStoreChannelData (channelName, channelClaimId) {
const url = `/api/channel-data/${channelName}/${channelClaimId}`;
const that = this;
return request(url)
.then(({ success, message, data }) => {
console.log('get channel data response:', data);
console.log('api/channel-data response:', data);
if (!success) {
return that.setState({error: message});
}
that.setState({
channelName : data.channelName,
claims : data.claims,
currentPage : data.currentPage,
longChannelClaimId : data.longChannelClaimId,
nextPage : data.nextPage,
previousPage : data.previousPage,
shortChannelClaimId: data.shortChannelClaimId,
totalPages : data.totalPages,
totalResults : data.totalResults,
});
})
.catch((error) => {
@ -66,18 +51,14 @@ class ShowChannel extends React.Component {
<h2>channel name: {this.props.channelName}</h2>
<p>full channel id: {this.state.longChannelClaimId ? this.state.longChannelClaimId : 'loading...'}</p>
<p>short channel id: {this.state.shortChannelClaimId ? this.state.shortChannelClaimId : 'loading...'}</p>
<p># of claims in channel: {this.state.totalResults >= 0 ? this.state.totalResults : 'loading...' }</p>
</div>
<div className="column column--10">
<div>
{/* claims here */}
{this.state.claims && this.state.claims.map((claim, index) => <AssetPreview
name={claim.name}
claimId={claim.claimId}
contentType={claim.contentType}
key={index}
/>)}
</div>
{ (this.state.channelName && this.state.longChannelClaimId) &&
<ChannelClaimsDisplay
channelName={this.state.channelName}
channelClaimId={this.state.longChannelClaimId}
/>
}
</div>
</div>
)}

View file

@ -9,7 +9,7 @@ const { createPublishParams, parsePublishApiRequestBody, parsePublishApiRequestF
const errorHandlers = require('../helpers/errorHandlers.js');
const { sendGoogleAnalyticsTiming } = require('../helpers/statsHelpers.js');
const { authenticateIfNoUserToken } = require('../auth/authentication.js');
const { getChannelViewData, getClaimId } = require('../controllers/serveController.js');
const { getChannelData, getChannelClaims, getClaimId } = require('../controllers/serveController.js');
const NO_CHANNEL = 'NO_CHANNEL';
const NO_CLAIM = 'NO_CLAIM';
@ -189,12 +189,28 @@ module.exports = (app) => {
errorHandlers.handleApiError(originalUrl, ip, error, res);
});
});
app.get('/api/channel-get-content/:name/:longId/:page', ({ ip, originalUrl, body, params }, res) => {
const channelName = params.name;
let channelClaimId = params.longId;
app.get('/api/channel-data/:channelName/:channelClaimId', ({ ip, originalUrl, body, params }, res) => {
const channelName = params.channelName;
let channelClaimId = params.channelClaimId;
if (channelClaimId === 'none') channelClaimId = null;
getChannelData(channelName, channelClaimId, 0) // getChannelViewData(channelName, channelId, 0)
.then(data => {
if (data === NO_CHANNEL) {
return res.status(200).json({success: false, message: 'No matching channel was found'});
}
res.status(200).json({success: true, data});
})
.catch(error => {
logger.error('api error getting channel contents', error);
errorHandlers.handleApiError(originalUrl, ip, error, res);
});
});
app.get('/api/channel-claims/:channelName/:channelClaimId/:page', ({ ip, originalUrl, body, params }, res) => {
const channelName = params.channelName;
let channelClaimId = params.channelClaimId;
if (channelClaimId === 'none') channelClaimId = null;
const page = params.page;
getChannelViewData(channelName, channelClaimId, page)
getChannelClaims(channelName, channelClaimId, page)// getChannelViewData(channelName, channelClaimId, page)
.then(data => {
if (data === NO_CHANNEL) {
return res.status(200).json({success: false, message: 'No matching channel was found'});