From 338fdeba5ecf768cf99fb46871fae8c3b8055f44 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Tue, 26 Jan 2021 15:05:46 +0100 Subject: [PATCH] Remove tugUtils.getAPiUrl() and integrate lang and entry-point-url attributes --- packages/common/test/unit.js | 5 ---- packages/common/tug-utils.js | 25 ------------------- .../assets/dbp-toolkit-showcase.html.ejs | 2 +- toolkit-showcase/rollup.config.js | 6 ----- ...dbp-check-in-place-select-demo-activity.js | 12 +++++++-- .../src/dbp-common-demo-activity.js | 11 ++++++-- .../src/dbp-data-table-view-demo-activity.js | 10 +++++++- toolkit-showcase/src/dbp-demo-template.js | 10 +++++++- .../src/dbp-file-handling-demo-activity.js | 10 +++++++- ...ase-web-page-element-view-demo-activity.js | 10 +++++++- .../src/dbp-language-select-demo-activity.js | 10 +++++++- .../src/dbp-matomo-demo-activity.js | 10 +++++++- .../src/dbp-notification-demo-activity.js | 10 +++++++- .../src/dbp-person-profile-demo-activity.js | 10 +++++++- .../src/dbp-person-select-demo-activity.js | 10 +++++++- .../src/dbp-qr-code-scanner-demo-activity.js | 10 +++++++- 16 files changed, 110 insertions(+), 51 deletions(-) delete mode 100644 packages/common/tug-utils.js diff --git a/packages/common/test/unit.js b/packages/common/test/unit.js index 87323cc3..4a931042 100644 --- a/packages/common/test/unit.js +++ b/packages/common/test/unit.js @@ -1,6 +1,5 @@ import {expect, assert} from 'chai'; import * as utils from '../utils'; -import * as tugUtils from '../tug-utils'; import * as styles from '../styles'; import '../jsonld.js'; @@ -35,10 +34,6 @@ suite('utils', () => { assert.isTrue(res); }); - test('getAPiUrl', () => { - assert(tugUtils.getAPiUrl().startsWith("http")); - }); - test('getAssetURL', () => { // Backwards compat assert.equal(new URL(utils.getAssetURL("foo/bar")).pathname, "/foo/bar"); diff --git a/packages/common/tug-utils.js b/packages/common/tug-utils.js deleted file mode 100644 index e537bc4f..00000000 --- a/packages/common/tug-utils.js +++ /dev/null @@ -1,25 +0,0 @@ -import environment from 'consts:environment'; - -export const getAPiUrl = (path = "") => { - let apiBaseUrl = ''; - - switch(environment) { - case "development": - apiBaseUrl = 'https://mw-dev.tugraz.at'; - break; - case "demo": - apiBaseUrl = 'https://api-demo.tugraz.at'; - break; - case "production": - apiBaseUrl = 'https://api.tugraz.at'; - break; - case "bs": - apiBaseUrl = 'http://bs-local.com:8000'; - break; - case "local": - default: - apiBaseUrl = 'http://127.0.0.1:8000'; - } - - return apiBaseUrl + path; -}; diff --git a/toolkit-showcase/assets/dbp-toolkit-showcase.html.ejs b/toolkit-showcase/assets/dbp-toolkit-showcase.html.ejs index 3ec8d00f..2085a3c1 100644 --- a/toolkit-showcase/assets/dbp-toolkit-showcase.html.ejs +++ b/toolkit-showcase/assets/dbp-toolkit-showcase.html.ejs @@ -54,7 +54,7 @@ <body> <dbp-provider id="root" - lang="de" entry-point-url="<%= entryPointURL %>" + lang="en" entry-point-url="<%= entryPointURL %>" nextcloud-web-app-password-url="<%= nextcloudWebAppPasswordURL %>" nextcloud-webdav-url="<%= nextcloudWebDavURL %>" nextcloud-name="<%= nextcloudName %>" diff --git a/toolkit-showcase/rollup.config.js b/toolkit-showcase/rollup.config.js index 73f47a9d..5004c26f 100644 --- a/toolkit-showcase/rollup.config.js +++ b/toolkit-showcase/rollup.config.js @@ -9,8 +9,6 @@ import json from '@rollup/plugin-json'; import replace from "@rollup/plugin-replace"; import serve from 'rollup-plugin-serve'; import urlPlugin from "@rollup/plugin-url"; -// TODO: remove consts if "environment" isn't needed because "getAPiUrl" is removed -import consts from 'rollup-plugin-consts'; import license from 'rollup-plugin-license'; import del from 'rollup-plugin-delete'; import md from 'rollup-plugin-md'; @@ -165,10 +163,6 @@ export default (async () => {return { del({ targets: 'dist/*' }), - // TODO: remove consts if "environment" isn't needed because "getAPiUrl" is removed - consts({ - environment: build, - }), emitEJS({ src: 'assets', include: ['**/*.ejs', '**/.*.ejs'], diff --git a/toolkit-showcase/src/dbp-check-in-place-select-demo-activity.js b/toolkit-showcase/src/dbp-check-in-place-select-demo-activity.js index 764d89be..1c4d9519 100644 --- a/toolkit-showcase/src/dbp-check-in-place-select-demo-activity.js +++ b/toolkit-showcase/src/dbp-check-in-place-select-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-check-in-place-select-demo': CheckInPlaceSelectDemo, @@ -18,6 +24,8 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -48,9 +56,9 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) } render() { - return html` + return html` ${unsafeHTML(readme)} - <dbp-check-in-place-select-demo id="demo" lang="en" no-auth></dbp-check-in-place-select-demo> + <dbp-check-in-place-select-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-check-in-place-select-demo> `; } } diff --git a/toolkit-showcase/src/dbp-common-demo-activity.js b/toolkit-showcase/src/dbp-common-demo-activity.js index 7214dab3..91cc10a5 100644 --- a/toolkit-showcase/src/dbp-common-demo-activity.js +++ b/toolkit-showcase/src/dbp-common-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpCommonDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-common-demo': DbpCommonDemo, @@ -18,6 +24,8 @@ class DbpCommonDemoActivity extends ScopedElementsMixin(AdapterLitElement) { static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -49,9 +57,8 @@ class DbpCommonDemoActivity extends ScopedElementsMixin(AdapterLitElement) { render() { return html` - ${unsafeHTML(readme)} - <dbp-common-demo id="demo" lang="en"></dbp-common-demo> + <dbp-common-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-common-demo> `; } } diff --git a/toolkit-showcase/src/dbp-data-table-view-demo-activity.js b/toolkit-showcase/src/dbp-data-table-view-demo-activity.js index 5bff3ed1..dee1780f 100644 --- a/toolkit-showcase/src/dbp-data-table-view-demo-activity.js +++ b/toolkit-showcase/src/dbp-data-table-view-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) { //TODO + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-data-table-view-demo': DataTableViewDemo, @@ -18,6 +24,8 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -51,7 +59,7 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) return html` ${unsafeHTML(readme)} - <dbp-data-table-view-demo id="demo" lang="en" no-auth></dbp-data-table-view-demo> + <dbp-data-table-view-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-data-table-view-demo> `; } } diff --git a/toolkit-showcase/src/dbp-demo-template.js b/toolkit-showcase/src/dbp-demo-template.js index fc80b919..f7ae5bd0 100644 --- a/toolkit-showcase/src/dbp-demo-template.js +++ b/toolkit-showcase/src/dbp-demo-template.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) { //TODO + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { // TODO @@ -19,6 +25,8 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -53,7 +61,7 @@ class DbpActivityNameDemoActivity extends ScopedElementsMixin(AdapterLitElement) <!-- TODO ${unsafeHTML(readme)} - <dbp-class-name-demo id="demo" lang="en"></dbp-class-name-demo> + <dbp-class-name-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-class-name-demo> --> `; } diff --git a/toolkit-showcase/src/dbp-file-handling-demo-activity.js b/toolkit-showcase/src/dbp-file-handling-demo-activity.js index ab4657e6..fbc6d984 100644 --- a/toolkit-showcase/src/dbp-file-handling-demo-activity.js +++ b/toolkit-showcase/src/dbp-file-handling-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpFileHandlingDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-file-handling-demo': FileSourceDemo, @@ -18,6 +24,8 @@ class DbpFileHandlingDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class DbpFileHandlingDemoActivity extends ScopedElementsMixin(AdapterLitElement) render() { return html` ${unsafeHTML(readme)} - <dbp-file-handling-demo id="demo" lang="en"></dbp-file-handling-demo> + <dbp-file-handling-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-file-handling-demo> `; } } diff --git a/toolkit-showcase/src/dbp-knowledge-base-web-page-element-view-demo-activity.js b/toolkit-showcase/src/dbp-knowledge-base-web-page-element-view-demo-activity.js index 419766d0..548c8ec6 100644 --- a/toolkit-showcase/src/dbp-knowledge-base-web-page-element-view-demo-activity.js +++ b/toolkit-showcase/src/dbp-knowledge-base-web-page-element-view-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class KnowledgeBaseWebPageElementViewDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-knowledge-base-web-page-element-view-demo': KnowledgeBaseWebPageElementViewDemo, @@ -18,6 +24,8 @@ class KnowledgeBaseWebPageElementViewDemoActivity extends ScopedElementsMixin(Ad static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class KnowledgeBaseWebPageElementViewDemoActivity extends ScopedElementsMixin(Ad render() { return html` ${unsafeHTML(readme)} - <dbp-knowledge-base-web-page-element-view-demo id="demo" lang="en" no-auth></dbp-knowledge-base-web-page-element-view-demo> + <dbp-knowledge-base-web-page-element-view-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-knowledge-base-web-page-element-view-demo> `; } } diff --git a/toolkit-showcase/src/dbp-language-select-demo-activity.js b/toolkit-showcase/src/dbp-language-select-demo-activity.js index f9fb39ec..3d84c6c9 100644 --- a/toolkit-showcase/src/dbp-language-select-demo-activity.js +++ b/toolkit-showcase/src/dbp-language-select-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpLanguageSelectDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-language-select-demo': LanguageSelectDemo, @@ -18,6 +24,8 @@ class DbpLanguageSelectDemoActivity extends ScopedElementsMixin(AdapterLitElemen static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -51,7 +59,7 @@ class DbpLanguageSelectDemoActivity extends ScopedElementsMixin(AdapterLitElemen return html` ${unsafeHTML(readme)} - <dbp-language-select-demo id="demo" lang="en"></dbp-language-select-demo> + <dbp-language-select-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-language-select-demo> `; } diff --git a/toolkit-showcase/src/dbp-matomo-demo-activity.js b/toolkit-showcase/src/dbp-matomo-demo-activity.js index 72a3b9ff..e1a49d98 100644 --- a/toolkit-showcase/src/dbp-matomo-demo-activity.js +++ b/toolkit-showcase/src/dbp-matomo-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpMatomoDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-matomo-demo': MatomoDemo, @@ -18,6 +24,8 @@ class DbpMatomoDemoActivity extends ScopedElementsMixin(AdapterLitElement) { static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class DbpMatomoDemoActivity extends ScopedElementsMixin(AdapterLitElement) { render() { return html` ${unsafeHTML(readme)} - <dbp-matomo-demo id="demo" lang="en" no-auth></dbp-matomo-demo> + <dbp-matomo-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-matomo-demo> `; } } diff --git a/toolkit-showcase/src/dbp-notification-demo-activity.js b/toolkit-showcase/src/dbp-notification-demo-activity.js index a07261bc..b9190370 100644 --- a/toolkit-showcase/src/dbp-notification-demo-activity.js +++ b/toolkit-showcase/src/dbp-notification-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpNotificationDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-notification-demo': NotificationDemo, @@ -18,6 +24,8 @@ class DbpNotificationDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class DbpNotificationDemoActivity extends ScopedElementsMixin(AdapterLitElement) render() { return html` ${unsafeHTML(readme)} - <dbp-notification-demo id="demo" lang="en"></dbp-notification-demo> + <dbp-notification-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-notification-demo> `; } } diff --git a/toolkit-showcase/src/dbp-person-profile-demo-activity.js b/toolkit-showcase/src/dbp-person-profile-demo-activity.js index 97214831..6ee3a02f 100644 --- a/toolkit-showcase/src/dbp-person-profile-demo-activity.js +++ b/toolkit-showcase/src/dbp-person-profile-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpPersonProfileDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-person-profile-demo': PersonProfileDemo, @@ -18,6 +24,8 @@ class DbpPersonProfileDemoActivity extends ScopedElementsMixin(AdapterLitElement static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class DbpPersonProfileDemoActivity extends ScopedElementsMixin(AdapterLitElement render() { return html` ${unsafeHTML(readme)} - <dbp-person-profile-demo id="demo" lang="en" no-auth></dbp-person-profile-demo> + <dbp-person-profile-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-person-profile-demo> `; } diff --git a/toolkit-showcase/src/dbp-person-select-demo-activity.js b/toolkit-showcase/src/dbp-person-select-demo-activity.js index 57d147f6..f2cdd7db 100644 --- a/toolkit-showcase/src/dbp-person-select-demo-activity.js +++ b/toolkit-showcase/src/dbp-person-select-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from "./styles"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpPersonSelectDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-person-select-demo': PersonSelectDemo, @@ -18,6 +24,8 @@ class DbpPersonSelectDemoActivity extends ScopedElementsMixin(AdapterLitElement) static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -50,7 +58,7 @@ class DbpPersonSelectDemoActivity extends ScopedElementsMixin(AdapterLitElement) render() { return html` ${unsafeHTML(readme)} - <dbp-person-select-demo id="demo" lang="en" no-auth></dbp-person-select-demo> + <dbp-person-select-demo id="demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" no-auth></dbp-person-select-demo> `; } } diff --git a/toolkit-showcase/src/dbp-qr-code-scanner-demo-activity.js b/toolkit-showcase/src/dbp-qr-code-scanner-demo-activity.js index 45f46849..73d679fa 100644 --- a/toolkit-showcase/src/dbp-qr-code-scanner-demo-activity.js +++ b/toolkit-showcase/src/dbp-qr-code-scanner-demo-activity.js @@ -10,6 +10,12 @@ import * as demoStyles from './styles'; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; class DbpQrCodeScannerDemoActivity extends ScopedElementsMixin(AdapterLitElement) { + constructor() { + super(); + this.lang = 'en'; + this.entryPointUrl = ''; + } + static get scopedElements() { return { 'dbp-qr-code-scanner-demo': QrCodeScannerDemo, @@ -18,6 +24,8 @@ class DbpQrCodeScannerDemoActivity extends ScopedElementsMixin(AdapterLitElement static get properties() { return this.getProperties({ + lang: { type: String }, + entryPointUrl: { type: String, attribute: 'entry-point-url' }, }); } @@ -47,7 +55,7 @@ class DbpQrCodeScannerDemoActivity extends ScopedElementsMixin(AdapterLitElement render() { return html` ${unsafeHTML(readme)} - <dbp-qr-code-scanner-demo id="scanner-demo" lang="en"></dbp-qr-code-scanner-demo> + <dbp-qr-code-scanner-demo id="scanner-demo" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-qr-code-scanner-demo> `; } } -- GitLab