-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DMED-119 - Spike: direktes Einbinden der edu-sharing-Suchumgebung in den "Lern-Store" der SVS #2933
base: main
Are you sure you want to change the base?
Changes from 114 commits
809a67f
732215c
5447ebc
04579e3
a2477fc
84cdc0d
6553556
a992fb5
5fc0edd
5d24415
f3a0254
b4e552b
0197e35
ce53db9
550aece
5fedcda
8265e7f
0b09fe0
acb6670
cdff7b9
f733737
92e31b1
01b1ad6
bc7181d
e9d3306
03031bc
0645315
4c2d004
4f41e78
749f198
f1ef6e8
2343856
6584536
5241bbd
8c55e78
35adf46
8bee07a
22679d4
8e15be5
a275e4f
68b96d8
0b70d0f
9224521
d4ea623
7fd8248
d8cd17a
3d4db0b
9dd6a0e
470cfae
55ca55f
72cb29d
0874654
89d1a96
ef87093
cc2cf48
4f40417
da5f813
eef6574
b01521d
51b8098
e6cc322
b955141
e9a6032
18e9c84
28b73e5
be2958f
e7e49b8
0c6f800
f8c3f49
2f364c0
b6596dc
0f471bc
ad0b9ef
c27cae3
dda73b8
437c1bb
3c60c6f
7540a51
825adbb
e758c03
299dba6
23de68b
ed41e4e
ba7bb7a
3fedbbc
2fb1d9b
75c2b91
ba8d88c
bc7d392
bf0ad60
0f19bbf
6e13b8b
21b94f4
cdca079
2aa37bf
1d06bb5
9bd221f
3be1441
bf2219f
ece563f
dd9ce6e
30f365f
8774d1c
1c055e0
c350394
2d955d9
579a385
de4936b
8144ecc
c2485c1
6e66c5d
f663dc5
eb3c683
2da05f3
1c07aac
b0a4edb
02df50a
7c2540d
656a7fd
a267658
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ __snapshots__ | |
|
||
# IntelliJ | ||
.idea/ | ||
|
||
# exclude the public/content directory | ||
public/content |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
const { createProxyMiddleware } = require("http-proxy-middleware"); | ||
const { isVueClient } = require("../../src/router/vue-client-route"); | ||
const { | ||
isServer, | ||
isEduSharing, | ||
isEduSharingRepo, | ||
isFileStorage, | ||
isH5pEditor, | ||
isServer, | ||
} = require("../../src/router/server-route"); | ||
const url = require("url"); | ||
const path = require("path"); | ||
|
||
const createLegacyClientProxy = () => { | ||
const legacyClientProxy = createProxyMiddleware({ | ||
|
@@ -23,6 +26,14 @@ const createServerProxy = () => { | |
return serverProxy; | ||
}; | ||
|
||
const createEduSharingProxy = () => { | ||
const eduSharingProxy = createProxyMiddleware({ | ||
target: "http://localhost:4450", | ||
changeOrigin: true, | ||
}); | ||
return eduSharingProxy; | ||
}; | ||
|
||
const createFileStorageProxy = () => { | ||
const fileStorageProxy = createProxyMiddleware({ | ||
target: "http://localhost:4444", | ||
|
@@ -39,15 +50,25 @@ const createH5pEditorProxy = () => { | |
return h5pEditorProxy; | ||
}; | ||
|
||
const createEduSharingRepoProxy = () => { | ||
const eduSharingRepoProxy = createProxyMiddleware({ | ||
target: "http://localhost:8100", | ||
changeOrigin: true, | ||
}); | ||
return eduSharingRepoProxy; | ||
}; | ||
|
||
const createDevServerConfig = () => { | ||
const legacyClientProxy = createLegacyClientProxy(); | ||
const serverProxy = createServerProxy(); | ||
const eduSharingProxy = createEduSharingProxy(); | ||
const eduSharingRepoProxy = createEduSharingRepoProxy(); | ||
const fileStorageProxy = createFileStorageProxy(); | ||
const h5pEditorProxy = createH5pEditorProxy(); | ||
|
||
const devServerConfig = { | ||
port: 4000, | ||
historyApiFallback: true, | ||
port: 4000, | ||
|
||
setupMiddlewares: (middlewares, devServer) => { | ||
if (!devServer) { | ||
|
@@ -63,6 +84,10 @@ const createDevServerConfig = () => { | |
fileStorageProxy(req, res, next); | ||
} else if (isH5pEditor(path)) { | ||
h5pEditorProxy(req, res, next); | ||
} else if (isEduSharing(path)) { | ||
eduSharingProxy(req, res, next); | ||
} else if (isEduSharingRepo(path)) { | ||
eduSharingRepoProxy(req, res, next); | ||
} else if (isServer(path)) { | ||
serverProxy(req, res, next); | ||
} else if (isVueClient(path)) { | ||
|
@@ -73,6 +98,20 @@ const createDevServerConfig = () => { | |
}, | ||
}); | ||
|
||
// Copy assets before the dev server starts | ||
const __base = path.resolve(__dirname, "../.."); | ||
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. Es wäre super wenn der Code dafür noch unter einer Funktion mit bezeichnenden Namen geclustert wird. Ehrlich gesagt müsste ich aber noch mal über das warum es notwendig ist nachdenken. Bzw. hier wäre drüber reden hilfreich. Sind die ganzen Änderung potentiel etwas das hinter ein feature flag liegen sollten? |
||
|
||
const fs = require("fs-extra"); | ||
const source = path.resolve( | ||
__base, | ||
"node_modules/ngx-edu-sharing-app-as-web-component" | ||
); | ||
const destination = path.resolve( | ||
__base, | ||
"public/content/vendor/edu-sharing" | ||
); | ||
fs.copySync(source, destination); | ||
|
||
return middlewares; | ||
}, | ||
allowedHosts: "all", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"supportsES6": true, | ||
"withInterfaces": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<template> | ||
<main class="main-container"> | ||
<form class="search-form" :onsubmit="onSubmit"> | ||
<v-text-field | ||
class="search-input" | ||
density="comfortable" | ||
flat | ||
:hide-details="true" | ||
name="searchString" | ||
single-line | ||
type="outlined" | ||
placeholder="Search" | ||
:prepend-inner-icon="mdiMagnify" | ||
variant="solo" | ||
/> | ||
</form> | ||
<edu-sharing-app /> | ||
</main> | ||
</template> | ||
|
||
<script> | ||
import { envConfigModule } from "@/store"; | ||
import { mdiMagnify } from "@mdi/js"; | ||
import { useEduSharingApi } from "../../composables/edu-sharing-api.composable"; | ||
|
||
export default { | ||
name: "EduSharingWrapper", | ||
components: {}, | ||
data() { | ||
return { | ||
mdiMagnify, | ||
}; | ||
}, | ||
mounted() { | ||
// Provide the backend URL for edu-sharing to the web component. | ||
window.__env = { | ||
EDU_SHARING_API_URL: | ||
envConfigModule.getEnv.EDU_SHARING__API_URL + "/rest", | ||
}; | ||
|
||
const runtime = document.createElement("script"); | ||
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. createElement |
||
runtime.setAttribute("src", "/content/vendor/edu-sharing/runtime.js"); | ||
runtime.setAttribute("type", "module"); | ||
document.body.appendChild(runtime); | ||
|
||
const polyfills = document.createElement("script"); | ||
polyfills.setAttribute("src", "/content/vendor/edu-sharing/polyfills.js"); | ||
polyfills.setAttribute("type", "module"); | ||
document.body.appendChild(polyfills); | ||
|
||
// <!-- Alternatively to loading `scripts.js`, provide your own versions of jQuery. --> | ||
const scripts = document.createElement("script"); | ||
scripts.setAttribute("src", "/content/vendor/edu-sharing/scripts.js"); | ||
scripts.setAttribute("defer", ""); | ||
document.body.appendChild(scripts); | ||
|
||
const main = document.createElement("script"); | ||
main.setAttribute("src", "/content/vendor/edu-sharing/main.js"); | ||
main.setAttribute("type", "module"); | ||
document.body.appendChild(main); | ||
|
||
const styles = document.createElement("link"); | ||
styles.setAttribute("href", "/content/vendor/edu-sharing/styles.css"); | ||
styles.setAttribute("rel", "stylesheet"); | ||
document.body.appendChild(styles); | ||
|
||
// retrieve the valid session ticket | ||
(async () => { | ||
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. Ich kann dir nicht sagen wie es aussehen muss. Aber die api zur Komponente zu importieren und beim mount ein async einzubauen klinkt erstmal nicht richtig. |
||
const { getTicketForUser } = useEduSharingApi(); | ||
const ticket = await getTicketForUser(); | ||
const eduSharingApp = document.getElementsByTagName("edu-sharing-app")[0]; | ||
eduSharingApp.setAttribute("ticket", ticket); | ||
})(); | ||
}, | ||
methods: { | ||
onSubmit(event) { | ||
event.preventDefault(); | ||
const data = new FormData(event.target); | ||
const searchString = data.get("searchString"); | ||
const eduSharingApp = document.getElementsByTagName("edu-sharing-app")[0]; | ||
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. document.getElementsByTagName("edu-sharing-app")[0] = erstes Element von irgendwas externen klinkt jetzt erstmal nicht nach Langzeit Maintaince save. |
||
eduSharingApp.setAttribute("search-string", searchString); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
.main-container { | ||
min-height: 0; | ||
flex-grow: 1; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
} | ||
.search-form { | ||
height: 64px; | ||
flex-shrink: 0; | ||
padding: 10px 16px; | ||
background: #f3f5f7; | ||
} | ||
.search-input { | ||
width: 500px; | ||
border-radius: 2px; | ||
border: 1px solid var(--Secondary-v-secondary-base, #54616e); | ||
background: var(--shades---v-white-base, #fff); | ||
} | ||
edu-sharing-app { | ||
flex-grow: 1; | ||
} | ||
:deep(.v-field) { | ||
height: 44px; | ||
} | ||
Comment on lines
+88
to
+113
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. muss so viel custom css sein?
Comment on lines
+89
to
+113
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. Warum so viel eigene styles? |
||
</style> |
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.
Warum benötigt man ein eduSharingProxy und ein eduSharingRepoProxy? Was ist der Unterschied zwischen beiden?