General cleanup
This commit is contained in:
parent
8e7c43798a
commit
c9216a4d79
|
@ -1,5 +1,3 @@
|
||||||
{
|
{
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": ["ui"]
|
||||||
"ui", "api"
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Chrome",
|
|
||||||
"type": "chrome",
|
|
||||||
"request": "launch",
|
|
||||||
"url": "http://localhost:3000",
|
|
||||||
"webRoot": "${workspaceRoot}/src"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -21,9 +21,6 @@ const adminQuery = gql`
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
/* margin-right: 500px; */
|
|
||||||
/* display: grid;
|
|
||||||
grid-template-columns: 80px 1fr 500px; */
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const SideMenu = styled.div`
|
const SideMenu = styled.div`
|
||||||
|
|
|
@ -1,22 +1,14 @@
|
||||||
import React, { useState } from 'react'
|
import gql from 'graphql-tag'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import styled from 'styled-components'
|
import React, { useState } from 'react'
|
||||||
import RouterProps from 'react-router-prop-types'
|
import { useQuery } from 'react-apollo'
|
||||||
import { Route, Switch } from 'react-router-dom'
|
import { Route, Switch } from 'react-router-dom'
|
||||||
|
import RouterProps from 'react-router-prop-types'
|
||||||
|
import { Form, Header, Icon, Input, Message } from 'semantic-ui-react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
import { getSharePassword, saveSharePassword } from '../../authentication'
|
||||||
import AlbumSharePage from './AlbumSharePage'
|
import AlbumSharePage from './AlbumSharePage'
|
||||||
import MediaSharePage from './MediaSharePage'
|
import MediaSharePage from './MediaSharePage'
|
||||||
import { useQuery } from 'react-apollo'
|
|
||||||
import gql from 'graphql-tag'
|
|
||||||
import {
|
|
||||||
Container,
|
|
||||||
Header,
|
|
||||||
Form,
|
|
||||||
Button,
|
|
||||||
Input,
|
|
||||||
Icon,
|
|
||||||
Message,
|
|
||||||
} from 'semantic-ui-react'
|
|
||||||
import { saveSharePassword, getSharePassword } from '../../authentication'
|
|
||||||
|
|
||||||
const shareTokenQuery = gql`
|
const shareTokenQuery = gql`
|
||||||
query SharePageToken($token: String!, $password: String) {
|
query SharePageToken($token: String!, $password: String) {
|
||||||
|
@ -61,9 +53,12 @@ const shareTokenQuery = gql`
|
||||||
}
|
}
|
||||||
downloads {
|
downloads {
|
||||||
title
|
title
|
||||||
url
|
mediaUrl {
|
||||||
width
|
url
|
||||||
height
|
width
|
||||||
|
height
|
||||||
|
fileSize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
highRes {
|
highRes {
|
||||||
url
|
url
|
||||||
|
|
|
@ -9,7 +9,7 @@ const Container = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
`
|
`
|
||||||
|
|
||||||
const AlbumBoxes = ({ loading, error, albums, getCustomLink }) => {
|
const AlbumBoxes = ({ error, albums, getCustomLink }) => {
|
||||||
if (error) return <div>Error {error.message}</div>
|
if (error) return <div>Error {error.message}</div>
|
||||||
|
|
||||||
let albumElements = []
|
let albumElements = []
|
||||||
|
@ -28,12 +28,7 @@ const AlbumBoxes = ({ loading, error, albums, getCustomLink }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <Container>{albumElements}</Container>
|
||||||
<Container>
|
|
||||||
{/* <Loader active={loading}>Loading albums</Loader> */}
|
|
||||||
{albumElements}
|
|
||||||
</Container>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlbumBoxes.propTypes = {
|
AlbumBoxes.propTypes = {
|
||||||
|
|
|
@ -4,14 +4,10 @@ import PropTypes from 'prop-types'
|
||||||
const getProtectedUrl = url => {
|
const getProtectedUrl = url => {
|
||||||
const imgUrl = new URL(url)
|
const imgUrl = new URL(url)
|
||||||
|
|
||||||
if (localStorage.getItem('token') == null) {
|
const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
|
||||||
// Get share token if not authorized
|
if (tokenRegex) {
|
||||||
|
const token = tokenRegex[1]
|
||||||
const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
|
imgUrl.searchParams.set('token', token)
|
||||||
if (tokenRegex) {
|
|
||||||
const token = tokenRegex[1]
|
|
||||||
imgUrl.searchParams.set('token', token)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return imgUrl.href
|
return imgUrl.href
|
||||||
|
@ -20,76 +16,25 @@ const getProtectedUrl = url => {
|
||||||
/**
|
/**
|
||||||
* An image that needs authorization to load
|
* An image that needs authorization to load
|
||||||
*/
|
*/
|
||||||
export const ProtectedImage = ({ src, ...props }) => {
|
export const ProtectedImage = ({ src, ...props }) => (
|
||||||
// const [imgSrc, setImgSrc] = useState(null)
|
<img {...props} src={getProtectedUrl(src)} crossOrigin="use-credentials" />
|
||||||
|
)
|
||||||
// useEffect(() => {
|
|
||||||
// if (imageCache[src]) return
|
|
||||||
|
|
||||||
// const fetchController = new AbortController()
|
|
||||||
// let canceled = false
|
|
||||||
|
|
||||||
// setImgSrc('')
|
|
||||||
|
|
||||||
// const imgUrl = new URL(src)
|
|
||||||
// const fetchHeaders = {}
|
|
||||||
|
|
||||||
// if (localStorage.getItem('token') == null) {
|
|
||||||
// // Get share token if not authorized
|
|
||||||
|
|
||||||
// const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
|
|
||||||
// if (tokenRegex) {
|
|
||||||
// const token = tokenRegex[1]
|
|
||||||
// imgUrl.searchParams.set('token', token)
|
|
||||||
|
|
||||||
// const tokenPassword = sessionStorage.getItem(`share-token-pw-${token}`)
|
|
||||||
// if (tokenPassword) {
|
|
||||||
// fetchHeaders['TokenPassword'] = tokenPassword
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fetchProtectedImage(imgUrl.href, {
|
|
||||||
// signal: fetchController.signal,
|
|
||||||
// headers: fetchHeaders,
|
|
||||||
// })
|
|
||||||
// .then(newSrc => {
|
|
||||||
// if (!canceled) {
|
|
||||||
// setImgSrc(newSrc)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch(error => {
|
|
||||||
// console.log('Fetch image error', error.message)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// return function cleanup() {
|
|
||||||
// canceled = true
|
|
||||||
// fetchController.abort()
|
|
||||||
// }
|
|
||||||
// }, [src])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<img {...props} src={getProtectedUrl(src)} crossOrigin="use-credentials" />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtectedImage.propTypes = {
|
ProtectedImage.propTypes = {
|
||||||
src: PropTypes.string.isRequired,
|
src: PropTypes.string.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProtectedVideo = ({ media, ...props }) => {
|
export const ProtectedVideo = ({ media, ...props }) => (
|
||||||
return (
|
<video
|
||||||
<video
|
{...props}
|
||||||
{...props}
|
controls
|
||||||
controls
|
key={media.id}
|
||||||
key={media.id}
|
crossOrigin="use-credentials"
|
||||||
crossOrigin="use-credentials"
|
poster={getProtectedUrl(media.thumbnail.url)}
|
||||||
poster={getProtectedUrl(media.thumbnail.url)}
|
>
|
||||||
>
|
<source src={getProtectedUrl(media.videoWeb.url)} type="video/mp4" />
|
||||||
<source src={getProtectedUrl(media.videoWeb.url)} type="video/mp4" />
|
</video>
|
||||||
</video>
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtectedVideo.propTypes = {
|
ProtectedVideo.propTypes = {
|
||||||
media: PropTypes.object.isRequired,
|
media: PropTypes.object.isRequired,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { ProtectedImage, ProtectedVideo } from '../ProtectedMedia'
|
import { ProtectedImage, ProtectedVideo } from '../ProtectedMedia'
|
||||||
|
|
Loading…
Reference in New Issue