Skip to content

Commit a7f6673

Browse files
committed
raise page image size
1 parent afe6960 commit a7f6673

File tree

7 files changed

+40
-19
lines changed

7 files changed

+40
-19
lines changed

components/gallery/CarouselImageView.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@ export const CarouselImageView: React.FunctionComponent<CarouselViewProps> = ({
1414
}) => {
1515
const { serverUrl, serverKey } = useContext<GlobalContextType>(GlobalContext);
1616
const [image, setImage] = useState("");
17-
1817
useEffect(() => {
19-
if (views && currentIndex) {
18+
if (views && currentIndex != undefined) {
2019
fetch(`${serverUrl}/api/files/thumbnail/${views[currentIndex].alt}`, {
2120
method: "GET",
2221
headers: {
2322
Authorization: serverKey,
2423
},
2524
})
2625
.then((res) => res.blob())
27-
.then((blob) => {
28-
console.log(views);
29-
setImage(URL.createObjectURL(blob));
30-
});
26+
.then((blob) => setImage(URL.createObjectURL(blob)));
3127
}
32-
}, [currentIndex, serverUrl, serverKey]);
28+
}, [currentIndex, views, serverUrl, serverKey]);
3329

3430
return (
3531
<div {...innerProps} style={{ width: "100%", height: "auto" }}>

components/gallery/SwanGallery.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Button } from "@material-ui/core";
1010
export const SwanGallery: React.FunctionComponent = () => {
1111
const [photos, setPhotos] = useState<PhotoProps[]>([]);
1212
const [currentImage, setCurrentImage] = useState(0);
13+
const [carouselIndex, setCarouselIndex] = useState(0);
1314
const [viewerIsOpen, setViewerIsOpen] = useState(false);
1415
const { serverUrl, serverKey } = useContext<GlobalContextType>(GlobalContext);
1516
const [cursor, setCursor] = useState<string | undefined>();
@@ -22,6 +23,7 @@ export const SwanGallery: React.FunctionComponent = () => {
2223

2324
const closeLightbox = () => {
2425
setCurrentImage(0);
26+
setCarouselIndex(0);
2527
setViewerIsOpen(false);
2628
};
2729

@@ -76,16 +78,18 @@ export const SwanGallery: React.FunctionComponent = () => {
7678
<Carousel
7779
trackProps={{
7880
onViewChange: (view: number) => {
79-
setCurrentImage(view);
81+
setCarouselIndex(view);
8082
},
8183
}}
82-
currentIndex={currentImage}
84+
currentIndex={carouselIndex}
8385
components={{ View: CarouselImageView }}
84-
views={photos.map((photo) => ({
85-
source: "/loading.gif",
86-
alt: photo.key,
87-
caption: photo.alt,
88-
}))}
86+
views={photos
87+
.slice(currentImage, currentImage + 25)
88+
.map((photo) => ({
89+
source: "/loading.gif",
90+
alt: photo.key,
91+
caption: photo.alt,
92+
}))}
8993
/>
9094
</Modal>
9195
) : null}

components/pages/PageContainer.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import Head from "next/head";
2-
import React, { useContext } from "react";
2+
import React, { useContext, useState } from "react";
33
import styles from "styles/Home.module.css";
44
import AppBar from "@material-ui/core/AppBar";
55
import Toolbar from "@material-ui/core/Toolbar";
66
import Typography from "@material-ui/core/Typography";
7-
import { InputBase } from "@material-ui/core";
7+
import { Button, InputBase } from "@material-ui/core";
88
import { GlobalContextType, GlobalContext } from "services/GlobalContext";
99
import { sha256 } from "js-sha256";
10+
import IconButton from "@material-ui/core/IconButton";
11+
import HttpsRoundedIcon from "@material-ui/icons/HttpsRounded";
1012

1113
export const PageContainer: React.FunctionComponent = ({ children }) => {
14+
const [url, setUrl] = useState("");
15+
const [key, setKey] = useState("");
1216
const { setServerUrl, setServerKey } = useContext<GlobalContextType>(
1317
GlobalContext
1418
);
@@ -22,16 +26,24 @@ export const PageContainer: React.FunctionComponent = ({ children }) => {
2226
<InputBase
2327
autoFocus={true}
2428
placeholder="Server URL"
25-
onChange={(event) => setServerUrl(event.target.value)}
29+
onChange={(event) => setUrl(event.target.value)}
2630
/>
2731
</div>
2832
<div className={styles.search}>
2933
<InputBase
3034
type="password"
3135
placeholder="Password"
32-
onChange={(event) => setServerKey(sha256(event.target.value))}
36+
onChange={(event) => setKey(sha256(event.target.value))}
3337
/>
3438
</div>
39+
<IconButton
40+
onClick={() => {
41+
setServerUrl(url);
42+
setServerKey(key);
43+
}}
44+
>
45+
<HttpsRoundedIcon />
46+
</IconButton>
3547
</Toolbar>
3648
</AppBar>
3749

hooks/useFiles.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const useFiles = (
1010

1111
useEffect(() => {
1212
const cursorUrlParam = cursor ? `cursor=${cursor}&` : "";
13-
const limitParam = "limit=50";
13+
const limitParam = "limit=1000";
1414

1515
if (serverUrl && serverKey) {
1616
fetch(`${serverUrl}/api/files?${cursorUrlParam}${limitParam}`, {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"@material-ui/core": "^4.11.3",
12+
"@material-ui/icons": "^4.11.2",
1213
"js-sha256": "^0.9.0",
1314
"next": "10.1.3",
1415
"react": "17.0.2",

styles/Home.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
border-radius: 5px;
132132
border-radius: 3;
133133
padding-left: 5px;
134+
padding-right: 5px;
134135
background-color: #c0d2f8;
135136
margin-left: 15px;
136137
width: auto;

yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@
8989
react-is "^16.8.0 || ^17.0.0"
9090
react-transition-group "^4.4.0"
9191

92+
"@material-ui/icons@^4.11.2":
93+
version "4.11.2"
94+
resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz#b3a7353266519cd743b6461ae9fdfcb1b25eb4c5"
95+
integrity sha512-fQNsKX2TxBmqIGJCSi3tGTO/gZ+eJgWmMJkgDiOfyNaunNaxcklJQFaFogYcFl0qFuaEz1qaXYXboa/bUXVSOQ==
96+
dependencies:
97+
"@babel/runtime" "^7.4.4"
98+
9299
"@material-ui/styles@^4.11.3":
93100
version "4.11.3"
94101
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.11.3.tgz#1b8d97775a4a643b53478c895e3f2a464e8916f2"

0 commit comments

Comments
 (0)