widgets.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  4. */
  5. /*
  6. * Cell widgets
  7. */
  8. class Widgets {
  9. constructor() {
  10. console.log("widget constructor")
  11. }
  12. get divider(){
  13. return {
  14. $cell: true,
  15. $type: "hr",
  16. class: "mdc-list-divider"
  17. }
  18. }
  19. get emptyDiv(){
  20. return {
  21. $type: "div",
  22. style: "padding-bottom: 30px;"
  23. }
  24. }
  25. get break(){
  26. return {
  27. $type: "br"
  28. }
  29. }
  30. get space() {
  31. return {
  32. $type: "span",
  33. $text: " "
  34. }
  35. }
  36. get p(){
  37. return {
  38. $type: "p"
  39. }
  40. }
  41. inputTextFieldOutlined(obj){
  42. function initFunc() {
  43. new mdc.textField.MDCTextField.attachTo(this);
  44. }
  45. let inputType = obj.type ? obj.type: 'text';
  46. let init = obj.init ? obj.init: initFunc;
  47. let style = obj.style ? obj.style: "";
  48. let fieldStyle = obj.fieldStyle ? obj.fieldStyle: "";
  49. return {
  50. $cell: true,
  51. $type: "div",
  52. class: "mdc-text-field mdc-text-field--outlined mdc-text-field--dense",
  53. style: style,
  54. $init: init,
  55. $components:[
  56. {
  57. $type: "input",
  58. type: inputType,
  59. id: obj.id,
  60. class: "mdc-text-field__input",
  61. value: obj.value,
  62. onchange: obj.change,
  63. style: obj.fieldStyle
  64. },
  65. {
  66. $type: "div",
  67. class: "mdc-notched-outline",
  68. $components:[
  69. {
  70. $type: "div",
  71. class: "mdc-notched-outline__leading"
  72. },
  73. {
  74. $type: "div",
  75. class: "mdc-notched-outline__notch",
  76. $components:[
  77. {
  78. $type: "label",
  79. class: "mdc-floating-label",
  80. for: obj.id,
  81. $text: obj.label
  82. }
  83. ]
  84. },
  85. {
  86. $type: "div",
  87. class: "mdc-notched-outline__trailing"
  88. }
  89. ]
  90. }
  91. ]
  92. //onclick: obj.onclick
  93. }
  94. }
  95. inputTextFieldStandart(obj){
  96. var propValue = obj.value;
  97. if (_app.helpers.testJSON(obj.value)){
  98. propValue = JSON.parse(obj.value);
  99. } else {
  100. propValue = obj.value;
  101. }
  102. return {
  103. $cell: true,
  104. $type: "div",
  105. class: "mdc-text-field text-field mdc-ripple-upgraded",
  106. _mdc: null,
  107. $init: function(){
  108. //new mdc.mdc.notchedOutline.MDCNotchedOutline(document.querySelector('.mdc-notched-outline'));
  109. this._mdc = new mdc.textField.MDCTextField.attachTo(this);
  110. },
  111. $components:[
  112. {
  113. $type: "input",
  114. type: "text",
  115. id: obj.id,
  116. class: "mdc-text-field__input",
  117. value: propValue,
  118. onchange: obj.change
  119. },
  120. {
  121. $type: "label",
  122. class: "mdc-floating-label",
  123. for: obj.id,
  124. $text: obj.label
  125. },
  126. {
  127. $type: "div",
  128. class: "mdc-line-ripple"
  129. }
  130. ]
  131. //onclick: obj.onclick
  132. }
  133. }
  134. headerH3(headertype, label, cssclass) {
  135. return {
  136. $cell: true,
  137. $type: headertype,
  138. class: cssclass,
  139. $text: label
  140. }
  141. }
  142. simpleCard(obj){
  143. let style = 'background-image: url(' + obj.imgSrc + '); background-size: cover; background-repeat: no-repeat; height:' + obj.imgHeight + ';';
  144. var addonClass = obj.addonClass;
  145. if (!addonClass){
  146. addonClass = ''
  147. }
  148. return {
  149. $cell: true,
  150. $type: "div",
  151. $components:[
  152. {
  153. $cell: true,
  154. $type: "div",
  155. class: "mdc-card" +' '+ addonClass,
  156. onclick: obj.onclickfunc,
  157. $components:[
  158. {
  159. $cell: true,
  160. $type: "section",
  161. class: "mdc-card__media",
  162. style: style
  163. },
  164. {
  165. $cell: true,
  166. $type: "section",
  167. class: "mdc-card__supporting-text",
  168. $text: obj.text
  169. }
  170. ]
  171. }
  172. ]
  173. }
  174. }
  175. listDivider() {
  176. return {
  177. $cell: true,
  178. $type: "hr",
  179. class: "mdc-list-divider mdc-list-divider--inset"
  180. }
  181. }
  182. createListItem(obj) {
  183. return {
  184. $cell: true,
  185. $type: "li",
  186. class: "mdc-list-item",
  187. $components: [
  188. {
  189. $cell: true,
  190. $type: "span",
  191. class: "mdc-list-item__graphic",
  192. $components: [
  193. {
  194. $cell: true,
  195. class: "createItems",
  196. $type: "img",
  197. src: obj.imgSrc,
  198. onclick: obj.onclickfunc
  199. }
  200. ]
  201. },
  202. {
  203. $cell: true,
  204. $type: "span",
  205. class: "mdc-list-item__text",
  206. $text: obj.title
  207. // $components: [
  208. // {
  209. // $text: obj.title
  210. // },
  211. // {
  212. // $cell: true,
  213. // $type: "span",
  214. // class: "mdc-list-item__secondary-text",
  215. // $text: obj.subTitle
  216. // }
  217. // ]
  218. }
  219. ]
  220. }
  221. }
  222. createCard(obj){
  223. return {
  224. $cell: true,
  225. $type: "div",
  226. $components:[
  227. {
  228. $cell: true,
  229. $type: "div",
  230. class: "mdc-card",
  231. $components:[
  232. {
  233. $cell: true,
  234. $type: "div",
  235. class: "mdc-card__horizontal-block",
  236. $components:[
  237. {
  238. $cell: true,
  239. $type: "section",
  240. class: "mdc-card__primary",
  241. $components:[
  242. {
  243. $cell: true,
  244. $type: "h1",
  245. class: "mdc-card__title mdc-card__title--large",
  246. $text: obj.title
  247. },
  248. {
  249. $cell: true,
  250. $type: "h2",
  251. class: "mdc-card__subtitle",
  252. $text: obj.subTitle
  253. }
  254. ]
  255. },
  256. {
  257. $cell: true,
  258. $type: "img",
  259. class: "",
  260. src: obj.imgSrc
  261. }
  262. ]
  263. },
  264. {
  265. $cell: true,
  266. $type: "section",
  267. class: "mdc-card__actions",
  268. $components:[
  269. {
  270. $cell: true,
  271. $type: "button",
  272. class: "mdc-button mdc-button--compact mdc-card__action",
  273. $text: obj.actionLabel
  274. }
  275. ]
  276. }
  277. ]
  278. }
  279. ]
  280. }
  281. }
  282. buttonStroked(obj){
  283. return {
  284. $cell: true,
  285. $type: "button",
  286. class: "mdc-button mdc-button--outlined",
  287. $text: obj.label,
  288. onclick: obj.onclick
  289. }
  290. }
  291. buttonRaised(obj){
  292. return {
  293. $cell: true,
  294. $type: "button",
  295. class: "mdc-button mdc-button--raised mdc-ripple-upgraded",
  296. $text: obj.label,
  297. onclick: obj.onclick
  298. }
  299. }
  300. buttonSimple(obj){
  301. return {
  302. $cell: true,
  303. $type: "button",
  304. class: "mdc-button",
  305. $components: [
  306. {
  307. $type: "span",
  308. class: "mdc-button__label",
  309. $text: obj.label
  310. }
  311. ],
  312. onclick: obj.onclick
  313. }
  314. }
  315. sliderDiscrete(obj) {
  316. return {
  317. $cell: true,
  318. $type: "div",
  319. class: "mdc-slider mdc-slider--discrete",
  320. role: "slider",
  321. 'aria-valuemin': obj.min,
  322. 'aria-valuemax': obj.max,
  323. 'aria-label': obj.label,
  324. $init: obj.init,
  325. $components: [
  326. {
  327. $cell: true,
  328. $type: "div",
  329. class: "mdc-slider__track-container",
  330. $components: [
  331. {
  332. $cell: true,
  333. $type: "div",
  334. class: "mdc-slider__track",
  335. }
  336. ]
  337. },
  338. {
  339. $cell: true,
  340. $type: "div",
  341. class: "mdc-slider__thumb-container",
  342. $components: [
  343. {
  344. $cell: true,
  345. $type: "div",
  346. class: "mdc-slider__pin",
  347. $components: [
  348. {
  349. $cell: true,
  350. $type: "span",
  351. class: "mdc-slider__pin-value-marker",
  352. }
  353. ]
  354. },
  355. {
  356. $cell: true,
  357. $type: "svg",
  358. class: "mdc-slider__thumb",
  359. width: 21,
  360. height: 21,
  361. $components: [
  362. {
  363. $cell: true,
  364. $type: "circle",
  365. cx: 10.5,
  366. cy: 10.5,
  367. r: 7.875
  368. }
  369. ]
  370. },
  371. {
  372. $cell: true,
  373. $type: "div",
  374. class: "mdc-slider__focus-ring"
  375. }
  376. ]
  377. }
  378. ]
  379. }
  380. }
  381. sliderContinuous(obj) {
  382. return {
  383. $cell: true,
  384. $type: "div",
  385. class: "mdc-slider",
  386. role: "slider",
  387. tabindex: 0,
  388. 'id': obj.id,
  389. 'aria-valuemin': obj.min,
  390. 'aria-valuemax': obj.max,
  391. 'aria-label': obj.label,
  392. 'aria-valuenow': obj.value,
  393. 'data-step': obj.step,
  394. $init: obj.init,
  395. $components: [
  396. {
  397. $cell: true,
  398. $type: "div",
  399. class: "mdc-slider__track-container",
  400. $components: [
  401. {
  402. $cell: true,
  403. $type: "div",
  404. class: "mdc-slider__track",
  405. }
  406. ]
  407. },
  408. {
  409. $cell: true,
  410. $type: "div",
  411. class: "mdc-slider__thumb-container",
  412. $components: [
  413. {
  414. $cell: true,
  415. $type: "svg",
  416. class: "mdc-slider__thumb",
  417. width: 21,
  418. height: 21,
  419. $components: [
  420. {
  421. $cell: true,
  422. $type: "circle",
  423. cx: 10.5,
  424. cy: 10.5,
  425. r: 7.875
  426. }
  427. ]
  428. },
  429. {
  430. $cell: true,
  431. $type: "div",
  432. class: "mdc-slider__focus-ring"
  433. }
  434. ]
  435. }
  436. ]
  437. }
  438. }
  439. textField(obj) {
  440. return {
  441. class: "mdc-text-field",
  442. style: "width: 100%",
  443. $cell: true,
  444. $type: "div",
  445. $components: [
  446. {
  447. class: "mdc-text-field__input prop-text-field-input",
  448. id: obj.id,
  449. $cell: true,
  450. $type: "input",
  451. type: "text",
  452. value: obj.value,
  453. onchange: obj.funconchange
  454. }
  455. ]
  456. }
  457. }
  458. icontoggle(obj) {
  459. var addClass = "";
  460. if (obj.styleClass){
  461. addClass = obj.styleClass;
  462. }
  463. return {
  464. $type: "button",
  465. class: addClass + " mdc-icon-button",
  466. //$text: obj.label,
  467. id: obj.id,
  468. //'data-toggle-on': obj.on,
  469. // 'data-toggle-off': obj.off,
  470. 'aria-pressed': obj.state,
  471. 'aria-hidden': true,
  472. $init: obj.init,
  473. $components:[
  474. {
  475. $type: "i",
  476. class: "material-icons mdc-icon-button__icon mdc-icon-button__icon--on",
  477. $text: JSON.parse(obj.on).content
  478. },
  479. {
  480. $type: "i",
  481. class: "material-icons mdc-icon-button__icon",
  482. $text: JSON.parse(obj.off).content
  483. },
  484. ]
  485. }
  486. }
  487. floatActionButton(obj) {
  488. var addClass = "";
  489. if (obj.styleClass){
  490. addClass = obj.styleClass;
  491. }
  492. return {
  493. $cell: true,
  494. $type: "button",
  495. class: "mdc-fab material-icons " + addClass,
  496. onclick: obj.onclickfunc,
  497. $components:[
  498. {
  499. $cell: true,
  500. $type: "span",
  501. class: "mdc-fab__icon",
  502. $text: obj.label
  503. }
  504. ]
  505. }
  506. }
  507. iconButton(obj) {
  508. var addClass = "";
  509. if (obj.styleClass){
  510. addClass = obj.styleClass;
  511. }
  512. return {
  513. $cell: true,
  514. $type: "button",
  515. class: "mdc-button " + addClass,
  516. onclick: obj.onclick,
  517. $components:[
  518. {
  519. $cell: true,
  520. $type: "i",
  521. class: "material-icons mdc-button__icon",
  522. $text: obj.label
  523. }
  524. ]
  525. }
  526. }
  527. imageButton(obj){
  528. return {
  529. $cell: true,
  530. $type: "button",
  531. class: "mdc-button mdc-button--compact",
  532. onclick: obj.onclickfunc,
  533. $components:[
  534. {
  535. $cell: true,
  536. class: obj.styleClass,
  537. $type: "img",
  538. src: obj.imgSrc
  539. }
  540. ]
  541. }
  542. }
  543. listTitle(obj){
  544. return {
  545. $type: "div",
  546. class: "mdc-layout-grid__inner",
  547. $components: [
  548. {
  549. $type: "div",
  550. class: "mdc-layout-grid__cell",
  551. $components: [
  552. {
  553. $type: "h3",
  554. class: "",
  555. $text: obj.text
  556. }
  557. ]
  558. }
  559. ]
  560. }
  561. }
  562. gridListItem(obj) {
  563. return {
  564. $type: "div",
  565. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2 tooltip " + obj.styleClass,
  566. $components:[
  567. {
  568. class: "tooltiptext",
  569. $type: "span",
  570. $text: obj.title
  571. },
  572. {
  573. $type: "div",
  574. style: "background-color: transparent;",
  575. $components:[
  576. {
  577. class: "",
  578. $type: "div",
  579. 'aria-label': obj.title,
  580. alt: obj.title,
  581. style: "background-image: url("+ obj.imgSrc + "); background-size: cover; background-repeat: no-repeat; height: "+ obj.imgSize + "; width: " + obj.imgSize + ";",
  582. onclick: obj.onclickfunc,
  583. }
  584. ]
  585. }
  586. ]
  587. }
  588. }
  589. switch(obj) {
  590. return {
  591. $cell: true,
  592. $type: "div",
  593. class: "mdc-switch",
  594. _switch: null,
  595. id: obj.id,
  596. $init: obj.init,
  597. //function(){
  598. // new mdc.switchControl.MDCSwitch(this);
  599. // },
  600. $components: [
  601. {
  602. $type: "div",
  603. class: "mdc-switch__track",
  604. },
  605. {
  606. $type: "div",
  607. class: "mdc-switch__thumb-underlay",
  608. $components:[
  609. {
  610. $type: "div",
  611. class: "mdc-switch__thumb",
  612. $components:[
  613. {
  614. $type: "input",
  615. type: "checkbox",
  616. class: "mdc-switch__native-control",
  617. id: 'input-' + obj.id,
  618. //$init: obj.init,
  619. //id: "basic-switch",
  620. onchange: obj.onchange,
  621. role: "switch"
  622. }
  623. ]
  624. }
  625. ]
  626. }
  627. // {
  628. // $type: "div",
  629. // class: "mdc-switch__background",
  630. // $components: [
  631. // {
  632. // $type: "div",
  633. // class: "mdc-switch__knob"
  634. // }
  635. // ]
  636. // }
  637. ]
  638. }
  639. }
  640. reflectorGUI() {
  641. let webrtcConnection = {
  642. $cell: true,
  643. $components: [
  644. {
  645. $type: "p",
  646. class: "mdc-typography--headline5",
  647. $text: "Use WebRTC for connection"
  648. },
  649. {
  650. $type: 'p'
  651. },
  652. _app.widgets.switch({
  653. 'id': 'forceWebRTC',
  654. 'init': function () {
  655. this._switch = new mdc.switchControl.MDCSwitch(this);
  656. let config = localStorage.getItem('lcs_config');
  657. this._switch.checked = JSON.parse(config).webrtc;
  658. // this._replaceSwitch = this._switch;
  659. },
  660. 'onchange': function (e) {
  661. if (this._switch) {
  662. let chkAttr = this._switch.checked;//this.getAttribute('checked');
  663. if (chkAttr) {
  664. let config = JSON.parse(localStorage.getItem('lcs_config'));
  665. config.webrtc = true;
  666. localStorage.setItem('lcs_config', JSON.stringify(config));
  667. //this._switch.checked = false;
  668. } else {
  669. let config = JSON.parse(localStorage.getItem('lcs_config'));
  670. config.webrtc = false;
  671. localStorage.setItem('lcs_config', JSON.stringify(config));
  672. }
  673. }
  674. }
  675. }
  676. ),
  677. {
  678. $type: 'label',
  679. for: 'input-forceWebRTC',
  680. $text: 'On / Off'
  681. }
  682. ]
  683. }
  684. let luminaryGlobalHB = {
  685. $cell: true,
  686. _luminarySwitch: null,
  687. $components: [
  688. {
  689. $type: "p",
  690. class: "mdc-typography--headline5",
  691. $text: "Use Global Heartbeat"
  692. },
  693. {
  694. $type: 'p'
  695. },
  696. _app.widgets.switch({
  697. 'id': 'forceLuminary',
  698. 'init': function () {
  699. this._switch = new mdc.switchControl.MDCSwitch(this);
  700. let config = localStorage.getItem('lcs_config');
  701. this._switch.checked = JSON.parse(config).luminaryGlobalHB;
  702. // this._replaceSwitch = this._switch;
  703. },
  704. 'onchange': function (e) {
  705. if (this._switch) {
  706. let chkAttr = this._switch.checked;//this.getAttribute('checked');
  707. if (chkAttr) {
  708. let config = JSON.parse(localStorage.getItem('lcs_config'));
  709. config.luminaryGlobalHB = true;
  710. localStorage.setItem('lcs_config', JSON.stringify(config));
  711. //this._switch.checked = false;
  712. } else {
  713. let config = JSON.parse(localStorage.getItem('lcs_config'));
  714. config.luminaryGlobalHB = false;
  715. localStorage.setItem('lcs_config', JSON.stringify(config));
  716. }
  717. }
  718. }
  719. }
  720. ),
  721. {
  722. $type: 'label',
  723. for: 'input-forceLuminary',
  724. $text: 'On / Off'
  725. }
  726. ]
  727. }
  728. let reflectorGUI =
  729. {
  730. $type: "div",
  731. id: "reflectorGUI",
  732. //style:"background-color: #efefef",
  733. class: "mdc-layout-grid mdc-layout-grid--align-left",
  734. _reflectorHost: null,
  735. _dbHost: null,
  736. _refHostField: null,
  737. _dbHostField: null,
  738. _lpath: null,
  739. _lpathField: null,
  740. _hbpath: null,
  741. _hbpathField: null,
  742. _initData: function () {
  743. this._reflectorHost = '';
  744. this._dbHost = '';
  745. let config = JSON.parse(localStorage.getItem('lcs_config'));
  746. if (config.reflector) {
  747. this._reflectorHost = config.reflector
  748. }
  749. if (config.dbhost) {
  750. this._dbHost =config.dbhost
  751. }
  752. if (config.luminaryPath) {
  753. this._lpath = config.luminaryPath
  754. }
  755. if (config.luminaryGlobalHBPath) {
  756. this._hbpath = config.luminaryGlobalHBPath
  757. }
  758. },
  759. $init: function () {
  760. this._initData();
  761. },
  762. $update: function () {
  763. this.$components = [
  764. {
  765. $type: "div",
  766. class: "mdc-layout-grid__inner",
  767. $components: [
  768. {
  769. $type: "div",
  770. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  771. $components: [
  772. {
  773. $type: "h4",
  774. class: "mdc-typography--headline4",
  775. $text: "Gun DB settings"
  776. }
  777. ]
  778. },
  779. {
  780. $type: "div",
  781. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  782. $components: [
  783. {
  784. $type: "span",
  785. class: "mdc-typography--headline5",
  786. $text: "DB Host: "
  787. },
  788. window._app.widgets.inputTextFieldOutlined({
  789. "id": 'dbhostInput',
  790. "label": "DB Host",
  791. "value": this._dbHost,
  792. "type": "text",
  793. "init": function() {
  794. this._dbHostField = new mdc.textField.MDCTextField(this);
  795. },
  796. "style": 'width: 400px;'
  797. }),
  798. ]
  799. },
  800. {
  801. $type: "div",
  802. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  803. $components: [
  804. {
  805. $type: "h4",
  806. class: "mdc-typography--headline4",
  807. $text: "Reflector settings"
  808. }
  809. ]
  810. },
  811. {
  812. $type: "div",
  813. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  814. $components: [
  815. {
  816. $type: "span",
  817. class: "mdc-typography--headline5",
  818. $text: "Reflector: "
  819. },
  820. window._app.widgets.inputTextFieldOutlined({
  821. "id": 'reflectorInput',
  822. "label": "Reflector",
  823. "value": this._reflectorHost,
  824. "type": "text",
  825. "init": function() {
  826. this._refHostField = new mdc.textField.MDCTextField(this);
  827. },
  828. "style": 'width: 400px;'
  829. }),
  830. ]
  831. },
  832. {
  833. $type: "div",
  834. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  835. $components: [webrtcConnection ]
  836. },
  837. {
  838. $type: "div",
  839. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  840. $components: [
  841. {
  842. $type: "h4",
  843. class: "mdc-typography--headline4",
  844. $text: "Krestianstvo Luminary settings (experimental)"
  845. }
  846. ]
  847. },
  848. {
  849. $type: "div",
  850. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  851. $components: [
  852. {
  853. $type: "span",
  854. class: "mdc-typography--headline5",
  855. $text: "Luminary Path: "
  856. },
  857. window._app.widgets.inputTextFieldOutlined({
  858. "id": 'lpathInput',
  859. "label": "Luminary Path",
  860. "value": this._lpath,
  861. "type": "text",
  862. "init": function() {
  863. this._lpathField = new mdc.textField.MDCTextField(this);
  864. },
  865. "style": 'width: 400px;'
  866. }),
  867. ]
  868. },
  869. {
  870. $type: "div",
  871. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  872. $components: [
  873. {
  874. $type: "span",
  875. class: "mdc-typography--headline5",
  876. $text: "Global Heartbeat Path: "
  877. },
  878. window._app.widgets.inputTextFieldOutlined({
  879. "id": 'hbpathInput',
  880. "label": "Global Heartbeat Path",
  881. "value": this._hbpath,
  882. "type": "text",
  883. "init": function() {
  884. this._hbpathField = new mdc.textField.MDCTextField(this);
  885. },
  886. "style": 'width: 400px;'
  887. }),
  888. ]
  889. },
  890. {
  891. $type: "div",
  892. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  893. $components: [luminaryGlobalHB ]
  894. },
  895. {
  896. $type: "div",
  897. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  898. $components: [
  899. window._app.widgets.buttonRaised(
  900. {
  901. "label": 'Update',
  902. "onclick": function (e) {
  903. e.preventDefault();
  904. let config = JSON.parse(localStorage.getItem('lcs_config'));
  905. config.reflector = this._refHostField.value;
  906. config.dbhost = this._dbHostField.value;
  907. config.luminaryPath = this._lpathField.value;
  908. config.luminaryGlobalHBPath = this._hbpathField.value;
  909. localStorage.setItem('lcs_config', JSON.stringify(config));
  910. window.location.reload(true);
  911. }
  912. }),
  913. {
  914. $type: 'span',
  915. $text: " "
  916. },
  917. {
  918. $type: "button",
  919. class: "mdc-button mdc-button--raised",
  920. $text: "Close",
  921. onclick: function (e) {
  922. window.location.pathname = '/'
  923. }
  924. }
  925. ]
  926. }
  927. ]
  928. }
  929. ]
  930. }
  931. }
  932. document.querySelector("#appGUI").$cell({
  933. id: "appGUI",
  934. $cell: true,
  935. $type: "div",
  936. $components: [reflectorGUI]
  937. }
  938. );
  939. }
  940. }
  941. export { Widgets }