Skip to content
Snippets Groups Projects
Commit a56df46f authored by Hermann's avatar Hermann
Browse files

attempt for dynamical config based on the environment we want to build for

parent c920458d
No related branches found
No related tags found
No related merge requests found
import m from 'mithril';
import axios from 'axios';
import ClientOAuth2 from 'client-oauth2';
import { apiUrl, ownUrl, oAuthID } from 'networkConfig';
import * as localStorage from './localStorage';
import config from './config.json';
import config from './resourceConfig.json';
// Object which stores the current login-state
const APISession = {
......@@ -12,9 +13,9 @@ const APISession = {
// OAuth Handler
const oauth = new ClientOAuth2({
clientId: 'Local Tool',
authorizationUri: `${config.apiUrl}/oauth`,
redirectUri: 'http://localhost:9000/oauthcallback',
clientId: oAuthID,
authorizationUri: `${apiUrl}/oauth`,
redirectUri: `${ownUrl}/oauthcallback`,
});
export function resetSession() {
......@@ -25,7 +26,7 @@ export function resetSession() {
}
const amivapi = axios.create({
baseURL: config.apiUrl,
baseURL: apiUrl,
timeout: 10000,
headers: { 'Content-Type': 'application/json' },
});
......@@ -73,7 +74,7 @@ export function getSession() {
return new Promise((resolve) => {
checkAuthenticated().then(() => {
const authenticatedSession = axios.create({
baseURL: config.apiUrl,
baseURL: apiUrl,
timeout: 10000,
headers: {
'Content-Type': 'application/json',
......
import m from 'mithril';
import { RaisedButton, RadioGroup, Slider } from 'polythene-mithril';
import { styler } from 'polythene-core-css';
import { apiUrl } from 'networkConfig';
import EditView from '../views/editView';
import { fileInput } from '../views/elements';
import { apiUrl } from '../config.json';
const style = [
{
......
import m from 'mithril';
import { events as config } from '../config.json';
import { events as config } from '../resourceConfig.json';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import { dateFormatter } from '../utils';
......
......@@ -7,8 +7,9 @@ import {
Icon,
} from 'polythene-mithril';
import { styler } from 'polythene-core-css';
import { apiUrl } from 'networkConfig';
import ItemView from '../views/itemView';
import { apiUrl, eventsignups as signupConfig } from '../config.json';
import { eventsignups as signupConfig } from '../resourceConfig.json';
import TableView from '../views/tableView';
import DatalistController from '../listcontroller';
import { dateFormatter } from '../utils';
......
import m from 'mithril';
import viewGroup from './viewGroup';
import newGroup from './newGroup';
export default class EventModal {
constructor() {
this.edit = false;
}
view() {
if (this.edit) {
return m(newGroup);
}
return m(viewGroup, { onEdit: () => { this.edit = true; } });
}
}
{
"apiUrl": "https://api-dev.amiv.ethz.ch",
"ownUrl": "http://localhost:9000",
"oAuthID": "Local Tool"
}
{
"apiUrl": "https://api-dev.amiv.ethz.ch",
"ownUrl": "https://amiv-admin.amiv.ethz.ch",
"oAuthID": "Admintools Beta"
}
{
"apiUrl": "https://api-dev.amiv.ethz.ch/",
"events": {
"keyDescriptors": {
"title_de": "German Title",
"title_en": "English Title",
"location": "Location",
"show_website": "Event is shown on the website",
"priority": "Priority",
"time_end": "Ending time",
"time_register_end": "Deadline for registration",
"time_start": "Starting time",
"spots": "Spots available",
"allow_email_signup": "Event open for non-AMIV members",
"price": "Price",
"signup_count": "Signed-up participants",
"catchphrase_en": "Catchphrase in English. Announce and Website.",
"catchphrase_de": "Schlagwort auf Deutsch",
"description_de": "Beschreibung auf Deutsch",
"description_en": "Description in English",
"img_banner": "Banner as png",
"img_poster": "Poster as png",
"img_thumbnail": "Thumbnail as png",
"show_infoscreen": "Does the event show on the infoscreen?",
"img_infoscreen": "Infoscreen as png",
"time_advertising_end": "Advertisment ends on",
"time_advertising_start": "Advertisement starts on",
"selection_strategy": "TODO what is this?",
"show_announce": "Does it belong to announce?",
"_id": "TODO Event ID how is this generated?"
},
"tableKeys": [
"title_de",
"time_start",
"time_end",
"time_register_end",
"show_website",
"priority"
],
"notPatchableKeys": [
"signup_count"
]
},
"users": {
"keyDescriptors": {
"legi": "Legi Number",
"firstname": "First Name",
"lastname": "Last Name",
"rfid": "RFID",
"phone": "Phone",
"nethz": "nethz Account",
"gender": "Gender",
"department": "Department",
"email": "Email"
},
"tableKeys": [
"firstname",
"lastname",
"nethz",
"legi",
"membership"
],
"searchKeys": [
"firstname",
"lastname",
"nethz",
"legi",
"department"
],
"notPatchableKeys": [
"password_set"
]
},
"groups": {
"keyDescriptors": {
"name": "Name"
},
"searchKeys": ["name"],
"patchableKeys": ["name"]
},
"groupmemberships": {
"patchableKeys": ["user", "group"]
},
"eventsignups": {
"patchableKeys": ["event"],
"tableKeys": [
"_created",
"user.lastname",
"user.firstname",
"email"
],
"searchKeys": []
}
}
......@@ -2,7 +2,7 @@ import m from 'mithril';
import UserEdit from './editUser';
import UserView from './viewUser';
import TableView from '../views/tableView';
import { users as config } from '../config.json';
import { users as config } from '../resourceConfig.json';
import DatalistController from '../listcontroller';
export class NewUser extends UserEdit {
......
......@@ -2,7 +2,7 @@ import m from 'mithril';
import ItemView from '../views/itemView';
import TableView from '../views/tableView';
import SelectList from '../views/selectList';
import { users as config } from '../config.json';
import { users as config } from '../resourceConfig.json';
import DatalistController from '../listcontroller';
export default class UserView extends ItemView {
......
import Ajv from 'ajv';
import { Checkbox } from 'polythene-mithril';
import { apiUrl } from 'networkConfig';
import ItemView from './itemView';
import { apiUrl } from '../config.json';
import { textInput, datetimeInput, numInput } from './elements';
const m = require('mithril');
......
......@@ -78,7 +78,13 @@ const config = {
],
},
],
},
// Dynamically include config
resolve: {
alias: {
networkConfig: `${__dirname}/src/networkConfig.json`,
},
},
devtool: 'eval-source-map', // Default development sourcemap
......
......@@ -21,4 +21,8 @@ config.plugins = [
}),
];
// Replace development with production config
config.resolve.alias.config = `${__dirname}/config.${process.env.BUILD_CONFIG_POSTFIX}.js`;
module.exports = config;
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