LoadedModulesService.js 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 _modularityFront = _interopRequireDefault(require("modularity-front"));
  8. var _API = _interopRequireDefault(require("./API"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. 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); }
  11. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12. 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); } }
  13. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17. 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); }
  18. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  19. var LoadedModules =
  20. /*#__PURE__*/
  21. function (_Modularity$Module) {
  22. _inherits(LoadedModules, _Modularity$Module);
  23. function LoadedModules(props) {
  24. var _this;
  25. _classCallCheck(this, LoadedModules);
  26. _this = _possibleConstructorReturn(this, _getPrototypeOf(LoadedModules).call(this, props));
  27. _this.API = new _API.default();
  28. _this.Modules.set([{
  29. link: "home",
  30. text: "Home",
  31. icon: "fa-home"
  32. }]);
  33. _this.API.get('/' + _this.APIURL.value).then(function (data) {
  34. var modules = data.map(function (item) {
  35. return {
  36. link: item.Route,
  37. text: item.Name,
  38. icon: item.Icon
  39. };
  40. });
  41. _this.Modules.set(modules);
  42. }).catch(function () {
  43. return console.log("NO SERVER");
  44. });
  45. return _this;
  46. }
  47. _createClass(LoadedModules, [{
  48. key: "render",
  49. value: function render() {
  50. return _react.default.createElement("div", null, this.__renderID(), this.__factoryOutput(this.Modules));
  51. }
  52. }]);
  53. return LoadedModules;
  54. }(_modularityFront.default.Module);
  55. LoadedModules.Outputs = {
  56. Modules: {}
  57. };
  58. LoadedModules.Inputs = {
  59. APIURL: {
  60. type: _modularityFront.default.Module.Types.Text,
  61. defaultValue: 'CrudModules'
  62. }
  63. };
  64. LoadedModules.Category = "Services";
  65. var _default = LoadedModules;
  66. exports.default = _default;