Skip to content

Commit

Permalink
Add login widget and configuration
Browse files Browse the repository at this point in the history
You can already use it to log in/out, but the login data is not used yet.
  • Loading branch information
stefandesu committed Nov 18, 2024
1 parent eb88dfe commit d98469e
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BASE=/coli-rich/app/
LOGIN=http://localhost:3004
121 changes: 121 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"cocoda-sdk": "^3.4.12",
"gbv-login-client-vue": "^1.0.0",
"jskos-tools": "^1.0.42",
"jskos-vue": "^0.3.16",
"vue": "^3.5.11"
Expand Down
19 changes: 19 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { useInit } from "./composables/init.js"
// Run initialization immediately, then wait for the promise later
const initPromise = useInit()
import { useLogin } from "./composables/login.js"
const { loginConfigured } = useLogin()
import { version, name, showWhenExistsKey, examples } from "./config.js"
const ppninput = ref("")
Expand Down Expand Up @@ -236,6 +239,9 @@ function submitEnrichments() {
⬅ zurück zur coli-conc Webseite
</a>
</li>
<li v-if="loginConfigured">
<user-status />
</li>
</ul>
<div style="clear:both" />
</header>
Expand Down Expand Up @@ -608,4 +614,17 @@ header > h1 {
.faded {
color: grey;
}
/* UserStatus style fixes */
.user-status {
z-index: 9999;
}
.user-status > a {
font-size: initial;
}
header .user-status li {
float: none;
}
header .user-status li a {
text-align: left;
}
</style>
11 changes: 11 additions & 0 deletions src/composables/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Login } from "gbv-login-client-vue"
import { loginServerUrl, loginServerSsl } from "../config.js"

export function useLogin() {
if (loginServerUrl) {
Login.connect(loginServerUrl, { ssl: loginServerSsl })
}
return {
loginConfigured: !!loginServerUrl,
}
}
5 changes: 5 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ export const concordanceRegistry = cdk.initializeRegistry({
provider: "MappingsApi",
api: concordanceApi,
})

// eslint-disable-next-line no-undef
const loginServer = LOGIN_SERVER || null
export const loginServerUrl = loginServer && loginServer.replace(/https?:\/\//, "")
export const loginServerSsl = loginServer && loginServer.startsWith("https://")
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ import { LoadingIndicator, Modal } from "jskos-vue"
app.use(LoadingIndicator)
app.use(Modal)

import "gbv-login-client-vue/style"
import * as LoginClientVue from "gbv-login-client-vue"
app.use(LoginClientVue)

app.mount("#app")
1 change: 1 addition & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig({
plugins: [vue()],
define: {
BASE: `"${base || ""}"`,
LOGIN_SERVER: `"${process.env.LOGIN || ""}"`,
},
resolve: {
alias: {
Expand Down

0 comments on commit d98469e

Please sign in to comment.