Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

network doesn't display icons for devices on first load #91

Open
Joncy opened this issue Apr 20, 2016 · 5 comments
Open

network doesn't display icons for devices on first load #91

Joncy opened this issue Apr 20, 2016 · 5 comments

Comments

@Joncy
Copy link
Member

Joncy commented Apr 20, 2016

Requires to refresh page to display.

@Joncy Joncy added the bug label Apr 20, 2016
@jsdario jsdario added the easy label May 18, 2016
@ankitkhedekar
Copy link
Contributor

ankitkhedekar commented Sep 28, 2016

I would like to contribute here. Would appreciate if you could help with a few more details.

I setup the project and tried the bulb-padjs example successfully. For a device to appear in the network, will I actually need a physical device? or is there a way to simulate?

Thanks.

@jsdario
Copy link
Member

jsdario commented Sep 28, 2016

Hi @ankitkhedekar, sounds great. It must work with simulated devices also.

This is the file on the frontend where the magic happens https://github.com/netbeast/dashboard/blob/master/public/components/devices/index.jsx

This is by the way, where the bug probably lays. If you know something about react it should be easy. Below here I would explain the Dashboard logic for the task, that may not be needed. If you have any doubts about front-end building, please ask on this issue :)

The devices rendered are the ones that are last emitted on the network/devices MQTT channel:

   componentWillMount () {
    window.addEventListener('resize', this.handleResize)
    this.mqtt.subscribe('netbeast/network')
    this.mqtt.on('message', (topic, message) => {
      if (topic !== 'netbeast/network') return

      const devices = JSON.parse(message)
      Session.save('devices', devices)
      this.setState({ devices })
    })
}

The scanner on the backend is this file: https://github.com/netbeast/dashboard/blob/master/src/services/scanner.js. The logic is the following: installed plugins that detect devices connected are pushed to the SQLite database, then retrieved via Resources.

It can happen that the resources are not correctly set up – in that case we must debug the SQLite database and test with plugins to see if the error is out there.

Thanks for your interest, count on us for anything!

@ankitkhedekar
Copy link
Contributor

My initial thoughts:

The scanner initially emits devices list on network/devices on the first interval even when the Devices component might not have been yet mounted. After it mounts, it subscribes to the channel, but here scanner will no longer emit device list as it checks for cached result until a new device is added.

Please advice if I am going in the right direction.

@jsdario
Copy link
Member

jsdario commented Sep 29, 2016

Sounds a 100% right hypothesis, we can test it out.

We can go to the scanner https://github.com/netbeast/dashboard/blob/master/src/services/scanner.js and make it subscribe to the network topic broker.client.subscribe('network/devices/request'). When the view is mounted we can emit a request so the scanner re-emits its cachedResult variable.

@ankitkhedekar
Copy link
Contributor

@jsdario , I have tried implementing the solution which you can check in #159

I have not been able to run test successfully as I have been getting 2 issues

  • 'should install get-started from github' keeps timing out
  • Error: App already exists

Would need a bit of help. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants