From 81351a1cdb03c63bdd91184cda03fe30c65965f0 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Mon, 28 Sep 2020 10:18:27 +0200 Subject: [PATCH] Add link to swagger API doc on home page #258 --- src/common/home.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/common/home.js b/src/common/home.js index 4bf124f..c6169c5 100644 --- a/src/common/home.js +++ b/src/common/home.js @@ -25,10 +25,25 @@ class Home extends React.Component { constructor(props) { super(props); + + + // create url for API documentation, distinguish between localhost and production deployment + let docs_url = ""; + let docs_location = "/swagger/index.html"; + let base_url = window.location.origin; + if (base_url.search("localhost") === -1){ + docs_url = base_url + docs_location; + } else { + // useful for local testing, replace port 3000 with port 4000 (port of backend) + docs_url = base_url.replace("3000", "4000") + docs_location; + } + this.state = { currentUser: LoginStore.getState().currentUser, - token: LoginStore.getState().token + token: LoginStore.getState().token, + docs_url: docs_url }; + } getCounts(type) { @@ -51,13 +66,17 @@ class Home extends React.Component { Logo VILLASweb

Home

- Welcome to {config.instance}!
- VILLASweb is a frontend for distributed real-time simulation hosted by {config.admin.name}. + Welcome to {config.instance} hosted by {config.admin.name}!

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

+

+ An interactive documentation of the VILLASweb API is available here. +

+ +

Data Model

Datamodel VILLASweb