From 27146cf2fd246cfad06149deb94fbddf845a38e8 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Thu, 3 Oct 2019 16:03:41 +0200 Subject: [PATCH] Port to common utils api --- packages/data-table-view/package.json | 1 - packages/data-table-view/rollup.config.js | 4 --- packages/data-table-view/src/utils.js | 34 ------------------ packages/data-table-view/src/vars.js | 35 ------------------- .../src/vpu-data-table-view-demo.js | 3 +- .../src/vpu-data-table-view.js | 1 - 6 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 packages/data-table-view/src/utils.js delete mode 100644 packages/data-table-view/src/vars.js diff --git a/packages/data-table-view/package.json b/packages/data-table-view/package.json index 8a50aa13..e1b60510 100644 --- a/packages/data-table-view/package.json +++ b/packages/data-table-view/package.json @@ -20,7 +20,6 @@ "rollup-plugin-multi-entry": "^2.1.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-postcss": "^2.0.3", - "rollup-plugin-replace": "^2.2.0", "rollup-plugin-serve": "^1.0.1", "rollup-plugin-terser": "^5.1.1", "rollup-plugin-url": "^2.2.2", diff --git a/packages/data-table-view/rollup.config.js b/packages/data-table-view/rollup.config.js index 200cf882..939a2ddc 100644 --- a/packages/data-table-view/rollup.config.js +++ b/packages/data-table-view/rollup.config.js @@ -4,7 +4,6 @@ import commonjs from 'rollup-plugin-commonjs'; import copy from 'rollup-plugin-copy'; import {terser} from "rollup-plugin-terser"; import json from 'rollup-plugin-json'; -import replace from "rollup-plugin-replace"; import serve from 'rollup-plugin-serve'; import multiEntry from 'rollup-plugin-multi-entry'; import url from "rollup-plugin-url"; @@ -61,9 +60,6 @@ export default { emitFiles: true, fileName: 'shared/[name].[hash][extname]' }), - replace({ - "process.env.BUILD": '"' + build + '"', - }), (build !== 'local' && build !== 'test') ? terser() : false, copy({ targets: [ diff --git a/packages/data-table-view/src/utils.js b/packages/data-table-view/src/utils.js deleted file mode 100644 index 9fb5d57d..00000000 --- a/packages/data-table-view/src/utils.js +++ /dev/null @@ -1,34 +0,0 @@ -import vars from './vars.js'; - -export const getAPiUrl = function(path = "", withPrefix = true) { - return vars.apiBaseUrl + (withPrefix ? vars.apiUrlPrefix : "") + path; -} - -/** - * Finds an object in a JSON result by identifier - * - * @param identifier - * @param results - * @param identifierAttribute - */ -export const findObjectInApiResults = (identifier, results, identifierAttribute = "@id") => { - const members = results["hydra:member"]; - - if (members === undefined) { - return; - } - - for (const object of members){ - if (object[identifierAttribute] === identifier) { - return object; - } - } -} - -/** - * Reads a setting - * - * @param key - * @returns {*} - */ -export const setting = (key) => vars[key]; diff --git a/packages/data-table-view/src/vars.js b/packages/data-table-view/src/vars.js deleted file mode 100644 index 0e25edd8..00000000 --- a/packages/data-table-view/src/vars.js +++ /dev/null @@ -1,35 +0,0 @@ -var config; - -switch(process.env.BUILD) { - case "development": - config = { - apiBaseUrl: 'https://mw-dev.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend', - }; - - break; - case "production": - config = { - apiBaseUrl: 'https://mw.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-prod-mw-frontend', - }; - break; - case "demo": - config = { - apiBaseUrl: 'https://api-demo.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend', - }; - break; - case "local": - default: - config = { - apiBaseUrl: 'http://127.0.0.1:8000', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend-local', - }; -} - -export default config; diff --git a/packages/data-table-view/src/vpu-data-table-view-demo.js b/packages/data-table-view/src/vpu-data-table-view-demo.js index c3de4f64..5744b927 100644 --- a/packages/data-table-view/src/vpu-data-table-view-demo.js +++ b/packages/data-table-view/src/vpu-data-table-view-demo.js @@ -1,6 +1,5 @@ import 'vpu-auth'; import './vpu-data-table-view.js'; -import {setting,} from './utils.js'; import {i18n} from './i18n'; import {html, LitElement} from 'lit-element'; import * as commonUtils from 'vpu-common/utils'; @@ -99,7 +98,7 @@ class DataTableViewDemo extends LitElement { getAuthComponentHtml() { return this.noAuth ? html`` : html` <div class="content"> - <vpu-auth lang="${this.lang}" client-id="${setting('keyCloakClientId')}" load-person force-login></vpu-auth> + <vpu-auth lang="${this.lang}" client-id="${commonUtils.setting('keyCloakClientId')}" load-person force-login></vpu-auth> </div> `; } diff --git a/packages/data-table-view/src/vpu-data-table-view.js b/packages/data-table-view/src/vpu-data-table-view.js index 3bff7bbc..ae1ae1c2 100644 --- a/packages/data-table-view/src/vpu-data-table-view.js +++ b/packages/data-table-view/src/vpu-data-table-view.js @@ -8,7 +8,6 @@ import de from '../assets/datatables/i18n/German'; import en from '../assets/datatables/i18n/English'; import * as commonUtils from 'vpu-common/utils'; -import * as utils from "./utils"; import bulmaCSSPath from "bulma/css/bulma.min.css"; dt(window, $); -- GitLab