RouterServiceInfo.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 _reactFontawesome = require("@fortawesome/react-fontawesome");
  10. var _reactMaterialize = require("react-materialize");
  11. require("./RouterServiceInfo.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 RouterServiceInfo =
  25. /*#__PURE__*/
  26. function (_Module) {
  27. _inherits(RouterServiceInfo, _Module);
  28. function RouterServiceInfo(props) {
  29. var _this;
  30. _classCallCheck(this, RouterServiceInfo);
  31. _this = _possibleConstructorReturn(this, _getPrototypeOf(RouterServiceInfo).call(this, props));
  32. _this.state = {
  33. modid: '',
  34. route: '',
  35. routeName: ''
  36. };
  37. return _this;
  38. }
  39. _createClass(RouterServiceInfo, [{
  40. key: "removeRoute",
  41. value: function removeRoute(modid, route) {
  42. this.RoutingSystem.removeRoute(modid, route);
  43. this.CoreSystem.refresh(true);
  44. this.forceUpdate();
  45. }
  46. }, {
  47. key: "render",
  48. value: function render() {
  49. var _this2 = this;
  50. var routes = this.RoutingSystem.getRoutes();
  51. return _react.default.createElement("div", {
  52. className: ''
  53. }, _react.default.createElement("div", {
  54. className: "row"
  55. }, this.__renderID()), _react.default.createElement("div", {
  56. className: "row"
  57. }, _react.default.createElement("div", {
  58. className: "col s4"
  59. }, "Current View :"), _react.default.createElement("div", {
  60. className: "col s8"
  61. }, this.RoutingSystem.getCurrentView())), _react.default.createElement("div", {
  62. className: "row"
  63. }, _react.default.createElement(_reactMaterialize.Table, {
  64. className: "white",
  65. bordered: true,
  66. hoverable: true,
  67. responsive: true
  68. }, _react.default.createElement("thead", null, _react.default.createElement("tr", null, _react.default.createElement("th", null), _react.default.createElement("th", null, "ModID"), _react.default.createElement("th", null, "Route"), _react.default.createElement("th", null, "Name"))), _react.default.createElement("tbody", null, routes.map(function (route, key) {
  69. return _react.default.createElement("tr", {
  70. key: route.route
  71. }, _react.default.createElement("td", null, _react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
  72. icon: "trash",
  73. onClick: function onClick() {
  74. return _this2.removeRoute(route.id, route.route);
  75. }
  76. })), _react.default.createElement("td", null, route.id), _react.default.createElement("td", null, route.route), _react.default.createElement("td", null, route.routeName));
  77. }), _react.default.createElement("tr", null, _react.default.createElement("td", null, _react.default.createElement("button", {
  78. onClick: function onClick() {
  79. _this2.RoutingSystem.addRoute(_this2.state.route, _this2.state.modid, _this2.state.routeName);
  80. _this2.setState({
  81. route: '',
  82. modid: ''
  83. });
  84. }
  85. }, "Add")), _react.default.createElement("td", null, _react.default.createElement("input", {
  86. type: "text",
  87. value: this.state.modid,
  88. onChange: function onChange(e) {
  89. return _this2.setState({
  90. modid: e.target.value
  91. });
  92. }
  93. })), _react.default.createElement("td", null, _react.default.createElement("input", {
  94. type: "text",
  95. value: this.state.route,
  96. onChange: function onChange(e) {
  97. return _this2.setState({
  98. route: e.target.value
  99. });
  100. }
  101. })), _react.default.createElement("td", null, _react.default.createElement("input", {
  102. type: "text",
  103. value: this.state.routeName,
  104. onChange: function onChange(e) {
  105. return _this2.setState({
  106. routeName: e.target.value
  107. });
  108. }
  109. })))))), _get(_getPrototypeOf(RouterServiceInfo.prototype), "render", this).call(this));
  110. }
  111. }]);
  112. return RouterServiceInfo;
  113. }(_Module2.default);
  114. RouterServiceInfo.Category = "Services";
  115. var _default = RouterServiceInfo;
  116. exports.default = _default;