From ab494a484e737a3f7b9ffead5e12eb815e8c5ffc Mon Sep 17 00:00:00 2001 From: irismarie Date: Fri, 26 Feb 2021 14:01:55 +0100 Subject: [PATCH] [WIP] allow branding --- src/branding/branding.js | 37 ++++++++++++++++++++ src/branding/brands.js | 70 +++++++++++++++++++++++++++++++++++++ src/common/header.js | 4 +-- src/common/home.js | 43 ++++------------------- src/common/menu-sidebar.js | 43 +++++++++++++++++++---- src/config.js | 15 ++++---- src/img/slew-logo.png | Bin 0 -> 3939 bytes src/router.js | 1 + 8 files changed, 160 insertions(+), 53 deletions(-) create mode 100644 src/branding/branding.js create mode 100644 src/branding/brands.js create mode 100644 src/img/slew-logo.png diff --git a/src/branding/branding.js b/src/branding/branding.js new file mode 100644 index 0000000..5baa395 --- /dev/null +++ b/src/branding/branding.js @@ -0,0 +1,37 @@ +/** + * This file is part of VILLASweb. + * + * VILLASweb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VILLASweb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with VILLASweb. If not, see . + ******************************************************************************/ + +import brands from './brands' +import config from '../config' +import _ from 'lodash'; + +class Branding { + constructor(chosenbrand) { + var brand = _.get(brands, [chosenbrand]); + if (!brand) { + console.error("Branding '" + chosenbrand + "' not available, will use 'villasweb' branding"); + brand = _.get(brands, ['villasweb']); + } + + this.brand = brand; + } + + static instance = Branding.instance || new Branding(config.branding); +}; + + +export default Branding; \ No newline at end of file diff --git a/src/branding/brands.js b/src/branding/brands.js new file mode 100644 index 0000000..45db6c7 --- /dev/null +++ b/src/branding/brands.js @@ -0,0 +1,70 @@ +/** + * This file is part of VILLASweb. + * + * VILLASweb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VILLASweb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with VILLASweb. If not, see . + ******************************************************************************/ + +const brands = { + villasweb: { + title: 'VILLASweb', + subtitle: 'ACS', + logo: 'villas_web.svg', + pages: { + home: true, + scenarios: true, + infrastructure: true, + users: true, + account: true, + api: true, + }, + links: { + "VILLASframework project": "http://fein-aachen.org/projects/villas-framework/", + "VILLASweb Documentation": "https://villas.fein-aachen.org/doc/web.html", + "VILLASweb frontend source": "https://git.rwth-aachen.de/acs/public/villas/web", + "VILLASweb backend source":"https://git.rwth-aachen.de/acs/public/villas/web-backend-go", + } + }, + slew: { + title: 'SLEW', + subtitle: 'Second Life for Energiewende', + logo: "slew-logo.png", + pages: { + home: true, + scenarios: true, + infrastructure: false, + users: false, + account: false, + api: false + }, + links: { + "DPsim Simulator": "https://dpsim.fein-aachen.org", + "VILLASframework": "https://villas.fein-aachen.org/doc" + } + }, + test: { + title: 'SLEW', + subtitle: 'Second Life for Energiewende', + logo: "slew-logo.png", + pages: { + home: true, + scenarios: true, + infrastructure: false, + users: false, + account: false, + api: false + }, + } +} + +export default brands; \ No newline at end of file diff --git a/src/common/header.js b/src/common/header.js index c5c71b7..69b0980 100644 --- a/src/common/header.js +++ b/src/common/header.js @@ -19,14 +19,14 @@ import React from 'react'; import { Col, Button } from 'react-bootstrap'; import { Hidden } from 'react-grid-system' import Icon from './icon'; -import config from '../config'; +import Branding from '../branding/branding'; class Header extends React.Component { render() { return (
-

{config.instance} - {config.subtitle}

+

{Branding.instance.brand.title} - {Branding.instance.brand.subtitle}

diff --git a/src/common/home.js b/src/common/home.js index 5932022..f8aa894 100644 --- a/src/common/home.js +++ b/src/common/home.js @@ -17,9 +17,11 @@ import React from 'react'; -import config from '../config'; import { Redirect } from "react-router-dom"; import { NavLink } from 'react-router-dom'; +import Branding from '../branding/branding'; + +const images = require.context('../img', true) class Home extends React.Component { @@ -38,50 +40,19 @@ class Home extends React.Component { return (); } + const brand = Branding.instance.brand; + return (
- Logo VILLASweb + Logo VILLASweb

Home

- {/*Welcome to {config.instance} hosted by {config.admin.name}!
*/} - Welcome to {config.instance}! + Welcome to {Branding.instance.brand.title}!

You are logged in as user {currentUser.username} with ID {currentUser.id} and role {currentUser.role}.

- - {/*

Data Model

- Datamodel VILLASweb - -

Terminology

- -
Infrastructure Component
-
    -
  • A component of research infrastructure
  • -
  • Category: for example simulator, gateway, amplifier, database, etc.
  • -
  • Type: for example RTDS, OpalRT, VILLASnode, Cassandra
  • -
- -
Component Configuration
-
    -
  • Input signals: Signals that can be modified in VILLASweb
  • -
  • Output signals: Signals that can be visualized on dashboards of VILLASweb
  • -
  • Parameters: Further configuration parameters of the infrastructure component
  • -
- -
Dashboard
-
    -
  • Visualize ongoing experiments in real-time
  • -
  • Interact with ongoing experiments in real-time
  • -
- -
Scenario
-
    -
  • A collection of component configurations and dashboards for a specific experiment
  • -
  • Users can have access to multiple scenarios
  • -
*/} -

Credits

VILLASweb is an open source project developed by the Institute for Automation of Complex Power Systems at RWTH Aachen University.

Logo ACS diff --git a/src/common/menu-sidebar.js b/src/common/menu-sidebar.js index 2e953f8..1b7208e 100644 --- a/src/common/menu-sidebar.js +++ b/src/common/menu-sidebar.js @@ -17,24 +17,53 @@ import React from 'react'; import { NavLink } from 'react-router-dom'; +import Branding from '../branding/branding'; + class SidebarMenu extends React.Component { render() { + const brand = Branding.instance.brand; + console.log(brand.links) + let links = [] + + /*++++ + for (var key of Object.keys(brand.links) ) { + console.log(`${key}: ${brand.links[key]}`); + links.push(
  • {key}
  • ); + }*/ + + if (brand.links) { + Object.keys(brand.links).forEach(key => { + console.log(`${key}: ${brand.links[key]}`); + links.push(
  • {key}
  • ); + }) + } + + return (

    Menu

      -
    • Home
    • -
    • Scenarios
    • -
    • Infrastructure Components
    • - { this.props.currentRole === 'Admin' ? -
    • User Management
    • : '' + + + + {this.props.currentRole === 'Admin' ? +
    • User Management
    • : '' } -
    • Account
    • +
    • Logout
    • -
    • API Browser
    • +
    + { + links.length > 0 ? +
    +

    +

    Links

    +
      {links}
    +
    + : '' + }
    ); } diff --git a/src/config.js b/src/config.js index 874e58f..c7998c0 100644 --- a/src/config.js +++ b/src/config.js @@ -16,13 +16,12 @@ ******************************************************************************/ const config = { - publicPathBase: 'public/', - instance: 'VILLASweb', - subtitle: 'ACS', - admin: { - name: 'Institute for Automation of Complex Power Systems (ACS), RWTH Aachen University, Germany', - mail: 'stvogel@eonerc.rwth-aachen.de' - } -}; + publicPathBase: 'public/', + admin: { + name: 'Institute for Automation of Complex Power Systems (ACS), RWTH Aachen University, Germany', + mail: 'stvogel@eonerc.rwth-aachen.de' + }, + branding: 'slew', +} export default config diff --git a/src/img/slew-logo.png b/src/img/slew-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..747bf8339dac5f79adc1e39d6a5c451e7481c3df GIT binary patch literal 3939 zcmdUxX;2f{-o|mm5d^nEM|NbBETAYLqB4M(0R&V?!wE`U(rSV$7#tB~MnsTB+0qEI zxJ<4>Iv|Gx1q4)3vs_@rNe_bq2nq-hVPq3zxnZW>dEXCj)vdbUZdY|Z=XvU!f1eNM z{Q7@omk&)#LsvshO-;+=yX||_)aKuxedo?oC75r}UX{#0;^OV1rdD!IbMn9fm7f!~ zhvuqQ)S%z1GK+TY^mhkGOV*j6+oO2p%j{@UQ`7$JvE9Z0`<4$mPp;niZl(KrT`y|! z;kQxb%xMkI`tuJi&BSq|7kJeL_@FJ#E}PcbT#WDSs0y>E7jA6q98SJ5=lMRms`P); z!*^_(rtM9QrLasify8wsO!+^<5r9Y^Yzj$NWSozSsbK9(HP2LF!LfxJhF}@Yek$0- z!^!X+Y*CGV{m0j{85HcwRAt-YwBLPELknw)6v%Lf(|gPWRsoDL`e(0nJgkHpn#ujy zOfcvzM0mJc$CnF*EINwXRj_g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