ModuleServiceInfo.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _Module2 = _interopRequireDefault(require("../Module"));
  8. var _ExtendableContainer = _interopRequireDefault(require("../base/ExtendableContainer"));
  9. var _ModuleUtilities = require("../ModuleUtilities");
  10. var _reactFontawesome = require("@fortawesome/react-fontawesome");
  11. require("./ModuleServiceInfo.css");
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  19. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  20. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  21. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  22. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  23. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  24. var ModuleServiceInfo =
  25. /*#__PURE__*/
  26. function (_Module) {
  27. _inherits(ModuleServiceInfo, _Module);
  28. function ModuleServiceInfo(props) {
  29. var _this;
  30. _classCallCheck(this, ModuleServiceInfo);
  31. _this = _possibleConstructorReturn(this, _getPrototypeOf(ModuleServiceInfo).call(this, props));
  32. _this.state = {
  33. modid: '',
  34. route: ''
  35. };
  36. return _this;
  37. }
  38. _createClass(ModuleServiceInfo, [{
  39. key: "loadModule",
  40. value: function loadModule(mod) {
  41. var answer = prompt("Module ID: ");
  42. if (!answer) return;
  43. mod.id = answer;
  44. this.ModuleSystem.loadModule(mod);
  45. this.CoreSystem.refresh(true);
  46. }
  47. }, {
  48. key: "removeModule",
  49. value: function removeModule(mod) {
  50. this.ModuleSystem.remove(mod);
  51. this.CoreSystem.refresh();
  52. this.forceUpdate();
  53. }
  54. }, {
  55. key: "render",
  56. value: function render() {
  57. var _this2 = this;
  58. var modules = this.ModuleSystem.getModules(); // console.log(modules);
  59. return _react.default.createElement("div", {
  60. className: 'ModuleServiceInfo'
  61. }, _react.default.createElement("div", {
  62. className: "row"
  63. }, this.__renderID()), _react.default.createElement("div", {
  64. className: "row"
  65. }, _react.default.createElement("div", {
  66. className: "col s3"
  67. }, "Modules"), _react.default.createElement("div", {
  68. className: "col"
  69. }, modules.length, _react.default.createElement(_ModuleUtilities.InputMarker, {
  70. onDrop: function onDrop(mod) {
  71. return _this2.loadModule(mod);
  72. }
  73. }))), _react.default.createElement("div", {
  74. className: "row ModuleList white z-depth-1"
  75. }, modules.map(function (mod, key) {
  76. return _react.default.createElement("div", {
  77. className: "col s6 text-left",
  78. style: {
  79. overflow: 'hidden'
  80. },
  81. key: mod.id
  82. }, _react.default.createElement("div", {
  83. style: {
  84. display: 'inline-block'
  85. }
  86. }, _react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
  87. icon: "eraser",
  88. onClick: function onClick() {
  89. return _this2.removeModule(mod.id);
  90. }
  91. })), _react.default.createElement("div", {
  92. style: {
  93. display: 'inline-block',
  94. width: 48
  95. }
  96. }, mod.id));
  97. })), _get(_getPrototypeOf(ModuleServiceInfo.prototype), "render", this).call(this));
  98. }
  99. }]);
  100. return ModuleServiceInfo;
  101. }(_Module2.default);
  102. ModuleServiceInfo.Category = "Services";
  103. var _default = ModuleServiceInfo;
  104. exports.default = _default;