fileControlPanel inital commit

This commit is contained in:
Roman Hergenreder 2021-01-07 20:47:43 +01:00
parent 61cebd4052
commit 7a603d7d90
7 changed files with 15187 additions and 0 deletions

@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}

23
fileControlPanel/.gitignore vendored Normal file

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

15038
fileControlPanel/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

@ -0,0 +1,41 @@
{
"name": "file-control-panel",
"version": "0.1.0",
"private": true,
"dependencies": {
"moment": "^2.26.0",
"react": "^16.13.1",
"react-collapse": "^5.0.1",
"react-dom": "^16.13.1",
"react-draft-wysiwyg": "^1.14.5",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1"
},
"scripts": {
"build": "webpack --mode production && mv dist/main.js ../js/files.min.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1",
"babel-loader": "^8.1.0",
"babel-polyfill": "^6.26.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
}
}

@ -0,0 +1,41 @@
import 'babel-polyfill';
export default class API {
constructor() {
this.loggedIn = false;
this.user = { };
}
csrfToken() {
return this.loggedIn ? this.user.session.csrf_token : null;
}
async apiCall(method, params) {
params = params || { };
params.csrf_token = this.csrfToken();
let response = await fetch("/api/" + method, {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(params)
});
let res = await response.json();
if (!res.success && res.msg === "You are not logged in.") {
document.location.reload();
}
return res;
}
async fetchUser() {
let response = await fetch("/api/user/info");
let data = await response.json();
this.user = data["user"];
this.loggedIn = data["loggedIn"];
return data && data.success && data.loggedIn;
}
async logout() {
return this.apiCall("user/logout");
}
};

@ -0,0 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom';
import API from "../../adminPanel/src/api";
class FileControlPanel extends React.Component {
constructor(props) {
super(props);
this.api = new API();
this.state = {
loaded: false
};
}
render() {
return <></>;
}
}
ReactDOM.render(
<FileControlPanel />,
document.getElementById('root')
);

@ -0,0 +1,17 @@
module.exports = {
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
};