UNPKG

solrkit

Version:

![Build Status](https://travis-ci.org/garysieling/solrkit.svg?branch=master) ![Dependencies](https://david-dm.org/garysieling/solrkit/status.svg) UI Components for Solr, using TypeScript + React

68 lines 2.79 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import * as React from 'react'; import { SearchPageApp } from './pages/SearchPage'; import { Route } from 'react-router'; import { DetailPageApp } from './pages/DetailPage'; import * as _ from 'lodash'; function namespace(params, core, ns) { var result = [core, { // TODO NAMESPACING type: 'QUERY', query: params.query, start: params.start }]; return result; } function fixParams(params) { return { type: 'QUERY', query: params.query, start: (parseInt(params.page || '1', 10) - 1) * 10 }; } var SearchApp = (function (_super) { __extends(SearchApp, _super); function SearchApp() { return _super.call(this) || this; } SearchApp.prototype.init = function () { var _this = this; // TODO I think this is the point where namespacing would start _.map(this.props.app.dataStore.cores, function (core, i) { return namespace(fixParams(_this.props.params), core, core.getNamespace()); }).map(function (thisCore) { return thisCore[0].stateTransition(thisCore[1]); }); }; SearchApp.prototype.componentDidMount = function () { this.init(); }; SearchApp.prototype.componentWillUnmount = function () { this.props.app.dataStore.clearEvents(); }; SearchApp.prototype.render = function () { return React.createElement(SearchPageApp, null); }; return SearchApp; }(React.Component)); var defaultParams = { page: '1', query: '*' }; var Routes = [(React.createElement(Route, { exact: true, path: "/talks", render: function () { return React.createElement(SearchApp, { params: defaultParams, app: SearchPageApp }); } })), (React.createElement(Route, { exact: true, path: "/talks/:query/:page", render: function (_a) { var match = _a.match; return React.createElement(SearchApp, { params: match.params, app: SearchPageApp }); } })), (React.createElement(Route, { path: "/view/:id", component: function (_a) { var match = _a.match; return React.createElement(DetailPageApp, { id: match.params.id }); } })) ]; export { Routes }; //# sourceMappingURL=index.js.map