Skip to content
Snippets Groups Projects
Commit 27146cf2 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Port to common utils api

parent 13c95f41
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
"rollup-plugin-multi-entry": "^2.1.0", "rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^2.0.3", "rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-serve": "^1.0.1", "rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "^5.1.1", "rollup-plugin-terser": "^5.1.1",
"rollup-plugin-url": "^2.2.2", "rollup-plugin-url": "^2.2.2",
......
...@@ -4,7 +4,6 @@ import commonjs from 'rollup-plugin-commonjs'; ...@@ -4,7 +4,6 @@ import commonjs from 'rollup-plugin-commonjs';
import copy from 'rollup-plugin-copy'; import copy from 'rollup-plugin-copy';
import {terser} from "rollup-plugin-terser"; import {terser} from "rollup-plugin-terser";
import json from 'rollup-plugin-json'; import json from 'rollup-plugin-json';
import replace from "rollup-plugin-replace";
import serve from 'rollup-plugin-serve'; import serve from 'rollup-plugin-serve';
import multiEntry from 'rollup-plugin-multi-entry'; import multiEntry from 'rollup-plugin-multi-entry';
import url from "rollup-plugin-url"; import url from "rollup-plugin-url";
...@@ -61,9 +60,6 @@ export default { ...@@ -61,9 +60,6 @@ export default {
emitFiles: true, emitFiles: true,
fileName: 'shared/[name].[hash][extname]' fileName: 'shared/[name].[hash][extname]'
}), }),
replace({
"process.env.BUILD": '"' + build + '"',
}),
(build !== 'local' && build !== 'test') ? terser() : false, (build !== 'local' && build !== 'test') ? terser() : false,
copy({ copy({
targets: [ targets: [
......
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];
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;
import 'vpu-auth'; import 'vpu-auth';
import './vpu-data-table-view.js'; import './vpu-data-table-view.js';
import {setting,} from './utils.js';
import {i18n} from './i18n'; import {i18n} from './i18n';
import {html, LitElement} from 'lit-element'; import {html, LitElement} from 'lit-element';
import * as commonUtils from 'vpu-common/utils'; import * as commonUtils from 'vpu-common/utils';
...@@ -99,7 +98,7 @@ class DataTableViewDemo extends LitElement { ...@@ -99,7 +98,7 @@ class DataTableViewDemo extends LitElement {
getAuthComponentHtml() { getAuthComponentHtml() {
return this.noAuth ? html`` : html` return this.noAuth ? html`` : html`
<div class="content"> <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> </div>
`; `;
} }
......
...@@ -8,7 +8,6 @@ import de from '../assets/datatables/i18n/German'; ...@@ -8,7 +8,6 @@ import de from '../assets/datatables/i18n/German';
import en from '../assets/datatables/i18n/English'; import en from '../assets/datatables/i18n/English';
import * as commonUtils from 'vpu-common/utils'; import * as commonUtils from 'vpu-common/utils';
import * as utils from "./utils";
import bulmaCSSPath from "bulma/css/bulma.min.css"; import bulmaCSSPath from "bulma/css/bulma.min.css";
dt(window, $); dt(window, $);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment