Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 624187f

Browse files
qvalentinGimleux
andauthored
Filesytem basics and navigation (#21)
* added the basics types and structure * basic layout * clicking is useless * first commit with new keyboard :D + added half the folder navigation * its working, don't click on files * formating * Removed Warnings * Added Table Head * removed new warning * Fixed missing render on manual change of view of file * use selfhosted cors anywhere * cleaning the logs Co-authored-by: Gimleux <[email protected]>
1 parent aecb034 commit 624187f

File tree

21 files changed

+1363
-37
lines changed

21 files changed

+1363
-37
lines changed

webapp_frontend/package-lock.json

Lines changed: 849 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp_frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@types/react-router-dom": "^5.1.6",
1717
"axios": "^0.20.0",
1818
"bootstrap": "^4.5.3",
19+
"eslint-plugin-react-hooks": "^4.2.0",
1920
"node-sass": "^4.14.1",
2021
"react": "^16.13.1",
2122
"react-bootstrap": "^1.4.0",
@@ -35,7 +36,7 @@
3536
"eject": "react-scripts eject",
3637
"storybook": "start-storybook -p 6006 -s public --no-dll",
3738
"build-storybook": "build-storybook -s public --no-dll",
38-
"sonar": "SONAR_LOGIN=$SONAR_LOGIN SONAR_PASSWORD=$SONAR_PASSWORD node src/sonar-scanner.js"
39+
"sonar": "SONAR_LOGIN=$SONAR_LOGIN SONAR_PASSWORD=$SONAR_PASSWORD node src/sonar-scanner.js"
3940
},
4041
"eslintConfig": {
4142
"extends": "react-app"

webapp_frontend/src/background/api/auth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ export const getAccessTokenWithRefreshToken = () => {
7878
},
7979
};
8080

81+
82+
8183
Axios.get(hostname + userPath + '/auth', config)
8284
.then((data) => {
8385
setAuthHeaderToAxios(data.data.tokenValue)
8486

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

89+
//TODO: also get User data here
90+
8791
})
8892
.catch(((error) => {
8993
store.dispatch(removeTokens()as RemoveTokens);
@@ -94,6 +98,9 @@ export const getAccessTokenWithRefreshToken = () => {
9498

9599
}
96100

101+
102+
103+
97104
export const logout=()=>{
98105
store.dispatch(removeTokens());
99106
deleteCookie(cookieName);
@@ -102,4 +109,4 @@ export const logout=()=>{
102109
function setAuthHeaderToAxios(accessToken: string) {
103110
Axios.defaults.headers.common['Authorization'] =
104111
`Bearer ${accessToken}`;
105-
}
112+
}
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
import {BackendFolderContentsData} from "./filesystemTypes";
2+
3+
4+
export const getFolderContents = (path: string) => new Promise<BackendFolderContentsData>((resolve, reject) => {
5+
console.log(`[filesytem api] request folder content of ${path}`);
6+
resolve(exampleValue(path))
7+
})
8+
9+
const exampleValue = (path: string): BackendFolderContentsData => {
10+
if (path === "/") return exampleFileSystem
11+
else if (path === "/fasel") return exampleFileSystem
12+
else if (path === "/bla") return {
13+
"files": [
14+
{
15+
"createdByUserId": 0,
16+
"id": 0,
17+
"lastUpdated": 0,
18+
"name": "inBLA",
19+
"permissionSet": {
20+
"editableForGroups": [
21+
"ADMIN"
22+
],
23+
"editableForUsers": [
24+
{
25+
"groups": [
26+
"ADMIN"
27+
],
28+
"id": 0,
29+
"username": "string"
30+
}
31+
],
32+
"visibleForGroups": [
33+
"ADMIN"
34+
],
35+
"visibleForUsers": [
36+
{
37+
"groups": [
38+
"ADMIN"
39+
],
40+
"id": 0,
41+
"username": "string"
42+
}
43+
]
44+
},
45+
"size": 0,
46+
"type": "file"
47+
}
48+
],
49+
"folders": [{
50+
"createdByUserId": 0,
51+
"id": 0,
52+
"lastUpdated": 0,
53+
"name": "unterBla",
54+
"path": "/bla/unterBla",
55+
"permissionSet": {
56+
"editableForGroups": [
57+
"ADMIN"
58+
],
59+
"editableForUsers": [
60+
{
61+
"groups": [
62+
"ADMIN"
63+
],
64+
"id": 0,
65+
"username": "string"
66+
}
67+
],
68+
"visibleForGroups": [
69+
"ADMIN"
70+
],
71+
"visibleForUsers": [
72+
{
73+
"groups": [
74+
"ADMIN"
75+
],
76+
"id": 0,
77+
"username": "string"
78+
}
79+
]
80+
},
81+
"size": 0,
82+
"type": "FOLDER"
83+
}]
84+
}
85+
else if (path === "/bla/unterBla") return {
86+
"files": [
87+
{
88+
"createdByUserId": 0,
89+
"id": 0,
90+
"lastUpdated": 0,
91+
"name": "inBLA",
92+
"permissionSet": {
93+
"editableForGroups": [
94+
"ADMIN"
95+
],
96+
"editableForUsers": [
97+
{
98+
"groups": [
99+
"ADMIN"
100+
],
101+
"id": 0,
102+
"username": "string"
103+
}
104+
],
105+
"visibleForGroups": [
106+
"ADMIN"
107+
],
108+
"visibleForUsers": [
109+
{
110+
"groups": [
111+
"ADMIN"
112+
],
113+
"id": 0,
114+
"username": "string"
115+
}
116+
]
117+
},
118+
"size": 0,
119+
"type": "file"
120+
}
121+
],
122+
"folders": []
123+
}
124+
return {"files": [], "folders": []}
125+
}
126+
127+
const exampleFileSystem = {
128+
"files": [
129+
{
130+
"createdByUserId": 0,
131+
"id": 0,
132+
"lastUpdated": 0,
133+
"name": "string",
134+
"permissionSet": {
135+
"editableForGroups": [
136+
"ADMIN"
137+
],
138+
"editableForUsers": [
139+
{
140+
"groups": [
141+
"ADMIN"
142+
],
143+
"id": 0,
144+
"username": "string"
145+
}
146+
],
147+
"visibleForGroups": [
148+
"ADMIN"
149+
],
150+
"visibleForUsers": [
151+
{
152+
"groups": [
153+
"ADMIN"
154+
],
155+
"id": 0,
156+
"username": "string"
157+
}
158+
]
159+
},
160+
"size": 0,
161+
"type": "FOLDER"
162+
}
163+
],
164+
"folders": [
165+
{
166+
"createdByUserId": 0,
167+
"id": 0,
168+
"lastUpdated": 0,
169+
"name": "bla",
170+
"path": "/bla",
171+
"permissionSet": {
172+
"editableForGroups": [
173+
"ADMIN"
174+
],
175+
"editableForUsers": [
176+
{
177+
"groups": [
178+
"ADMIN"
179+
],
180+
"id": 0,
181+
"username": "string"
182+
}
183+
],
184+
"visibleForGroups": [
185+
"ADMIN"
186+
],
187+
"visibleForUsers": [
188+
{
189+
"groups": [
190+
"ADMIN"
191+
],
192+
"id": 0,
193+
"username": "string"
194+
}
195+
]
196+
},
197+
"size": 0,
198+
"type": "FOLDER"
199+
},
200+
{
201+
"createdByUserId": 0,
202+
"id": 0,
203+
"lastUpdated": 0,
204+
"name": "fasel",
205+
"path": "/fasel",
206+
"permissionSet": {
207+
"editableForGroups": [
208+
"ADMIN"
209+
],
210+
"editableForUsers": [
211+
{
212+
"groups": [
213+
"ADMIN"
214+
],
215+
"id": 0,
216+
"username": "string"
217+
}
218+
],
219+
"visibleForGroups": [
220+
"ADMIN"
221+
],
222+
"visibleForUsers": [
223+
{
224+
"groups": [
225+
"ADMIN"
226+
],
227+
"id": 0,
228+
"username": "string"
229+
}
230+
]
231+
},
232+
"size": 0,
233+
"type": "FOLDER"
234+
}
235+
]
236+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
export interface UsersSet {
3+
groups: string[];
4+
id: number;
5+
username: string;
6+
}
7+
8+
9+
export interface PermissionSet {
10+
editableForGroups: string[];
11+
editableForUsers: UsersSet[];
12+
visibleForGroups: string[];
13+
visibleForUsers: UsersSet[];
14+
}
15+
16+
export interface File {
17+
createdByUserId: number;
18+
id: number;
19+
lastUpdated: number;
20+
name: string;
21+
permissionSet: PermissionSet;
22+
size: number;
23+
type: string;
24+
}
25+
26+
export interface Folder {
27+
createdByUserId: number;
28+
id: number;
29+
lastUpdated: number;
30+
name: string;
31+
path: string;
32+
permissionSet: PermissionSet;
33+
size: number;
34+
type: string;
35+
}
36+
37+
export interface BackendFolderContentsData {
38+
files: File[];
39+
folders: Folder[];
40+
}
41+
42+

webapp_frontend/src/background/constants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const prod: constants = {
1111

1212
const dev: constants = {
1313
url: {
14-
API_URL: 'https://cors-anywhere.herokuapp.com/http://filefighter.ddns.net:3001',
14+
API_URL: 'http://filefighter.ddns.net:1081/http://filefighter.ddns.net:3001',
1515
// API_URL: 'http://localhost:8080',
1616
}
1717
};

webapp_frontend/src/background/methods/redirect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const internRedirect = (event: { preventDefault: () => void; }, history: any, path: string): void => {
2-
event.preventDefault();
1+
const internRedirect = (history: any, path: string, event?: { preventDefault: () => void; }): void => {
2+
if (event) event.preventDefault();
33
if (path) {
44
const element = document.getElementById(path)
55
if (element) {

webapp_frontend/src/components/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {ReactElement} from 'react';
22
import './App.css';
3-
import {Container} from 'react-bootstrap';
43
import Header from "./basicElements/Header";
54
import Footer from "./basicElements/Footer";
65
import {BrowserRouter} from "react-router-dom";
@@ -16,7 +15,6 @@ import Login from "./basicElements/Login";
1615
import {checkForCookie} from "../background/api/auth";
1716

1817

19-
2018
// this takes the redux store and maps everything that is needed to the function props
2119
const mapState = (state: SystemState) => ({
2220
tokens: {refreshToken: state.tokens.refreshToken, accessToken: state.tokens.accessToken, checkedCookies: state.tokens.checkedCookies},
@@ -51,9 +49,7 @@ function App(props: Props): ReactElement {
5149
<div className="App">
5250
<BrowserRouter>
5351
<Header/>
54-
<Container>
55-
<Router/>
56-
</Container>
52+
<Router/>
5753
<Footer/>
5854
<PermanentAssets/>
5955
</BrowserRouter>

0 commit comments

Comments
 (0)