Merge branch 'master' of git.friedl.net:incubator/fling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-07-29 01:53:31 +02:00
commit 5c6bd1b1ad
Signed by: armin
GPG key ID: 48C726EEE7FBCBC8
11 changed files with 31 additions and 13 deletions

View file

@ -2,7 +2,11 @@ FROM alpine:latest
ARG VERSION
RUN apk add --update --no-cache nginx openjdk11-jre && \
ENV FLING_API_BASE http://localhost:3000
ENV FLING_LOG_LEVEL warn
ENV FLING_FILESIZE 209715200
RUN apk add --update --no-cache nginx openjdk11-jre gettext && \
mkdir -p /var/fling/files && \
mkdir -p /tmp/fling && \
wget -O /tmp/fling/service.jar "https://nexus.friedl.net/service/rest/v1/search/assets/download?sort=version&maven.groupId=net.friedl&maven.artifactId=fling&maven.baseVersion=$(echo -n $VERSION | tr [:lower:] [:upper:])&maven.extension=jar" && \
@ -14,7 +18,8 @@ RUN apk add --update --no-cache nginx openjdk11-jre && \
mv /tmp/fling/service.jar ./service.jar
COPY ./etc/nginx/conf.d /etc/nginx/conf.d
COPY ./entrypoint.sh ./usr/local/bin/entrypoint.sh
COPY ./var/www/fling/config.js.template /var/www/fling/config.js.template
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
VOLUME /var/fling/

View file

@ -6,4 +6,6 @@ mkdir /var/run/nginx # nginx fails with /var/run/nginx/nginx.pid not found in al
nginx
cat /var/www/fling/config.js.template | envsubst > /var/www/fling/config.js
java ${FL_JVM_OPTS} -jar service.jar

View file

@ -0,0 +1,5 @@
window['flingconfig'] = {
API_BASE: "${FLING_API_BASE}",
LOG_LEVEL: "${FLING_LOG_LEVEL}",
FILESIZE: "${FLING_FILESIZE}"
}

View file

@ -0,0 +1,5 @@
window['flingconfig'] = {
API_BASE: "http://localhost:8080",
LOG_LEVEL: "warn",
FILESIZE: 209715200
}

View file

@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/fling.ico">
<script src="%PUBLIC_URL%/config.js"></script>
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.

View file

@ -22,7 +22,7 @@ function FlingArtifactControl(props) {
// the browser downloads the file fine, it also reloads the page, hence
// loosing all logs and state
let frame = document.createElement("iframe");
let url = `${process.env.REACT_APP_API.replace(/\/+$/, '')}/api/artifacts/${props.artifact.id}/data?derivedToken=${token}`;
let url = `${window['flingconfig'].API_BASE.replace(/\/+$/, '')}/api/artifacts/${props.artifact.id}/data?derivedToken=${token}`;
log.trace(`Generated download url: ${url}`);
frame.src = url;
iframeContainer.current.appendChild(frame);

View file

@ -82,7 +82,7 @@ export default function Upload() {
stopEvent(ev);
ev.persist();
let maxSize = process.env.REACT_APP_FILESIZE;
let maxSize = window['flingconfig'].FILESIZE;
let evFiles = fileListToArray(ev.dataTransfer.files);
for (let i = evFiles.length - 1; i >= 0; i--) {
@ -211,7 +211,7 @@ export default function Upload() {
</div>
<div className="upload-command-line m-2">
<span className="total-upload">Total Size: {totalSize()}</span>
<span className="total-upload">{`Max: ${prettifyBytes(process.env.REACT_APP_FILESIZE)}`}</span>
<span className="total-upload">{`Max: ${prettifyBytes(window['flingconfig'].FILESIZE)}`}</span>
<button className="btn btn-primary btn-upload" onClick={handleUpload}>Upload</button>
</div>
</div>

View file

@ -16,7 +16,7 @@ export default function FlingUser(props) {
let authClient = new AuthClient();
authClient.deriveToken({ singleUse: true })
.then(token => {
let url = `${process.env.REACT_APP_API.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
let url = `${window['flingconfig'].API_BASE.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
log.trace(`Generated download url for link: ${url}`);
setDownloadUrl(url);
})
@ -28,7 +28,7 @@ export default function FlingUser(props) {
// the browser downloads the file fine, it also reloads the page, hence
// loosing all logs and state
let frame = document.createElement("iframe");
let url = `${process.env.REACT_APP_API.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
let url = `${window['flingconfig'].API_BASE.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
log.trace(`Generated download url: ${url}`);
frame.src = url;
iframeContainer.current.appendChild(frame);

View file

@ -123,7 +123,7 @@ function Upload(props) {
stopEvent(ev);
ev.persist();
let maxSize = process.env.REACT_APP_FILESIZE;
let maxSize = window['flingconfig'].FILESIZE;
let evFiles = fileListToArray(ev.dataTransfer.files);
for (let i = evFiles.length - 1; i >= 0; i--) {
@ -252,7 +252,7 @@ function Upload(props) {
</div>
<div className="upload-command-line m-2">
<span className="total-upload">Total Size: {totalSize()}</span>
<span className="total-upload">{`Max: ${prettifyBytes(process.env.REACT_APP_FILESIZE)}`}</span>
<span className="total-upload">{`Max: ${prettifyBytes(window['flingconfig'].FILESIZE)}`}</span>
<button className="btn btn-primary btn-upload" onClick={handleUpload}>Upload</button>
</div>
</div>
@ -290,7 +290,7 @@ export default function FlingUserList(props) {
// the browser downloads the file fine, it also reloads the page, hence
// loosing all logs and state
let frame = document.createElement("iframe");
let url = `${process.env.REACT_APP_API.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
let url = `${window['flingconfig'].API_BASE.replace(/\/+$/, '')}/api/fling/${props.fling.id}/data?derivedToken=${token}`;
log.trace(`Generated download url: ${url}`);
frame.src = url;
setInProgress(false);

View file

@ -21,8 +21,8 @@ import * as serviceWorker from './serviceWorker';
/* Logging Setup */
log.setDefaultLevel(log.levels.TRACE);
if (process.env.REACT_APP_LOGLEVEL) {
log.setLevel(process.env.REACT_APP_LOGLEVEL);
if (window['flingconfig'].LOG_LEVEL) {
log.setLevel(window['flingconfig'].LOG_LEVEL);
}
/* Store setup */

View file

@ -9,7 +9,7 @@ import * as fc from '@fling/flingclient';
*/
let clientConfig = (token) => {
let config = new fc.ApiClient();
config.basePath = process.env.REACT_APP_API.replace(/\/+$/, '');
config.basePath = window['flingconfig'].API_BASE.replace(/\/+$/, '');
token = token || sessionStorage.getItem('token');
if (token) { config.authentications['bearer'].accessToken = token; }