widgets.js 39 KB

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