jsgui: Fix case when entity details don't load

Handles case when application-tree hasn't rendered a details view when
the page is first loaded. Also includes a few basic code improvements in
application-tree.js.