Skip to content

Commit

Permalink
Perform the search and show the results (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed May 31, 2021
1 parent 03f8d81 commit 9aaeb18
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/aspects/exploration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
4 changes: 4 additions & 0 deletions frontend/src/aspects/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'));
14 changes: 14 additions & 0 deletions frontend/src/explorer/explorer-event-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/explorer/route-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

0 comments on commit 9aaeb18

Please sign in to comment.