Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Merged
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
852 changes: 849 additions & 3 deletions webapp_frontend/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion webapp_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@types/react-router-dom": "^5.1.6",
"axios": "^0.20.0",
"bootstrap": "^4.5.3",
"eslint-plugin-react-hooks": "^4.2.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-bootstrap": "^1.4.0",
Expand All @@ -35,7 +36,7 @@
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public --no-dll",
"build-storybook": "build-storybook -s public --no-dll",
"sonar": "SONAR_LOGIN=$SONAR_LOGIN SONAR_PASSWORD=$SONAR_PASSWORD node src/sonar-scanner.js"
"sonar": "SONAR_LOGIN=$SONAR_LOGIN SONAR_PASSWORD=$SONAR_PASSWORD node src/sonar-scanner.js"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
9 changes: 8 additions & 1 deletion webapp_frontend/src/background/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ export const getAccessTokenWithRefreshToken = () => {
},
};



Axios.get(hostname + userPath + '/auth', config)
.then((data) => {
setAuthHeaderToAxios(data.data.tokenValue)

store.dispatch(addAccessToken({token: data.data.tokenValue, timestamp: data.data.validUntil}as AccessToken));

//TODO: also get User data here

})
.catch(((error) => {
store.dispatch(removeTokens()as RemoveTokens);
Expand All @@ -94,6 +98,9 @@ export const getAccessTokenWithRefreshToken = () => {

}




export const logout=()=>{
store.dispatch(removeTokens());
deleteCookie(cookieName);
Expand All @@ -102,4 +109,4 @@ export const logout=()=>{
function setAuthHeaderToAxios(accessToken: string) {
Axios.defaults.headers.common['Authorization'] =
`Bearer ${accessToken}`;
}
}
236 changes: 236 additions & 0 deletions webapp_frontend/src/background/api/filesystem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
import {BackendFolderContentsData} from "./filesystemTypes";


export const getFolderContents = (path: string) => new Promise<BackendFolderContentsData>((resolve, reject) => {
console.log(`[filesytem api] request folder content of ${path}`);
resolve(exampleValue(path))
})

const exampleValue = (path: string): BackendFolderContentsData => {
if (path === "/") return exampleFileSystem
else if (path === "/fasel") return exampleFileSystem
else if (path === "/bla") return {
"files": [
{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "inBLA",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "file"
}
],
"folders": [{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "unterBla",
"path": "/bla/unterBla",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "FOLDER"
}]
}
else if (path === "/bla/unterBla") return {
"files": [
{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "inBLA",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "file"
}
],
"folders": []
}
return {"files": [], "folders": []}
}

const exampleFileSystem = {
"files": [
{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "string",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "FOLDER"
}
],
"folders": [
{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "bla",
"path": "/bla",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "FOLDER"
},
{
"createdByUserId": 0,
"id": 0,
"lastUpdated": 0,
"name": "fasel",
"path": "/fasel",
"permissionSet": {
"editableForGroups": [
"ADMIN"
],
"editableForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
],
"visibleForGroups": [
"ADMIN"
],
"visibleForUsers": [
{
"groups": [
"ADMIN"
],
"id": 0,
"username": "string"
}
]
},
"size": 0,
"type": "FOLDER"
}
]
}
42 changes: 42 additions & 0 deletions webapp_frontend/src/background/api/filesystemTypes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

export interface UsersSet {
groups: string[];
id: number;
username: string;
}


export interface PermissionSet {
editableForGroups: string[];
editableForUsers: UsersSet[];
visibleForGroups: string[];
visibleForUsers: UsersSet[];
}

export interface File {
createdByUserId: number;
id: number;
lastUpdated: number;
name: string;
permissionSet: PermissionSet;
size: number;
type: string;
}

export interface Folder {
createdByUserId: number;
id: number;
lastUpdated: number;
name: string;
path: string;
permissionSet: PermissionSet;
size: number;
type: string;
}

export interface BackendFolderContentsData {
files: File[];
folders: Folder[];
}


2 changes: 1 addition & 1 deletion webapp_frontend/src/background/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const prod: constants = {

const dev: constants = {
url: {
API_URL: 'https://cors-anywhere.herokuapp.com/http://filefighter.ddns.net:3001',
API_URL: 'http://filefighter.ddns.net:1081/http://filefighter.ddns.net:3001',
// API_URL: 'http://localhost:8080',
}
};
Expand Down
4 changes: 2 additions & 2 deletions webapp_frontend/src/background/methods/redirect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const internRedirect = (event: { preventDefault: () => void; }, history: any, path: string): void => {
event.preventDefault();
const internRedirect = (history: any, path: string, event?: { preventDefault: () => void; }): void => {
if (event) event.preventDefault();
if (path) {
const element = document.getElementById(path)
if (element) {
Expand Down
6 changes: 1 addition & 5 deletions webapp_frontend/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {ReactElement} from 'react';
import './App.css';
import {Container} from 'react-bootstrap';
import Header from "./basicElements/Header";
import Footer from "./basicElements/Footer";
import {BrowserRouter} from "react-router-dom";
Expand All @@ -16,7 +15,6 @@ import Login from "./basicElements/Login";
import {checkForCookie} from "../background/api/auth";



// this takes the redux store and maps everything that is needed to the function props
const mapState = (state: SystemState) => ({
tokens: {refreshToken: state.tokens.refreshToken, accessToken: state.tokens.accessToken, checkedCookies: state.tokens.checkedCookies},
Expand Down Expand Up @@ -51,9 +49,7 @@ function App(props: Props): ReactElement {
<div className="App">
<BrowserRouter>
<Header/>
<Container>
<Router/>
</Container>
<Router/>
<Footer/>
<PermanentAssets/>
</BrowserRouter>
Expand Down
Loading