First version of rust web server serving album.json

This commit is contained in:
2020-02-10 21:30:20 -08:00
parent 1c99396705
commit e191b2a3ff
3 changed files with 17 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ class Album extends React.Component {
}
componentDidMount() {
let {album} = this.props;
fetch(process.env.PUBLIC_URL + `/photosync/${album}/album.json`)
fetch(process.env.PUBLIC_URL + `/api/album/${album}`)
.then(res => res.json())
.then(
(result) => this.setState({media_items: result}),
@@ -30,7 +30,7 @@ class Album extends React.Component {
// TODO(wathiede): use coverPhotoMediaItemId and fetch from a
// locally cached image.
return <figure key={ mi.id } className="figure">
<img height="256" width="256" src={ `/photosync/images/${mi.id}/${mi.filename}?thumb` } className="mr-3" alt={ mi.filename }/>
<img height="256" width="256" src={ `/api/image/${mi.id}?w=256&h=256` } className="mr-3" alt={ mi.filename }/>
<figcaption className="figure-caption">
<a key={ mi.id } href={ mi.productUrl }>
<p className="text-truncate">{ mi.filename}</p>
@@ -53,7 +53,7 @@ class AlbumIndex extends React.Component {
};
}
componentDidMount() {
fetch(process.env.PUBLIC_URL + "/photosync/albums.json")
fetch(process.env.PUBLIC_URL + "/api/albums")
.then(res => res.json())
.then(
(result) => this.setState({albums: result}),
@@ -68,8 +68,8 @@ class AlbumIndex extends React.Component {
console.log(albums);
return albums.map((a) => {
let img = <img src="https://via.placeholder.com/256x128" className="mr-3" alt="unset"/>;
if (a.coverPhotoBaseUrl !== undefined) {
img = <img src={ a.coverPhotoBaseUrl + "=w256" } className="mr-3" alt={ a.title }/>;
if (a.coverPhotoMediaItemId !== undefined) {
img = <img height="256" width="256" src={ `/api/image/${a.coverPhotoMediaItemId}?w=256&h=256` } className="mr-3" alt={ a.title }/>
}
let figure = <figure key={ a.id } className="figure">