├── .dockerignore ├── .gitignore ├── .huskyrc.js ├── Dockerfile ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── docker-compose.yml ├── eas-kb-demo-dataimport ├── .eslintrc.json ├── .gitignore ├── data │ ├── elastic-co-discuss.json │ └── elastic-co-docs.json ├── package.json └── src │ ├── cli.js │ ├── client │ ├── client.js │ └── index.js │ ├── config │ ├── index.js │ └── read-config.js │ ├── document │ └── processor.js │ └── input │ └── file.js ├── eas-kb-demo-frontend ├── .env ├── .eslintignore ├── .eslintrc.yml ├── .gitignore ├── cypress.json ├── cypress │ ├── .gitignore │ ├── fixtures │ │ └── .gitignore │ ├── integration │ │ ├── autocomplete.spec.js │ │ ├── contact.spec.js │ │ ├── homepage.spec.js │ │ └── search.spec.js │ ├── plugins │ │ └── index.js │ └── support │ │ ├── commands.js │ │ └── index.js ├── env.sh ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App │ ├── App.js │ ├── assets │ │ ├── images │ │ │ └── circles.svg │ │ └── stylesheets │ │ │ └── App.scss │ └── index.js │ ├── Contact │ ├── ContactCallout.js │ ├── ContactLink.js │ ├── ContactModal.js │ ├── assets │ │ ├── images │ │ │ ├── close-icon-small.png │ │ │ ├── help-icon-large.svg │ │ │ ├── help-icon-small.svg │ │ │ ├── mail-icon-small.png │ │ │ └── modal-title-background.png │ │ └── stylesheets │ │ │ └── Contact.scss │ └── index.js │ ├── Layout │ ├── Footer.js │ ├── Header.js │ ├── assets │ │ ├── images │ │ │ └── searchco-logo.svg │ │ └── stylesheets │ │ │ └── Layout.scss │ └── index.js │ ├── Search │ ├── SearchConnector.js │ ├── SearchContainer.js │ ├── components │ │ ├── Facets │ │ │ ├── FacetOptionView.js │ │ │ ├── FacetView.js │ │ │ ├── Facets.scss │ │ │ └── index.js │ │ ├── Result │ │ │ ├── Result.scss │ │ │ ├── ResultView.js │ │ │ └── index.js │ │ └── index.js │ ├── images │ │ ├── arrow-icon.png │ │ ├── background-home.svg │ │ ├── background-search-result.svg │ │ ├── products-icons │ │ │ ├── elastic-stack.svg │ │ │ ├── icon-auditbeat-64-color.svg │ │ │ ├── icon-filebeat-64-color.svg │ │ │ ├── icon-function-beat-64-color.svg │ │ │ ├── icon-heartbeat-64-color.svg │ │ │ ├── icon-language-clients-64-color.svg │ │ │ ├── icon-logging-64-color.svg │ │ │ ├── icon-machine-learning-64-color.svg │ │ │ ├── icon-metricbeat-64-color.svg │ │ │ ├── icon-packetbeat-64-color.svg │ │ │ ├── icon-winlogbeat-64-color.svg │ │ │ ├── logo-apm-64-color.svg │ │ │ ├── logo-app-search-64-color.svg │ │ │ ├── logo-beats-64-color.svg │ │ │ ├── logo-cloud-64-color.svg │ │ │ ├── logo-ece-64-color.svg │ │ │ ├── logo-eck-64-color.svg │ │ │ ├── logo-elasticsearch-color-64.svg │ │ │ ├── logo-endpoint-64-color.svg │ │ │ ├── logo-kibana-64-color.svg │ │ │ ├── logo-logging-64-color.svg │ │ │ ├── logo-logstash-64-color.svg │ │ │ ├── logo-metrics-64-color.svg │ │ │ ├── logo-siem-64-color.svg │ │ │ ├── logo-site-search-32-color.svg │ │ │ ├── logo-uptime-64-color.svg │ │ │ └── logo-workplace-search-64-color.svg │ │ ├── search-icon.png │ │ └── search-icon.svg │ ├── index.js │ └── stylesheets │ │ ├── ProductIcons.scss │ │ ├── Search.scss │ │ └── SearchUIComponents.scss │ └── index.js ├── package.json ├── scripts ├── retrieve-credentials.sh ├── start-dataimport.sh └── start-frontend.sh └── yarn.lock /.dockerignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | .pnp 4 | .pnp.js 5 | */node_modules 6 | */.pnp 7 | */.pnp.js 8 | 9 | # Testing 10 | */coverage 11 | 12 | # Production 13 | build 14 | 15 | # Misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | # Temporary env files 23 | */public/env-config.js 24 | */env-config.js 25 | 26 | # Logs 27 | npm-debug.log* 28 | yarn-debug.log* 29 | yarn-error.log* 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /.huskyrc.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | const tasks = arr => arr.join(' && ') 21 | 22 | module.exports = { 23 | 'hooks': { 24 | 'pre-commit': tasks([ 25 | 'yarn lint', 26 | ]) 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12.6 as builder 2 | 3 | WORKDIR /usr/src/app 4 | RUN mkdir eas-kb-demo-dataimport eas-kb-demo-frontend 5 | COPY package.json yarn.lock ./ 6 | COPY eas-kb-demo-dataimport/package.json ./eas-kb-demo-dataimport/ 7 | COPY eas-kb-demo-frontend/package.json ./eas-kb-demo-frontend/ 8 | RUN yarn install 9 | COPY eas-kb-demo-frontend/ eas-kb-demo-frontend/ 10 | COPY eas-kb-demo-dataimport/ eas-kb-demo-dataimport/ 11 | 12 | RUN yarn build 13 | RUN yarn run isolate-workspace -w eas-kb-demo-dataimport -o dist/dataimport && \ 14 | cd dist/dataimport && \ 15 | yarn install 16 | 17 | 18 | FROM node:12.6 as dataimport 19 | WORKDIR /usr/app 20 | COPY --from=builder /usr/src/app/dist/dataimport/ . 21 | COPY scripts/retrieve-credentials.sh /usr/local/bin/ 22 | COPY scripts/start-dataimport.sh /usr/local/bin/ 23 | 24 | CMD ["/usr/local/bin/start-dataimport.sh"] 25 | 26 | FROM node:12.6 as frontend 27 | RUN npm install -g serve 28 | WORKDIR /usr/app 29 | 30 | COPY --from=builder /usr/src/app/eas-kb-demo-frontend/build/ . 31 | COPY scripts/retrieve-credentials.sh /usr/local/bin/ 32 | COPY scripts/start-frontend.sh /usr/local/bin/ 33 | COPY eas-kb-demo-frontend/env.sh /usr/local/bin/ 34 | 35 | CMD ["/usr/local/bin/start-frontend.sh"] -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 Elasticsearch B.V. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Elastic App Search Knowledge Base Demo. 2 | 3 | Copyright 2012-2019 Elasticsearch B.V. 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elastic App Search Knowledge Base Demo 2 | 3 | ![eas-kb-demo](https://user-images.githubusercontent.com/786943/79903734-347d7300-83d9-11ea-8405-6b801fcd74ac.gif) 4 | 5 | ## Build and run frontend for testing 6 | 7 | ## Frontend only 8 | 9 | If you wish to test the frontend only, you can build and run the frontend docker image, you can run the following command from the project root directory: 10 | 11 | ```bash 12 | docker build . --target=frontend -t eas-kb-demo/frontend 13 | docker run -p5000:5000 --rm --env-file=eas-kb-demo-frontend/.env eas-kb-demo/frontend 14 | ``` 15 | 16 | You can now use the frontend from your browser at http://host.docker.internal:5000. 17 | 18 | **Note:** 19 | - The docker build is a snapshot version of the production build to be deployed. 20 | - Data from an ESS App Search instance 21 | - If you want to develop the frontend, read the development documentation bellow. 22 | 23 | 24 | ## Full stack 25 | 26 | If you wish to test the full stack build locally, you have to boot all the required services (Elasticsearch, App Search) using the `docker-compose.yml` config with the project. 27 | 28 | ``` 29 | docker-compose up -d 30 | ``` 31 | 32 | It could take few minutes, for the stack to be fully booted. Once finished, you should be able to access: 33 | - App Search admin at http://host.docker.internal:3002 using `enterprise_search`/ `password` credentials 34 | - The frontend at http://host.docker.internal:5000 35 | 36 | Note: 37 | - All data are automatically imported when starting the stack. It can take few minutes before the result start to appear in the frontend. 38 | - You can tune the engine relevance, curations, and synonyms by using the `helpdesk` meta engine in App Search. 39 | - The docker-compose stack is not intended to develop but to test built images. Images need to be refreshed everytime a change is made to the code using `docker-compose build`. 40 | 41 | If something goes wrong with the import (use `docker-compose logs -f dataimport` to view logs), you can restart it with: 42 | 43 | ``` 44 | docker-compose run dataimport start-dataimport.sh 45 | ``` 46 | 47 | To reset the whole stack (all data will be lost), use: 48 | 49 | ``` 50 | docker-compose down 51 | ``` 52 | 53 | ## Development 54 | 55 | ### Install dependencies 56 | 57 | The project can be installed by running: 58 | 59 | ```bash 60 | yarn install 61 | ``` 62 | 63 | ### Frontend development 64 | 65 | All sources of the frontend are located into the `eas-kb-demo-frontend` workspace of the main yarn project. 66 | 67 | By default, the frontend is configured to use the production App Search instance deployed in Elastic Cloud. 68 | Because frontend is a R/O application it should not be an issue. 69 | 70 | To start the frontend, you can use: 71 | 72 | ```bash 73 | yarn start 74 | ``` 75 | 76 | To run cypress tests for the frontend, you can use: 77 | 78 | ```bash 79 | yarn cypress run 80 | ``` 81 | 82 | ### Data import development 83 | 84 | #### Starting the stack 85 | 86 | When working on the import, you should use your own version of App Search during the development. 87 | The easiest way to get the stack up and running is to use the `docker-compose` file bundled with this demo: 88 | 89 | ```bash 90 | docker-compose up -d 91 | ``` 92 | 93 | After the stack will have finished to start, you can then access to App Search through your browser at http://localhost:3002 with the following credentials: 94 | 95 | - **login:** `enterprise_search` 96 | - **password:** `password` 97 | 98 | **Notes :** 99 | 100 | - This demo uses meta engine which are available only when using a Platinum license.
101 | You have to start a new trial for your App Search instance using the following command: 102 | 103 | ```bash 104 | docker-compose exec elasticsearch curl -XPOST -uelastic:elasticpassword "localhost:9200/_license/start_trial?acknowledge=true" 105 | docker-compose restart enterprise_search 106 | ``` 107 | - When using Docker for Mac, please make sure you have at least 4GiB of memory allocated to Docker (`Preferences > Advanced`).
108 | Out of memory errors can cause ElasticSearch or App Search container to be killed (`docker logs --tail` can help to detect it). 109 | 110 | #### Importing the data 111 | 112 | The demo uses two different data sources: 113 | - data scrapped from the Elastic documentation (`dataimport/data/data/elastic-co-docs.json`) 114 | - data scrapped from the Elastic discussion forum (`dataimport/data/data/elastic-co-discuss.json`) 115 | 116 | You can import theses data into App Search by running: 117 | 118 | ```bash 119 | yarn dataimport 120 | ``` 121 | 122 | **Notes:** 123 | - The script will create one search engine in App Search for each dataset. 124 | - The script will create one meta engine `helpdesk` that will be used to query all the dataset. 125 | If needed, relevance tunning should be done in the meta engine. 126 | - You will need to information during the setup: 127 | - App Search API base URL: default is set to `http://localhost:3002/api/as/v1/` (should be fine) 128 | - App Search API private key: you can find it into the credentials section of the App Search dashboard (http://localhost:3002/as#/credentials) 129 | 130 | ## License 131 | 132 | [Apache-2.0](https://github.com/elastic/app-search-kb-demo/blob/master/LICENSE.txt) © [Elastic](https://github.com/elastic) 133 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.4" 2 | 3 | services: 4 | elasticsearch: 5 | image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 6 | environment: 7 | - "node.name=es-node" 8 | - "discovery.type=single-node" 9 | - "cluster.name=app-search-docker-cluster" 10 | - "bootstrap.memory_lock=true" 11 | - "ELASTIC_PASSWORD=elasticpassword" 12 | - "xpack.security.enabled=true" 13 | - "xpack.license.self_generated.type=trial" 14 | ports: 15 | - 9200:9200 16 | ulimits: 17 | memlock: 18 | soft: -1 19 | hard: -1 20 | enterprise_search: 21 | image: docker.elastic.co/enterprise-search/enterprise-search:7.8.0 22 | environment: 23 | - "elasticsearch.host=http://elasticsearch:9200" 24 | - "elasticsearch.password=elasticpassword" 25 | - "ENT_SEARCH_DEFAULT_PASSWORD=password" 26 | - "allow_es_settings_modification=true" 27 | - "secret_management.encryption_keys=[changeme]" 28 | ports: 29 | - 3002:3002 30 | frontend: 31 | build: 32 | context: '.' 33 | target: frontend 34 | environment: 35 | - "AS_BASE_URL=http://host.docker.internal:3002/" 36 | - "AS_USERNAME=enterprise_search" 37 | - "AS_PASSWORD=password" 38 | ports: 39 | - 5000:5000 40 | dataimport: 41 | build: 42 | context: '.' 43 | target: dataimport 44 | environment: 45 | - "AS_BASE_URL=http://host.docker.internal:3002/" 46 | - "AS_USERNAME=enterprise_search" 47 | - "AS_PASSWORD=password" 48 | volumes: 49 | esdata: 50 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "strongloop", 3 | "env": { 4 | "es6": true 5 | }, 6 | "parserOptions": { 7 | "ecmaVersion": 2018 8 | }, 9 | "rules": { 10 | "max-len": ["error", 120, 2, { 11 | "ignoreUrls": true, 12 | "ignoreComments": false, 13 | "ignoreRegExpLiterals": true, 14 | "ignoreStrings": false, 15 | "ignoreTemplateLiterals": false 16 | }] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | /.pnp 4 | .pnp.js 5 | 6 | # Testing 7 | /coverage 8 | 9 | # Production 10 | /build 11 | 12 | # Misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | # Logs 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* 23 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "eas-kb-demo-dataimport", 4 | "version": "0.0.1", 5 | "license": "Apache-2.0", 6 | "scripts": { 7 | "dataimport": "node src/cli.js", 8 | "lint": "eslint ." 9 | }, 10 | "dependencies": { 11 | "@elastic/app-search-node": "^7.6.0", 12 | "cli-progress": "^3.6.0", 13 | "jsonfile": "^6.0.1", 14 | "moment": "^2.24.0", 15 | "prompts": "^2.3.1" 16 | }, 17 | "devDependencies": { 18 | "eslint": "^6.8.0", 19 | "eslint-config-strongloop": "^2.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/cli.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const { readConfig } = require('./config'); 23 | const { factory: clientFactory } = require('./client'); 24 | const { getImportedFiles } = require('./input/file'); 25 | const documentProcessor = require('./document/processor'); 26 | const cliProgress = require('cli-progress'); 27 | 28 | (async() => { 29 | try { 30 | const config = await readConfig(); 31 | console.info('✔ Config read sucessfully.'); 32 | 33 | const client = await clientFactory(config); 34 | console.info('✔ Connected to the App Search server successfully.'); 35 | 36 | const importedFiles = await getImportedFiles(config); 37 | 38 | await Promise.all(importedFiles.map((inputFile) => { 39 | const engine = inputFile.getEngineName(); 40 | return client.initEngine(engine, config.language) 41 | .then(engineData => { 42 | if (engineData.isNew === true) { 43 | console.info(`✔ Created ${engine} engine.`); 44 | } else { 45 | console.info(`✔ Using already existing ${engine} engine.`); 46 | } 47 | return Promise.resolve(engineData); 48 | }).catch(reason => Promise.reject(`Unable to initialiaze engine ${engine} (${reason})`)); 49 | })).then(() => { 50 | const sourceEngines = importedFiles.map(_ => _.getEngineName()); 51 | const { metaEngineName } = config; 52 | return client.initMetaEngine(metaEngineName, sourceEngines) 53 | .then((engineData) => { 54 | if (engineData.isNew === true) { 55 | console.info(`✔ Created ${metaEngineName} meta-engine.`); 56 | } else { 57 | console.info(`✔ Updated ${metaEngineName} meta-engine sources.`); 58 | } 59 | return Promise.resolve(engineData); 60 | }); 61 | }).then(() => { 62 | const progressBar = new cliProgress.MultiBar(config.progressBarConfig, cliProgress.Presets.shades_grey); 63 | return Promise.all(importedFiles.map((inputFile) => { 64 | return inputFile.getDocuments(documentProcessor) 65 | .then(docs => { 66 | const fileProgressBar = progressBar.create(docs.length, 0); 67 | if (fileProgressBar) { 68 | fileProgressBar.update(0, {filename: inputFile.filename.padEnd(100)}); 69 | } 70 | const progressCallback = (importedDocs) => { 71 | if (fileProgressBar) { 72 | fileProgressBar.increment(importedDocs); 73 | } 74 | }; 75 | return client.importDocuments(inputFile.getEngineName(), docs, progressCallback) 76 | .then(({ importedDocs }) => { 77 | if (!fileProgressBar) { 78 | const filename = inputFile.filename; 79 | const engineName = inputFile.getEngineName(); 80 | console.info(`✔ Imported ${importedDocs} documents from file ${filename} into engine ${engineName}.`); 81 | } 82 | return Promise.resolve(importedDocs); 83 | }); 84 | }); 85 | })).then(async(docCounts) => { 86 | progressBar.stop(); 87 | const expectedDocCount = Math.min(10000, docCounts.reduce((acc, value) => acc + value, 0)); 88 | const { metaEngineName } = config; 89 | while (await client.getSearchableDocCount(metaEngineName) < expectedDocCount) { 90 | await new Promise(resolve => setTimeout(resolve, 100)); 91 | }; 92 | console.info(`✔ Meta engine ${metaEngineName} contains ${expectedDocCount} searchable documents.`); 93 | }); 94 | }).catch(reason => { 95 | throw reason; 96 | }); 97 | } catch (reason) { 98 | console.error(`✘ Error: ${reason}`); 99 | process.exit(1); 100 | } 101 | })(); 102 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/client/client.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const AppSearchClient = require('@elastic/app-search-node'); 23 | 24 | class Client { 25 | 26 | /** 27 | * Instantiate a new client from config. 28 | * The client is return as a promise only when a successful response to a ping is received. 29 | * 30 | * @param {Object} config 31 | * 32 | * @returns {Promise} Client as a promise. 33 | */ 34 | static factory(config) { 35 | const client = new Client(config); 36 | return client.ping().then(() => Promise.resolve(client)); 37 | } 38 | 39 | /** 40 | * Init the client from config. 41 | * 42 | * @param {Object} config App Search Client config. 43 | * @param {string} config.apiKey App Search Client API key. 44 | * @param {string} config.appSearchUrl App Search Client API endpoint base URL. 45 | * @param {number} config.batchSize Batch size used by the client to import docs. 46 | */ 47 | constructor({ apiKey, appSearchUrl, batchSize }) { 48 | this.client = new AppSearchClient(undefined, apiKey, () => appSearchUrl); 49 | this.batchSize = batchSize; 50 | } 51 | 52 | /** 53 | * Try to connect to the App Search backend with current config. 54 | * 55 | * @returns {Promise} Ping result promise. 56 | */ 57 | ping() { 58 | return this.client.listEngines() 59 | .then(() => Promise.resolve(true)) 60 | .catch((_) => Promise.reject(`Unable to connect to App Search (URL: ${this.client.client.baseUrl})`)); 61 | } 62 | 63 | /** 64 | * This method create an engine if it does not exists yet and return engine data. 65 | * If the engine already exists, the promise is resolved with engine data. 66 | * 67 | * @param {string} engine Engine name. 68 | * @param {string} [language=null] Language (null for universal). 69 | * 70 | * @returns {Promive { 74 | 75 | if (message === 'Not Found') { 76 | return this.client.createEngine(engine, { language }) 77 | .catch(({ message }) => Promise.reject(`Unable to create engine ${engine}: ${message}`)) 78 | .then((engineData) => { return { isNew: true, ...engineData }; }); 79 | } 80 | 81 | return Promise.reject({ message }); 82 | }); 83 | } 84 | 85 | /** 86 | * This method create a meta engine if it does not exist yet and return engine data as a promise. 87 | * If the engine already exists, the promise is resolved when source engines have been added to the list. 88 | * 89 | * @param {string} engineName Meta engine name. 90 | * @param {string[]} sourceEngines Source engines list. 91 | * 92 | * @returns {Promive { 96 | if (engineData.type !== 'meta') { 97 | return Promise.reject(`Engine ${engineName} already exists but is not a meta-engine`); 98 | } 99 | return Promise.resolve({engineData}); 100 | }).catch((reason) => { 101 | if (typeof reason === 'string') { 102 | return Promise.reject(reason); 103 | } 104 | return this.client.createMetaEngine(engineName, sourceEngines).then((engineData) => { 105 | return Promise.resolve({isNew: true, ...engineData}); 106 | }).catch(({ errorMessages: [message] }) => { 107 | return Promise.reject(`Unable to create meta engine ${engineName} (${message}).`); 108 | }); 109 | }).then(engineData => { 110 | if (engineData.isNew !== true) { 111 | return this.client.addMetaEngineSources(engineName, sourceEngines) 112 | .then(_ => Promise.resolve(engineData)) 113 | .catch(({ errorMessages: [message] }) => { 114 | return Promise.reject(`Error while updating meta-engine ${engineName} sources (${message}).`); 115 | }); 116 | } 117 | return Promise.resolve(engineData); 118 | }); 119 | } 120 | 121 | /** 122 | * Import documents into an engine. 123 | * The method automatically chunk the data to avoid too large requests. 124 | * 125 | * @param {string} engineName Target engine name. 126 | * @param {Object[]} documents Documents to be imported. 127 | * @param {*} progressCallback A callback called each time for each imported chunk. 128 | */ 129 | async importDocuments(engineName, documents, progressCallback) { 130 | var importedDocs = 0; 131 | for (var i = 0; i < documents.length; i += this.batchSize) { 132 | const currentBatch = documents.slice(i, i + this.batchSize); 133 | try { 134 | const indexingResponse = await this.client.indexDocuments(engineName, currentBatch); 135 | 136 | importedDocs += indexingResponse.filter(({errors}) => errors.length === 0).length; 137 | 138 | if (progressCallback) { 139 | progressCallback(currentBatch.length); 140 | } 141 | 142 | } catch ({ errorMessages: [message], ...error }) { 143 | return Promise.reject(`Error while importing documents in engine ${engineName} (${message})`); 144 | } 145 | } 146 | 147 | return Promise.resolve({ engine: engineName, importedDocs }); 148 | } 149 | 150 | /** 151 | * Return searchable doc count for the specified engine. 152 | * 153 | * @param {string} engineName Target engine name. 154 | */ 155 | async getSearchableDocCount(engineName) { 156 | try { 157 | const searchResponse = await this.client.search(engineName, '', { page: { size: 1 } }).then(); 158 | const { meta: { page: { total_results: docCount } } } = searchResponse; 159 | return Promise.resolve(docCount); 160 | } catch ({ errorMessages: [message], ...error }) { 161 | return Promise.reject(`Unable to retrieve searchable doc count for ${engineName} (${message})`); 162 | } 163 | } 164 | } 165 | 166 | module.exports = Client; 167 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/client/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const Client = require('./client'); 23 | 24 | module.exports = { factory: Client.factory, Client: Client }; 25 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/config/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const readConfig = require('./read-config'); 23 | 24 | module.exports = { readConfig }; 25 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/config/read-config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const prompts = require('prompts'); 23 | 24 | const DEFAULT_URL = 'http://localhost:3002/'; 25 | const DEFAULT_META_ENGINE_NAME = 'helpdesk'; 26 | const DEFAULT_LANGUAGE = 'en'; 27 | 28 | const BATCH_SIZE = 100; 29 | 30 | const DATA_DIR_NAME = `${require('path').resolve(`${__dirname}/../..`)}/data`; 31 | const API_BASE_PATH = '/api/as/v1/'; 32 | 33 | const PROGRESS_BAR_FORMAT = ' Importing {filename} [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'; 34 | const PROGRESS_BAR_CONFIG = { 35 | clearOnComplete: false, 36 | hideCursor: true, 37 | format: PROGRESS_BAR_FORMAT, 38 | }; 39 | 40 | /** 41 | * Read config from environment variables. 42 | * 43 | * @returns {Promise} Config. 44 | */ 45 | const readFromEnvironment = () => { 46 | const { AS_BASE_URL: appSearchUrl, AS_PRIVATE_API_KEY: apiKey } = process.env; 47 | const config = { appSearchUrl, apiKey }; 48 | 49 | if (appSearchUrl === undefined || apiKey === undefined) { 50 | return Promise.reject(config); 51 | } 52 | 53 | return Promise.resolve(config); 54 | }; 55 | 56 | /** 57 | * Read config from the prompt. 58 | * 59 | * @returns {Promise} Config. 60 | */ 61 | const promptConfig = () => { 62 | const promptQuestions = [ 63 | { 64 | type: 'text', 65 | name: 'appSearchUrl', 66 | message: 'App Search Server URL:', 67 | initial: process.env.AS_BASE_URL || DEFAULT_URL, 68 | }, 69 | { 70 | type: 'text', 71 | name: 'apiKey', 72 | message: 'App Search Private API key:', 73 | initial: process.env.AS_PRIVATE_API_KEY, 74 | }, 75 | ]; 76 | 77 | return prompts(promptQuestions); 78 | }; 79 | 80 | /** 81 | * Validate the config. 82 | * 83 | * @param {Onject} config Config. 84 | * @param {string} config.appSearchUrl App Search API base URL 85 | * @param {string} config.appSearchUrl App Search API private key. 86 | * 87 | * @returns {Promise} Validated config. 88 | */ 89 | const validateConfig = ({ appSearchUrl, apiKey, ...config }) => { 90 | appSearchUrl = appSearchUrl.replace(/[\s/]+$/g, ''); 91 | if (!appSearchUrl.endsWith(API_BASE_PATH)) { 92 | appSearchUrl = `${appSearchUrl}${API_BASE_PATH}`; 93 | } 94 | 95 | if (!appSearchUrl.startsWith('http')) { 96 | appSearchUrl = `http://${appSearchUrl}`; 97 | } 98 | 99 | if (!apiKey.startsWith('private-')) { 100 | return Promise.reject('Api key should start with "private-"'); 101 | } 102 | 103 | return Promise.resolve({ appSearchUrl, apiKey, ...config }); 104 | }; 105 | 106 | /** 107 | * Read and validate the dataimport config. 108 | * 109 | * @returns {Promise} Validated config. 110 | */ 111 | const readConfig = () => { 112 | const defaultValues = { 113 | metaEngineName: DEFAULT_META_ENGINE_NAME, 114 | inputDir: DATA_DIR_NAME, 115 | language: DEFAULT_LANGUAGE, 116 | batchSize: BATCH_SIZE, 117 | progressBarConfig: PROGRESS_BAR_CONFIG, 118 | }; 119 | 120 | return readFromEnvironment().catch(promptConfig).then(validateConfig).then(({ ...config }) => { 121 | return { ...defaultValues, ...config }; 122 | }); 123 | }; 124 | 125 | module.exports = readConfig; 126 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/document/processor.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const moment = require('moment'); 23 | 24 | /*eslint quote-props: ["error", "always"]*/ 25 | const productNameMapping = { 26 | 'Metricbeat': 'Beats', 27 | 'Filebeat': 'Beats', 28 | 'Clients': 'Elasticsearch', 29 | 'Packetbeat': 'Beats', 30 | 'Hadoop and Elasticsearch': 'Elasticsearch', 31 | 'Libbeat': 'Beats', 32 | 'Auditbeat': 'Beats', 33 | 'Heartbeat': 'Beats', 34 | 'Winlogbeat': 'Beats', 35 | 'Journalbeat': 'Beats', 36 | 'Functionbeat': 'Beats', 37 | 'Logs': 'Logging', 38 | 'Elastic Cloud Enterprise': 'Elastic Cloud Enterprise', 39 | 'Elastic Cloud on Kubernetes (ECK)': 'Elastic Cloud on Kubernetes', 40 | 'Siem': 'SIEM', 41 | 'Azure Marketplace And Resource Manager (ARM) Template': 'Cloud', 42 | 'Enterprise Search': 'Workplace Search', 43 | 'Rally': 'Elasticsearch', 44 | 'Beats Developers': 'Beats', 45 | 'Community Beats': 'Beats', 46 | 'Central Management': 'Beats', 47 | 'Machine Learning': 'Elasticsearch', 48 | 'Elastic Logging Plugin': 'Beats', 49 | 'Infrastructure': 'Elastic Stack', 50 | 51 | }; 52 | 53 | /** 54 | * Handle document processing (cleaning, value mapping, ...). 55 | * 56 | * @param {Object} rawDocument Document to be processed. 57 | * 58 | * @returns {Object} 59 | */ 60 | const processDocument = ({ title, date, published_at, category, product_name, product_name_raw, ...docFields }) => { 61 | // pubished_at field is removed in favor of the date field. 62 | if (published_at) { 63 | date = published_at; 64 | } 65 | 66 | // Parse the date field 67 | if (date && date.match(/(.*?(am|pm))/)) { 68 | date = moment(date.match(/(.*?(am|pm))/g)[0], 'MMMM DD, YYYY, H:mma').format(); 69 | } 70 | 71 | // Move content of the category field in product_name 72 | if (category) { 73 | product_name = category; 74 | } 75 | 76 | // Keep only the first product_name value and map the value. 77 | if (product_name) { 78 | if (Array.isArray(product_name)) { 79 | product_name = product_name[0]; 80 | } 81 | 82 | if (productNameMapping[product_name]) { 83 | product_name = productNameMapping[product_name]; 84 | } 85 | } 86 | 87 | // Parse title to remove breadcrumbs or sections data from it. 88 | title = title.replace(/\[.*\]/g, '') 89 | .replace(/\| .* Reference/g, '') 90 | .replace(/\| Getting Started/g, '') 91 | .replace(/\| Elastic Stack Overview/g, ''); 92 | 93 | return { title, date, product_name, ...docFields }; 94 | }; 95 | 96 | module.exports = processDocument; 97 | -------------------------------------------------------------------------------- /eas-kb-demo-dataimport/src/input/file.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | 'use strict'; 21 | 22 | const fs = require('fs'); 23 | const jsonfile = require('jsonfile'); 24 | 25 | class InputFile { 26 | /** 27 | * Constructor. 28 | * 29 | * @param {string} dir File directory. 30 | * @param {string} filename File name. 31 | */ 32 | constructor(dir, filename) { 33 | this.dir = dir; 34 | this.filename = filename; 35 | } 36 | 37 | /** 38 | * Compute the engine name where data should be imported from the filename. 39 | * 40 | * @returns {string} 41 | */ 42 | getEngineName() { 43 | return this.filename.split('.')[0]; 44 | } 45 | 46 | /** 47 | * Promise containing all docs in from the input file. 48 | * 49 | * @returns {Promise} 50 | */ 51 | getDocuments(documentProcessor) { 52 | return new Promise((resolve, reject) => { 53 | jsonfile.readFile(`${this.dir}/${this.filename}`, function(err, rawDocs) { 54 | if (err) { 55 | reject(`Unable to read file ${this.dir}/${this.filename}`); 56 | } 57 | 58 | resolve(documentProcessor ? rawDocs.map(documentProcessor) : documentProcessor); 59 | }); 60 | }); 61 | }; 62 | }; 63 | 64 | /** 65 | * Get list of input files to be imported from the data input directory. 66 | * 67 | * @param {Object} config 68 | * @param {string} config.inputDir 69 | * 70 | * @returns {Promise} 71 | */ 72 | const getImportedFiles = ({ inputDir }) => { 73 | return new Promise((resolve, reject) => { 74 | return fs.readdir(inputDir, (err, files) => { 75 | return err != null ? reject(err) : resolve(files.map(filename => new InputFile(inputDir, filename))); 76 | }); 77 | }); 78 | }; 79 | 80 | module.exports = { getImportedFiles }; 81 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/.env: -------------------------------------------------------------------------------- 1 | AS_BASE_URL=https://71daad31a11749f5acc4be9f71cc2d58.app-search.europe-west1.gcp.cloud.es.io 2 | AS_SEARCH_API_KEY=search-3cpc6u6zp2838p19kc3c59k8 3 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/.eslintignore: -------------------------------------------------------------------------------- 1 | src/serviceWorker.js -------------------------------------------------------------------------------- /eas-kb-demo-frontend/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | parserOptions: 2 | sourceType: module 3 | ecmaVersion: 2018 4 | ecmaFeatures: 5 | jsx: true 6 | experimentalObjectRestSpread: true 7 | 8 | env: 9 | amd: true 10 | browser: true 11 | es6: true 12 | jquery: true 13 | node: true 14 | 15 | plugins: 16 | - react 17 | 18 | # http://eslint.org/docs/rules/ 19 | rules: 20 | # Possible Errors 21 | comma-dangle: [2, never] 22 | no-cond-assign: 2 23 | no-console: 0 24 | no-constant-condition: 2 25 | no-control-regex: 2 26 | no-debugger: 2 27 | no-dupe-args: 2 28 | no-dupe-keys: 2 29 | no-duplicate-case: 2 30 | no-empty: 2 31 | no-empty-character-class: 2 32 | no-ex-assign: 2 33 | no-extra-boolean-cast: 2 34 | no-extra-parens: 0 35 | no-extra-semi: 2 36 | no-func-assign: 2 37 | no-inner-declarations: [2, functions] 38 | no-invalid-regexp: 2 39 | no-irregular-whitespace: 2 40 | no-negated-in-lhs: 2 41 | no-obj-calls: 2 42 | no-regex-spaces: 2 43 | no-sparse-arrays: 2 44 | no-unexpected-multiline: 2 45 | no-unreachable: 2 46 | use-isnan: 2 47 | valid-jsdoc: 0 48 | valid-typeof: 2 49 | 50 | # Best Practices 51 | accessor-pairs: 2 52 | block-scoped-var: 0 53 | complexity: 0 54 | consistent-return: 0 55 | curly: 0 56 | default-case: 0 57 | dot-location: 0 58 | dot-notation: 0 59 | eqeqeq: 2 60 | guard-for-in: 2 61 | no-alert: 2 62 | no-caller: 2 63 | no-case-declarations: 2 64 | no-div-regex: 2 65 | no-else-return: 0 66 | no-empty-pattern: 2 67 | no-eq-null: 2 68 | no-eval: 2 69 | no-extend-native: 2 70 | no-extra-bind: 2 71 | no-fallthrough: 2 72 | no-floating-decimal: 0 73 | no-implicit-coercion: 0 74 | no-implied-eval: 2 75 | no-invalid-this: 0 76 | no-iterator: 2 77 | no-labels: 2 78 | no-lone-blocks: 2 79 | no-loop-func: 2 80 | no-magic-number: 0 81 | no-multi-spaces: 0 82 | no-multi-str: 0 83 | no-native-reassign: 2 84 | no-new-func: 2 85 | no-new-wrappers: 2 86 | no-new: 2 87 | no-octal-escape: 2 88 | no-octal: 2 89 | no-proto: 2 90 | no-redeclare: 2 91 | no-return-assign: 2 92 | no-script-url: 2 93 | no-self-compare: 2 94 | no-sequences: 0 95 | no-throw-literal: 0 96 | no-unused-expressions: 2 97 | no-useless-call: 2 98 | no-useless-concat: 2 99 | no-void: 2 100 | no-warning-comments: 0 101 | no-with: 2 102 | radix: 2 103 | vars-on-top: 0 104 | wrap-iife: [2, any] 105 | yoda: 0 106 | 107 | # Strict 108 | strict: 0 109 | 110 | # Variables 111 | init-declarations: 0 112 | no-catch-shadow: 2 113 | no-delete-var: 2 114 | no-label-var: 2 115 | no-shadow-restricted-names: 2 116 | no-shadow: 0 117 | no-undef-init: 2 118 | no-undef: 0 119 | no-undefined: 0 120 | no-unused-vars: 0 121 | no-use-before-define: 0 122 | 123 | # Node.js and CommonJS 124 | callback-return: 2 125 | global-require: 2 126 | handle-callback-err: 2 127 | no-mixed-requires: 0 128 | no-new-require: 0 129 | no-path-concat: 2 130 | no-process-exit: 2 131 | no-restricted-modules: 0 132 | no-sync: 0 133 | 134 | # Stylistic Issues 135 | array-bracket-spacing: 0 136 | block-spacing: 0 137 | brace-style: 0 138 | camelcase: 0 139 | comma-spacing: 0 140 | comma-style: 0 141 | computed-property-spacing: 0 142 | consistent-this: 0 143 | eol-last: 0 144 | func-names: 0 145 | func-style: 0 146 | id-length: 0 147 | id-match: 0 148 | indent: 0 149 | jsx-quotes: 0 150 | key-spacing: 0 151 | linebreak-style: 0 152 | lines-around-comment: 0 153 | max-depth: 0 154 | max-len: 0 155 | max-nested-callbacks: 0 156 | max-params: 0 157 | max-statements: [2, 30] 158 | new-cap: 0 159 | new-parens: 0 160 | newline-after-var: 0 161 | no-array-constructor: 0 162 | no-bitwise: 0 163 | no-continue: 0 164 | no-inline-comments: 0 165 | no-lonely-if: 0 166 | no-mixed-spaces-and-tabs: 0 167 | no-multiple-empty-lines: 0 168 | no-negated-condition: 0 169 | no-nested-ternary: 0 170 | no-new-object: 0 171 | no-plusplus: 0 172 | no-restricted-syntax: 0 173 | no-spaced-func: 0 174 | no-ternary: 0 175 | no-trailing-spaces: 2 176 | no-underscore-dangle: 0 177 | no-unneeded-ternary: 0 178 | object-curly-spacing: 0 179 | one-var: 0 180 | operator-assignment: 0 181 | operator-linebreak: 0 182 | padded-blocks: 0 183 | quote-props: 0 184 | quotes: 0 185 | require-jsdoc: 0 186 | semi-spacing: 0 187 | semi: 0 188 | sort-vars: 0 189 | keyword-spacing: 0 190 | space-before-blocks: 0 191 | space-before-function-paren: 0 192 | space-in-parens: 0 193 | space-infix-ops: 0 194 | space-unary-ops: 0 195 | spaced-comment: 0 196 | wrap-regex: 0 197 | 198 | # ECMAScript 6 199 | arrow-body-style: 0 200 | arrow-parens: 0 201 | arrow-spacing: 0 202 | constructor-super: 0 203 | generator-star-spacing: 0 204 | no-class-assign: 0 205 | no-const-assign: 0 206 | no-dupe-class-members: 0 207 | no-this-before-super: 0 208 | no-var: 0 209 | object-shorthand: 0 210 | prefer-arrow-callback: 0 211 | prefer-const: 0 212 | prefer-reflect: 0 213 | prefer-spread: 0 214 | prefer-template: 0 215 | require-yield: 0 216 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | /.pnp 4 | .pnp.js 5 | 6 | # Testing 7 | /coverage 8 | 9 | # Production 10 | /build 11 | 12 | # Misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | # Temporary env files 20 | /public/env-config.js 21 | env-config.js 22 | 23 | # Logs 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:3000", 3 | "viewportWidth": 1280, 4 | "viewportHeight": 1024 5 | } 6 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/.gitignore: -------------------------------------------------------------------------------- 1 | screenshots 2 | videos 3 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/fixtures/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/cypress/fixtures/.gitignore -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/integration/autocomplete.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | describe('Autocomplete', () => { 21 | 22 | const searchQuery = 'elasticsearch api'; 23 | 24 | beforeEach(() => { 25 | cy.visit('/') 26 | }) 27 | 28 | describe('Type in the search bar', () => { 29 | it('should display autocomplete', () => { 30 | cy.get('[data-testid=search-bar]').type(searchQuery).then(() => { 31 | cy.get('.search-container__autocomplete').then(() => { 32 | cy.get('.search-container__autocomplete__result').should('have.length', 5) 33 | }) 34 | }) 35 | }) 36 | }) 37 | 38 | describe('Close autocomplete', () => { 39 | it('when input lost the focus', () => { 40 | cy.get('[data-testid=search-bar]').type(searchQuery).then((inputBar) => { 41 | cy.get('.search-container__autocomplete').then(() => { 42 | cy.get(inputBar).blur() 43 | cy.get('.search-container__autocomplete').should('not.exist') 44 | }) 45 | }) 46 | }) 47 | }) 48 | }) 49 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/integration/contact.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | describe('Contact form', () => { 21 | 22 | describe('Homepage', () => { 23 | beforeEach(() => { 24 | cy.visit('/') 25 | }) 26 | 27 | describe('Open modal', () => { 28 | it ('should be present in the header', () => { 29 | cy.get('.layout__header__actions .contact__link').contains('Contact Support').click() 30 | cy.get('.contact__modal__container').should('be.visible') 31 | }) 32 | 33 | it ('should be present before footer', () => { 34 | cy.get('.contact__callout').within(() => { 35 | cy.get('.contact__callout__title').contains('Can’t find what you’re looking for?') 36 | cy.get('.contact__callout__content').contains('We’re here to help. Get in touch and we’ll get back to you as soon as possible.').within(() => { 37 | cy.get('.contact__link') 38 | }) 39 | }) 40 | 41 | cy.get('.contact__callout .contact__link').contains('Contact Support').click() 42 | cy.get('.contact__modal__container').should('be.visible') 43 | }) 44 | }) 45 | 46 | describe('Close modal', () => { 47 | const selectors = ['.button__primary', '.button__secondary', '.contact__modal__title__close'] 48 | 49 | beforeEach(() => { 50 | cy.get('.layout__header__actions .contact__link').click() 51 | }) 52 | 53 | selectors.forEach((selector) => { 54 | it('should be closed when clicking', () => { 55 | cy.get('.contact__modal__container').within(() => { 56 | cy.get(selector).click() 57 | cy.get('.contact__modal__container').should('not.be.visible') 58 | }) 59 | }) 60 | }) 61 | }) 62 | 63 | describe('Autocomplete', () => { 64 | 65 | const query = 'elasticsea'; 66 | 67 | beforeEach(() => { 68 | cy.get('.layout__header__actions .contact__link').click() 69 | }) 70 | 71 | it('should display suggestions', () => { 72 | cy.get('.contact__modal__content .form-row').first().within(() => { 73 | cy.get('input').type(query) 74 | cy.get('dl.suggestions dt').contains('Recommended for you') 75 | cy.get('dl.suggestions dd').should('has.length', 6) 76 | cy.get('dl.suggestions dd').first().contains('elasticsearch').click() 77 | }) 78 | }) 79 | 80 | it('suggestions should be clickable', () => { 81 | cy.get('.contact__modal__content .form-row').first().within(() => { 82 | cy.get('input').type(query) 83 | cy.get('dl.suggestions dd').first().contains('elasticsearch').click() 84 | cy.get('input').should('have.value', 'elasticsearch') 85 | cy.get('dl.suggestions').should('not.be.visible') 86 | }) 87 | }) 88 | }) 89 | }) 90 | }) 91 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/integration/homepage.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | describe('Homepage', () => { 21 | 22 | before(() => { 23 | cy.visit('/') 24 | }) 25 | 26 | describe('Page Layout', () => { 27 | describe('Content', () => { 28 | describe('Help text', () => { 29 | it('has title', () => { 30 | cy.contains('.app__content h1', 'Help Center') 31 | }) 32 | 33 | it('has title', () => { 34 | cy.contains('.search-container-home__title h1', 'Help Center') 35 | }) 36 | 37 | it('has description', () => { 38 | cy.contains('.search-container-home__title p', 'Skip the support line and search for your issue in our knowledge base.') 39 | }) 40 | }) 41 | 42 | describe('Search form', () => { 43 | it('has search input', () => { 44 | cy.get('[data-testid=search-bar]').should(($inputBar) => { 45 | expect($inputBar.attr('placeholder')).to.be.eq('Search...') 46 | }); 47 | }) 48 | 49 | it('has submit button', () => { 50 | cy.get('.sui-search-box > input[type=submit]') 51 | }) 52 | }) 53 | }) 54 | 55 | describe('Header', () => { 56 | const getHeader = () => { 57 | return cy.get('.layout__header') 58 | } 59 | 60 | it('should be visible', () => { 61 | getHeader().should('be.visible') 62 | }) 63 | 64 | it('should contains logo', () => { 65 | getHeader().get('#header-logo') 66 | }) 67 | }) 68 | 69 | describe('Footer', () => { 70 | it('contains demo notice', () => { 71 | cy.contains('.layout__footer', 'Demo created for Elastic internal use only.') 72 | }) 73 | }) 74 | }) 75 | 76 | const viewPorts = ['iphone-6', 'iphone-x', 'ipad-2', 'macbook-15'] 77 | 78 | describe('Viewports', () => { 79 | viewPorts.forEach((viewport) => { 80 | describe('Test viewport ' + viewport, () => { 81 | beforeEach(() => { 82 | cy.viewport(viewport) 83 | }) 84 | 85 | it('should fit in viewport', () => { 86 | cy.get('#root').then((rootNode) => { 87 | cy.window().then((window) => { 88 | expect(rootNode.width()).to.be.at.most(window.innerWidth) 89 | expect(rootNode.height()).to.be.at.most(window.innerHeight) 90 | }) 91 | }) 92 | }) 93 | }) 94 | }) 95 | }) 96 | }) 97 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/integration/search.spec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | describe('Search result page', () => { 21 | 22 | const searchQuery = 'elasticsearch api'; 23 | 24 | describe('Launch search from the homepage', () => { 25 | beforeEach(() => { 26 | cy.visit('/') 27 | }) 28 | 29 | const typeSearch = (searchQuery) => { 30 | return cy.get('[data-testid=search-bar]').type(searchQuery); 31 | } 32 | 33 | it ('when pressing ENTER', () => { 34 | typeSearch(searchQuery + '{enter}') 35 | cy.get('.search-container-results') 36 | }) 37 | 38 | it ('when pressing clicking the submit button', () => { 39 | typeSearch(searchQuery) 40 | cy.get('.sui-search-box > input[type=submit]').click() 41 | cy.get('.search-container-results') 42 | }) 43 | }) 44 | 45 | describe('Search result page for "' + searchQuery + '"', () => { 46 | before(() => { 47 | cy.visit('/?q=' + searchQuery) 48 | }) 49 | 50 | describe('Search form', () => { 51 | it('has search input with value "' + searchQuery + '"', () => { 52 | cy.get('[data-testid=search-bar]').should('have.value', searchQuery); 53 | }) 54 | 55 | it('has submit button', () => { 56 | cy.get('.sui-search-box > input[type=submit]') 57 | }) 58 | }) 59 | 60 | describe('Paging info', () => { 61 | it('should contain the search query', () => { 62 | cy.contains('.sui-paging-info', searchQuery); 63 | }) 64 | }) 65 | 66 | describe('Results', () => { 67 | it('should display 10 results', () => { 68 | cy.get('.search-container__search-result-layout__list').within(() => { 69 | cy.get('li > div.search-container__search-result-layout__list__result').should('have.length', 10) 70 | }) 71 | }) 72 | }) 73 | 74 | describe('Sidebar', () => { 75 | describe('Mobile viewports', () => { 76 | ['iphone-6', 'iphone-x', 'ipad-2'].forEach((viewport) => { 77 | it ('should be hidden on device "' + viewport + '"', () => { 78 | cy.viewport(viewport) 79 | cy.get('.search-container__search-result-layout__sidebar').should('not.be.visible') 80 | }) 81 | }) 82 | }) 83 | 84 | describe('Default viewport', () => { 85 | 86 | describe('Sidebar', () => { 87 | it('should be visible by default', () => { 88 | cy.get('.search-container__search-result-layout__sidebar').should('be.visible') 89 | }) 90 | 91 | describe('Facets', () => { 92 | beforeEach(() => { 93 | cy.visit('/?q=' + searchQuery) 94 | }) 95 | 96 | describe('Product facet', () => { 97 | it('should have a product facet', () => { 98 | cy.get('.search-container__search-result-layout__sidebar').within(() => { 99 | cy.get('.facet').first().within(() => { 100 | cy.get('.facet__title').contains('Product') 101 | cy.get('.facet__option:first-of-type').should('have.class', 'selected').contains('All') 102 | cy.get('.facet__option').not(':first-of-type').each((filterNode) => { 103 | cy.wrap(filterNode).find('.facet__option__link').click(); 104 | }) 105 | }) 106 | }) 107 | }) 108 | }) 109 | }) 110 | }) 111 | }) 112 | }) 113 | }) 114 | }) 115 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | module.exports = (on, config) => { 21 | } 22 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/cypress/support/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import './commands' 21 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Recreate config file 4 | rm -rf ./env-config.js 5 | touch ./env-config.js 6 | 7 | # Add assignment 8 | echo "window._env_ = {" >> ./env-config.js 9 | 10 | # Read each line in .env file 11 | # Each line represents key=value pairs 12 | while read -r line || [[ -n "$line" ]]; 13 | do 14 | # Split env variables by character `=` 15 | if printf '%s\n' "$line" | grep -q -e '='; then 16 | varname=$(printf '%s\n' "$line" | sed -e 's/=.*//') 17 | varvalue=$(printf '%s\n' "$line" | sed -e 's/^[^=]*=//') 18 | fi 19 | 20 | # Read value of current variable if exists as Environment variable 21 | value=$(printf '%s\n' "${!varname}") 22 | # Otherwise use value from .env file 23 | [[ -z $value ]] && value=${varvalue} 24 | 25 | # Append configuration property to JS file 26 | echo " $varname: \"$value\"," >> ./env-config.js 27 | done < .env 28 | 29 | echo "}" >> ./env-config.js 30 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "eas-kb-demo-frontend", 4 | "version": "0.0.1", 5 | "license": "Apache-2.0", 6 | "dependencies": { 7 | "@elastic/react-search-ui": "^1.3.2", 8 | "@elastic/search-ui-app-search-connector": "^1.3.2", 9 | "@testing-library/jest-dom": "^5.1.1", 10 | "@testing-library/react": "^9.3.2", 11 | "@testing-library/user-event": "^10.0.0", 12 | "node-sass": "^4.13.1", 13 | "react": "^16.13.0", 14 | "react-dom": "^16.13.0", 15 | "react-scripts": "^3.4.0" 16 | }, 17 | "devDependencies": { 18 | "cypress": "^4.3.0" 19 | }, 20 | "scripts": { 21 | "start": "chmod +x ./env.sh && ./env.sh && cp env-config.js ./public/ && react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "lint": "eslint src" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/public/favicon.ico -------------------------------------------------------------------------------- /eas-kb-demo-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | Elastic App Search - Helpdesk Demo 15 | 16 | 17 | 18 | 19 | 20 |
21 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/public/logo192.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Elastic App Search - Helpdesk Demo", 3 | "name": "Elastic App Search - Helpdesk Demo", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "sizes": "192x192", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": ".", 17 | "display":"standalone", 18 | "orientation":"portrait", 19 | "theme_color": "#69707D", 20 | "background_color": "#F5F7FA" 21 | } 22 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/App/App.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import { useState } from 'react'; 23 | 24 | import './assets/stylesheets/App.scss'; 25 | 26 | import { Footer, Header } from '../Layout'; 27 | import { ContactCallout, ContactLink, ContactModal } from '../Contact'; 28 | import { SearchContainer } from '../Search'; 29 | 30 | const App = () => { 31 | 32 | const [showHelpModal, setShowHelp] = useState(false) 33 | 34 | return
35 |
36 |
37 | setShowHelp(true)} /> 38 |
39 |
40 |
41 | 42 | setShowHelp(true)} /> 43 |
44 |
45 | 46 | setShowHelp(false)}/> 47 | 48 |
49 | }; 50 | 51 | export default App; 52 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/App/assets/images/circles.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/App/assets/stylesheets/App.scss: -------------------------------------------------------------------------------- 1 | html { 2 | background: #69707D; 3 | } 4 | body { 5 | margin: 0; 6 | font-family: 'Inter', '-apple-system', BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 7 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 8 | sans-serif; 9 | letter-spacing: -0.01em; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | background: #69707D 13 | } 14 | 15 | code { 16 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 17 | monospace; 18 | } 19 | 20 | .app{ 21 | &__content { 22 | background-color: #F5F7FA; 23 | color: #69707D; 24 | min-height: calc(100vh - 84px); 25 | padding: 84px 0 0 0; 26 | display: flex; 27 | flex-direction: column; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/App/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import App from './App'; 21 | 22 | export default App; 23 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/ContactCallout.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './assets/stylesheets/Contact.scss'; 23 | 24 | const Callout = (props) => { 25 | return
26 |

Can’t find what you’re looking for?

27 |

28 | We’re here to help. Get in touch and we’ll get back to you as soon as possible. {props.children} 29 |

30 |
31 | }; 32 | 33 | export default Callout; 34 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/ContactLink.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './assets/stylesheets/Contact.scss'; 23 | 24 | const ContactLink = ({ onClick }) => { 25 | 26 | const onShowModal = (ev) => { 27 | ev.preventDefault(); 28 | onClick(); 29 | } 30 | 31 | return Contact Support 32 | }; 33 | 34 | export default ContactLink; 35 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/ContactModal.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './assets/stylesheets/Contact.scss'; 23 | 24 | import { WithSearch, SearchProvider } from "@elastic/react-search-ui"; 25 | 26 | import searchConnector from '../Search/SearchConnector'; 27 | 28 | const searchProviderConfig = { 29 | apiConnector: searchConnector, 30 | autocompleteQuery: { 31 | suggestions: { 32 | types: { documents: { fields: ["product_name", "sections"] } }, 33 | size: 6 34 | } 35 | } 36 | }; 37 | 38 | const ContactModal = ({ visible, onClose }) => { 39 | const objectFieldRef = React.createRef(); 40 | 41 | return
42 |
43 |
44 |
45 | {ev.preventDefault(); onClose();}}>Close 46 |

We’re here to help.

47 |
48 |
49 |
50 | 51 | context}> 52 | {({ setSearchTerm, autocompletedSuggestions }) => { 53 | const onInputChange = (ev) => { 54 | setSearchTerm(ev.target.value, {refresh: false, autocompleteSuggestions: true}) 55 | } 56 | 57 | const hideSuggestions = () => { 58 | setSearchTerm('', {refresh: false, autocompleteSuggestions: true}); 59 | }; 60 | 61 | const renderSuggestion = ({suggestion}, i) => { 62 | const onCLick = (ev) => { 63 | ev.preventDefault(); 64 | objectFieldRef.current.value = suggestion; 65 | hideSuggestions(); 66 | } 67 | return
{suggestion}
68 | }; 69 | 70 | return 78 | }} 79 |
80 |
81 |
82 |
83 | 84 |
85 |
86 | 87 |
How do we get in touch with you?
88 |
89 |
90 | 91 | or 92 | 93 |
94 |
95 |
96 |
97 | }; 98 | 99 | export default ContactModal; 100 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/images/close-icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/src/Contact/assets/images/close-icon-small.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/images/help-icon-large.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/images/help-icon-small.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/images/mail-icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/src/Contact/assets/images/mail-icon-small.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/images/modal-title-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/src/Contact/assets/images/modal-title-background.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/assets/stylesheets/Contact.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | $boxShadow: 0px 2.76726px 2.21381px rgba(0, 0, 0, 0.00843437), 0px 6.6501px 5.32008px rgba(0, 0, 0, 0.0121168), 0px 12.5216px 10.0172px rgba(0, 0, 0, 0.015), 0px 22.3363px 17.869px rgba(0, 0, 0, 0.0178832), 0px 41.7776px 33.4221px rgba(0, 0, 0, 0.0215656), 0px 100px 80px rgba(0, 0, 0, 0.03); 21 | 22 | .contact { 23 | &__callout { 24 | width: 610px; 25 | max-width: 100%; 26 | margin: 0px auto ; 27 | height: 185px; 28 | color: #343741; 29 | background: #FFFFFF 57px 52px url(../images/help-icon-large.svg) no-repeat; 30 | box-shadow: $boxShadow; 31 | 32 | &__title { 33 | font-weight: 600; 34 | font-size: 21px; 35 | line-height: 25px; 36 | margin: 54px 0 0 176px; 37 | padding: 0; 38 | } 39 | 40 | &__content { 41 | font-size: 14px; 42 | line-height: 140%; 43 | margin: 17px 78px 0 176px; 44 | padding: 0; 45 | } 46 | 47 | .contact__link { 48 | cursor: pointer; 49 | color: #006DE4; 50 | font-weight: bold; 51 | text-decoration: underline; 52 | 53 | &:after { 54 | content: " →" 55 | } 56 | } 57 | } 58 | 59 | &__modal { 60 | display: none; 61 | 62 | &[aria-hidden=false] { 63 | display: block; 64 | } 65 | 66 | &__overlay { 67 | position: fixed; 68 | width: 100%; 69 | height: 100%; 70 | top: 0px; 71 | background: rgba(0,0,0, 0.5); 72 | } 73 | 74 | &__container { 75 | position: fixed; 76 | width: calc(100% - 20px); 77 | max-width: 610px; 78 | height: 605px; 79 | left: calc(max(10px, (100% - 610px)/2)); 80 | top: calc(max(10px, (100vh - 630px)/2)); 81 | background: #FFFFFF; 82 | box-shadow: $boxShadow; 83 | max-height: calc(100vh - 20px); 84 | display: flex; 85 | flex-direction: column; 86 | } 87 | 88 | &__title { 89 | flex: 1; 90 | background: center url(../images/modal-title-background.png) no-repeat; 91 | max-height: 114px; 92 | display: flex; 93 | align-items: center; 94 | 95 | h2 { 96 | text-align: center; 97 | width: 100%; 98 | font-size: 32px; 99 | line-height: 40px; 100 | } 101 | 102 | &__close { 103 | background: center url(../images/close-icon-small.png) no-repeat; 104 | color: transparent; 105 | position: absolute; 106 | width: 10px; 107 | height: 10px; 108 | float: right; 109 | top: 10px; 110 | right: 10px; 111 | } 112 | } 113 | 114 | &__content { 115 | flex: 1; 116 | padding: 40px 60px; 117 | box-sizing: border-box; 118 | display: flex; 119 | flex-direction: column; 120 | 121 | .form-row { 122 | flex: 1; 123 | margin: 10px 0 0; 124 | 125 | .help-text { 126 | font-size: 10.5px; 127 | line-height: 18px; 128 | color: #69707D; 129 | margin: 4px; 130 | } 131 | 132 | label { 133 | display: block; 134 | width: 100%; 135 | margin: 0 0 4px; 136 | font-weight: 600; 137 | font-size: 12px; 138 | line-height: 18px; 139 | 140 | &:active, &:focus, &:focus-within { 141 | color: #006BB4; 142 | } 143 | } 144 | 145 | .suggestions { 146 | position: absolute; 147 | margin: -40px -30px; 148 | left: calc(100%); 149 | background: #FFF; 150 | list-style: none; 151 | padding: 0 0 20px; 152 | border-radius: 4px; 153 | box-shadow: $boxShadow; 154 | border: 1px solid #D3DAE6; 155 | width: 272px; 156 | 157 | &:before { 158 | content: " "; 159 | border-left: 1px solid #D3DAE6; 160 | border-bottom: 1px solid #D3DAE6; 161 | width: 20px; 162 | height: 20px; 163 | display: block; 164 | transform: rotate(45deg); 165 | margin: 13px -12px; 166 | position: absolute; 167 | background: white; 168 | } 169 | 170 | dt { 171 | padding: 12px 16px; 172 | font-size: 14px; 173 | line-height: 24px; 174 | border-bottom: 1px solid #D3DAE6; 175 | text-transform: uppercase; 176 | color: #000000; 177 | font-weight: bold; 178 | } 179 | 180 | dd { 181 | margin: 8px 16px; 182 | text-overflow: ellipsis; 183 | white-space: nowrap; 184 | overflow: hidden; 185 | font-size: 14px; 186 | line-height: 24px; 187 | 188 | a { 189 | color: #006BB4; 190 | text-decoration: none; 191 | } 192 | } 193 | } 194 | 195 | textarea { 196 | height: 96px; 197 | } 198 | 199 | input, textarea { 200 | display: block; 201 | background: #F2F4F8; 202 | border-radius: 5px; 203 | outline: none; 204 | border: none; 205 | width: calc(100% - 24px); 206 | color: #343741; 207 | padding: 11px 12px; 208 | font-size: 12px; 209 | line-height: 18px; 210 | 211 | &[type=email] { 212 | background: #F2F4F8 12px 14px url(../images/mail-icon-small.png) no-repeat; 213 | padding: 11px 12px 11px 38px; 214 | width: calc(100% - 52px); 215 | &:active, &:focus { 216 | background-position: 10px 12px; 217 | padding: 9px 12px 9px 36px; 218 | } 219 | } 220 | 221 | &:active, &:focus { 222 | background-color: #FFFFFF; 223 | border: 2px solid #D9E9FB; 224 | padding: 9px 10px; 225 | border-radius: 5px; 226 | } 227 | } 228 | } 229 | 230 | .form-controls { 231 | padding: 40px 0; 232 | 233 | .button__primary { 234 | padding: 8px 12px; 235 | background: #006BB4; 236 | border-radius: 7px; 237 | color: #FFF; 238 | outline: none; 239 | font-weight: 500; 240 | font-size: 14px; 241 | line-height: 23px; 242 | cursor: pointer; 243 | } 244 | 245 | .button__secondary { 246 | color: #006BB4; 247 | outline: none; 248 | border:none; 249 | font-size: 14px; 250 | line-height: 24px; 251 | text-decoration: underline; 252 | background: none; 253 | cursor: pointer; 254 | padding: 0; 255 | } 256 | } 257 | } 258 | } 259 | } 260 | 261 | .layout__header { 262 | .contact__link { 263 | padding: 0 0 0 24px; 264 | background: #FFFFFF 0 4px url(../images/help-icon-small.svg) no-repeat; 265 | display: block; 266 | } 267 | } 268 | 269 | 270 | @media screen and (max-width: 768px) { 271 | .contact { 272 | &__callout { 273 | width: 100%; 274 | } 275 | 276 | &__modal { 277 | &__content { 278 | .form-row { 279 | .suggestions { 280 | margin: 10px 90px; 281 | left: 0; 282 | &:before { 283 | transform: rotate(135deg); 284 | margin: -11px 21px; 285 | } 286 | } 287 | } 288 | } 289 | } 290 | } 291 | 292 | 293 | } 294 | 295 | @media screen and (max-width: 600px) { 296 | .contact__modal{ 297 | &__title h2 { 298 | font-size: 24px; 299 | line-height: 32px; 300 | } 301 | &__content { 302 | padding: 20px 20px; 303 | .form-row { 304 | .suggestions { 305 | margin: 10px 40px; 306 | } 307 | } 308 | } 309 | } 310 | .contact__callout { 311 | text-align: center; 312 | 313 | &__title { 314 | font-size: 16px; 315 | margin: 30px 30px 10px; 316 | } 317 | 318 | &__content { 319 | font-size: 13px; 320 | margin: 10px 30px 30px; 321 | a { 322 | width: 100%; 323 | margin-top: 10px; 324 | white-space: nowrap; 325 | display: inline-block; 326 | } 327 | } 328 | 329 | background: #FFF; 330 | height: auto; 331 | } 332 | } 333 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Contact/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | export {default as ContactCallout} from './ContactCallout'; 21 | export {default as ContactLink} from './ContactLink'; 22 | export {default as ContactModal} from './ContactModal'; 23 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Layout/Footer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './assets/stylesheets/Layout.scss'; 23 | 24 | const Footer = () => { 25 | return
26 |

Demo created for Elastic internal use only.

27 |
28 | }; 29 | 30 | export default Footer; 31 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Layout/Header.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import logo from './assets/images/searchco-logo.svg'; 23 | 24 | import './assets/stylesheets/Layout.scss'; 25 | 26 | const Header = (props) => { 27 | return
28 |
29 |
30 | 31 |
32 |
33 | {props.children} 34 |
35 |
36 |
37 | }; 38 | 39 | export default Header; 40 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Layout/assets/images/searchco-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Layout/assets/stylesheets/Layout.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .layout { 21 | &__header { 22 | width: 100%; 23 | height: 84px; 24 | left: 0px; 25 | top: 0px; 26 | position: absolute; 27 | background: white; 28 | box-shadow: 0px 0.498106px 1.1069px rgba(0, 0, 0, 0.0365489), 0px 1.19702px 2.66004px rgba(0, 0, 0, 0.0525061), 0px 2.25388px 5.00862px rgba(0, 0, 0, 0.065), 0px 4.02054px 8.93452px rgba(0, 0, 0, 0.0774939), 0px 7.51997px 16.711px rgba(0, 0, 0, 0.0934511), 0px 18px 40px rgba(0, 0, 0, 0.13); 29 | 30 | &__content { 31 | display: flex; 32 | height: 100%; 33 | max-width: 1108px; 34 | margin: 0 auto; 35 | padding: 0 20px; 36 | align-items: center; 37 | } 38 | 39 | &__logo { 40 | margin: 23px auto; 41 | flex: 1; 42 | 43 | &__img { 44 | height: 1.5rem; 45 | } 46 | } 47 | 48 | &__action { 49 | font-size: 16px; 50 | line-height: 24px; 51 | margin-left: 10px; 52 | 53 | a { 54 | color: #006BB4; 55 | text-decoration: none; 56 | 57 | &:hover { 58 | text-decoration: underline; 59 | } 60 | } 61 | } 62 | } 63 | 64 | &__footer { 65 | margin: 60px auto; 66 | border-top: 1px solid #D3DAE6; 67 | max-width: 722px; 68 | height: 43px; 69 | font-size: 12px; 70 | width: 100%; 71 | 72 | p { 73 | margin: 0; 74 | line-height: 100%; 75 | height: 100%; 76 | justify-content: center; 77 | display: flex; 78 | align-items: flex-end; 79 | } 80 | } 81 | } 82 | 83 | @media screen and (max-width: 768px) { 84 | .layout { 85 | &__footer { 86 | margin: 0 auto 30px; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Layout/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | export { default as Footer } from './Footer'; 21 | export { default as Header } from './Header'; 22 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/SearchConnector.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import AppSearchAPIConnector from '@elastic/search-ui-app-search-connector'; 21 | 22 | const appSearchConnector = new AppSearchAPIConnector({ 23 | endpointBase: window._env_.AS_BASE_URL, 24 | searchKey: window._env_.AS_SEARCH_API_KEY, 25 | engineName: 'elastic-co-docs' 26 | }); 27 | 28 | export default appSearchConnector; 29 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/SearchContainer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import { PagingInfo, Paging, SearchBox, SearchProvider, Results, WithSearch } from "@elastic/react-search-ui"; 23 | 24 | import { ProductFacet, PageTypeFacet, ResultView } from './components'; 25 | 26 | import searchConnector from './SearchConnector'; 27 | 28 | import './stylesheets/Search.scss'; 29 | 30 | const queryBaseResultFields = { 31 | title: { raw: { }, snippet: { size: 200, fallback: true } }, 32 | url: { raw : { } }, 33 | // date: { raw : { } }, 34 | website_area: { raw: { } }, 35 | product_version: { raw : { } }, 36 | product_name: { raw : { } }, 37 | // author: { raw : { } }, 38 | body: { raw: {}, snippet: { size: 200, fallback: true } } 39 | } 40 | 41 | const queryFacets = { 42 | // website_area: { type: "value", size: 10 }, 43 | product_name: { type: "value", size: 30 } 44 | } 45 | 46 | const searchProviderConfig = { 47 | apiConnector: searchConnector, 48 | autocompleteQuery: { 49 | results: { 50 | result_fields: { ...queryBaseResultFields } 51 | } 52 | }, 53 | searchQuery: { 54 | facets: { ...queryFacets }, 55 | disjunctiveFacets: ['product_name', 'website_area'], 56 | result_fields: { 57 | ...queryBaseResultFields, 58 | body: { raw: {}, snippet: { size: 200, fallback: true } } 59 | } 60 | }, 61 | initialState: { 62 | resultsPerPage: 10 63 | } 64 | } 65 | 66 | const searchBarInputProps = { placeholder: 'Search...', 'data-testid': 'search-bar', autoFocus: true } 67 | 68 | class HomeView extends React.Component { 69 | renderTitle() { 70 | return ( 71 |
72 |

Help Center

73 |

Skip the support line and search for your issue in our knowledge base.

74 |
75 | ) 76 | } 77 | 78 | autocompleteView({ autocompletedResults, getItemProps }) { 79 | return
80 | {autocompletedResults.slice(0, 5).map((result) => { 81 | return
82 | 83 |
84 | })} 85 |
86 | } 87 | 88 | renderSearchBox() { 89 | const autocompleteResultProps = { urlField: "url", titleField: "title", linkTarget: '_blank' } 90 | return ( 91 |
92 | 93 |
94 | ) 95 | } 96 | 97 | render() { 98 | return ( 99 |
100 | {this.renderTitle()} 101 | {this.renderSearchBox()} 102 |
103 | ) 104 | } 105 | } 106 | 107 | class SearchResultView extends React.Component { 108 | renderSearchBox() { 109 | return
110 | 111 |
112 | } 113 | 114 | renderFacets() { 115 | return <> 116 | 117 | 118 | 119 | } 120 | 121 | resultView({ key, ...props }) { 122 | return
  • 123 | 124 |
  • 125 | } 126 | 127 | renderResults() { 128 | return 129 | } 130 | 131 | render() { 132 | if (this.props.isLoading) { 133 | window.scrollTo(0, 0) 134 | } 135 | 136 | return
    137 | {this.renderSearchBox()} 138 |
    139 |
    140 | {this.renderFacets()} 141 |
    142 |
    143 | {this.props.isLoading &&
    } 144 | {!this.props.isLoading && <> 145 | 146 | {this.renderResults()} 147 | 148 | } 149 |
    150 |
    151 |
    152 | } 153 | } 154 | 155 | const SearchContainer = () => { 156 | return 157 | context}> 158 | {({ resultSearchTerm, isLoading, wasSearched, ...props }) => { 159 | return resultSearchTerm.length || isLoading || wasSearched ? : 160 | }} 161 | 162 | 163 | }; 164 | 165 | export default SearchContainer; 166 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Facets/FacetOptionView.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './Facets.scss'; 23 | 24 | const productIconClassName = ({ value: productName }) => { 25 | return `product-icon product-icon__${productName.replace(/\s+/g, '-').toLowerCase()}` 26 | }; 27 | 28 | const FacetOptionView = (props) => { 29 | const { value, selected, icon, count } = props 30 | const label = props.label || value 31 | const onRemove = (ev) => { 32 | ev.preventDefault() 33 | props.onRemove(value) 34 | } 35 | const onSelect = (ev) => { 36 | ev.preventDefault() 37 | props.onSelect(value) 38 | } 39 | 40 | return
  • 41 | 42 | {icon &&
  • 47 | }; 48 | 49 | export default FacetOptionView; 50 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Facets/FacetView.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './Facets.scss'; 23 | 24 | const FacetView = (props) => { 25 | const { label, options, onSelect, onRemove, optionView, icon, values } = props 26 | 27 | const onShowAll = (ev) => { 28 | ev.preventDefault() 29 | onRemove(values[0]) 30 | } 31 | 32 | const onSelectWithReset = (value) => { 33 | onRemove(values[0]) 34 | onSelect(value) 35 | } 36 | 37 | return
    38 |
    {label}
    39 |
      40 |
    • 41 | 42 | All 43 | 44 |
    • 45 | {options.map(option => { 46 | return optionView({ onSelect: onSelectWithReset, onRemove: onRemove, icon:icon, key: option.value, ...option }) 47 | })} 48 |
    49 |
    50 | }; 51 | 52 | export default FacetView; 53 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Facets/Facets.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .search-container { 21 | .facet { 22 | &:not(:first-child) { 23 | margin: 42px 0; 24 | } 25 | 26 | &__title { 27 | font-style: normal; 28 | font-weight: 600; 29 | font-size: 12px; 30 | line-height: 15px; 31 | color: #69707D; 32 | border-bottom: 1px solid #D3DAE6; 33 | padding: 0 0 13px; 34 | } 35 | 36 | &__options { 37 | margin: 10px 0; 38 | font-style: normal; 39 | font-weight: 400; 40 | font-size: 14px; 41 | line-height: 33px; 42 | list-style: none; 43 | padding: 0; 44 | } 45 | 46 | &__option { 47 | &__link { 48 | display: flex; 49 | align-items: center; 50 | 51 | &__count { 52 | margin-left: auto; 53 | color: #96A2B5; 54 | } 55 | 56 | .product-icon { 57 | margin: 0px 12px 0 0; 58 | } 59 | } 60 | 61 | &.selected a { 62 | font-weight: 600; 63 | color: #006BB4; 64 | } 65 | } 66 | } 67 | 68 | a { 69 | color: #69707D; 70 | text-decoration: none; 71 | } 72 | } 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Facets/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import { Facet } from "@elastic/react-search-ui"; 23 | 24 | import FacetOptionView from './FacetOptionView'; 25 | import FacetView from './FacetView'; 26 | 27 | const PageTypeFacet = (props) => { 28 | const facetOptionView = (props) => { 29 | const optionLabel = props.value === 'documentation' ? 'Documentation' : 'Discussions'; 30 | return 31 | } 32 | const facetView = (props) => 33 | 34 | return () 35 | }; 36 | 37 | const ProductFacet = (props) => { 38 | const facetOptionView = (props) => 39 | const facetView = (props) => 40 | return () 41 | }; 42 | 43 | export { PageTypeFacet, ProductFacet }; 44 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Result/Result.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | @mixin search-result { 21 | $resultClass: &; 22 | 23 | a { 24 | color: black; 25 | text-decoration: none; 26 | } 27 | 28 | &__title { 29 | display: flex; 30 | align-items: center; 31 | color: black; 32 | 33 | .product-icon { 34 | width: 21px; 35 | height: 21px; 36 | margin-right: 8px; 37 | flex: none; 38 | } 39 | 40 | &__text { 41 | font-weight: 600; 42 | font-size: 16px; 43 | display: inline-block; 44 | margin: 0 10px 0 0; 45 | 46 | em { 47 | background: rgba(#F5A700, 0.2); 48 | font-style: normal; 49 | font-weight: 800; 50 | padding: 2px; 51 | } 52 | } 53 | } 54 | 55 | &__meta { 56 | display: flex; 57 | align-items: center; 58 | 59 | &__tags { 60 | display: flex; 61 | align-items: center; 62 | } 63 | 64 | &__tag { 65 | padding-right: .5rem; 66 | font-weight: 600; 67 | color: #333742; 68 | 69 | &:after { 70 | content: '•'; 71 | padding-left: .5rem; 72 | color: #C2C3C6; 73 | } 74 | } 75 | } 76 | 77 | &__content { 78 | padding: 8px 0 0; 79 | font-size: 13px; 80 | line-height: 16px; 81 | color: #69707D; 82 | 83 | &__url { 84 | width: 100%; 85 | text-overflow: ellipsis; 86 | white-space: nowrap; 87 | overflow: hidden; 88 | 89 | a { 90 | color: #017D73; 91 | font-weight: 500; 92 | } 93 | } 94 | 95 | &__text { 96 | display: -webkit-box; 97 | -webkit-line-clamp: 2; 98 | -webkit-box-orient: vertical; 99 | overflow: hidden; 100 | text-overflow: ellipsis; 101 | margin: 13px 0 0 0; 102 | line-height: 1.45; 103 | 104 | em { 105 | background: rgba(#F5A700, 0.1); 106 | color: black; 107 | font-style: normal; 108 | font-weight: 600; 109 | padding: 2px; 110 | } 111 | } 112 | 113 | b { 114 | color: #017D73; 115 | } 116 | } 117 | } 118 | 119 | .search-container { 120 | 121 | &__search-result-layout__list { 122 | li { 123 | + li { 124 | border-top: 1px solid #F5F7FA; 125 | } 126 | } 127 | 128 | &__result { 129 | @include search-result; 130 | margin: 0; 131 | padding: 1.25rem 0.5rem; 132 | 133 | &__title__text { 134 | font-size: 21px; 135 | a:hover { 136 | color: #006DE4; 137 | } 138 | } 139 | } 140 | } 141 | 142 | &__autocomplete { 143 | [aria-selected=true] { 144 | background: rgba(#006DE4, 0.10); 145 | } 146 | 147 | &__result { 148 | @include search-result; 149 | padding: 16px 32px; 150 | color: black; 151 | text-decoration: none; 152 | display: block; 153 | 154 | &:not(last-child) { 155 | border-bottom: 1px solid #D3DAE6; 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Result/ResultView.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | 22 | import './Result.scss'; 23 | 24 | const productIconClassName = ({ result }) => { 25 | const { product_name: productName } = result; 26 | return `product-icon ${productName ? `product-icon__${productName.raw.replace(/\s+/g, '-').toLowerCase()}` : ''}` 27 | } 28 | 29 | const ResultLink = ({ result, ...props }) => { 30 | const { title: { raw: title }, url: { raw: url } } = result 31 | return 32 | {props.children} 33 | 34 | } 35 | 36 | const getResultTitle = ({ result, className, onClickLink }) => { 37 | const { 38 | title: { snippet: title, raw: rawTitle }, 39 | website_area: { raw: resultType } 40 | } = result 41 | 42 | return
    43 | {resultType === 'documentation' &&
    } 44 |
    45 | {title && } 46 | {title === undefined && {rawTitle}} 47 |
    48 |
    49 | } 50 | 51 | const getResultContent = ({ result, className, onClickLink }) => { 52 | const { 53 | url: { raw: url }, 54 | website_area: { raw: resultType }, 55 | body: { snippet: body, raw: rawBody }, 56 | author 57 | } = result 58 | return
    59 |
    60 |
    61 |
    {resultType === 'documentation' ? 'Documentation' : 'Discussion'}
    62 |
    63 | {
    64 | {url} 65 |
    } 66 |
    67 | 68 | {body &&

    } 69 | {body === undefined &&

    70 | {rawBody} 71 |

    } 72 | {resultType === 'discuss' &&
    73 | Posted {author && author.raw && <>by {author.raw}} 74 |
    } 75 |
    76 | } 77 | 78 | const ResultView = ({className, result, ...props}) =>
    79 |
    80 | {getResultTitle({ result, className, ...props })} 81 | {getResultContent({ result, className, ...props })} 82 |
    83 |
    84 | 85 | export default ResultView; 86 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/Result/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | export { default as ResultView } from './ResultView'; 21 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/components/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | export { PageTypeFacet, ProductFacet } from './Facets'; 21 | export { ResultView } from './Result'; 22 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/arrow-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/src/Search/images/arrow-icon.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/background-home.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/background-search-result.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/elastic-stack.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-auditbeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-auditbeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-filebeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-filebeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-function-beat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-function-beat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-heartbeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-heartbeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-language-clients-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-language-clients-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-logging-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-machine-learning-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-machine-learning-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-metricbeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-metricbeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-packetbeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-packetbeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/icon-winlogbeat-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-winlogbeat-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-apm-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / amp / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-app-search-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / app-search / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-beats-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / beats / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-cloud-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / cloud / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-ece-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / ece / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-eck-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-elasticsearch-color-64.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / elastic sesrch / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-endpoint-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-kibana-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / stack / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-logging-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / logging / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-logstash-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / logstash / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-metrics-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / metrics / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-siem-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-site-search-32-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 32x32px / site-search / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-uptime-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon / product-logo / 64x64px / uptime / color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/products-icons/logo-workplace-search-64-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | logo-workplace-64-color 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/search-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/app-search-kb-demo/aa32ccea1e5c2192aa60582e77379fb146bc5a09/eas-kb-demo-frontend/src/Search/images/search-icon.png -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/images/search-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | export { default as SearchContainer } from './SearchContainer'; 21 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/stylesheets/ProductIcons.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .product-icon { 21 | width: 16px; 22 | height: 16px; 23 | display: inline-block; 24 | background-position: center; 25 | background-size: cover; 26 | 27 | &__apm { 28 | background-image: url(../images/products-icons/logo-apm-64-color.svg); 29 | } 30 | 31 | &__app-search { 32 | background-image: url(../images/products-icons/logo-app-search-64-color.svg); 33 | } 34 | 35 | &__metricbeat { 36 | background-image: url(../images/products-icons/icon-metricbeat-64-color.svg); 37 | } 38 | 39 | &__filebeat { 40 | background-image: url(../images/products-icons/icon-filebeat-64-color.svg); 41 | } 42 | 43 | &__packetbeat { 44 | background-image: url(../images/products-icons/icon-packetbeat-64-color.svg); 45 | } 46 | 47 | &__libbeat { 48 | background-image: url(../images/products-icons/logo-beats-64-color.svg); 49 | } 50 | 51 | &__auditbeat { 52 | background-image: url(../images/products-icons/icon-auditbeat-64-color.svg); 53 | } 54 | 55 | &__heartbeat { 56 | background-image: url(../images/products-icons/icon-heartbeat-64-color.svg); 57 | } 58 | 59 | &__winlogbeat { 60 | background-image: url(../images/products-icons/icon-winlogbeat-64-color.svg); 61 | } 62 | 63 | &__journalbeat { 64 | background-image: url(../images/products-icons/logo-beats-64-color.svg); 65 | } 66 | 67 | &__functionbeat { 68 | background-image: url(../images/products-icons/icon-function-beat-64-color.svg); 69 | } 70 | 71 | &__beats { 72 | background-image: url(../images/products-icons/logo-beats-64-color.svg); 73 | } 74 | 75 | &__cloud, 76 | &__elastic-cloud { 77 | background-image: url(../images/products-icons/logo-cloud-64-color.svg); 78 | } 79 | 80 | &__ece, 81 | &__cloud-ece, 82 | &__elastic-cloud-enterprise { 83 | background-image: url(../images/products-icons/logo-ece-64-color.svg); 84 | } 85 | 86 | &__eck, 87 | &__elastic-cloud-on-kubernetes, 88 | &__elastic-cloud-kubernetes { 89 | background-image: url(../images/products-icons/logo-eck-64-color.svg); 90 | } 91 | 92 | &__elasticsearch { 93 | background-image: url(../images/products-icons/logo-elasticsearch-color-64.svg); 94 | } 95 | 96 | &__elastic-stack { 97 | background-image: url(../images/products-icons/elastic-stack.svg); 98 | } 99 | 100 | &__endpoint-security { 101 | background-image: url(../images/products-icons/logo-endpoint-64-color.svg); 102 | } 103 | 104 | &__kibana { 105 | background-image: url(../images/products-icons/logo-kibana-64-color.svg); 106 | } 107 | 108 | &__logging { 109 | background-image: url(../images/products-icons/logo-logging-64-color.svg); 110 | } 111 | 112 | &__logstash { 113 | background-image: url(../images/products-icons/logo-logstash-64-color.svg); 114 | } 115 | 116 | &__metrics { 117 | background-image: url(../images/products-icons/logo-metrics-64-color.svg); 118 | } 119 | 120 | &__siem { 121 | background-image: url(../images/products-icons/logo-siem-64-color.svg); 122 | } 123 | 124 | &__site-search { 125 | background-image: url(../images/products-icons/logo-site-search-32-color.svg); 126 | } 127 | 128 | &__uptime { 129 | background-image: url(../images/products-icons/logo-uptime-64-color.svg); 130 | } 131 | 132 | &__workplace-search { 133 | background-image: url(../images/products-icons/logo-workplace-search-64-color.svg); 134 | } 135 | 136 | &__clients { 137 | background-image: url(../images/products-icons/icon-language-clients-64-color.svg); 138 | } 139 | 140 | &__machine-learning { 141 | background-image: url(../images/products-icons/icon-machine-learning-64-color.svg); 142 | } 143 | 144 | &__elastic-logging-plugin, 145 | &__logs { 146 | background-image: url(../images/products-icons/icon-logging-64-color.svg); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/stylesheets/Search.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .search-container { 21 | 22 | @import 'SearchUIComponents.scss'; 23 | @import 'ProductIcons.scss'; 24 | 25 | $searchContainerClass: &; 26 | 27 | top: 84px; 28 | width: 100%; 29 | display: flex; 30 | align-items: center; 31 | justify-content: center; 32 | flex-direction: column; 33 | flex: 1; 34 | 35 | &-home { 36 | flex: 1 1 auto; 37 | max-height: 736px; 38 | min-height: 500px; 39 | background: #1B1C20 center url(../images/background-home.svg) no-repeat; 40 | margin: 0 0 -80px; 41 | 42 | #{$searchContainerClass}__search-box-wrapper { 43 | max-width: 736px; 44 | width: 100%; 45 | } 46 | 47 | &__title { 48 | color: #FFFFFF; 49 | max-width: 736px; 50 | margin: 0 auto; 51 | 52 | h1 { 53 | font-style: normal; 54 | font-weight: 600; 55 | font-size: 40px; 56 | line-height: 48px; 57 | text-align: center; 58 | margin: 19px auto; 59 | } 60 | 61 | p { 62 | font-style: normal; 63 | font-weight: normal; 64 | font-size: 16px; 65 | line-height: 19px; 66 | text-align: center; 67 | } 68 | } 69 | } 70 | 71 | &-results { 72 | #{$searchContainerClass}__search-box-wrapper { 73 | margin: 0 0 -150px; 74 | height: 317px; 75 | padding: 22px 0 0; 76 | width: calc(100%); 77 | background: #1B1C20 center url(../images/background-search-result.svg) no-repeat; 78 | } 79 | } 80 | 81 | &__search-result-layout { 82 | width: 100%; 83 | max-width: 1108px; 84 | margin: 20px 0 66px; 85 | background: #FFFFFF; 86 | box-shadow: 0px 2.76726px 2.21381px rgba(0, 0, 0, 0.00843437), 0px 6.6501px 5.32008px rgba(0, 0, 0, 0.0121168), 0px 12.5216px 10.0172px rgba(0, 0, 0, 0.015), 0px 22.3363px 17.869px rgba(0, 0, 0, 0.0178832), 0px 41.7776px 33.4221px rgba(0, 0, 0, 0.0215656), 0px 100px 80px rgba(0, 0, 0, 0.03); 87 | display: flex; 88 | flex: 1; 89 | 90 | &__sidebar { 91 | margin: 25px 0 25px 35px; 92 | width: 240px; 93 | flex: none; 94 | } 95 | 96 | &__main { 97 | margin: 25px 35px 25px; 98 | max-width: calc(100% - 345px); 99 | flex: 1; 100 | 101 | &__loading { 102 | width: calc(100%); 103 | height: calc(100%); 104 | max-height: 400px; 105 | max-width: 400px; 106 | margin: 0px auto; 107 | min-height: 300px; 108 | background: white; 109 | } 110 | 111 | &__search-box-wrapper { 112 | form { 113 | width: 100%; 114 | } 115 | } 116 | } 117 | 118 | &__list { 119 | list-style-type: none; 120 | padding: 0; 121 | } 122 | } 123 | 124 | &__autocomplete { 125 | width: calc(100% - 40px); 126 | margin: 1px auto 0; 127 | max-width: 696px; 128 | position: absolute; 129 | background: #FFF; 130 | box-shadow: 0px 2.76726px 2.21381px rgba(0, 0, 0, 0.00843437), 0px 6.6501px 5.32008px rgba(0, 0, 0, 0.0121168), 0px 12.5216px 10.0172px rgba(0, 0, 0, 0.015), 0px 22.3363px 17.869px rgba(0, 0, 0, 0.0178832), 0px 41.7776px 33.4221px rgba(0, 0, 0, 0.0215656), 0px 100px 80px rgba(0, 0, 0, 0.03); 131 | 132 | &> div { 133 | width: calc(100%); 134 | } 135 | } 136 | } 137 | 138 | @media screen and (max-width: 768px) { 139 | .search-container { 140 | 141 | $searchContainerClass: &; 142 | 143 | &__search-result-layout { 144 | margin: 20px 0; 145 | &__sidebar { 146 | display: none; 147 | } 148 | 149 | &__main { 150 | margin: 25px 25px; 151 | width: calc(100% - 50px); 152 | max-width: none; 153 | } 154 | } 155 | 156 | &-home { 157 | margin: 0; 158 | min-height: auto; 159 | 160 | #{$searchContainerClass}__search-box-wrapper { 161 | form[aria-expanded=true] { 162 | position: absolute; 163 | top: 84px; 164 | left: 0px; 165 | width: calc(100%); 166 | height: calc(100vh - 84px); 167 | background: rgba(black, 0.3); 168 | } 169 | } 170 | } 171 | 172 | &__autocomplete { 173 | min-width: calc(100% - 46px); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/Search/stylesheets/SearchUIComponents.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .sui-search-box { 21 | width: calc(100% - 40px); 22 | margin: 41px auto; 23 | max-width: 722px; 24 | 25 | &__text-input { 26 | width: calc(100% - 56px); 27 | line-height: 25px; 28 | background: rgba(white, 0.95); 29 | padding: 22px 28px; 30 | box-shadow: 0px 0.815184px 1.81152px rgba(0, 0, 0, 0.0592299), 0px 2.25388px 5.00862px rgba(0, 0, 0, 0.085), 0px 5.42647px 12.0588px rgba(0, 0, 0, 0.11077), 0px 18px 40px rgba(0, 0, 0, 0.17); 31 | font-style: normal; 32 | font-weight: normal; 33 | font-size: 21px; 34 | line-height: 26px; 35 | border: none; 36 | transition: all 0.2s ease; 37 | 38 | &:focus { 39 | outline: none; 40 | background: white; 41 | box-shadow: 42 | 0px 0.815184px 1.81152px rgba(0, 0, 0, 0.0992), 43 | 0px 2.25388px 5.00862px rgba(0, 0, 0, 0.125), 44 | 0px 10.43px 22.06px rgba(0, 0, 0, 0.1508), 45 | 0px 28px 60px rgba(0, 0, 0, 0.22); 46 | } 47 | 48 | &::placeholder { 49 | color: #98A2B3; 50 | } 51 | } 52 | 53 | &__submit { 54 | float: right; 55 | position: relative; 56 | margin: -51px 20px; 57 | background: transparent url(../images/search-icon.svg); 58 | border: none; 59 | color: transparent; 60 | width: 32px; 61 | height: 32px; 62 | cursor: pointer; 63 | 64 | &:focus { 65 | outline:none; 66 | } 67 | } 68 | } 69 | 70 | .sui-paging-info { 71 | font-style: normal; 72 | font-weight: normal; 73 | font-size: 12px; 74 | line-height: 15px; 75 | border-bottom: 1px solid #D3DAE6; 76 | padding: 0 0 13px; 77 | 78 | em { 79 | font-weight: bold; 80 | font-style: normal; 81 | color: #343741; 82 | } 83 | } 84 | 85 | .sui-paging { 86 | text-align: center; 87 | font-style: normal; 88 | font-weight: normal; 89 | font-size: 14px; 90 | padding: 30px 0 22px; 91 | border-top: 1px solid #D3DAE6; 92 | display: flex; 93 | align-items: center; 94 | justify-content: center; 95 | 96 | & > li { 97 | display: inline-block; 98 | text-align: center; 99 | padding: 0px 2px; 100 | cursor: pointer; 101 | margin: 0 4px; 102 | outline: none; 103 | line-height: 24px; 104 | 105 | &.rc-pagination-jump-next, &.rc-pagination-jump-prev { 106 | .rc-pagination-item-link:after { 107 | content: '...' 108 | } 109 | } 110 | 111 | &.rc-pagination-prev, &.rc-pagination-next { 112 | height: 24px; 113 | width: 4px; 114 | background: no-repeat center url(../images/arrow-icon.png); 115 | &.rc-pagination-prev { 116 | transform: rotate(180deg); 117 | margin: 0 6px 0 4px; 118 | } 119 | 120 | &[aria-disabled=true] { 121 | opacity: 0.3; 122 | cursor: default; 123 | } 124 | } 125 | 126 | &.rc-pagination-item-active a { 127 | font-weight: bold; 128 | text-decoration: underline; 129 | color: #006BB4; 130 | } 131 | 132 | a, a:active, a:hover, a:focus { 133 | outline: 0; 134 | outline-offset: 0; 135 | box-shadow: none; 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /eas-kb-demo-frontend/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch B.V. under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch B.V. licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import React from 'react'; 21 | import ReactDOM from 'react-dom'; 22 | import App from './App/'; 23 | 24 | ReactDOM.render(, document.getElementById('root')); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": [ 4 | "eas-kb-demo-dataimport", 5 | "eas-kb-demo-frontend" 6 | ], 7 | "scripts": { 8 | "start": "yarn workspace eas-kb-demo-frontend start", 9 | "build": "yarn workspace eas-kb-demo-frontend build", 10 | "test": "yarn workspace eas-kb-demo-frontend test", 11 | "lint": "yarn workspaces run lint", 12 | "dataimport": "yarn workspace eas-kb-demo-dataimport dataimport", 13 | "cypress": "yarn workspace eas-kb-demo-frontend run cypress" 14 | }, 15 | "dependencies": { 16 | "husky": "^4.2.5", 17 | "yarn-workspace-isolator": "^0.1.0-rc1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /scripts/retrieve-credentials.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | function wait_for_as { 6 | local AS_BASE_URL=${AS_BASE_URL:-"http://localhost:3002"} 7 | local continue=1 8 | set +e 9 | while [ $continue -gt 0 ]; do 10 | curl --connect-timeout 5 --max-time 10 --retry 10 --retry-delay 0 --retry-max-time 120 --retry-connrefuse -s -o /dev/null ${AS_BASE_URL}/login 11 | continue=$? 12 | if [ $continue -gt 0 ]; then 13 | sleep 1 14 | fi 15 | done 16 | } 17 | 18 | function load_api_keys { 19 | local AS_USERNAME=${AS_USERNAME:-"enterprise_search"} 20 | local AS_PASSWORD=${AS_PASSWORD:-"password"} 21 | local AS_BASE_URL=${AS_BASE_URL:-"http://localhost:3002"} 22 | local SEARCH_URL="${AS_BASE_URL}/as/credentials/collection?page%5Bcurrent%5D=1" 23 | echo $(curl -u${AS_USERNAME}:${AS_PASSWORD} -s ${SEARCH_URL} | sed -E "s/.*(${1}-[[:alnum:]]{24}).*/\1/") 24 | } 25 | 26 | echo "Waiting for App Search to be started..." 27 | wait_for_as 28 | 29 | echo "Connected to App Search." 30 | export AS_BASE_URL=${AS_BASE_URL:-"http://localhost:3002"} 31 | 32 | echo "Retrieve Search API key ..." 33 | export AS_PRIVATE_API_KEY=`load_api_keys private` 34 | 35 | echo "Retrieve Private API key ..." 36 | export AS_SEARCH_API_KEY=`load_api_keys search` 37 | 38 | unset -f load_api_keys 39 | -------------------------------------------------------------------------------- /scripts/start-dataimport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ -z "${AS_BASE_URL}" ]]; then 6 | echo "The environment variable AS_BASE_URL must be set to start the container." 7 | exit 1 8 | fi 9 | 10 | if [[ -z "${AS_PRIVATE_API_KEY}" ]]; then 11 | if [[ -z "${AS_USERNAME}" ]] || [[ -z "${AS_PASSWORD}" ]]; then 12 | echo "The environment variable AS_SEARCH_API_KEY must be set to start the container." 13 | exit 1; 14 | fi 15 | source /usr/local/bin/retrieve-credentials.sh 16 | 17 | if [[ -z "${AS_PRIVATE_API_KEY}" ]]; then 18 | echo "Unable to retrieve App Search credentials." 19 | exit 1; 20 | fi 21 | fi 22 | 23 | yarn dataimport 24 | -------------------------------------------------------------------------------- /scripts/start-frontend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ -z "${AS_BASE_URL}" ]]; then 6 | echo "The environment variable AS_BASE_URL must be set to start the container." 7 | exit 1 8 | fi 9 | 10 | if [[ -z "${AS_SEARCH_API_KEY}" ]]; then 11 | if [[ -z "${AS_USERNAME}" ]] || [[ -z "${AS_PASSWORD}" ]]; then 12 | echo "The environment variable AS_SEARCH_API_KEY must be set to start the container." 13 | exit 1; 14 | fi 15 | source /usr/local/bin/retrieve-credentials.sh 16 | 17 | if [[ -z "${AS_SEARCH_API_KEY}" ]]; then 18 | echo "Unable to retrieve App Search credentials." 19 | exit 1; 20 | fi 21 | fi 22 | 23 | echo AS_BASE_URL=$AS_SEARCH_API_KEY >> .env 24 | echo AS_SEARCH_API_KEY=$AS_SEARCH_API_KEY >> .env 25 | 26 | /usr/local/bin/env.sh 27 | 28 | exec serve -s 29 | --------------------------------------------------------------------------------