mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 90 forks source link

Replace webcomponents import #486

Closed elgarfo closed 5 years ago

elgarfo commented 5 years ago

@jkandasa in reference to this thread: https://forum.mycontroller.org/topic/376/custom-widget-send-command-to-node/8

this PR resolves multiple problems which became obvious in the above mentioned thread:

to combat a race condition between angulars bootstrap process, slower internet connections and the process of loading additional JS from local or remote servers, i opted to:

  1. defer angulars bootstrapping process. (see: https://docs.angularjs.org/guide/bootstrap)
  2. load additional JS resources via $.getScript (see: https://api.jquery.com/jquery.getscript/)
  3. use promises to handle the asynchronous process
  4. test if the specified additional angularJS modules can be loaded (angular crashes if modules can not be loaded)
  5. finally resume angulars bootstrap and pass additional modules to load

this has been tested so far on windows 10 x64 1806 with firefox 63.0.3 64-bit and is working fine for me. i've been able to plug your custom slider widget example right into the frontend without modifying app.js. as far as i can tell, the websites is working flawless, on first an subsequent visits, with or without additional modules specified.

jkandasa commented 5 years ago

@elgarfo Thank you for the awesome work! I will review this PR soon and merge it if everything goes well.

jkandasa commented 5 years ago

@elgarfo All works great! Thank you so much for your contributions! There are minor update needs,

jkandasa commented 5 years ago

@elgarfo I have updated the changes. Thanks!

elgarfo commented 5 years ago

@jkandasa thanks for taking the time to fix this. sorry for not pushing the requested changes, i simply had not enough time before and during the holidays. i guess everything is working well, or did you encounter any difficulties with any browser?

jkandasa commented 5 years ago

@elgarfo I tested only on Chrome and I do not face any issue. It was a simple change I made. Thank you for your great PR.

wanvo commented 5 years ago

I checked this widget with new SNAPSHOT in Chrome, it works great. In Firefox, all menus look like this ({{variable}}.

elgarfo commented 5 years ago

@wanvo which version of firefox and what OS did u use? can you try with a new firefox profile?

wanvo commented 5 years ago

@elgarfo I am using Windows7 x64, the latest version of Firefox x64. I created a new firefox profile and I tried the widget in it.The menus look the same {{variable}}. After I replased lines in "HTML additional headers": https://localhost:8443/mylib/rzslider.min.css https://localhost:8443/mylib/gauge.min.js https://localhost:8443/mylib/rzslider.min.js to the lines https://cdnjs.cloudflare.com/ajax/libs/angularjs-slider/6.6.0/rzslider.min.css https://cdnjs.cloudflare.com/ajax/libs/angularjs-slider/6.6.0/rzslider.min.js and cleared the firefox cache, everything started to work fine.

Then I returned everything to the original situation. I registered the paths to the css and js files in the local mylib. Firefox began to render the frontend correctly and the widgets work well.