1
Fork 0

Add sorting and filters

This commit is contained in:
viktorstrate 2019-07-23 22:38:41 +02:00
parent 3560c2cae8
commit 7c714449f9
5 changed files with 13 additions and 10 deletions

View File

@ -3,7 +3,7 @@ enum Role {
User User
} }
type User @hasRole(roles: [Admin]) { type User {
id: ID! id: ID!
username: String! username: String!
albums: [Album] @relation(name: "OWNS", direction: "OUT") albums: [Album] @relation(name: "OWNS", direction: "OUT")
@ -12,7 +12,7 @@ type User @hasRole(roles: [Admin]) {
admin: Boolean admin: Boolean
} }
type Album @hasRole(roles: [Admin]) { type Album {
id: ID! id: ID!
title: String title: String
photos: [Photo] @relation(name: "CONTAINS", direction: "OUT") photos: [Photo] @relation(name: "CONTAINS", direction: "OUT")
@ -31,7 +31,7 @@ type PhotoURL {
height: Int height: Int
} }
type Photo @hasRole(roles: [Admin]) { type Photo {
id: ID! id: ID!
title: String title: String
# Local filepath for the photo # Local filepath for the photo

View File

@ -10,7 +10,7 @@ const albumQuery = gql`
query albumQuery($id: ID) { query albumQuery($id: ID) {
album(id: $id) { album(id: $id) {
title title
subAlbums { subAlbums(orderBy: title_asc) {
id id
title title
photos { photos {
@ -19,7 +19,7 @@ const albumQuery = gql`
} }
} }
} }
photos { photos(orderBy: title_desc) {
id id
thumbnail { thumbnail {
url url

View File

@ -6,7 +6,7 @@ import { Query } from 'react-apollo'
const getAlbumsQuery = gql` const getAlbumsQuery = gql`
query getMyAlbums { query getMyAlbums {
myAlbums(filter: { parentAlbum: null }) { myAlbums(filter: { parentAlbum: null }, orderBy: title_asc) {
id id
title title
photos { photos {

View File

@ -6,7 +6,7 @@ import PhotoGallery from '../../PhotoGallery'
const photoQuery = gql` const photoQuery = gql`
query allPhotosPage { query allPhotosPage {
myPhotos { myPhotos(orderBy: title_desc) {
id id
title title
thumbnail { thumbnail {

View File

@ -66,9 +66,12 @@ const PhotoGallery = ({ activeIndex = -1, photos, loading, onSelectImage }) => {
photoElements = photos.map((photo, index) => { photoElements = photos.map((photo, index) => {
const active = activeIndex == index const active = activeIndex == index
const minWidth = Math.floor( let minWidth = 100
(photo.thumbnail.width / photo.thumbnail.height) * 200 if (photo.thumbnail) {
) minWidth = Math.floor(
(photo.thumbnail.width / photo.thumbnail.height) * 200
)
}
return ( return (
<PhotoContainer <PhotoContainer