Skip to content
Snippets Groups Projects
Commit 8cb63bdd authored by danieldeng2's avatar danieldeng2
Browse files

Merge branch 'master' into 3-css-grid-timeline

parents 68355bbd 90dc5def
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ import styles from "./style.module.scss"; ...@@ -5,6 +5,7 @@ import styles from "./style.module.scss";
import classNames from "classnames"; import classNames from "classnames";
import { faGlobe, faLink } from "@fortawesome/free-solid-svg-icons"; import { faGlobe, faLink } from "@fortawesome/free-solid-svg-icons";
import PageButtonGroup from "components/molecules/PageButtonGroup"; import PageButtonGroup from "components/molecules/PageButtonGroup";
import queryString from "query-string";
import { request } from "../../../utils/api"; import { request } from "../../../utils/api";
import { api, methods } from "../../../constants/routes"; import { api, methods } from "../../../constants/routes";
...@@ -33,13 +34,19 @@ const ModuleDashboard: React.FC = () => { ...@@ -33,13 +34,19 @@ const ModuleDashboard: React.FC = () => {
data.json().then((json) => { data.json().then((json) => {
for (const key in json) { for (const key in json) {
let resource = json[key]; let resource = json[key];
if (resource.type !== "link") continue; let resourceURL = queryString.parseUrl(resource.path);
newButtons.push({ if (
title: resource.title, resource.type === "link" &&
icon: faLink, resourceURL.url !==
url: resource.path, "https://imperial.cloud.panopto.eu/Panopto/Pages/Viewer.aspx"
}); ) {
newButtons.push({
title: resource.title,
icon: faLink,
url: resource.path,
});
}
} }
setButtons((b) => b.concat(newButtons)); setButtons((b) => b.concat(newButtons));
}); });
...@@ -63,7 +70,10 @@ const ModuleDashboard: React.FC = () => { ...@@ -63,7 +70,10 @@ const ModuleDashboard: React.FC = () => {
<Dandruff heading={generateHeading(id)} /> <Dandruff heading={generateHeading(id)} />
<h4 className={classNames(styles.moduleSectionHeader)}>Module Aims</h4> <h4 className={classNames(styles.moduleSectionHeader)}>Module Aims</h4>
<div className={styles.moduleDashboardText} style={{ paddingTop: "0.75rem" }}> <div
className={styles.moduleDashboardText}
style={{ paddingTop: "0.75rem" }}
>
<span>In this module you will have the opportunity to:</span> <span>In this module you will have the opportunity to:</span>
<ul> <ul>
<li> <li>
......
...@@ -58,16 +58,17 @@ class ModuleResources extends React.Component<ResourcesProps, ResourceState> { ...@@ -58,16 +58,17 @@ class ModuleResources extends React.Component<ResourcesProps, ResourceState> {
let resourceURL = queryString.parseUrl(resource.path); let resourceURL = queryString.parseUrl(resource.path);
let thumbnail = undefined; let thumbnail = undefined;
let altType = undefined;
if ( if (
resource.type === "video" &&
resourceURL.url === resourceURL.url ===
"https://imperial.cloud.panopto.eu/Panopto/Pages/Viewer.aspx" "https://imperial.cloud.panopto.eu/Panopto/Pages/Viewer.aspx"
) { ) {
altType = "video";
thumbnail = `https://imperial.cloud.panopto.eu/Panopto/Services/FrameGrabber.svc/FrameRedirect?objectId=${resourceURL.query.id}&mode=Delivery`; thumbnail = `https://imperial.cloud.panopto.eu/Panopto/Services/FrameGrabber.svc/FrameRedirect?objectId=${resourceURL.query.id}&mode=Delivery`;
} }
resourceArr.push({ resourceArr.push({
title: resource.title, title: resource.title,
type: resource.type, type: altType || resource.type,
tags: resource.tags, tags: resource.tags,
folder: resource.category.toLowerCase(), folder: resource.category.toLowerCase(),
thumbnail: thumbnail, thumbnail: thumbnail,
...@@ -79,12 +80,11 @@ class ModuleResources extends React.Component<ResourcesProps, ResourceState> { ...@@ -79,12 +80,11 @@ class ModuleResources extends React.Component<ResourcesProps, ResourceState> {
}); });
}; };
const onFailure = (error: { text: () => Promise<any> }) => { const onFailure = (error: { text: () => Promise<any> }) => {
if (error.text){ if (error.text) {
error.text().then((errorText) => { error.text().then((errorText) => {
this.setState({ error: errorText, isLoaded: true }); this.setState({ error: errorText, isLoaded: true });
}); });
} }
}; };
request(api.MATERIALS_RESOURCES, methods.GET, onSuccess, onFailure, { request(api.MATERIALS_RESOURCES, methods.GET, onSuccess, onFailure, {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment