Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scientia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zhige Yu
scientia
Commits
0ddc93ea
Commit
0ddc93ea
authored
4 years ago
by
Wilson Chua
Browse files
Options
Downloads
Patches
Plain Diff
Update with changes from materials test resources
parent
10486ce1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/components/pages/ModuleResources/index.tsx
+54
-151
54 additions, 151 deletions
frontend/src/components/pages/ModuleResources/index.tsx
frontend/src/components/pages/StandardView/index.tsx
+1
-1
1 addition, 1 deletion
frontend/src/components/pages/StandardView/index.tsx
with
55 additions
and
152 deletions
frontend/src/components/pages/ModuleResources/index.tsx
+
54
−
151
View file @
0ddc93ea
...
@@ -15,43 +15,73 @@ import ResourcesFolderView from "components/molecules/ResourcesFolderView";
...
@@ -15,43 +15,73 @@ import ResourcesFolderView from "components/molecules/ResourcesFolderView";
import
CurrentDirectoryView
from
"
components/molecules/CurrentDirectoryView
"
;
import
CurrentDirectoryView
from
"
components/molecules/CurrentDirectoryView
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
export
interface
Resource
{
title
:
string
;
type
:
string
;
tags
:
string
[];
folder
:
string
;
id
:
number
;
}
const
ModuleResources
:
React
.
FC
<
{
year
:
string
}
>
=
({
year
})
=>
{
const
ModuleResources
:
React
.
FC
<
{
year
:
string
}
>
=
({
year
})
=>
{
let
{
id
,
scope
}
=
useParams
();
let
{
id
,
scope
}
=
useParams
();
scope
=
scope
===
undefined
?
""
:
scope
;
scope
=
scope
===
undefined
?
""
:
scope
;
const
module_code
=
id
.
startsWith
(
"
CO
"
)
?
id
.
slice
(
2
)
:
id
;
//maybe refactor into class?
const
[
error
,
setError
]
=
useState
(
null
);
const
[
isLoaded
,
setIsLoaded
]
=
useState
(
false
);
const
[
resources
,
setResources
]
=
useState
<
Resource
[]
>
([]);
const
quickAccessItems
=
resource
Item
s
.
filter
(
const
quickAccessItems
=
resources
.
filter
(
({
tags
,
folder
})
=>
({
tags
,
folder
})
=>
tags
.
includes
(
"
new
"
)
&&
(
scope
===
""
||
scope
===
folder
)
tags
.
includes
(
"
new
"
)
&&
(
scope
===
""
||
scope
===
folder
)
);
);
const
currentDirectoryFiles
=
resource
Item
s
.
filter
(
const
currentDirectoryFiles
=
resources
.
filter
(
({
folder
})
=>
folder
===
scope
({
folder
})
=>
folder
===
scope
);
);
const
module_code
=
id
.
startsWith
(
"
CO
"
)
?
id
:
id
.
slice
(
2
);
//maybe refactor into class?
let
folders
:
{
title
:
string
;
id
:
number
;}[]
=
Array
.
from
(
new
Set
<
string
>
(
resources
.
map
((
res
:
Resource
)
=>
{
// const [error, setError] = useState(null);
return
res
.
folder
;
}))).
map
((
title
:
string
)
=>
{
// const [isLoaded, setIsLoaded] = useState(false);
return
{
// const [resources, setResources] = useState([]);
title
:
title
,
id
:
0
,
};
})
// useEffect(() => {
useEffect
(()
=>
{
// setIsLoaded(false);
setIsLoaded
(
false
);
// const onSuccess = (data: any) => {
const
onSuccess
=
(
data
:
{
json
:
()
=>
any
[];
})
=>
{
// setIsLoaded(true);
var
resourceArr
=
[];
// setResources(data.json());
var
json
=
data
.
json
()
// }
for
(
const
key
in
json
)
{
// const onFailure = (error: any) => {
let
resource
=
json
[
key
]
// setIsLoaded(true);
resourceArr
.
push
({
// setError(error);
title
:
resource
.
title
,
// }
type
:
resource
.
type
,
tags
:
resource
.
tags
,
folder
:
resource
.
category
,
id
:
resource
.
id
,
}
as
Resource
);
}
setResources
(
resourceArr
);
console
.
log
(
resources
);
setIsLoaded
(
true
);
}
const
onFailure
=
(
error
:
any
)
=>
{
setError
(
error
);
setIsLoaded
(
true
);
}
//
request(api.MATERIALS_RESOURCES, "GET", onSuccess, onFailure, {
request
(
api
.
MATERIALS_RESOURCES
,
"
GET
"
,
onSuccess
,
onFailure
,
{
//
"year": year,
"
year
"
:
year
,
//
"course": module_code
"
course
"
:
module_code
//
})
})
//
}, [year, module_code]);
},
[
year
,
module_code
]);
return
(
return
(
<>
<>
<
MyBreadcrumbs
/>
<
MyBreadcrumbs
/>
...
@@ -68,7 +98,7 @@ const ModuleResources: React.FC<{ year: string}> = ({year}) => {
...
@@ -68,7 +98,7 @@ const ModuleResources: React.FC<{ year: string}> = ({year}) => {
</
InputGroup
.
Append
>
</
InputGroup
.
Append
>
</
InputGroup
>
</
InputGroup
>
{
scope
===
""
&&
folder
Item
s
.
length
>
0
?
<
ResourcesFolderView
folderItems
=
{
folder
Item
s
}
/>
:
null
}
{
scope
===
""
&&
folders
.
length
>
0
?
<
ResourcesFolderView
folderItems
=
{
folders
}
/>
:
null
}
{
scope
!==
""
&&
currentDirectoryFiles
.
length
>
0
?
<
CurrentDirectoryView
documentItems
=
{
currentDirectoryFiles
}
/>
:
null
}
{
scope
!==
""
&&
currentDirectoryFiles
.
length
>
0
?
<
CurrentDirectoryView
documentItems
=
{
currentDirectoryFiles
}
/>
:
null
}
{
scope
===
""
&&
quickAccessItems
.
length
>
0
?
<
QuickAccessView
quickAccessItems
=
{
quickAccessItems
}
/>
:
null
}
{
scope
===
""
&&
quickAccessItems
.
length
>
0
?
<
QuickAccessView
quickAccessItems
=
{
quickAccessItems
}
/>
:
null
}
...
@@ -77,130 +107,3 @@ const ModuleResources: React.FC<{ year: string}> = ({year}) => {
...
@@ -77,130 +107,3 @@ const ModuleResources: React.FC<{ year: string}> = ({year}) => {
};
};
export
default
ModuleResources
;
export
default
ModuleResources
;
let
folderItems
=
[
{
title
:
"
Lecture Notes
"
,
id
:
0
,
},
{
title
:
"
Logic Exercise
"
,
id
:
1
,
},
{
title
:
"
Pandora Lab
"
,
id
:
2
,
},
{
title
:
"
Extra
"
,
id
:
3
,
},
];
let
resourceItems
=
[
{
title
:
"
How To Use Pandora
"
,
type
:
"
video
"
,
tags
:
[
"
new
"
,
"
WATCHME
"
],
folder
:
"
Pandora Lab
"
,
id
:
14
,
},
{
title
:
"
Logic Exercise 1
"
,
type
:
"
File
"
,
tags
:
[
"
Week 1
"
],
folder
:
"
Logic Exercise
"
,
id
:
8
,
},
{
title
:
"
Logic Exercise 2
"
,
type
:
"
File
"
,
tags
:
[
"
Week 2
"
],
folder
:
"
Logic Exercise
"
,
id
:
9
,
},
{
title
:
"
Logic Exercise 3
"
,
type
:
"
File
"
,
tags
:
[
"
new
"
,
"
Week 3
"
],
folder
:
"
Logic Exercise
"
,
id
:
10
,
},
{
title
:
"
Syntax Semantics Propositional Logic
"
,
type
:
"
pdf
"
,
tags
:
[
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
0
,
},
{
title
:
"
Classical First-Order Predicate Logic
"
,
type
:
"
pdf
"
,
tags
:
[
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
1
,
},
{
title
:
"
Translation Validity
"
,
type
:
"
pdf
"
,
tags
:
[
"
new
"
,
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
2
,
},
{
title
:
"
validityPL-part1
"
,
type
:
"
pdf
"
,
tags
:
[
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
3
,
},
{
title
:
"
validityPL-part2
"
,
type
:
"
pdf
"
,
tags
:
[
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
4
,
},
{
title
:
"
validityPL-part3
"
,
type
:
"
pdf
"
,
tags
:
[
"
new
"
,
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
5
,
},
{
title
:
"
validityFOL-part1
"
,
type
:
"
pdf
"
,
tags
:
[
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
6
,
},
{
title
:
"
validityFOL-part2
"
,
type
:
"
pdf
"
,
tags
:
[
"
new
"
,
"
Slides
"
],
folder
:
"
Lecture Notes
"
,
id
:
7
,
},
{
title
:
"
Pandora Lab
"
,
type
:
"
File
"
,
tags
:
[],
folder
:
"
Pandora Lab
"
,
id
:
11
,
},
{
title
:
"
Propositional Logic Exercises
"
,
type
:
"
pdf
"
,
tags
:
[
"
new
"
,
"
Revision
"
],
folder
:
"
Extra
"
,
id
:
12
,
},
{
title
:
"
Extra Logic Exercises
"
,
type
:
"
pdf
"
,
tags
:
[
"
new
"
,
"
Revision
"
],
folder
:
"
Extra
"
,
id
:
13
,
},
];
This diff is collapsed.
Click to expand it.
frontend/src/components/pages/StandardView/index.tsx
+
1
−
1
View file @
0ddc93ea
...
@@ -76,7 +76,7 @@ const StandardView: React.FC<StandardViewProps> = ({
...
@@ -76,7 +76,7 @@ const StandardView: React.FC<StandardViewProps> = ({
</
Route
>
</
Route
>
<
Route
path
=
"/modules/:id/resources/:scope?"
>
<
Route
path
=
"/modules/:id/resources/:scope?"
>
<
ModuleResources
year
=
"
1819
"
/>
<
ModuleResources
year
=
"
2021
"
/>
</
Route
>
</
Route
>
<
Route
path
=
"/modules/:id/feedback"
component
=
{
ModuleFeedback
}
/>
<
Route
path
=
"/modules/:id/feedback"
component
=
{
ModuleFeedback
}
/>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment