Commit bdf95678 authored by Dorian Goepp's avatar Dorian Goepp

Merge branch 'dgoepp/fix#1' into 'master'

fix a tiny bug in Video Stream

See merge request behaviors-ai/the_dashboard!8
parents 2280357f 60059b71
...@@ -42,13 +42,13 @@ class VideoStream extends Component { ...@@ -42,13 +42,13 @@ class VideoStream extends Component {
this.store = new VideoStore(); this.store = new VideoStore();
// Automatically detect if the configured topic name is valid
this.hasTopic = observable.box(false);
this.searchForTopic()
// Fill the undefined fields of the configuration object with their default values. // Fill the undefined fields of the configuration object with their default values.
defaultConfig(this.store); defaultConfig(this.store);
this.props.store.components['video'] = this.store; this.props.store.components['video'] = this.store;
// Automatically detect if the configured topic name is valid
this.hasTopic = observable.box(false);
this.searchForTopic();
} }
defaultImage = 'images/default.svg'; defaultImage = 'images/default.svg';
...@@ -62,7 +62,7 @@ class VideoStream extends Component { ...@@ -62,7 +62,7 @@ class VideoStream extends Component {
get streamUrl() { get streamUrl() {
if ('url' in this.props && this.props.url) { if ('url' in this.props && this.props.url) {
return this.props.url; return this.props.url;
} else if (this.hasTopic.get()) { } else if (this.hasTopic.get()) {
// all requierd configuration fields are defined // all requierd configuration fields are defined
return 'http://' + this.store.config.host + '/stream?topic=' return 'http://' + this.store.config.host + '/stream?topic='
+ this.store.config.topic; + this.store.config.topic;
...@@ -74,7 +74,7 @@ class VideoStream extends Component { ...@@ -74,7 +74,7 @@ class VideoStream extends Component {
/** /**
* Check that all the requirements are met for subscribing to the required * Check that all the requirements are met for subscribing to the required
* topic * topic
* *
* Thanks to MobX magic, the result is computed again each time the topic * Thanks to MobX magic, the result is computed again each time the topic
* configuration is changed. * configuration is changed.
*/ */
...@@ -88,19 +88,18 @@ class VideoStream extends Component { ...@@ -88,19 +88,18 @@ class VideoStream extends Component {
this.props.ros.getTopics(infos => { this.props.ros.getTopics(infos => {
this.hasTopic.set(undefined !== infos.topics.find( this.hasTopic.set(undefined !== infos.topics.find(
elem => elem === this.store.config.topic)); elem => elem === this.store.config.topic));
if (!this.hasTopic.get()) { if (!this.hasTopic.get()) {
console.warn("[VideoStream] The required topic " console.warn("[VideoStream] The required topic "
+ this.store.config.topic + " is not published"); + this.store.config.topic + " is not published");
} }
console.debug(this.hasTopic.get());
}) })
} else { } else {
console.warn("[VideoStream] either no topic is configured " console.warn("[VideoStream] either no topic is configured "
+ "or no host is configured. This should never " + "or no host is configured. This should never "
+ "happen at runtime. Contact the developpers."); + "happen at runtime. Contact the developpers.");
} }
}) }, {fireImmediately: true})
} else { } else {
console.warn("[VideoStream] ROS property is provided. This should " console.warn("[VideoStream] ROS property is provided. This should "
+ "never happen at runtime. Contact the developpers."); + "never happen at runtime. Contact the developpers.");
......
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