Commit 04076aa0 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

Add preset selector for urls

parent 0f8e062f
import React, { PureComponent } from 'react'
import {Navbar, Nav, NavItem, NavDropdown, MenuItem, Glyphicon, Jumbotron, Button} from 'react-bootstrap'
import {DropdownButton, Navbar, Nav, NavItem, NavDropdown, MenuItem, Glyphicon, Jumbotron, Button} from 'react-bootstrap'
import {Row, Col, Collapse, FormControl, FormGroup, ControlLabel, HelpBlock, PanelGroup, Panel} from 'react-bootstrap'
import FontAwesome from 'react-fontawesome'
......@@ -22,6 +22,13 @@ export function expiresText(expires) {
class Component extends PureComponent {
constructor(props) {
super(props)
this.state = {
customEndpoint: ""
}
}
updateAPIendpoint(e) {
this.setState({customEndpoint: e.target.value})
}
......@@ -38,6 +45,22 @@ class Component extends PureComponent {
this.props.httpRequestStart(endpoint)
}
preselect(key, event) {
console.log("Key", key, "event", event)
this.setState({customEndpoint: key})
}
renderDropdownButton() {
const i = "drpdwn"
const title = "Load preset URL"
return (
<DropdownButton bsStyle="default" title={title} key={i} id={`dropdown-basic-${i}`} onSelect={this.preselect.bind(this)}>
<MenuItem eventKey="https://groups-api.dataporten.no/groups/me/groups">groups-api.dataporten.no/groups/me/groups</MenuItem>
<MenuItem eventKey="https://4f2.httpjs.net/">https://4f2.httpjs.net/</MenuItem>
</DropdownButton>
);
}
render() {
console.error("Component", this.props)
......@@ -48,7 +71,6 @@ class Component extends PureComponent {
}
let userinfo = null
if (this.props.serverConfig.userinfo_endpoint) {
userinfo = (
......@@ -61,13 +83,16 @@ class Component extends PureComponent {
)
}
return (
<Panel header="HTTP Client using OAuth Access Token" eventKey="1" collapsible={true} expanded={true}>
{userinfo}
<div>
<p>Fetch userinfo from</p>
<p>Fetch data from</p>
{this.renderDropdownButton()}
<FormGroup
className="gutter"
controlId="formBasicText"
......@@ -76,6 +101,7 @@ class Component extends PureComponent {
type="text"
bsSize="large"
placeholder="http://httpjs.net/foo"
value={this.state.customEndpoint}
onChange={this.updateAPIendpoint.bind(this)}
/>
<HelpBlock>Fill out the hostname of your OAuth server. Will only work if your OAuth server support OpenID Connect Discovery. If not, please enter configuration manually.</HelpBlock>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment