"use strict";
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.weak-map.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("core-js/modules/es.array.map.js");
require("core-js/modules/es.function.name.js");
var _startCase3 = _interopRequireDefault(require("lodash/startCase"));
var bootstrap = _interopRequireWildcard(require("react-bootstrap"));
var utilsHelper = _interopRequireWildcard(require("../../helpers/utils"));
var _react = _interopRequireDefault(require("react"));
var _entity = require("../../helpers/entity");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/*
* Copyright (C) 2018 Akhilesh Kumar <akhilesh5991@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
var Table = bootstrap.Table;
var formatDate = utilsHelper.formatDate;
/**
* Renders the document and displays the topEditors table.
* @param {TopEditorsTableProps} props - The properties passed to the TopEditorsTableProps component.
* @returns {ReactElement} a HTML document which displays the topEditors table
* in the statistics page
*/
function TopEditorsTable(_ref) {
var editors = _ref.editors;
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h2", null, "Top 10 Editors")), /*#__PURE__*/_react.default.createElement(Table, {
bordered: true,
striped: true,
size: "sm"
}, /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("th", {
width: "8%"
}, "#"), /*#__PURE__*/_react.default.createElement("th", {
width: "42%"
}, "Editor's Name"), /*#__PURE__*/_react.default.createElement("th", {
width: "25%"
}, "Total Revisions"), /*#__PURE__*/_react.default.createElement("th", {
width: "25%"
}, "Registration Date"))), /*#__PURE__*/_react.default.createElement("tbody", null, editors.map(function (editor, i) {
return /*#__PURE__*/_react.default.createElement("tr", {
key: editor.id
}, /*#__PURE__*/_react.default.createElement("td", null, i + 1), /*#__PURE__*/_react.default.createElement("td", null, /*#__PURE__*/_react.default.createElement("a", {
href: "/editor/".concat(editor.id)
}, editor.name)), /*#__PURE__*/_react.default.createElement("td", null, editor.totalRevisions), /*#__PURE__*/_react.default.createElement("td", null, formatDate(new Date(editor.createdAt))));
}))));
}
TopEditorsTable.displayName = 'TopEditorsTable';
/**
* Renders the document and displays the EntityCountTable table.
* @param {EntityCountTableProps} props - The properties passed to the EntityCountTable component.
* @returns {JSX.Element} a HTML document which displays the
* EntityCountTable table in the statistics page
*/
function EntityCountTable(_ref2) {
var allEntities = _ref2.allEntities,
last30DaysEntities = _ref2.last30DaysEntities;
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h2", null, "Total Entities")), /*#__PURE__*/_react.default.createElement(Table, {
bordered: true,
striped: true,
size: "sm"
}, /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("th", {
width: "8%"
}, "#"), /*#__PURE__*/_react.default.createElement("th", {
width: "42%"
}, "Entity Type"), /*#__PURE__*/_react.default.createElement("th", {
width: "25%"
}, "Total"), /*#__PURE__*/_react.default.createElement("th", {
width: "25%"
}, "Added in Last 30 days"))), /*#__PURE__*/_react.default.createElement("tbody", null, allEntities.map(function (entity, i) {
return /*#__PURE__*/_react.default.createElement("tr", {
key: entity.modelName
}, /*#__PURE__*/_react.default.createElement("td", null, i + 1), /*#__PURE__*/_react.default.createElement("td", null, (0, _entity.genEntityIconHTMLElement)(entity.modelName), (0, _startCase3.default)(entity.modelName)), /*#__PURE__*/_react.default.createElement("td", null, entity.Count), /*#__PURE__*/_react.default.createElement("td", null, last30DaysEntities[entity.modelName]));
}))));
}
/**
* Renders the document and displays the 'Statistics' page.
* @param {StatisticsPageProps} props - The properties passed to the StatisticsPage component.
* @returns {JSX.Element} A HTML document which displays the statistics page.
*/
function StatisticsPage(_ref3) {
var allEntities = _ref3.allEntities,
last30DaysEntities = _ref3.last30DaysEntities,
topEditors = _ref3.topEditors;
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
className: "page-header"
}, /*#__PURE__*/_react.default.createElement("h1", null, "Statistics of BookBrainz")), /*#__PURE__*/_react.default.createElement(TopEditorsTable, {
editors: topEditors
}), /*#__PURE__*/_react.default.createElement(EntityCountTable, {
allEntities: allEntities,
last30DaysEntities: last30DaysEntities
}));
}
StatisticsPage.displayName = 'StatisticsPage';
var _default = StatisticsPage;
exports.default = _default;
//# sourceMappingURL=statistics.js.map