From f69a28898187580c2cfe281271384a56d3832930 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Mon, 25 Jan 2021 12:47:46 +0100 Subject: [PATCH] Remove "consts" dependencies --- packages/app-shell/src/app-shell.js | 17 ++++++++++++----- packages/app-shell/src/build-info.js | 25 +++++++++++++++++++------ packages/common/errorreport.js | 7 +++++-- packages/matomo/src/matomo.js | 5 +++-- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/app-shell/src/app-shell.js b/packages/app-shell/src/app-shell.js index 45745cf0..4969de66 100644 --- a/packages/app-shell/src/app-shell.js +++ b/packages/app-shell/src/app-shell.js @@ -8,7 +8,6 @@ import {AuthMenuButton} from './auth-menu-button.js'; import {Notification} from '@dbp-toolkit/notification'; import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonUtils from '@dbp-toolkit/common/utils'; -import buildinfo from 'consts:buildinfo'; import {classMap} from 'lit-html/directives/class-map.js'; import {Router} from './router.js'; import {BuildInfo} from './build-info.js'; @@ -58,6 +57,10 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { this.keycloakConfig = null; this.noWelcomePage = false; this.menuHeight = -1; + this.gitInfo = ''; + this.env = ''; + this.buildUrl = ''; + this.buildTime = ''; this._updateAuth = this._updateAuth.bind(this); this._loginStatus = 'unknown'; @@ -242,7 +245,11 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { noWelcomePage: { type: Boolean, attribute: "no-welcome-page" }, shellName: { type: String, attribute: "shell-name" }, shellSubname: { type: String, attribute: "shell-subname" }, - noBrand: { type: Boolean, attribute: "no-brand" } + noBrand: { type: Boolean, attribute: "no-brand" }, + gitInfo: { type: String, attribute: "git-info" }, + buildUrl: { type: String, attribute: "build-url" }, + buildTime: { type: String, attribute: "build-time" }, + env: { type: String }, }); } @@ -786,7 +793,7 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { }); } - const prodClassMap = classMap({hidden: buildinfo.env === 'production' || buildinfo.env === 'demo'}); + const prodClassMap = classMap({hidden: this.env === 'production' || this.env === 'demo' || this.env === ''}); this.updatePageTitle(); @@ -809,7 +816,7 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { return html` <slot class="${slotClassMap}"></slot> <dbp-auth-keycloak lang="${this.lang}" url="${kc.url}" realm="${kc.realm}" client-id="${kc.clientId}" silent-check-sso-redirect-uri="${kc.silentCheckSsoRedirectUri || ''}" scope="${kc.scope || ''}" idp-hint="${kc.idpHint || ''}" load-person ?force-login="${kc.forceLogin}" ?try-login="${!kc.forceLogin}"></dbp-auth-keycloak> - <dbp-matomo endpoint="${this.matomoUrl}" site-id="${this.matomoSiteId}"></dbp-matomo> + <dbp-matomo endpoint="${this.matomoUrl}" site-id="${this.matomoSiteId}" git-info="${this.gitInfo}"></dbp-matomo> <div class="${mainClassMap}"> <div id="main"> <dbp-notification lang="${this.lang}"></dbp-notification> @@ -854,7 +861,7 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { <a target="_blank" rel="noopener" class="int-link-external" href="https://datenschutz.tugraz.at/erklaerung/">${i18n.t('privacy-policy')}</a> <a target="_blank" rel="noopener" class="int-link-external" href="${imprintUrl}">${i18n.t('imprint')}</a> <a rel="noopener" class="int-link-external" href="mailto:it-support@tugraz.at">${i18n.t('contact')}</a> - <dbp-build-info class="${prodClassMap}"></dbp-build-info> + <dbp-build-info class="${prodClassMap}" git-info="${this.gitInfo}" env="${this.env}" build-url="${this.buildUrl}" build-time="${this.buildTime}"></dbp-build-info> </footer> </div> </div> diff --git a/packages/app-shell/src/build-info.js b/packages/app-shell/src/build-info.js index 4178c1d9..f84e436f 100644 --- a/packages/app-shell/src/build-info.js +++ b/packages/app-shell/src/build-info.js @@ -1,11 +1,24 @@ -import {html, LitElement, css} from 'lit-element'; +import {html, css} from 'lit-element'; import * as commonStyles from '@dbp-toolkit/common/styles'; -import buildinfo from 'consts:buildinfo'; +import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; -export class BuildInfo extends LitElement { +export class BuildInfo extends AdapterLitElement { constructor() { super(); + this.env = ''; + this.gitInfo = ''; + this.buildUrl = ''; + this.buildTime = ''; + } + + static get properties() { + return this.getProperties({ + env: { type: String }, + buildUrl: { type: String, attribute: "build-url" }, + buildTime: { type: String, attribute: "build-time" }, + gitInfo: { type: String, attribute: "git-info" } + }); } static get styles() { @@ -21,13 +34,13 @@ export class BuildInfo extends LitElement { } render() { - const date = new Date(buildinfo.time); + const date = new Date(this.buildTime); return html` - <a href="${buildinfo.url}" style="float: right"> + <a href="${this.buildUrl}" style="float: right"> <div class="tags has-addons" title="Build Time: ${date.toString()}"> <span class="tag is-light">build</span> - <span class="tag is-dark">${buildinfo.info} (${buildinfo.env})</span> + <span class="tag is-dark">${this.gitInfo} (${this.env})</span> </div> </a> `; diff --git a/packages/common/errorreport.js b/packages/common/errorreport.js index d1cfcb18..d6185786 100644 --- a/packages/common/errorreport.js +++ b/packages/common/errorreport.js @@ -1,5 +1,4 @@ import * as Sentry from '@sentry/browser'; -import environment from 'consts:environment'; let _isInitialized = false; let _canReportEvent = false; @@ -24,12 +23,16 @@ export function init(options) { if (_isInitialized) throw new Error("Already initialized"); - let sentryOptions = {debug: actual.debug, environment: environment}; + let sentryOptions = {debug: actual.debug}; if (actual.release) { sentryOptions['release'] = actual.release; } + if (actual.environment) { + sentryOptions['environment'] = actual.environment; + } + if (!sentryDSN) { if (options.debug) console.log("No sentry DSN set, sentry disabled"); diff --git a/packages/matomo/src/matomo.js b/packages/matomo/src/matomo.js index 8e189c72..4af66dfa 100644 --- a/packages/matomo/src/matomo.js +++ b/packages/matomo/src/matomo.js @@ -1,6 +1,5 @@ import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; import {EventBus} from '@dbp-toolkit/common'; -import buildInfo from 'consts:buildinfo'; function pushEvent(event) { window._paq = window._paq || []; @@ -15,6 +14,7 @@ export class MatomoElement extends DBPLitElement { this.siteId = -1; this.isRunning = false; this.lastEvent = []; + this.gitInfo = ''; } @@ -22,6 +22,7 @@ export class MatomoElement extends DBPLitElement { return { endpoint: { type: String }, siteId: { type: Number, attribute: 'site-id' }, + gitInfo: { type: Number, attribute: 'git-info' }, }; } @@ -55,7 +56,7 @@ export class MatomoElement extends DBPLitElement { } console.log('add matomo...'); - pushEvent(['setCustomVariable', 1, "GitCommit", buildInfo.info, "visit"]); + pushEvent(['setCustomVariable', 1, "GitCommit", this.gitInfo, "visit"]); pushEvent(['enableHeartBeatTimer']); pushEvent(['disableCookies']); pushEvent(['trackPageView']); -- GitLab