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

Move utils to common

parent c60e85f8
No related branches found
No related tags found
No related merge requests found
import {setting, getAPiUrl} from './utils.js';
import {i18n} from './i18n.js'; import {i18n} from './i18n.js';
import {html, LitElement} from 'lit-element'; import {html, LitElement} from 'lit-element';
import './person-select.js'; import './person-select.js';
...@@ -35,20 +34,20 @@ class PersonSelectDemo extends LitElement { ...@@ -35,20 +34,20 @@ class PersonSelectDemo extends LitElement {
<h1 class="title">Person-Select-Demo</h1> <h1 class="title">Person-Select-Demo</h1>
</div> </div>
<div class="container"> <div class="container">
<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>
<div class="container"> <div class="container">
<form> <form>
<div class="field"> <div class="field">
<label class="label">Person 1</label> <label class="label">Person 1</label>
<div class="control"> <div class="control">
<vpu-person-select lang="${this.lang}" entry-point-url="${getAPiUrl()}"></vpu-person-select> <vpu-person-select lang="${this.lang}" entry-point-url="${commonUtils.getAPiUrl()}"></vpu-person-select>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label">Person 2</label> <label class="label">Person 2</label>
<div class="control"> <div class="control">
<vpu-person-select lang="${this.lang}" entry-point-url="${getAPiUrl()}"></vpu-person-select> <vpu-person-select lang="${this.lang}" entry-point-url="${commonUtils.getAPiUrl()}"></vpu-person-select>
</div> </div>
</div> </div>
</form> </form>
......
import $ from 'jquery'; import $ from 'jquery';
import {getAPiUrl, getAssetURL, findObjectInApiResults} from './utils.js'; import {getAssetURL, findObjectInApiResults} from './utils.js';
import select2 from 'select2'; import select2 from 'select2';
import select2LangDe from './i18n/de/select2' import select2LangDe from './i18n/de/select2'
import select2LangEn from './i18n/en/select2' import select2LangEn from './i18n/en/select2'
...@@ -18,7 +18,7 @@ class PersonSelect extends VPULitElementJQuery { ...@@ -18,7 +18,7 @@ class PersonSelect extends VPULitElementJQuery {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this.lang = 'de';
this.entryPointUrl = getAPiUrl(); this.entryPointUrl = commonUtils.getAPiUrl();
this.jsonld = null; this.jsonld = null;
this.$select = null; this.$select = null;
// For some reason using the same ID on the whole page twice breaks select2 (regardless if they are in different custom elements) // For some reason using the same ID on the whole page twice breaks select2 (regardless if they are in different custom elements)
......
import vars from './vars.js';
export const getAssetURL = (path) => { export const getAssetURL = (path) => {
const elm = document.getElementById('vpu-library-shelving-wc-src'); const elm = document.getElementById('vpu-library-shelving-wc-src');
if (!elm) if (!elm)
...@@ -10,10 +8,6 @@ export const getAssetURL = (path) => { ...@@ -10,10 +8,6 @@ export const getAssetURL = (path) => {
return new URL(path, url).href; return new URL(path, url).href;
} }
export const getAPiUrl = function(path = "", withPrefix = true) {
return vars.apiBaseUrl + (withPrefix ? vars.apiUrlPrefix : "") + path;
}
/** /**
* Finds an object in a JSON result by identifier * Finds an object in a JSON result by identifier
* *
...@@ -34,11 +28,3 @@ export const findObjectInApiResults = (identifier, results, identifierAttribute ...@@ -34,11 +28,3 @@ export const findObjectInApiResults = (identifier, results, identifierAttribute
} }
} }
} }
/**
* 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;
auth @ 159424d2
Subproject commit a84042737467c0649c083746aa35b43613fdf64a Subproject commit 159424d24146333ea48ff59d907120acf976ed37
common @ fdcb4c14
Subproject commit 332288561f010110799081f426d4addfc0b1ffcd Subproject commit fdcb4c14ef0375b5dc61d48ca4f59bd6c2561708
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