This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
feature/SC-3505/nexboard #230
Open
CeEv
wants to merge
15
commits into
develop
Choose a base branch
from
feature/SC-3505/Nextboard
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
40f6700
linter
CeEv 65db14c
linter
CeEv e1fdb8f
Merge branch 'develop' into feature/SC-3505/Nextboard
CeEv b1d0a1f
cleanup code
CeEv 715b2cb
Merge branch 'develop' into feature/SC-3505/Nextboard
CeEv 4d5be20
cleanup code and settings
57b121e
Merge branch 'feature/SC-3505/Nextboard' of https://github.com/schul-…
d01a61f
Add plugin to list.
5619dc2
WIP rewrite nextboard plugin
d073eb6
fix keys
b21a203
solved envs
CeEv b276aff
Merge branch 'develop' into feature/SC-3505/Nextboard
CeEv 434c2ff
Merge branch 'develop' into feature/SC-3505/Nextboard
CeEv 85905ac
Merge branch 'develop' into feature/SC-3505/Nextboard
CordlessWool eb4270c
Merge branch 'develop' into feature/SC-3505/Nextboard
CordlessWool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ envs=( | |
"SERVER_API_URL" | ||
"EDITOR_SOCKET_URL" | ||
"HOMEWORK_URI" | ||
"ETHERPAD_URL" | ||
"ENABLE_LTI" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
// We need the RAW file from the root dir | ||
// https://github.com/parcel-bundler/parcel/issues/1087#issuecomment-576810737 | ||
const script = document.createElement("script"); | ||
script.setAttribute("src", "env.js"); | ||
script.setAttribute("src", "/env.js"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this make problems when hosting in a subpath There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The env.js is placed on the same location like the editor base stuff. But the urls /course/id/... also include in the path if they load the env without /. |
||
script.setAttribute("type", "text/javascript"); | ||
document.head.prepend(script); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,10 +36,15 @@ import { createImagePlugin } from "@edtr-io/plugin-image" | |
// import { h5pPlugin } from "@edtr-io/plugin-h5p" | ||
|
||
// import nexboardPlugin from "./nexboard" | ||
import etherpadPlugin, {SizedEtherpadIcon} from "./etherpad" | ||
import etherpadPlugin, { SizedEtherpadIcon } from "./etherpad" | ||
import etherpadPluginPreview from "./etherpad/Preview" | ||
|
||
import nexboardPlugin, { SizedNextboardIcon } from "./nexboard" | ||
import nexboardPluginPreview from "./nexboard/Preview" | ||
|
||
// import lichtblickPlugin, {SizedLichtblickIcon} from "./lichtblick" | ||
// import lichtblickPluginPreview from "./lichtblick/Preview" | ||
|
||
import homework, {SizedHomeworkIcon} from "./homework" | ||
import ltiPlugin, {SizedLtiIcon} from "./lti" | ||
import ltiPluginPreview from "./lti/Preview" | ||
|
@@ -305,17 +310,27 @@ addPlugin({ | |
addPlugin({ | ||
name: 'etherpad', | ||
title: 'Etherpad', | ||
icon: SizedEtherpadIcon, | ||
description: 'Real time collaboration', | ||
icon: SizedEtherpadIcon, | ||
plugin: etherpadPlugin, | ||
preview: etherpadPluginPreview | ||
}) | ||
|
||
|
||
addPlugin({ | ||
name: "nxboard", | ||
title: "Nexboard", | ||
description: "Benutze das digitale Nexboard, um all deine Ideen festzuhalten!", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please localize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow up |
||
icon: SizedNextboardIcon, | ||
plugin: nexboardPlugin, | ||
preview: nexboardPluginPreview | ||
}) | ||
|
||
addPlugin({ | ||
name: 'homework', | ||
title: 'Aufgabe', | ||
icon: SizedHomeworkIcon, | ||
description: "Binde eine Aufgabe aus dem Kurs ein.", | ||
icon: SizedHomeworkIcon, | ||
plugin: homework, | ||
preview: homeworkPreview, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,82 @@ | ||
import React, { useState, useEffect, useContext } from "react" | ||
import LessonContext from "~/Contexts/Lesson.context" | ||
import UserContext from "~/Contexts/User" | ||
|
||
import { createBoard, getBoard } from "./utils" | ||
import Action from "~/components/Action" | ||
import Flex from "~/components/Flex" | ||
import Loader from "~/components/Loader" | ||
|
||
const Nexboard = ({ focused, state }) => { | ||
const [loading, setLoading] = useState(true) | ||
const [board, setBoard] = useState({}) | ||
const { store } = useContext(LessonContext) | ||
const { store: user } = useContext(UserContext) | ||
async function bootstrap() { | ||
try { | ||
let board | ||
if (state._id.value) { | ||
board = await getBoard(state._id.value) | ||
} else { | ||
board = await createBoard( | ||
store.lesson._id, | ||
`${store.lesson.title} Nexboard`, | ||
) | ||
} | ||
state._id.set(board._id) | ||
setBoard(board) | ||
} catch (err) {} | ||
const [loading, setLoading] = useState(true) | ||
const [error, setError] = useState(null) | ||
const [board, setBoard] = useState({}) | ||
const { store } = useContext(LessonContext) | ||
|
||
Metauriel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async function bootstrap() { | ||
try { | ||
let board | ||
const id = state.id.get(); | ||
if (id && id !== '<empty string>') { | ||
board = await getBoard(id) | ||
} else { | ||
const { _id: lessonId, attachments, title } = store.lesson; | ||
board = await createBoard(lessonId.toString(),{ | ||
title:`${title} Nexboard`, // TODO: should set by user | ||
attachments, | ||
description: '' | ||
}) | ||
state.id.set(board.id.toString()) | ||
} | ||
setBoard(board) | ||
} catch (err) { | ||
console.warn(err); | ||
setError(err); | ||
} | ||
|
||
setLoading(false) | ||
} | ||
setLoading(false) | ||
} | ||
|
||
useEffect(() => { | ||
bootstrap() | ||
}, []) | ||
useEffect(() => { | ||
bootstrap() | ||
}, []) | ||
|
||
if (loading) { | ||
return ( | ||
<Flex justifyCenter> | ||
<Loader /> | ||
</Flex> | ||
) | ||
} else { | ||
return ( | ||
<Flex column alignEnd> | ||
<iframe | ||
src={`${board.publicLink}?username=${user.displayName}`} | ||
style={{ | ||
width: "100%", | ||
height: "600px", | ||
resize: "vertical", | ||
overflow: "auto", | ||
border: "none", | ||
}} | ||
/> | ||
<Action | ||
a | ||
to={`${board.publicLink}?username=${user.displayName}`} | ||
target="_blank"> | ||
if (error) { | ||
return ( | ||
<div> | ||
<p>Can not render nexboard!</p> | ||
{JSON.stringify(error.message)} | ||
</div> | ||
) | ||
} else if (loading) { | ||
return ( | ||
<Flex justifyCenter> | ||
<Loader /> | ||
</Flex> | ||
) | ||
} else { | ||
const displayName = (store.user || {}).displayName || 'user'; | ||
// TODO: Username is not pass at he moment | ||
return ( | ||
<Flex column alignEnd> | ||
<iframe | ||
src={`${board.publicLink}?username=${displayName}`} | ||
style={{ | ||
width: "100%", | ||
height: "600px", | ||
resize: "vertical", | ||
overflow: "auto", | ||
border: "none", | ||
}} | ||
/> | ||
<Action | ||
a | ||
to={`${board.publicLink}?username=${displayName}`} | ||
target="_blank"> | ||
in neuem Tab öffnen | ||
</Action> | ||
</Flex> | ||
) | ||
} | ||
</Action> | ||
</Flex> | ||
) | ||
} | ||
} | ||
|
||
export default Nexboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import { serverApi } from "~/utils/api" | ||
import { editorApi, serverApi } from "~/utils/api" | ||
import config from "~/config" | ||
// TODO: do not use sockets for creating attachments | ||
// TODO: config is not set | ||
const { NEXBOARD_BOARDS_URI, NEXBOARD_PROJECTS_URI } = config; | ||
|
||
export const createBoard = async (lessonId, title) => { | ||
let nexboardAttachment = await serverApi.get( | ||
`/editor/attachments?key=nexboard&lesson=${lessonId}`, | ||
) | ||
const TYPE = 'nexboard-projectId'; | ||
export const createBoard = async (lessonId, { title, attachments = [], description }) => { | ||
let attach = attachments.find(a => a.type === TYPE) | ||
if (!attach) { | ||
const project = await serverApi.post(NEXBOARD_PROJECTS_URI, { | ||
title, | ||
}) | ||
attach = await editorApi.post("attachments", { | ||
type: TYPE, | ||
value: project.id.toString(), | ||
target: lessonId, | ||
targetModel: 'lesson' | ||
}) | ||
} | ||
|
||
if (!nexboardAttachment.length) { | ||
const nexboardProject = await serverApi.post(`/nexboard/projects`, { | ||
// title, | ||
}) | ||
|
||
nexboardAttachment = await serverApi.post("/editor/attachments", { | ||
key: "nexboard", | ||
value: nexboardProject._id, | ||
lesson: lessonId, | ||
}) | ||
} else { | ||
nexboardAttachment = nexboardAttachment[0] | ||
} | ||
|
||
const board = await serverApi.post(`/nexboard/boards`, { | ||
title, | ||
projectId: nexboardAttachment.value, | ||
// description, | ||
}) | ||
return board | ||
const board = await serverApi.post(NEXBOARD_BOARDS_URI, { | ||
title, | ||
projectId: attach.value.toString(), | ||
description, | ||
}) | ||
return board | ||
} | ||
|
||
export const getBoard = id => { | ||
return serverApi.get(`/nexboard/boards/${id}`) | ||
return serverApi.get(`${NEXBOARD_BOARDS_URI }/${id.toString()}`) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have no proper logger available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment no. It is log it to the browser console. We will later wrap the logger into a util. But i do not know if we must replace it with any popular logger. It will pass additional kBit to the editor that do not more then the base console logger.
If any error is throw it is pass to the user information, or to sentry send us. But this stuff is not finished, only as prototype.