From 6f52cd6b07970010c40270003d63aa74f84f6ae9 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Wed, 27 Apr 2022 00:29:20 +1000
Subject: Use EOL vernacular-names data for searching

Add data/eolNamesToSqlite.py to read EOL vernacular-names data and add
to sqlite db.  Adjust server.py to handle search requests, and adjust
SearchModal to make them.
---
 src/components/SearchModal.vue | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/components/SearchModal.vue')

diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue
index f3bb237..cd4bede 100644
--- a/src/components/SearchModal.vue
+++ b/src/components/SearchModal.vue
@@ -20,17 +20,19 @@ export default defineComponent({
 			let input = this.$refs.searchInput as HTMLInputElement;
 			// Query server
 			let url = new URL(window.location.href);
-			url.pathname = '/data/node';
+			url.pathname = '/data/search';
 			url.search = '?name=' + encodeURIComponent(input.value);
 			fetch(url.toString())
-				.then(response => {
+				.then(response => response.json())
+				.then(tolNodeName => {
 					// Search successful. Get nodes in parent-chain, add to tolMap, then emit event.
 					url.pathname = '/data/chain';
+					url.search = '?name=' + encodeURIComponent(tolNodeName);
 					fetch(url.toString())
 						.then(response => response.json())
 						.then(obj => {
 							Object.getOwnPropertyNames(obj).forEach(key => {this.tolMap.set(key, obj[key])});
-							this.$emit('search-node', input.value);
+							this.$emit('search-node', tolNodeName);
 						})
 						.catch(error => {
 							console.log('ERROR loading tolnode chain', error);
-- 
cgit v1.2.3

