cessda.cdc.searchkit

User Interface component for CESSDA Data Catalogue

https://github.com/cessda/cessda.cdc.searchkit

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

User Interface component for CESSDA Data Catalogue

Basic Info
Statistics
  • Stars: 0
  • Watchers: 3
  • Forks: 1
  • Open Issues: 3
  • Releases: 8
Created almost 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

CESSDA.CDC.SEARCHKIT

Build Status Quality Gate Status Coverage SQAaaS badge shields.io

This repository contains all source code for the CESSDA Data Catalogue web application.

CESSDA's repositories are used for harvesting and indexing with very minimal changes to Elasticsearch mappings: cessda.metadata.harvester cessda.cdc.osmh-indexer.cmm

Prerequisites

Node.js version 18 (LTS) is required to install and run this application.

An instance of Elasticsearch 8 populated using the CDC Indexer is required.

Quick Start

Please be aware of Known Issues (see bottom) before running.

  1. Check Prerequisites and install any required software.
  2. Clone the repository to your local workspace.
  3. Open a terminal window and navigate to the project root directory.
  4. Run npm install to install all required dependencies of the application.
  5. Set the required environment variables (see Configuration below).
  6. Run the application using one of the following commands.
    • Development: npm run startdev
    • Production: npm run startprod (Requires the application to be built. See Building below.)

Building: In order to run the application in production it must first be built using the npm run build command. This will compile assets into the /dist directory. This is not needed if the application is started with npm run startdev.
Updating: When fetching/pulling new builds it is recommended to run npm install again. This will ensure all locally installed dependencies match their development environment counterparts.
Testing: Tests can be run using npm run test. Code coverage will be reported in the /coverage directory.

Configuration

The application can be configured using the following environment variables.

| Variable | Default Value | Description | ---------------------------------- | ------------------------ | ----------- | PASC_DEBUG_MODE | false | Enables debug mode which outputs additional debugging information in the user interface and web browser console. | PASC_PORT | 8088 | The port number which will be used to access this web application. | PASC_ELASTICSEARCH_URL | http://localhost:9200/ | The web address of the Elasticsearch instance which powers all searches. | SEARCHKIT_ELASTICSEARCH_USERNAME | undefined | The username to use when accessing a secured Elasticsearch cluster. | SEARCHKIT_ELASTICSEARCH_PASSWORD | undefined | The password to use when accessing a secured Elasticsearch cluster. | SEARCHKIT_LOG_LEVEL | info | The logging level used for server side events. | SEARCHKIT_USE_JSON_LOGGING | false | Enables logging using JSON rather than plain text.

Set environment variables using the following syntax.

  • Windows: set PASC_PORT=80 (CMD) / $Env:PASC_PORT='80' (PowerShell)
  • macOS/Linux: export PASC_PORT=80
  • Dockerfile: ENV PASC_PORT=80

If running in a development environment using JetBrains WebStorm (see Tooling below), variables can be set within the IDE using this documentation.

Project Structure

This project follows a best practice structure for React+Redux applications. Redux Toolkit is used for simplified store setup and usage.

bash <ROOT> ├── coverage # The output directory for the code coverage report using the test command. ├── dist # The output directory for compilation using the build command. ├── node_modules # Third party packages and dependencies. ├── common # Common source code, shared between the client and the server. ├── server # Markup and source code for the Searchkit server. └── src # Contains all source code and assets for the client. ├── actions # Redux actions and action creators for state container. ├── components # React user interface components. ├── containers # React page container components. ├── i18n # Language translations. ├── img # Image assets. ├── reducers # Redux reducers for state container. ├── styles # SASS files for styling. └── utilities # Miscellaneous scripts and helpers. └── tests # Jest unit tests.

Technology Stack

Several frameworks are used in this application.

The primary programming language is TypeScript. See Tooling (below) for compatible IDEs.

| Framework/Technology | Description | ---------------------------------------------------- | -------------------------------------------------------- | JavaScript/JSX | ECMAScript with XML-like syntax extensions. | React | JavaScript library for building web applications. | Redux | Predictable state container for JavaScript applications. | Searchkit | React component library for Elasticsearch. | Babel | JavaScript compiler for ECMAScript 6. | TypeScript | Static type checker for JavaScript. | Webpack | JavaScript module bundler. | Sass | CSS extension language. | Bulma | CSS framework based on Flexbox. | Jest | JavaScript testing framework. | React Testing Library| JavaScript testing utility for React Components. | Winston | JavaScript logging framework.

See package.json in the root directory for a full list of third party libraries used.

Tooling

For development, the following software tools are recommended and have full support for the technologies/languages used in this project.

How To

Add a new Collection (Thematic View)

  • See instructions in /docs/collections/howto.md.

Add a new language

  1. Create a new language file in the /src/i18n/ directory, using the 2 letter language ISO code for the directory name. It is recommended to copy the English file en/translation.json and use that as a template/starting point.
  2. Add your translations to the new file. Basic HTML mark-up is supported but its use should be limited. Some strings use variables which are defined as %(VARIABLE)s. Do not modify the JSON structure or object keys.
  3. Notify the application about this new file by adding it to the languages array defined in /src/utilities/language.js. It is expected that each language will have its own Elasticsearch index. Use the following syntax:

javascript { code: 'code', // The 2 letter ISO code for this language. label: 'label', // The native label for this language. index: 'cmmstudy_code' // The Elasticsearch index containing data for this language. }

Translations can be displayed in mark-up using const { t, i18n } = useTranslation(); and t("filters.summary.label") where t takes the JSON path to the specific string required.

Add a new field

  1. Each study retrieved from Elasticsearch is first routed through the getStudyModel() method located in /src/utilities/metadata.js. This cleans the data and applies type restrictions. Add the new field to the object returned from this method. Like other fields, it should be provided from Elasticsearch as a child property of the data._source object.
  2. If the field should be displayed on the search page for each result, modify the /src/components/Result.jsx component. Add additional HTML mark-up as necessary and the new field will be available as a child property of the item object. For example <p>{item.newField}</p>.
  3. If the field should be displayed on the study detail page, modify the /src/components/Detail.jsx component. Add additional HTML mark-up as necessary and the new field will be available as a child property of the item object. For example <p>{item.newField}</p>.
  4. Remember to add new strings to the translations located in /src/locales if necessary (i.e. for the new field label etc.)
  5. Remember to modify the getJsonLd() method if you want the new field to be available in the JSON-LD Schema (see how to Modify Schema.org JSON-LD below).

Modify search filters

All search filters are created in /src/containers/SearchPage.jsx and their Elasticsearch configuration is in /server/helper.ts.

Example of RefinementList from InstantSearch:

js { attribute: "country", field: "searchField", type: "string", nestedPath: "studyAreaCountries" }

jsx <RefinementList attribute="country" searchable sortBy={['name:asc']} limit={200} showMore={true} showMoreLimit={500} classNames={{ searchBox: 'focus-visible', checkbox: 'focus-visible', list: 'ais-CustomRefinementList' }}/>

A high limit can be used here because the ais-CustomRefinementList class makes the values horizontally scrollable. Usually, a lower limit (e.g. 16) is recommended in the absence of the ais-CustomRefinementList class, along with setting showMore to false. Setting searchable is always recommended for any filter that supports it.

Modify sorting fields

The list of available fields for sorting can be modified in /server/helper.ts and /src/containers/SearchPage.jsx.

Modify Elasticsearch queries

Queries performed against Elasticsearch are defined in /server/helper.ts and /server/elasticsearch.ts. The browser client is configured in in /src/utilities/searchkit.js and the server-side client is configured in /server/helper.ts.

Modify Schema.org JSON-LD (used by Google Dataset search)

  1. General organisation information and social media links are generated for every page. JSON-LD can be modified in /src/components/Footer.jsx.
  2. Dataset metadata is generated on the detail page for a single study record. JSON-LD can be modified in /src/utilities/metadata.js using method getJsonLd(). This method takes a study returned from getStudyModel() as its input.

Google documentation on supported dataset JSON-LD properties can be found at https://developers.google.com/search/docs/data-types/dataset

Versioning

See Semantic Versioning for guidance.

License

See the LICENSE file.

Owner

  • Name: CESSDA
  • Login: cessda
  • Kind: organization
  • Location: Norway

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: CESSDA Data Catalogue - Searchkit component
message: >-
  If you use this software, please cite it using https://doi.org/10.5281/zenodo.3786299
type: software
authors:
  - given-names: Ashley
    family-names: Fox
    email: foxonlinesolutions@co.uk
    affiliation: Fox online solutions
  - given-names: John William
    family-names: Shepherdson
    email: john.shepherdson@cessda.eu
    affiliation: CESSDA
    orcid: 'https://orcid.org/0000-0002-4402-9644'
  - given-names: Matthew
    family-names: Morris
    email: matthew.morris@cessda.eu
    affiliation: CESSDA
  - given-names: Daniel
    family-names: Arnrup-Øien
    email: daniel.oien@openconcept.no
    affiliation: Open Concept
  - given-names: Markus
    family-names: Tuominen
    email: markus.tuominen@tuni.fi
    affiliation: CESSDA/TAU-FSD
    orcid: 'https://orcid.org/0000-0002-3092-1690'

GitHub Events

Total
  • Release event: 3
  • Delete event: 116
  • Issue comment event: 22
  • Push event: 139
  • Pull request review comment event: 3
  • Pull request review event: 94
  • Pull request event: 232
  • Create event: 130
Last Year
  • Release event: 3
  • Delete event: 116
  • Issue comment event: 22
  • Push event: 139
  • Pull request review comment event: 3
  • Pull request review event: 94
  • Pull request event: 232
  • Create event: 130

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 3
  • Total pull requests: 243
  • Average time to close issues: 31 minutes
  • Average time to close pull requests: 4 days
  • Total issue authors: 1
  • Total pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.22
  • Merged pull requests: 169
  • Bot issues: 3
  • Bot pull requests: 221
Past Year
  • Issues: 2
  • Pull requests: 114
  • Average time to close issues: 31 minutes
  • Average time to close pull requests: 2 days
  • Issue authors: 1
  • Pull request authors: 3
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.14
  • Merged pull requests: 74
  • Bot issues: 2
  • Bot pull requests: 107
Top Authors
Issue Authors
  • dependabot[bot] (3)
Pull Request Authors
  • dependabot[bot] (256)
  • markusjt (15)
  • matthew-morris-cessda (8)
  • Joshocan (1)
Top Labels
Issue Labels
dependencies (3) javascript (3)
Pull Request Labels
dependencies (256) javascript (253) docker (3) enhancement (2)

Dependencies

Dockerfile docker
  • build latest build
  • node 20 build
package-lock.json npm
  • 1045 dependencies
package.json npm
  • @babel/cli 7.22.5 development
  • @babel/core 7.22.1 development
  • @babel/plugin-proposal-class-properties 7.18.6 development
  • @babel/plugin-transform-runtime 7.22.4 development
  • @babel/preset-env 7.22.4 development
  • @babel/preset-react 7.22.3 development
  • @babel/preset-typescript 7.22.5 development
  • @tsconfig/node16 16.1.0 development
  • @types/body-parser 1.19.2 development
  • @types/compression 1.7.2 development
  • @types/cors 2.8.13 development
  • @types/counterpart 0.18.1 development
  • @types/enzyme 3.10.13 development
  • @types/enzyme-adapter-react-16 1.0.6 development
  • @types/express 4.17.17 development
  • @types/express-http-proxy 1.6.3 development
  • @types/jest 29.5.1 development
  • @types/jquery 3.5.16 development
  • @types/method-override 0.0.32 development
  • @types/node 20.6.0 development
  • @types/node-fetch 2.6.2 development
  • @types/prop-types 15.7.5 development
  • @types/react 16.14.35 development
  • @types/react-dom 16.9.18 development
  • @types/react-redux 5.0.24 development
  • @types/react-router 3.0.28 development
  • @types/react-router-redux 4.0.55 development
  • @types/react-select 1.3.6 development
  • @types/redux-mock-store 1.0.3 development
  • @types/response-time 2.3.5 development
  • @types/webpack-hot-middleware 2.25.6 development
  • @typescript-eslint/eslint-plugin 6.7.0 development
  • @typescript-eslint/parser 6.7.0 development
  • babel-jest 29.7.0 development
  • babel-loader 9.1.2 development
  • babel-plugin-transform-react-remove-prop-types 0.4.24 development
  • bulma 0.9.4 development
  • clean-webpack-plugin 4.0.0 development
  • css-loader 6.8.1 development
  • ejs 3.1.9 development
  • enzyme 3.11.0 development
  • enzyme-adapter-react-16 1.15.7 development
  • eslint 8.50.0 development
  • eslint-plugin-react 7.33.0 development
  • event-source-polyfill 1.0.31 development
  • html-loader 4.2.0 development
  • html-webpack-plugin 5.5.1 development
  • identity-obj-proxy 3.0.0 development
  • jest 29.5.0 development
  • jest-editor-support 31.1.0 development
  • jest-environment-jsdom 29.7.0 development
  • jest-junit 16.0.0 development
  • jest-mock-fetch 2.0.5 development
  • mini-css-extract-plugin 2.7.5 development
  • node-mocks-http 1.13.0 development
  • process 0.11.10 development
  • react-test-renderer 16.14.0 development
  • redux-devtools-extension 2.13.9 development
  • redux-mock-store 1.5.4 development
  • rimraf 5.0.0 development
  • sass 1.68.0 development
  • sass-loader 13.3.2 development
  • schema-dts 1.1.2 development
  • style-loader 3.3.2 development
  • ts-jest 29.1.0 development
  • ts-node 10.9.1 development
  • typescript 5.2.2 development
  • util 0.12.5 development
  • webpack 5.88.0 development
  • webpack-cli 5.1.0 development
  • webpack-dev-middleware 6.1.0 development
  • webpack-hot-middleware 2.25.3 development
  • webpack-merge 5.9.0 development
  • @elastic/elasticsearch 8.7.0
  • @js-joda/core 5.5.3
  • body-parser 1.20.2
  • bodybuilder 2.5.0
  • compression 1.7.4
  • cors 2.8.5
  • counterpart 0.18.6
  • detect-browser 5.3.0
  • express 4.18.2
  • express-http-proxy 2.0.0
  • jquery 3.7.0
  • lodash 4.17.21
  • method-override 3.0.0
  • node-fetch 2.6.9
  • node-ipinfo 3.4.0
  • prom-client 14.2.0
  • prop-types 15.8.1
  • react 16.14.0
  • react-dom 16.14.0
  • react-icons 4.11.0
  • react-interpolate-component 0.12.0
  • react-redux 5.1.2
  • react-router 3.2.6
  • react-router-redux 4.0.8
  • react-select 1.3.0
  • react-translate-component 0.15.1
  • redux 4.2.1
  • redux-thunk 2.4.2
  • response-time 2.3.2
  • searchkit 2.4.4
  • striptags 3.2.0
  • winston 3.10.0