diff --git a/.drone.yml b/.drone.yml
index 5850895..12f0143 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -26,7 +26,7 @@ steps:
commands:
- ls -al
- cd web/fling
- - npm install && CI=false npm run build
+ - npm install && npm run build
- tar czf fling-web-latest.tar.gz build/
- curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file ./fling-web-latest.tar.gz https://nexus.friedl.net/repository/build-artifacts/fling-web-latest.tar.gz
diff --git a/service/fling/src/main/resources/application-local.yml b/service/fling/src/main/resources/application-local.yml
index ffaf6ee..57a824b 100644
--- a/service/fling/src/main/resources/application-local.yml
+++ b/service/fling/src/main/resources/application-local.yml
@@ -1,6 +1,6 @@
spring:
datasource:
- url: jdbc:h2:file:~/Desktop/testdb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;IFEXISTS=TRUE;
+ url: jdbc:h2:file:~/Desktop/testdb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;
driverClassName: org.h2.Driver
username: sa
password:
diff --git a/web/fling/src/components/LandingPage.jsx b/web/fling/src/components/LandingPage.jsx
index 4f2d774..1d48787 100644
--- a/web/fling/src/components/LandingPage.jsx
+++ b/web/fling/src/components/LandingPage.jsx
@@ -1,4 +1,3 @@
-import log from 'loglevel';
import React, {useState} from 'react';
import admin_area from './resources/admin_area.svg';
diff --git a/web/fling/src/components/admin/Error.jsx b/web/fling/src/components/admin/Error.jsx
index be4d4c4..25e07b9 100644
--- a/web/fling/src/components/admin/Error.jsx
+++ b/web/fling/src/components/admin/Error.jsx
@@ -1,7 +1,4 @@
-import React, {useState} from 'react';
-import classNames from 'classnames';
-
-import log from 'loglevel';
+import React from 'react';
export default (props) => {
function renderError() {
diff --git a/web/fling/src/components/admin/FlingAdmin.jsx b/web/fling/src/components/admin/FlingAdmin.jsx
index 9024fd2..50ce0ca 100644
--- a/web/fling/src/components/admin/FlingAdmin.jsx
+++ b/web/fling/src/components/admin/FlingAdmin.jsx
@@ -1,11 +1,10 @@
-import log from 'loglevel';
-import React, {useState} from 'react';
+import React from 'react';
import Navbar from './Navbar';
import FlingList from './FlingList';
import FlingContent from './FlingContent';
-import {useParams, BrowserRouter} from 'react-router-dom';
+import {useParams} from 'react-router-dom';
export default function FlingAdmin() {
let { fling } = useParams();
diff --git a/web/fling/src/components/admin/FlingArtifacts.jsx b/web/fling/src/components/admin/FlingArtifacts.jsx
index 6bf066d..52de4cd 100644
--- a/web/fling/src/components/admin/FlingArtifacts.jsx
+++ b/web/fling/src/components/admin/FlingArtifacts.jsx
@@ -1,13 +1,9 @@
import log from 'loglevel';
import React, {useState, useEffect, useRef} from 'react';
-import {useHistory, useLocation} from 'react-router-dom';
-
-import classNames from 'classnames';
import {artifactClient} from '../../util/flingclient';
function FlingArtifactControl(props) {
- let history = useHistory();
let iframeContainer = useRef(null);
function handleDelete(ev) {
diff --git a/web/fling/src/components/admin/FlingContent.jsx b/web/fling/src/components/admin/FlingContent.jsx
index 02b886d..e39a539 100644
--- a/web/fling/src/components/admin/FlingContent.jsx
+++ b/web/fling/src/components/admin/FlingContent.jsx
@@ -1,10 +1,6 @@
import log from 'loglevel';
-import React, {useState, useEffect, useRef} from 'react';
-import {Switch, Route, Redirect, BrowserRouter, useLocation, useParams, Link} from "react-router-dom";
-
-import classNames from 'classnames';
-
-import {artifactClient} from '../../util/flingclient';
+import React from 'react';
+import {Switch, Route, useLocation, Link} from "react-router-dom";
import FlingArtifacts from './FlingArtifacts';
import Upload from './Upload';
diff --git a/web/fling/src/components/admin/FlingList.jsx b/web/fling/src/components/admin/FlingList.jsx
index 247ad64..3b501a6 100644
--- a/web/fling/src/components/admin/FlingList.jsx
+++ b/web/fling/src/components/admin/FlingList.jsx
@@ -7,7 +7,18 @@ import FlingTile from './FlingTile';
export default function FlingList(props) {
const [flings, setFlings] = useState([]);
- useEffect(() => { refreshFlingList(); }, []);
+ useEffect(() => { (async () => {
+ let flings = await flingClient.getFlings();
+ let newFlings = [];
+
+ for (let fling of flings) {
+ let flingTile = ;
+ newFlings.push(flingTile);
+ }
+ setFlings(newFlings);
+ })(); } , []);
return(
@@ -22,15 +33,5 @@ export default function FlingList(props) {
);
async function refreshFlingList() {
- let flings = await flingClient.getFlings();
- let newFlings = [];
-
- for (let fling of flings) {
- let flingTile =
;
- newFlings.push(flingTile);
- }
- setFlings(newFlings);
}
}
diff --git a/web/fling/src/components/admin/FlingTile.jsx b/web/fling/src/components/admin/FlingTile.jsx
index 499f7ca..8b9b7f0 100644
--- a/web/fling/src/components/admin/FlingTile.jsx
+++ b/web/fling/src/components/admin/FlingTile.jsx
@@ -1,7 +1,7 @@
import log from 'loglevel';
-import React, {useRef, useState} from 'react';
+import React, {useRef} from 'react';
import classNames from 'classnames';
-import {Switch, Route, Redirect, BrowserRouter, useLocation, useParams, NavLink} from "react-router-dom";
+import {NavLink} from "react-router-dom";
import {flingClient} from '../../util/flingclient';
@@ -10,9 +10,9 @@ function TileAction(props) {
return(
diff --git a/web/fling/src/components/admin/Login.jsx b/web/fling/src/components/admin/Login.jsx
index 28e8380..361dc46 100644
--- a/web/fling/src/components/admin/Login.jsx
+++ b/web/fling/src/components/admin/Login.jsx
@@ -76,6 +76,9 @@ export default function Login() {
case "password":
setPassword(val);
break;
+ default:
+ log.error(`Cannot handle change ${name}`);
+ break;
}
};
diff --git a/web/fling/src/components/admin/Navbar.jsx b/web/fling/src/components/admin/Navbar.jsx
index 4b3e837..a189f66 100644
--- a/web/fling/src/components/admin/Navbar.jsx
+++ b/web/fling/src/components/admin/Navbar.jsx
@@ -1,8 +1,6 @@
-import log from 'loglevel';
import React, {useState} from 'react';
import New from './New';
-import request from '../../util/request';
import send from '../resources/send.svg';
export default function Navbar() {
diff --git a/web/fling/src/components/admin/New.jsx b/web/fling/src/components/admin/New.jsx
index 1028393..7a8fb30 100644
--- a/web/fling/src/components/admin/New.jsx
+++ b/web/fling/src/components/admin/New.jsx
@@ -1,5 +1,5 @@
import log from 'loglevel';
-import React, {useState, useEffect, useRef} from 'react';
+import React, {useState} from 'react';
import {flingClient} from '../../util/flingclient';
diff --git a/web/fling/src/components/admin/Settings.jsx b/web/fling/src/components/admin/Settings.jsx
index a5783a6..a516792 100644
--- a/web/fling/src/components/admin/Settings.jsx
+++ b/web/fling/src/components/admin/Settings.jsx
@@ -1,8 +1,5 @@
import log from 'loglevel';
-import React, {useState, useEffect, useRef} from 'react';
-import {useLocation, useHistory} from 'react-router-dom';
-
-import classNames from 'classnames';
+import React, {useState, useEffect} from 'react';
import {flingClient} from '../../util/flingclient';
@@ -14,13 +11,10 @@ export default function Settings(props) {
let [fling, setFling] = useState(defaultState());
let [shareUrlUnique, setShareUrlUnique] = useState(true);
let [authCodeChangeable, setAuthCodeChangeable] = useState(false);
- let location = useLocation();
- let history = useHistory();
+ let [reload, setReload] = useState(true);
- useEffect(() => loadSettings(), [props.activeFling]);
-
- function loadSettings() {
- if(props.activeFling) {
+ useEffect(() => {
+ if(props.activeFling && reload) {
flingClient.getFling(props.activeFling)
.then(result => {
let f = {...fling, ...result};
@@ -32,14 +26,15 @@ export default function Settings(props) {
setFling(f);
setAuthCodeChangeable(!f.authCode);
+ setReload(false);
});
}
- }
+ }, [props.activeFling, reload, fling]);
function reloadSettings(ev) {
ev.preventDefault();
setFling(defaultState());
- loadSettings();
+ setReload(true);
}
function resetAuthCode(ev) {
diff --git a/web/fling/src/components/admin/Upload.jsx b/web/fling/src/components/admin/Upload.jsx
index e0296cc..edf034e 100644
--- a/web/fling/src/components/admin/Upload.jsx
+++ b/web/fling/src/components/admin/Upload.jsx
@@ -1,8 +1,5 @@
import log from 'loglevel';
import React, {useState, useEffect, useRef} from 'react';
-import {Switch, Route, Redirect, BrowserRouter, useLocation, useParams, Link} from "react-router-dom";
-
-import classNames from 'classnames';
import {artifactClient} from '../../util/flingclient';
@@ -155,8 +152,6 @@ export default function Upload(props) {
}
function handleUpload() {
- let f = [...files];
-
files.forEach((file, idx) => {
artifactClient.postArtifact(props.activeFling, file)
.then(response => {
diff --git a/web/fling/src/components/user/DirectDownload.jsx b/web/fling/src/components/user/DirectDownload.jsx
index aec7c78..1055018 100644
--- a/web/fling/src/components/user/DirectDownload.jsx
+++ b/web/fling/src/components/user/DirectDownload.jsx
@@ -1,4 +1,3 @@
-import log from 'loglevel';
import React, {useRef, useState, useEffect} from 'react';
import {flingClient} from '../../util/flingclient';
diff --git a/web/fling/src/components/user/FlingUser.jsx b/web/fling/src/components/user/FlingUser.jsx
index 4b6dc55..ec13db7 100644
--- a/web/fling/src/components/user/FlingUser.jsx
+++ b/web/fling/src/components/user/FlingUser.jsx
@@ -1,7 +1,6 @@
-import log from 'loglevel';
import React, {useState, useEffect} from 'react';
-import {useParams, BrowserRouter} from 'react-router-dom';
+import {useParams} from 'react-router-dom';
import {flingClient} from '../../util/flingclient';
diff --git a/web/fling/src/components/user/FlingUserList.jsx b/web/fling/src/components/user/FlingUserList.jsx
index c61e46a..8985435 100644
--- a/web/fling/src/components/user/FlingUserList.jsx
+++ b/web/fling/src/components/user/FlingUserList.jsx
@@ -1,7 +1,7 @@
import log from 'loglevel';
import React, {useState, useEffect, useRef} from 'react';
-import {Switch, Route, Redirect, BrowserRouter, useLocation, useParams, Link} from "react-router-dom";
+import {Switch, Route, useLocation, Link} from "react-router-dom";
import {flingClient, artifactClient} from '../../util/flingclient';
@@ -33,10 +33,6 @@ function Artifacts(props) {
return d.toLocaleDateString();
}
- function getArtifactInfo() {
- return `${readableBytes(artifact.size)}, ${localizedDate(artifact.uploadTime)}`;
- }
-
return(
@@ -208,8 +204,6 @@ function Upload(props) {
}
function handleUpload() {
- let f = [...files];
-
files.forEach((file, idx) => {
artifactClient.postArtifact(props.fling.id, file)
.then(response => {
@@ -280,11 +274,8 @@ export default function FlingUserList(props) {
let iframeContainer = useRef(null);
let [infoText, setInfoText] = useState("");
let [inProgress, setInProgress] = useState(false);
- let [downloadUrl, setDownloadUrl] = useState("");
- useEffect(() => flingInfo(props.fling.id), [props.fling.id]);
-
- function flingInfo(flingId) {
+ useEffect((flingId) => {
if(!flingId) return;
function readableBytes(bytes) {
@@ -313,7 +304,7 @@ export default function FlingUserList(props) {
setInfoText(`${localizedDate(props.fling.creationTime)} - ${countArtifacts} files - ${readableBytes(totalSize)}`);
});
- }
+ }, [props.fling.id, props.fling.creationTime]);
function handleDownload(ev) {
ev.preventDefault();
@@ -328,7 +319,6 @@ export default function FlingUserList(props) {
let frame = document.createElement("iframe");
frame.src = downloadUrl;
iframeContainer.current.appendChild(frame);
- setDownloadUrl(downloadUrl);
setInProgress(false);
});
}
diff --git a/web/fling/src/components/user/Unlock.jsx b/web/fling/src/components/user/Unlock.jsx
index 55c09d2..3dec25c 100644
--- a/web/fling/src/components/user/Unlock.jsx
+++ b/web/fling/src/components/user/Unlock.jsx
@@ -4,10 +4,7 @@ import {useHistory, useLocation} from 'react-router-dom';
import request, {setAuth} from '../../util/request';
-import Error from './Error';
-
export default function Unlock() {
- const [errors, setErrors] = useState([]);
const [authCode, setAuthCode] = useState("");
const history = useHistory();
const location = useLocation();
@@ -23,7 +20,7 @@ export default function Unlock() {
history.replace(location.state.from);
})
.catch(err => {/* ignored */});
- }, [location]);
+ }, [location, history]);
return (
@@ -54,8 +51,6 @@ export default function Unlock() {
})
.catch(error => {
log.error(error);
- let response = error.response;
- response.data && response.data.message && setErrors( prev => [response.data.message, ...prev] );
});
};
@@ -63,8 +58,4 @@ export default function Unlock() {
let val = ev.target.value;
setAuthCode(val);
};
-
- function clearErrors() {
- setErrors([]);
- }
}
diff --git a/web/fling/src/util/flingclient.js b/web/fling/src/util/flingclient.js
index 85b42e8..543ee43 100644
--- a/web/fling/src/util/flingclient.js
+++ b/web/fling/src/util/flingclient.js
@@ -1,5 +1,4 @@
import log from 'loglevel';
-import axios from 'axios';
import request from './request';
diff --git a/web/fling/src/util/request.js b/web/fling/src/util/request.js
index 673b171..22830e8 100644
--- a/web/fling/src/util/request.js
+++ b/web/fling/src/util/request.js
@@ -1,4 +1,3 @@
-import log from 'loglevel';
import axios from 'axios';
import jwtDecode from 'jwt-decode';