appui.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //-----App ui-----
  2. function createApp() {
  3. let self = this
  4. return {
  5. $cell: true,
  6. $type: "div",
  7. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  8. $components: [
  9. {
  10. $cell: true,
  11. $type: "div",
  12. class: "mdc-layout-grid__inner",
  13. $components: [
  14. {
  15. $type: "div",
  16. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  17. $components: [
  18. self.widgets.inputTextFieldOutlined({
  19. "id": 'deviceIDInput',
  20. "label": "Device ID",
  21. "value": window._LegoView.device.id,
  22. "change": function (e) {
  23. window._LegoView.changeDeviceID(this.value);
  24. }
  25. })
  26. ]
  27. },
  28. {
  29. $cell: true,
  30. $type: "div",
  31. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  32. $components: [
  33. self.widgets.buttonRaised(
  34. {
  35. "label": _LegoView.isConnected() ? "Disconnect" : "Connect",
  36. "onclick": function (e) {
  37. if (!_LegoView.isConnected()) {
  38. this.$text = 'Disconnect';
  39. _LegoView.connect();
  40. } else {
  41. this.$text = 'Connect';
  42. _LegoView.disconnect();
  43. }
  44. }
  45. }
  46. ),
  47. // _app.widgets.divider,
  48. // {
  49. // $cell: true,
  50. // $type: "button",
  51. // class: "mdc-button mdc-button--raised",
  52. // $text: "Start tracking",
  53. // onclick: function (e) {
  54. // // window._LegoView.testLED();
  55. // }
  56. // },
  57. {
  58. $cell: true,
  59. $type: "button",
  60. class: "mdc-button mdc-button--raised",
  61. $text: "Create Robot device",
  62. onclick: function (e) {
  63. let sceneID = vwf.find("", "/")[0];
  64. let boostID = _LegoView.isConnected() ? _LegoView.device.id : 'none';
  65. vwf_view.kernel.callMethod(sceneID, "createLegoBoost", [boostID]);
  66. }
  67. },
  68. _app.widgets.divider,
  69. {
  70. $cell: true,
  71. $type: "button",
  72. class: "mdc-button mdc-button--raised",
  73. $text: "Действие!",
  74. onclick: function (e) {
  75. let sceneID = vwf.find("", "/")[0];
  76. vwf_view.kernel.callMethod(sceneID, "doLegoBoostAction");
  77. }
  78. }
  79. ]
  80. }
  81. ]
  82. }
  83. ]
  84. }
  85. }