From 9aaeb18c049bf5a9e935559c69993e3088a6900f Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Mon, 31 May 2021 03:42:50 +0200 Subject: [PATCH] Perform the search and show the results (#455) --- frontend/src/aspects/exploration.ts | 4 ++++ frontend/src/aspects/navigation.ts | 4 ++++ frontend/src/explorer/explorer-event-controller.ts | 14 ++++++++++++++ frontend/src/explorer/route-patterns.ts | 1 + 4 files changed, 23 insertions(+) diff --git a/frontend/src/aspects/exploration.ts b/frontend/src/aspects/exploration.ts index 99989120d..38b8649a0 100644 --- a/frontend/src/aspects/exploration.ts +++ b/frontend/src/aspects/exploration.ts @@ -7,6 +7,7 @@ import mainRouter from '../global/main-router'; import explorer from '../global/explorer-view'; import controller from '../global/explorer-controller'; import welcomeView from '../global/welcome-view'; +import semanticSearchView from '../global/semantic-search'; import SuggestionsPanel from '../panel-suggestions/suggestions-view'; import deparam from '../utilities/deparam'; @@ -89,5 +90,8 @@ channel.on('currentRoute', (route, panel) => { // panel. browserHistory.replaceState(panel.cid, document.title); }); + welcomeView.on({'search:start': controller.resetSourceListFromSearchResults}, controller); welcomeView.on({'suggestions:show': controller.showSuggestionsPanel}, controller); + +semanticSearchView.on('search', controller.resetSemanticSearch, controller); diff --git a/frontend/src/aspects/navigation.ts b/frontend/src/aspects/navigation.ts index c6dc15411..e20d61bf8 100644 --- a/frontend/src/aspects/navigation.ts +++ b/frontend/src/aspects/navigation.ts @@ -12,6 +12,7 @@ import explorationRouter from '../global/exploration-router'; import userFsm from '../global/user-fsm'; import explorerView from '../global/explorer-view'; import notFoundView from '../global/notfound-view'; +import semanticSearchView from '../global/semantic-search'; history.once('route notfound', () => { menuView.render().$el.appendTo('#header'); @@ -54,5 +55,8 @@ userFsm.on('exit:lost', () => notFoundView.$el.detach()); menuView.on('feedback', () => feedbackView.render().$el.appendTo('body')); feedbackView.on('close', () => feedbackView.$el.detach()); + welcomeView.on('search:start', () => userFsm.handle('explore')); welcomeView.on('suggestions:show', () => userFsm.handle('explore')); + +semanticSearchView.on('search', () => userFsm.handle('explore')); diff --git a/frontend/src/explorer/explorer-event-controller.ts b/frontend/src/explorer/explorer-event-controller.ts index fb1374780..a770d7a54 100644 --- a/frontend/src/explorer/explorer-event-controller.ts +++ b/frontend/src/explorer/explorer-event-controller.ts @@ -36,6 +36,7 @@ import { isOntologyClass, } from '../utilities/linked-data-utilities'; import { itemsForSourceQuery } from '../sparql/compile-query'; +import modelToQuery from '../semantic-search/modelToQuery'; interface ExplorerEventController extends Events {} class ExplorerEventController { @@ -90,6 +91,19 @@ class ExplorerEventController { this.explorerView.reset(sourceListPanel); } + resetSemanticSearch(model: Model): SearchResultListView { + const query = modelToQuery(model); + const items = new ItemGraph(); + items.sparqlQuery(query); + const collection = new FlatItemCollection(items); + const resultsView = new SearchResultListView({ + collection, + selectable: false, + }); + this.explorerView.reset(resultsView); + return resultsView; + } + showSuggestionsPanel() { const suggestionsView = new SuggestionsView(); this.explorerView.reset(suggestionsView); diff --git a/frontend/src/explorer/route-patterns.ts b/frontend/src/explorer/route-patterns.ts index 7cbee016a..ea6831153 100644 --- a/frontend/src/explorer/route-patterns.ts +++ b/frontend/src/explorer/route-patterns.ts @@ -11,4 +11,5 @@ export default { 'item:external:edit': 'explore/item/:serial/external/edit', 'item:annotations': 'explore/item/:serial/annotations', 'search:results:sources': 'explore/sources?*queryParams', + 'search:results:semantic': 'explore/query', };