mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
fix HTTPS issues for node endpoint urls
This commit is contained in:
parent
3c31ffb802
commit
48f899ac90
5 changed files with 25 additions and 31 deletions
|
@ -35,11 +35,16 @@ class WebsocketAPI {
|
|||
}
|
||||
|
||||
getURL(node) {
|
||||
if (node.relativeEndpoint) {
|
||||
return 'ws://' + window.location.host + '/' + node.endpoint;
|
||||
} else {
|
||||
return 'ws://' + node.endpoint;
|
||||
}
|
||||
// create an anchor element (note: no need to append this element to the document)
|
||||
var link = document.createElement('a');
|
||||
link.href = node.endpoint;
|
||||
|
||||
if (link.protocol === 'https:')
|
||||
link.protocol = 'wss:';
|
||||
else
|
||||
link.protocol = 'ws:';
|
||||
|
||||
return link.href;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
import React from 'react';
|
||||
import { FormGroup, FormControl, ControlLabel, Checkbox } from 'react-bootstrap';
|
||||
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
|
||||
|
||||
import Dialog from './dialog';
|
||||
|
||||
|
@ -35,7 +35,6 @@ class NewNodeDialog extends React.Component {
|
|||
endpoint: '',
|
||||
config: {},
|
||||
simulators: [],
|
||||
relativeEndpoint: false,
|
||||
_id: ''
|
||||
};
|
||||
}
|
||||
|
@ -59,7 +58,7 @@ class NewNodeDialog extends React.Component {
|
|||
}
|
||||
|
||||
resetState() {
|
||||
this.setState({ name: this.props.node.name, endpoint: this.props.node.endpoint, config: this.props.node.config, simulators: this.props.node.simulators, _id: this.props.node._id, relativeEndpoint: this.props.node.relativeEndpoint });
|
||||
this.setState({ name: this.props.node.name, endpoint: this.props.node.endpoint, config: this.props.node.config, simulators: this.props.node.simulators, _id: this.props.node._id });
|
||||
}
|
||||
|
||||
validateForm(target) {
|
||||
|
@ -96,9 +95,6 @@ class NewNodeDialog extends React.Component {
|
|||
<FormControl type="text" placeholder="Enter endpoint" value={this.state.endpoint} onChange={(e) => this.handleChange(e)} />
|
||||
<FormControl.Feedback />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Checkbox id="relativeEndpoint" checked={this.state.relativeEndpoint} onChange={e => this.handleChange(e)}>Relative Endpoint</Checkbox>
|
||||
</FormGroup>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
import React from 'react';
|
||||
import { FormGroup, FormControl, ControlLabel, Checkbox } from 'react-bootstrap';
|
||||
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
|
||||
|
||||
import Dialog from './dialog';
|
||||
|
||||
|
@ -34,8 +34,7 @@ class ImportNodeDialog extends React.Component {
|
|||
this.state = {
|
||||
name: '',
|
||||
endpoint: '',
|
||||
simulators: [],
|
||||
relativeEndpoint: false
|
||||
simulators: []
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,7 @@ class ImportNodeDialog extends React.Component {
|
|||
}
|
||||
|
||||
resetState() {
|
||||
this.setState({ name: '', endpoint: '', relativeEndpoint: false });
|
||||
this.setState({ name: '', endpoint: '' });
|
||||
|
||||
this.imported = false;
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ class ImportNodeDialog extends React.Component {
|
|||
// read simulator
|
||||
const node = JSON.parse(event.target.result);
|
||||
self.imported = true;
|
||||
self.setState({ name: node.name, endpoint: node.endpoint, simulators: node.simulators, relativeEndpoint: node.relativeEndpoint });
|
||||
self.setState({ name: node.name, endpoint: node.endpoint, simulators: node.simulators });
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
|
@ -121,9 +120,6 @@ class ImportNodeDialog extends React.Component {
|
|||
<FormControl readOnly={!this.imported} type="text" placeholder="Enter endpoint" value={this.state.endpoint} onChange={(e) => this.handleChange(e)} />
|
||||
<FormControl.Feedback />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Checkbox id="relativeEndpoint" checked={this.state.relativeEndpoint} onChange={e => this.handleChange(e)}>Relative Endpoint</Checkbox>
|
||||
</FormGroup>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
import React from 'react';
|
||||
import { FormGroup, FormControl, ControlLabel, Checkbox } from 'react-bootstrap';
|
||||
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
|
||||
|
||||
import Dialog from './dialog';
|
||||
|
||||
|
@ -34,8 +34,7 @@ class NewNodeDialog extends React.Component {
|
|||
name: '',
|
||||
endpoint: '',
|
||||
config: {},
|
||||
simulators: [],
|
||||
relativeEndpoint: false
|
||||
simulators: []
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ class NewNodeDialog extends React.Component {
|
|||
}
|
||||
|
||||
resetState() {
|
||||
this.setState({ name: '', endpoint: '', config: {}, simulators: [], relativeEndpoint: false });
|
||||
this.setState({ name: '', endpoint: '', config: {}, simulators: [] });
|
||||
}
|
||||
|
||||
validateForm(target) {
|
||||
|
@ -95,9 +94,6 @@ class NewNodeDialog extends React.Component {
|
|||
<FormControl type="text" placeholder="Enter endpoint" value={this.state.endpoint} onChange={(e) => this.handleChange(e)} />
|
||||
<FormControl.Feedback />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Checkbox id="relativeEndpoint" checked={this.state.relativeEndpoint} onChange={e => this.handleChange(e)}>Relative Endpoint</Checkbox>
|
||||
</FormGroup>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
|
@ -29,11 +29,12 @@ class NodesDataManager extends RestDataManager {
|
|||
}
|
||||
|
||||
getURL(node) {
|
||||
if (node.relativeEndpoint) {
|
||||
return 'http://' + window.location.host + '/' + node.endpoint + '/api/v1';
|
||||
} else {
|
||||
return 'http://' + node.endpoint + '/api/v1';
|
||||
}
|
||||
// create an anchor element (note: no need to append this element to the document)
|
||||
var link = document.createElement('a');
|
||||
link.href = node.endpoint;
|
||||
link.pathname = link.pathname + 'api/v1';
|
||||
|
||||
return link.href;
|
||||
}
|
||||
|
||||
getSimulators(node) {
|
||||
|
|
Loading…
Add table
Reference in a new issue