Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/components/Admin/Log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import getConfig from 'next/config';
import he from 'he';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR from 'swr';
Expand Down Expand Up @@ -112,7 +111,10 @@ function LogHeader(properties) {
}

const decodeHtml = (line, index) => {
const lines = he.decode(line).split('<br>');
const BR_PLACEHOLDER = '\u0000BR\u0000';
const escaped = line.replace(/<br>/gi, BR_PLACEHOLDER);
const doc = new DOMParser().parseFromString(escaped, 'text/html');
const lines = doc.documentElement.textContent.split(BR_PLACEHOLDER);
return lines.map(element => {
index++;
return <p key={index}>{element}</p>;
Expand Down
5 changes: 1 addition & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
"@leifandersen/react-codemirror2": "^7.2.1",
"axios": "^0.21.0",
"codemirror": "^5.63.3",
"file-saver": "^2.0.5",
"he": "^1.2.0",
"html-react-parser": "^2.0.0",
"husky": "^8.0.1",
"jszip": "^3.6.0",
"mime-types": "^2.1.35",
"next": "10.0.1",
Expand All @@ -69,7 +66,6 @@
"react-toastify": "9.0.0",
"react-windowed-select": "^3.1.2",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.9",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"showdown": "^2.1.0",
Expand All @@ -96,6 +92,7 @@
"eslint-plugin-sonarjs": "^0.7.0",
"eslint-plugin-unicorn": "^32.0.1",
"eslint-plugin-unused-imports": "^1.1.5",
"husky": "^8.0.1",
"jest": "^27.0.1",
"lint-staged": "^11.0.0",
"prettier": "^2.3.0"
Expand Down
10 changes: 8 additions & 2 deletions frontend/redux/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios';
import { saveAs } from 'file-saver';
import JSZip from 'jszip';

import { mutate } from 'swr';
Expand Down Expand Up @@ -901,7 +900,14 @@ export const downloadFiles =
}
zip.generateAsync({ type: 'blob' }).then(function (content) {
dispatch({ type: types.SHOWDOWNLOAD, payload: false });
saveAs(content, zipFilename);
const url = URL.createObjectURL(content);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', zipFilename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
});
});
};
Expand Down
7 changes: 4 additions & 3 deletions frontend/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { useMemo } from 'react';
import { applyMiddleware, createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import { applyMiddleware, compose, createStore } from 'redux';
import thunkMiddleware from 'redux-thunk';

import reducers from './reducers';

let store;

function initStore(initialState) {
const composeEnhancers =
(typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
return createStore(
reducers,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
composeEnhancers(applyMiddleware(thunkMiddleware))
);
}

Expand Down
Loading