![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-form/js/layouteditor/RemoteFormPreview.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _BaseEditor = _interopRequireDefault(require("../core/BaseEditor")); var _FCore = _interopRequireWildcard(require("../core/FCore")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _Toast = _interopRequireDefault(require("absol-acomp/js/Toast")); var _FmFragment = require("../core/FmFragment"); var _Assembler = require("../core/Assembler"); require("../../css/remoteformpreview.css"); function RemoteFormPreview() { _BaseEditor.default.call(this); this.id = location.search.replace(/^\?/, '').split('&').reduce((ac, txt) => { var p = txt.split('='); var key = p[0].trim(); var value = (p[1] || '').trim(); ac[key] = value; return ac; }, { client_id: 0 }).client_id || 'D' + Math.floor(Math.random() * 1000) + ''; } _OOP.default.mixClass(RemoteFormPreview, _BaseEditor.default); RemoteFormPreview.prototype.createView = function () { this.$view = (0, _FCore._)({ class: 'af-remote-form-preview', child: [{ class: 'af-remote-form-preview-header', child: ['span.mdi.mdi-cellphone-play', { text: 'ID: ' + this.id }] }, { class: 'af-remote-form-preview-body' }] }); this.$body = (0, _FCore.$)('.af-remote-form-preview-body', this.$view); }; RemoteFormPreview.prototype.onStart = function () { if (!window.MQTT) { _Toast.default.make({ props: { variant: 'error', htitle: "Can not start", disappearTimeout: 4000 }, child: { style: { padding: '5px' }, child: { text: 'Can not fount MQTT library!' } } }); return; } this.prepareMQTT(); }; RemoteFormPreview.prototype.prepareMQTT = function () { var client = window.MQTT.connect('wss:absol.cf:9884'); this.mqttClient = client; window.mqttClient = client; client.on('connect', () => { client.subscribe('rfp/' + this.id, err => { if (!err) { _Toast.default.make({ props: { variant: 'success', htitle: "Connect with id = " + this.id, disappearTimeout: 14000 }, child: { style: { padding: '5px' }, child: { text: 'Subscribe channel ' + 'rfp/' + this.id } } }); } }); }); client.on('message', (topic, payload) => { try { var message = JSON.parse(payload.toString()); if (message.type === 'form') { var clazz = (0, _FmFragment.makeFmFragmentClass)({ tag: 'TestFragment', contentViewData: message.data }); _Assembler.AssemblerInstance.addClass(clazz); this.$body.clearChild(); var frg = _Assembler.AssemblerInstance.build({ class: 'TestFragment' }); this.$body.addChild(frg.domElt); frg.start(); } } catch (e) { console.error(e); } }); }; RemoteFormPreview.prototype.onStop = function () {}; var _default = RemoteFormPreview; exports.default = _default;