Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results

Target

Select target project
  • 987FCF504483CBC8/toolkit
1 result
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results
Show changes
Commits on Source (139)
Showing
with 779 additions and 370 deletions
image: registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v1 image: registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v2
cache: cache:
key: ${CI_PROJECT_PATH} key: ${CI_PROJECT_PATH}
...@@ -51,8 +51,10 @@ publish: ...@@ -51,8 +51,10 @@ publish:
- chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa - chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -t rsa "${DEPLOY_HOST}" >> ~/.ssh/known_hosts - ssh-keyscan -t rsa "${DEPLOY_HOST}" >> ~/.ssh/known_hosts
# Deploy # Deploy
- cd toolkit-showcase - cd .gitlab-ci
- dep deploy --file ./../.gitlab-ci/deploy.php "${CI_ENVIRONMENT_NAME}" - export DO_NOT_TRACK=1
- composer install
- composer exec -- deployer.phar deploy "stage=${CI_ENVIRONMENT_NAME}"
- echo "Deployed to ${CI_ENVIRONMENT_URL}" - echo "Deployed to ${CI_ENVIRONMENT_URL}"
# Simple health check # Simple health check
- curl --max-time 10 --retry 3 --output /dev/null --silent --show-error --fail --location "${CI_ENVIRONMENT_URL}" - curl --max-time 10 --retry 3 --output /dev/null --silent --show-error --fail --location "${CI_ENVIRONMENT_URL}"
......
vendor/
\ No newline at end of file
FROM debian:buster FROM debian:bullseye
ENV LANG C.UTF-8 ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
...@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y \ ...@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y \
firefox-esr \ firefox-esr \
composer \ composer \
php-zip \ php-zip \
php-curl \
rsync \ rsync \
sudo \ sudo \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -34,11 +35,3 @@ RUN useradd -u 1000 -ms /bin/bash user ...@@ -34,11 +35,3 @@ RUN useradd -u 1000 -ms /bin/bash user
RUN echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER user USER user
WORKDIR /home/user WORKDIR /home/user
# Install deployer globally and add it to PATH
ENV COMPOSER_HOME="/home/user/.composer"
RUN mkdir -p "${COMPOSER_HOME}"
ADD composer.lock "${COMPOSER_HOME}"
ADD composer.json "${COMPOSER_HOME}"
RUN composer global install
ENV PATH "${COMPOSER_HOME}/vendor/bin:${PATH}"
\ No newline at end of file
#!/bin/bash #!/bin/bash
set -e set -e
TAG="registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v1" TAG="registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v2"
sudo docker build --tag "${TAG}" --file "Dockerfile" . sudo docker build --tag "${TAG}" --file "Dockerfile" .
echo "Now run: sudo docker push '$TAG'" echo "Now run: sudo docker push '$TAG'"
{ {
"require": { "require": {
"symfony/process": " ^4.4", "symfony/process": " ^5.0",
"symfony/console": " ^4.4", "symfony/console": " ^5.0",
"symfony/yaml": " ^4.4", "symfony/yaml": " ^5.0",
"deployer/deployer": " ^6.4", "deployer/deployer": "^7.0.0-rc.3"
"deployer/recipes": " ^6.2" },
"config": {
"platform": {
"php": "7.3"
}
} }
} }
This diff is collapsed.
<?php <?php
declare(strict_types=1);
namespace Deployer; namespace Deployer;
require 'recipe/common.php'; import('recipe/common.php');
require 'recipe/rsync.php'; import('contrib/rsync.php');
// Global config $PROJECT_ROOT = dirname(__DIR__).'/toolkit-showcase';
set('allow_anonymous_stats', false);
set('rsync',[ $RSYNC_CONFIG = [
'exclude' => [ 'exclude' => [],
'.git',
'deploy.php',
],
'exclude-file' => false, 'exclude-file' => false,
'include' => [], 'include' => [],
'include-file' => false, 'include-file' => false,
'filter' => [], 'filter' => [],
'filter-file' => false, 'filter-file' => false,
'filter-perdir'=> false, 'filter-perdir' => false,
'flags' => 'rz', 'flags' => 'rz',
'options' => ['delete'], 'options' => ['delete', 'links'],
'timeout' => 60, 'timeout' => 60,
]); ];
set('rsync_src', __DIR__ . '/../toolkit-showcase/dist');
set('rsync_dest','{{release_path}}');
// Hosts // Hosts
host('demo') host('demo')
->stage('demo') ->set('labels', ['stage' => 'demo'])
->hostname('mw@vpu01-demo.tugraz.at') ->setHostname('mw@vpu01-demo.tugraz.at')
->set('rsync', $RSYNC_CONFIG)
->set('rsync_src', $PROJECT_ROOT.'/dist')
->set('deploy_path', '/home/mw/demo/deploy/apps/demo'); ->set('deploy_path', '/home/mw/demo/deploy/apps/demo');
host('development') host('development')
->stage('development') ->set('labels', ['stage' => 'development'])
->hostname('mw@mw01-dev.tugraz.at') ->setHostname('mw@mw01-dev.tugraz.at')
->set('rsync', $RSYNC_CONFIG)
->set('rsync_src', $PROJECT_ROOT.'/dist')
->set('deploy_path', '/home/mw/dev/deploy/apps/demo'); ->set('deploy_path', '/home/mw/dev/deploy/apps/demo');
task('build', function () { task('build', function () use ($PROJECT_ROOT) {
$stage = get('stage'); $options = ['cwd' => $PROJECT_ROOT];
runLocally("yarn install --frozen-lockfile"); $stage = get('labels')['stage'];
runLocally("APP_ENV=$stage yarn run build"); runLocally("yarn install --frozen-lockfile", $options);
runLocally("APP_ENV=$stage yarn run build", $options);
}); });
// Deploy task // Deploy task
task('deploy', [ task('deploy', [
'deploy:info', 'deploy:info',
'build', 'build',
'deploy:prepare', 'deploy:setup',
'deploy:lock', 'deploy:lock',
'deploy:release', 'deploy:release',
'rsync', 'rsync',
'deploy:shared', 'deploy:shared',
'deploy:symlink', 'deploy:symlink',
'deploy:unlock', 'deploy:unlock',
'cleanup', 'deploy:cleanup',
'success', 'deploy:success',
]); ]);
after('deploy:failed', 'deploy:unlock'); after('deploy:failed', 'deploy:unlock');
...@@ -35,6 +35,7 @@ the version number in its `package.json` is higher than the version number on np ...@@ -35,6 +35,7 @@ the version number in its `package.json` is higher than the version number on np
| `unsubscribe` | Reserved for future use | | `unsubscribe` | Reserved for future use |
| `auth` | Authentication information, set by the authentication component | | `auth` | Authentication information, set by the authentication component |
| `lang` | Currently selected language, set by the language selector | | `lang` | Currently selected language, set by the language selector |
| `lang-dir` | Location of the i18n language file where all required i18n translations are |
| `entry-point-url` | Entry point url for all api requests | | `entry-point-url` | Entry point url for all api requests |
| `requested-login-status` | Used by the login buttons to trigger a login in auth components | | `requested-login-status` | Used by the login buttons to trigger a login in auth components |
| `initial-file-handling-state` | Used by the file-handling component to sync file source/sink at first time open | | `initial-file-handling-state` | Used by the file-handling component to sync file source/sink at first time open |
......
{ {
"name": "dbp-toolkit", "name": "dbp-toolkit",
"version": "0.1.1", "version": "0.1.2",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"private": true, "private": true,
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"author": "", "author": "",
"license": "LGPL-2.1-or-later", "license": "LGPL-2.1-or-later",
"devDependencies": { "devDependencies": {
"lerna": "^4.0.0" "lerna": "^5.0.0"
}, },
"dependencies": {} "dependencies": {}
} }
{ {
"name": "@dbp-toolkit/app-shell", "name": "@dbp-toolkit/app-shell",
"homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/app-shell", "homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/app-shell",
"version": "0.3.1", "version": "0.3.3",
"main": "src/index.js", "main": "src/index.js",
"license": "LGPL-2.1-or-later", "license": "LGPL-2.1-or-later",
"repository": { "repository": {
...@@ -15,18 +15,18 @@ ...@@ -15,18 +15,18 @@
}, },
"devDependencies": { "devDependencies": {
"@esm-bundle/chai": "^4.2.0", "@esm-bundle/chai": "^4.2.0",
"@rollup/plugin-commonjs": "^21.0.0", "@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0", "@rollup/plugin-node-resolve": "^13.0.0",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-plugin-jsdoc": "^39.0.0", "eslint-plugin-jsdoc": "^39.0.0",
"glob": "^7.1.6", "glob": "^8.0.0",
"i18next-parser": "^6.3.0", "i18next-parser": "^6.3.0",
"karma": "^6.0.0", "karma": "^6.0.0",
"karma-chrome-launcher": "^3.0.0", "karma-chrome-launcher": "^3.0.0",
"karma-firefox-launcher": "^2.1.0", "karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1", "karma-mocha": "^2.0.1",
"mocha": "^9.0.0", "mocha": "^10.0.0",
"playwright-core": "^1.20.2", "playwright-core": "^1.20.2",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"rollup": "^2.33.3", "rollup": "^2.33.3",
...@@ -36,12 +36,13 @@ ...@@ -36,12 +36,13 @@
"rollup-plugin-serve": "^1.0.1" "rollup-plugin-serve": "^1.0.1"
}, },
"dependencies": { "dependencies": {
"@dbp-toolkit/auth": "^0.3.0", "@dbp-toolkit/auth": "^0.3.1",
"@dbp-toolkit/common": "^0.3.0", "@dbp-toolkit/common": "^0.3.3",
"@dbp-toolkit/language-select": "^0.3.0", "@dbp-toolkit/language-select": "^0.3.1",
"@dbp-toolkit/matomo": "^0.2.2", "@dbp-toolkit/matomo": "^0.2.6",
"@dbp-toolkit/notification": "^0.3.0", "@dbp-toolkit/notification": "^0.3.1",
"@dbp-toolkit/person-profile": "^0.2.2", "@dbp-toolkit/person-profile": "^0.2.5",
"@dbp-toolkit/theme-switcher": "^0.0.4",
"@open-wc/scoped-elements": "^2.1.0", "@open-wc/scoped-elements": "^2.1.0",
"i18next": "^21.4.2", "i18next": "^21.4.2",
"lit": "^2.0.0", "lit": "^2.0.0",
......
...@@ -62,6 +62,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -62,6 +62,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
this._roles = []; this._roles = [];
this._i18n = createInstance(); this._i18n = createInstance();
this.lang = this._i18n.language; this.lang = this._i18n.language;
this._extra = [];
this.matomoUrl = ''; this.matomoUrl = '';
this.matomoSiteId = -1; this.matomoSiteId = -1;
...@@ -73,6 +74,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -73,6 +74,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
this.initateOpenMenu = false; this.initateOpenMenu = false;
this.auth = {}; this.auth = {};
this.langDir = '';
} }
static get scopedElements() { static get scopedElements() {
...@@ -179,6 +181,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -179,6 +181,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
return { return {
lang: this.lang, lang: this.lang,
component: '', component: '',
extra: [],
}; };
}, },
}, },
...@@ -191,18 +194,20 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -191,18 +194,20 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
return { return {
lang: params.lang, lang: params.lang,
component: '', component: '',
extra: [],
}; };
}, },
}, },
{ {
name: 'mainRoute', name: 'mainRoute',
path: '/:component', path: ['/:component', '/:component/(.*)'],
action: (context, params) => { action: (context, params) => {
// remove the additional parameters added by Keycloak let componentTag = params.component.toLowerCase();
let componentTag = params.component.toLowerCase().replace(/&.+/, ''); let extra = params[0] ? params[0].split('/') : [];
return { return {
lang: params.lang, lang: params.lang,
component: componentTag, component: componentTag,
extra: extra,
}; };
}, },
}, },
...@@ -218,17 +223,20 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -218,17 +223,20 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
let state = { let state = {
component: this.activeView, component: this.activeView,
lang: this.lang, lang: this.lang,
extra: this._extra,
}; };
return state; return state;
}, },
setState: (state) => { setState: (state) => {
this.updateLangIfChanged(state.lang); this.updateLangIfChanged(state.lang);
this.switchComponent(state.component); this.switchComponent(state.component);
this._extra = state.extra;
}, },
getDefaultState: () => { getDefaultState: () => {
return { return {
lang: 'de', lang: 'de',
component: this.routes[0], component: this.routes[0],
extra: [],
}; };
}, },
}, },
...@@ -264,14 +272,17 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -264,14 +272,17 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
buildTime: {type: String, attribute: 'build-time'}, buildTime: {type: String, attribute: 'build-time'},
env: {type: String}, env: {type: String},
auth: {type: Object}, auth: {type: Object},
langDir: {type: String, attribute: 'lang-dir'},
}; };
} }
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
if (this.src) this.fetchMetadata(this.src);
this.initRouter(); this.initRouter();
if (this.src) {
this.fetchMetadata(this.src);
}
} }
/** /**
...@@ -692,7 +703,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -692,7 +703,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
background-position:center center; background-position:center center;
margin: 0 0.5% 0 1.5%; margin: 0 0.5% 0 1.5%;
font-size:94%; font-size:94%;
} }
*/ */
.menu a { .menu a {
......
...@@ -4,7 +4,7 @@ import {unsafeHTML} from 'lit/directives/unsafe-html.js'; ...@@ -4,7 +4,7 @@ import {unsafeHTML} from 'lit/directives/unsafe-html.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
import {Icon} from '@dbp-toolkit/common'; import {Icon} from '@dbp-toolkit/common';
import {AdapterLitElement} from '@dbp-toolkit/provider/src/adapter-lit-element'; import {AdapterLitElement} from '@dbp-toolkit/common';
import {LoginStatus} from '@dbp-toolkit/auth/src/util'; import {LoginStatus} from '@dbp-toolkit/auth/src/util';
export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) { export class AuthMenuButton extends ScopedElementsMixin(AdapterLitElement) {
......
import {html, css} from 'lit'; import {html, css} from 'lit';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
import {AdapterLitElement} from '@dbp-toolkit/provider/src/adapter-lit-element'; import {AdapterLitElement} from '@dbp-toolkit/common';
export class BuildInfo extends AdapterLitElement { export class BuildInfo extends AdapterLitElement {
constructor() { constructor() {
......
...@@ -61,7 +61,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) { ...@@ -61,7 +61,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
cursor: pointer; cursor: pointer;
text-decoration: none; text-decoration: none;
} }
h2 a { h2 a {
white-space: nowrap; white-space: nowrap;
} }
...@@ -80,7 +80,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) { ...@@ -80,7 +80,7 @@ class AppShellWelcome extends ScopedElementsMixin(LitElement) {
-webkit-mask-position: center center; -webkit-mask-position: center center;
mask-position: center center; mask-position: center center;
margin: 0 2px 0 0px; margin: 0 2px 0 0px;
padding: 0 0 0.25% 0; padding: 0;
-webkit-mask-size: 100%; -webkit-mask-size: 100%;
mask-size: 100%; mask-size: 100%;
} }
......
import UniversalRouter from 'universal-router'; import UniversalRouter from 'universal-router';
import generateUrls from 'universal-router/generateUrls'; import generateUrls from 'universal-router/generateUrls';
function stateMatches(a, b) {
return JSON.stringify(a, Object.keys(a).sort()) === JSON.stringify(b, Object.keys(b).sort());
}
/** /**
* A wrapper around UniversalRouter which adds history integration * A wrapper around UniversalRouter which adds history integration
*/ */
...@@ -31,28 +35,24 @@ export class Router { ...@@ -31,28 +35,24 @@ export class Router {
window.addEventListener('popstate', (event) => { window.addEventListener('popstate', (event) => {
this.setStateFromCurrentLocation(); this.setStateFromCurrentLocation();
this.dispatchLocationChanged(); this._dispatchLocationChanged();
}); });
} }
async _getStateForPath(pathname) {
let isBasePath = pathname.replace(/\/$/, '') === this.router.baseUrl.replace(/\/$/, '');
if (isBasePath) {
return this.getDefaultState();
}
return this.router.resolve({pathname: pathname});
}
/** /**
* In case something else has changed the location, update the app state accordingly. * In case something else has changed the location, update the app state accordingly.
*/ */
setStateFromCurrentLocation() { setStateFromCurrentLocation() {
const oldPathName = location.pathname; this._getStateForPath(location.pathname)
this.router
.resolve({pathname: oldPathName})
.then((page) => { .then((page) => {
const newPathname = this.getPathname(page);
// In case of a router redirect, set the new location
if (newPathname !== oldPathName) {
const referrerUrl = location.href;
window.history.replaceState({}, '', newPathname);
this.dispatchLocationChanged(referrerUrl);
} else if (this.isBasePath(oldPathName)) {
page = this.getDefaultState();
}
this.setState(page); this.setState(page);
}) })
.catch((e) => { .catch((e) => {
...@@ -61,10 +61,6 @@ export class Router { ...@@ -61,10 +61,6 @@ export class Router {
}); });
} }
isBasePath(pathname) {
return pathname.replace(/\/$/, '') === this.router.baseUrl.replace(/\/$/, '');
}
/** /**
* Update the router after some internal state change. * Update the router after some internal state change.
*/ */
...@@ -72,18 +68,21 @@ export class Router { ...@@ -72,18 +68,21 @@ export class Router {
// Queue updates so we can call this multiple times when changing state // Queue updates so we can call this multiple times when changing state
// without it resulting in multiple location changes // without it resulting in multiple location changes
setTimeout(() => { setTimeout(() => {
const newPathname = this.getPathname(); this._getStateForPath(location.pathname)
const oldPathname = location.pathname; .then((page) => {
if (newPathname === oldPathname) return; const newState = this.getState();
// if the state has changed we update
const defaultPathname = this.getPathname(this.getDefaultState()); if (!stateMatches(newState, page)) {
if (newPathname === defaultPathname && this.isBasePath(oldPathname)) { const newPathname = this.getPathname();
return; const referrerUrl = location.href;
} window.history.pushState({}, '', newPathname);
this._dispatchLocationChanged(referrerUrl);
const referrerUrl = location.href; }
window.history.pushState({}, '', newPathname); })
this.dispatchLocationChanged(referrerUrl); .catch((e) => {
// In case we can't resolve the location, just leave things as is.
// This happens when a user enters a wrong URL or when testing with karma.
});
}); });
} }
...@@ -93,14 +92,15 @@ export class Router { ...@@ -93,14 +92,15 @@ export class Router {
* @param {string} pathname * @param {string} pathname
*/ */
updateFromPathname(pathname) { updateFromPathname(pathname) {
this.router this._getStateForPath(pathname)
.resolve({pathname: pathname})
.then((page) => { .then((page) => {
if (location.pathname === pathname) return; const oldState = this.getState();
const referrerUrl = location.href; if (!stateMatches(oldState, page)) {
window.history.pushState({}, '', pathname); const referrerUrl = location.href;
this.setState(page); window.history.pushState({}, '', pathname);
this.dispatchLocationChanged(referrerUrl); this.setState(page);
this._dispatchLocationChanged(referrerUrl);
}
}) })
.catch((err) => { .catch((err) => {
throw new Error(`Route not found: ${pathname}: ${err}`); throw new Error(`Route not found: ${pathname}: ${err}`);
...@@ -117,7 +117,9 @@ export class Router { ...@@ -117,7 +117,9 @@ export class Router {
*/ */
getPathname(partialState) { getPathname(partialState) {
const currentState = this.getState(); const currentState = this.getState();
if (partialState === undefined) partialState = {}; if (partialState === undefined) {
partialState = {};
}
let combined = {...currentState, ...partialState}; let combined = {...currentState, ...partialState};
try { try {
...@@ -128,7 +130,7 @@ export class Router { ...@@ -128,7 +130,7 @@ export class Router {
} }
} }
dispatchLocationChanged(referrerUrl = '') { _dispatchLocationChanged(referrerUrl = '') {
// fire a locationchanged event // fire a locationchanged event
window.dispatchEvent( window.dispatchEvent(
new CustomEvent('locationchanged', { new CustomEvent('locationchanged', {
......
import {html, css} from 'lit'; import {html, css} from 'lit';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
import {createInstance} from './i18n.js'; import {createInstance} from './i18n.js';
import {AdapterLitElement} from '@dbp-toolkit/provider/src/adapter-lit-element'; import {AdapterLitElement} from '@dbp-toolkit/common';
export class TUGrazLogo extends AdapterLitElement { export class TUGrazLogo extends AdapterLitElement {
constructor() { constructor() {
......
packages/auth/assets/favicon.ico

2.49 KiB | W: 16px | H: 16px

packages/auth/assets/favicon.ico

1.12 KiB | W: 16px | H: 16px

packages/auth/assets/favicon.ico
packages/auth/assets/favicon.ico
packages/auth/assets/favicon.ico
packages/auth/assets/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
{ {
"name": "@dbp-toolkit/auth", "name": "@dbp-toolkit/auth",
"homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/auth", "homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/auth",
"version": "0.3.0", "version": "0.3.1",
"main": "src/index.js", "main": "src/index.js",
"license": "LGPL-2.1-or-later", "license": "LGPL-2.1-or-later",
"repository": { "repository": {
...@@ -15,20 +15,20 @@ ...@@ -15,20 +15,20 @@
}, },
"devDependencies": { "devDependencies": {
"@esm-bundle/chai": "^4.2.0", "@esm-bundle/chai": "^4.2.0",
"@rollup/plugin-commonjs": "^21.0.0", "@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0", "@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^4.0.0", "@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-url": "^6.0.0", "@rollup/plugin-url": "^7.0.0",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-plugin-jsdoc": "^39.0.0", "eslint-plugin-jsdoc": "^39.0.0",
"glob": "^7.1.6", "glob": "^8.0.0",
"i18next-parser": "^6.3.0", "i18next-parser": "^6.3.0",
"karma": "^6.0.0", "karma": "^6.0.0",
"karma-chrome-launcher": "^3.0.0", "karma-chrome-launcher": "^3.0.0",
"karma-firefox-launcher": "^2.1.0", "karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1", "karma-mocha": "^2.0.1",
"mocha": "^9.0.0", "mocha": "^10.0.0",
"playwright-core": "^1.20.2", "playwright-core": "^1.20.2",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"rollup": "^2.33.3", "rollup": "^2.33.3",
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"rollup-plugin-terser": "^7.0.2" "rollup-plugin-terser": "^7.0.2"
}, },
"dependencies": { "dependencies": {
"@dbp-toolkit/common": "^0.3.0", "@dbp-toolkit/common": "^0.3.3",
"@open-wc/scoped-elements": "^2.1.0", "@open-wc/scoped-elements": "^2.1.0",
"event-target-shim": "^6.0.0", "event-target-shim": "^6.0.0",
"lit": "^2.0.0" "lit": "^2.0.0"
......
...@@ -2,7 +2,8 @@ import {createInstance} from './i18n.js'; ...@@ -2,7 +2,8 @@ import {createInstance} from './i18n.js';
import JSONLD from '@dbp-toolkit/common/jsonld'; import JSONLD from '@dbp-toolkit/common/jsonld';
import {KeycloakWrapper} from './keycloak.js'; import {KeycloakWrapper} from './keycloak.js';
import {LoginStatus} from './util.js'; import {LoginStatus} from './util.js';
import {AdapterLitElement} from '@dbp-toolkit/provider/src/adapter-lit-element'; import {AdapterLitElement} from '@dbp-toolkit/common';
import {send} from '@dbp-toolkit/common/notification';
/** /**
* Keycloak auth web component * Keycloak auth web component
...@@ -219,17 +220,28 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -219,17 +220,28 @@ export class AuthKeycloak extends AdapterLitElement {
this._kcwrapper.addEventListener('changed', this._onKCChanged); this._kcwrapper.addEventListener('changed', this._onKCChanged);
const handleLogin = async () => { const handleLogin = async () => {
if (this.forceLogin || this._kcwrapper.isLoggingIn()) { try {
this._setLoginStatus(LoginStatus.LOGGING_IN); if (this.forceLogin || this._kcwrapper.isLoggingIn()) {
await this._kcwrapper.login({lang: this.lang, scope: this.scope || ''}); this._setLoginStatus(LoginStatus.LOGGING_IN);
} else if (this.tryLogin) { await this._kcwrapper.login({lang: this.lang, scope: this.scope || ''});
this._setLoginStatus(LoginStatus.LOGGING_IN); } else if (this.tryLogin) {
await this._kcwrapper.tryLogin(); this._setLoginStatus(LoginStatus.LOGGING_IN);
if (!this._authenticated) { await this._kcwrapper.tryLogin();
if (!this._authenticated) {
this._setLoginStatus(LoginStatus.LOGGED_OUT);
}
} else {
this._setLoginStatus(LoginStatus.LOGGED_OUT); this._setLoginStatus(LoginStatus.LOGGED_OUT);
} }
} else { } catch (error) {
// In case the keycloak server is offline for example
this._setLoginStatus(LoginStatus.LOGGED_OUT); this._setLoginStatus(LoginStatus.LOGGED_OUT);
send({
summary: this._i18n.t('login-failed'),
type: 'danger',
timeout: 5,
});
throw error;
} }
}; };
......
{ {
"login": "Anmelden", "login": "Anmelden",
"login-failed": "Kommunikation mit dem Anmeldeserver fehlgeschlagen",
"logout": "Abmelden" "logout": "Abmelden"
} }