Skip to content

Commit 9aaeb18

Browse files
committed
Perform the search and show the results (#455)
1 parent 03f8d81 commit 9aaeb18

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

frontend/src/aspects/exploration.ts

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import mainRouter from '../global/main-router';
77
import explorer from '../global/explorer-view';
88
import controller from '../global/explorer-controller';
99
import welcomeView from '../global/welcome-view';
10+
import semanticSearchView from '../global/semantic-search';
1011
import SuggestionsPanel from '../panel-suggestions/suggestions-view';
1112
import deparam from '../utilities/deparam';
1213

@@ -89,5 +90,8 @@ channel.on('currentRoute', (route, panel) => {
8990
// panel.
9091
browserHistory.replaceState(panel.cid, document.title);
9192
});
93+
9294
welcomeView.on({'search:start': controller.resetSourceListFromSearchResults}, controller);
9395
welcomeView.on({'suggestions:show': controller.showSuggestionsPanel}, controller);
96+
97+
semanticSearchView.on('search', controller.resetSemanticSearch, controller);

frontend/src/aspects/navigation.ts

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import explorationRouter from '../global/exploration-router';
1212
import userFsm from '../global/user-fsm';
1313
import explorerView from '../global/explorer-view';
1414
import notFoundView from '../global/notfound-view';
15+
import semanticSearchView from '../global/semantic-search';
1516

1617
history.once('route notfound', () => {
1718
menuView.render().$el.appendTo('#header');
@@ -54,5 +55,8 @@ userFsm.on('exit:lost', () => notFoundView.$el.detach());
5455
menuView.on('feedback', () => feedbackView.render().$el.appendTo('body'));
5556

5657
feedbackView.on('close', () => feedbackView.$el.detach());
58+
5759
welcomeView.on('search:start', () => userFsm.handle('explore'));
5860
welcomeView.on('suggestions:show', () => userFsm.handle('explore'));
61+
62+
semanticSearchView.on('search', () => userFsm.handle('explore'));

frontend/src/explorer/explorer-event-controller.ts

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
isOntologyClass,
3737
} from '../utilities/linked-data-utilities';
3838
import { itemsForSourceQuery } from '../sparql/compile-query';
39+
import modelToQuery from '../semantic-search/modelToQuery';
3940

4041
interface ExplorerEventController extends Events {}
4142
class ExplorerEventController {
@@ -90,6 +91,19 @@ class ExplorerEventController {
9091
this.explorerView.reset(sourceListPanel);
9192
}
9293

94+
resetSemanticSearch(model: Model): SearchResultListView {
95+
const query = modelToQuery(model);
96+
const items = new ItemGraph();
97+
items.sparqlQuery(query);
98+
const collection = new FlatItemCollection(items);
99+
const resultsView = new SearchResultListView({
100+
collection,
101+
selectable: false,
102+
});
103+
this.explorerView.reset(resultsView);
104+
return resultsView;
105+
}
106+
93107
showSuggestionsPanel() {
94108
const suggestionsView = new SuggestionsView();
95109
this.explorerView.reset(suggestionsView);

frontend/src/explorer/route-patterns.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export default {
1111
'item:external:edit': 'explore/item/:serial/external/edit',
1212
'item:annotations': 'explore/item/:serial/annotations',
1313
'search:results:sources': 'explore/sources?*queryParams',
14+
'search:results:semantic': 'explore/query',
1415
};

0 commit comments

Comments
 (0)