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 10 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
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
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
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 { NEXBOARD_BOARDS_URI, NEXBOARD_PROJECTS_URI } from "~/config" | ||
// TODO: do not use sockets for creating attachments | ||
// TODO: config is not set | ||
console.log('####', NEXBOARD_BOARDS_URI, NEXBOARD_PROJECTS_URI); | ||
CeEv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 || '/nexboard/projects', { | ||
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 || '/nexboard/boards', { | ||
title, | ||
projectId: attach.value.toString(), | ||
description, | ||
}) | ||
return board | ||
} | ||
|
||
export const getBoard = id => { | ||
return serverApi.get(`/nexboard/boards/${id}`) | ||
return serverApi.get(`${NEXBOARD_BOARDS_URI || '/nexboard/boards'}/${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.
Please localize
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.
follow up