aboutsummaryrefslogtreecommitdiff
path: root/javascript/app
diff options
context:
space:
mode:
authoralexwl <alexey.a.kiryushin@gmail.com>2019-02-06 21:42:29 +0300
committeralexwl <alexey.a.kiryushin@gmail.com>2019-02-06 21:42:29 +0300
commitd6a64db1ced3d3577886a7aec140a5174cbceb48 (patch)
tree88a6535043547da7093c126df642770533a4ab71 /javascript/app
parentb796d370c6b7ec7452a37440b089fd45853a47f4 (diff)
Add identifier search in all indexed packages
Diffstat (limited to 'javascript/app')
-rw-r--r--javascript/app/controllers/packages.js19
-rw-r--r--javascript/app/controllers/search.js28
-rw-r--r--javascript/app/router.js5
-rw-r--r--javascript/app/routes/packages.js3
-rw-r--r--javascript/app/routes/search.js42
-rw-r--r--javascript/app/styles/app.scss14
-rw-r--r--javascript/app/templates/components/input-with-autocomplete.hbs2
-rw-r--r--javascript/app/templates/package.hbs3
-rw-r--r--javascript/app/templates/package/search.hbs6
-rw-r--r--javascript/app/templates/packages.hbs24
-rw-r--r--javascript/app/templates/search.hbs46
-rw-r--r--javascript/app/utils/api-urls.js3
12 files changed, 185 insertions, 10 deletions
diff --git a/javascript/app/controllers/packages.js b/javascript/app/controllers/packages.js
index a1724dd..614ecd8 100644
--- a/javascript/app/controllers/packages.js
+++ b/javascript/app/controllers/packages.js
@@ -1,4 +1,6 @@
import Ember from 'ember';
+import {goToDefinition} from '../utils/go-to-definition';
+
export default Ember.Controller.extend({
queryObserver : Ember.observer("query",function() {
Ember.run.debounce(this, () => {
@@ -8,5 +10,20 @@ export default Ember.Controller.extend({
this.set('packages',packages);
});
}, 300);
- })
+ }),
+ actions: {
+ searchIdentifier (query) {
+ if(query) {
+ document.title = "Haskell code explorer";
+ this.transitionToRoute('search',query);
+ }
+ },
+ showIdentifier (identifierInfo) {
+ goToDefinition(this.get('store'),
+ identifierInfo.locationInfo,
+ 1,//left mouse button
+ null);
+ return false;
+ }
+ }
});
diff --git a/javascript/app/controllers/search.js b/javascript/app/controllers/search.js
new file mode 100644
index 0000000..5d77770
--- /dev/null
+++ b/javascript/app/controllers/search.js
@@ -0,0 +1,28 @@
+import Ember from 'ember';
+import {goToDefinition} from '../utils/go-to-definition';
+
+export default Ember.Controller.extend({
+ store : Ember.inject.service('store'),
+ actions : {
+ goToDefinition (locationInfo,event) {
+ goToDefinition(this.get('store'),
+ locationInfo,
+ event.which,
+ null);
+ return false;
+ },
+ searchIdentifier (query) {
+ if(query) {
+ document.title = "Haskell code explorer";
+ this.transitionToRoute('search',query);
+ }
+ },
+ showIdentifier (identifierInfo) {
+ goToDefinition(this.get('store'),
+ identifierInfo.locationInfo,
+ 1,//left mouse button
+ null);
+ return false;
+ }
+ }
+});
diff --git a/javascript/app/router.js b/javascript/app/router.js
index f58e9ab..7fce17a 100644
--- a/javascript/app/router.js
+++ b/javascript/app/router.js
@@ -7,14 +7,15 @@ var Router = Ember.Router.extend({
Router.map(function() {
this.route('packages',{path:''});
+ this.route('search',{path:'/search/:query'});
this.route('package', {path:'/package/:packageId'}, function() {
this.route('show',function() {
this.route('file', {path:'*filePath'}, function() {
});
});
this.route('search',{path:'/search/:query'});
- });
- this.route('bad-url', { path: '/*badurl' });
+ });
+ this.route('bad-url', { path: '/*badurl' });
});
export default Router;
diff --git a/javascript/app/routes/packages.js b/javascript/app/routes/packages.js
index 2bbf9bc..34a454d 100644
--- a/javascript/app/routes/packages.js
+++ b/javascript/app/routes/packages.js
@@ -9,6 +9,9 @@ export default Ember.Route.extend({
setupController(controller, model) {
this._super(controller, model);
controller.set('packages',model);
+ controller.set('createSearchUrlFunction',(query) => {
+ return urls.globalIdentifiersUrl(query);
+ });
},
afterModel () {
document.title = config.APP.title;
diff --git a/javascript/app/routes/search.js b/javascript/app/routes/search.js
new file mode 100644
index 0000000..c181c2f
--- /dev/null
+++ b/javascript/app/routes/search.js
@@ -0,0 +1,42 @@
+import Ember from 'ember';
+import {urls} from '../utils/api-urls';
+import {goToDefinition} from '../utils/go-to-definition';
+
+export default Ember.Route.extend({
+ store : Ember.inject.service('store'),
+ model (params) {
+ return {
+ query: params.query,
+ url: urls.globalIdentifiersUrl(params.query)+"?per_page=20"
+ };
+ },
+ setupController(controller, model) {
+ this._super(controller, model);
+ controller.set('createSearchUrlFunction',(query) => {
+ return urls.globalIdentifiersUrl(query);
+ });
+ },
+ afterModel () {
+ const onmouseup = (event) => {
+ // This makes links in documentation clickable
+ if(event.target.dataset.location) {
+ let location;
+ try {
+ location = JSON.parse(event.target.dataset.location);
+ } catch (e) {
+ console.log(e);
+ }
+ if(location) {
+ goToDefinition(this.get('store'),location,event.which);
+ }
+ }
+ };
+ this._onmouseup = onmouseup;
+ document.addEventListener('mouseup',onmouseup);
+ },
+ deactivate() {
+ if(this._onmouseup) {
+ document.removeEventListener('mouseup',this._onmouseup);
+ }
+ }
+});
diff --git a/javascript/app/styles/app.scss b/javascript/app/styles/app.scss
index bca1dce..a6e322e 100644
--- a/javascript/app/styles/app.scss
+++ b/javascript/app/styles/app.scss
@@ -135,6 +135,11 @@ li {
margin-top:20px;
}
+.global-identifier-search-form {
+ max-width:500px;
+ margin-top:20px;
+}
+
.package-header-filename {
white-space: nowrap;
}
@@ -530,6 +535,14 @@ button {
right:0px;
}
+.global-search-results-content {
+ position:absolute;
+ top:80px;
+ bottom:0px;
+ left:0px;
+ right:0px;
+}
+
.search-result {
padding:5px;
}
@@ -557,6 +570,7 @@ button {
.identifier-menu-item {
margin-right:10px;
}
+
.references-packages {
position:absolute;
width:230px;
diff --git a/javascript/app/templates/components/input-with-autocomplete.hbs b/javascript/app/templates/components/input-with-autocomplete.hbs
index eb0100d..1a73c07 100644
--- a/javascript/app/templates/components/input-with-autocomplete.hbs
+++ b/javascript/app/templates/components/input-with-autocomplete.hbs
@@ -14,6 +14,6 @@
{{/if}}
</div>
<div class="input-group-append">
- <button id="search-input" class="btn btn-outline-secondary" {{action "onSubmit" query}}>Search</button>
+ <button id="search-input" class="btn btn-outline-secondary" {{action "onSubmit" query}}>{{searchButtonText}}</button>
</div>
</div>
diff --git a/javascript/app/templates/package.hbs b/javascript/app/templates/package.hbs
index 8c6d1a4..5f9fa68 100644
--- a/javascript/app/templates/package.hbs
+++ b/javascript/app/templates/package.hbs
@@ -7,6 +7,7 @@
createSearchUrlFunction=createSearchUrlFunction
maxItems=10
selectItem=(action 'showIdentifier')
+ searchButtonText="Search"
placeholder="Identifier" as |identifier|}}
<span class="source-code-font">{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span>
<div class="module-name">
@@ -31,7 +32,7 @@
</div>
{{/resizable-panel}}
<div id="right-panel" class="right-panel">
- <div id="file-container" class="file-container">
+ <div id="file-container" class="file-container">
{{outlet}}
</div>
{{#bottom-panel visible=bottomPanelVisible topPanelElementId="#file-container" containerElementId="#right-panel" as |section|}}
diff --git a/javascript/app/templates/package/search.hbs b/javascript/app/templates/package/search.hbs
index ebc4d52..37b3992 100644
--- a/javascript/app/templates/package/search.hbs
+++ b/javascript/app/templates/package/search.hbs
@@ -2,11 +2,11 @@
Query : {{model.query}}
</div>
<div class="search-results-content">
- {{#paginated-list url=model.url as |identifiers|}}
+ {{#paginated-list url=model.url as |identifiers|}}
<ul>
{{#each identifiers as |identifier|}}
- <li class="search-result">
- <span class="source-code" >{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span>
+ <li class="search-result">
+ <span class="source-code" ><b>{{identifier.demangledOccName}}</b> :: {{type-signature-text components=identifier.idType.components}}</span>
<div><a href="#" onmouseup={{action "goToDefinition" identifier.locationInfo}}>Go to definition</a></div>
<div class="identifier-module">
{{#if identifier.locationInfo.modulePath}}
diff --git a/javascript/app/templates/packages.hbs b/javascript/app/templates/packages.hbs
index 6dc4b7b..80464e6 100644
--- a/javascript/app/templates/packages.hbs
+++ b/javascript/app/templates/packages.hbs
@@ -1,6 +1,26 @@
<div class="flex-container container">
- <div>
- <!-- <p class="lead"><b>Haskell code explorer</b> </p> -->
+ <div>
+ <div class="global-identifier-search-form">
+ {{#input-with-autocomplete
+ onSubmit=(action 'searchIdentifier')
+ createSearchUrlFunction=createSearchUrlFunction
+ maxItems=10
+ selectItem=(action 'showIdentifier')
+ searchButtonText="Search in all packages"
+ placeholder="Haskell identifier" as |identifier|}}
+ <span class="source-code-font">{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span>
+ <div class="module-name">
+ <b>{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}</b>
+ {{#if identifier.locationInfo.modulePath}}
+ {{identifier.locationInfo.modulePath}}
+ {{else}}
+ {{identifier.locationInfo.moduleName}}
+ {{/if}}
+ </div>
+ {{/input-with-autocomplete}}
+ </div>
+ </div>
+ <div>
<div class="package-search-form">
{{input class="form-control" type="text" value=query placeholder="Package name"}}
<span>Number of packages : {{packages.length}}</span>
diff --git a/javascript/app/templates/search.hbs b/javascript/app/templates/search.hbs
new file mode 100644
index 0000000..343ce68
--- /dev/null
+++ b/javascript/app/templates/search.hbs
@@ -0,0 +1,46 @@
+<div class="flex-container container">
+ <div style="position:relative;height:100%">
+ <div class="absolute-container">
+ <div class="global-identifier-search-form">
+ {{#input-with-autocomplete
+ onSubmit=(action 'searchIdentifier')
+ createSearchUrlFunction=createSearchUrlFunction
+ maxItems=10
+ selectItem=(action 'showIdentifier')
+ searchButtonText="Search in all packages"
+ placeholder="Haskell identifier" as |identifier|}}
+ <span class="source-code-font">{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span>
+ <div class="module-name">
+ <b>{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}</b>
+ {{#if identifier.locationInfo.modulePath}}
+ {{identifier.locationInfo.modulePath}}
+ {{else}}
+ {{identifier.locationInfo.moduleName}}
+ {{/if}}
+ </div>
+ {{/input-with-autocomplete}}
+ </div>
+ <div>
+ Query : {{model.query}}
+ </div>
+ <div class="global-search-results-content">
+ {{#paginated-list url=model.url as |identifiers|}}
+ <ul>
+ {{#each identifiers as |identifier|}}
+ <li class="search-result">
+ <span class="source-code" ><b>{{identifier.demangledOccName}}</b> :: {{type-signature-text components=identifier.idType.components}}</span>
+ <div><a href="#" onmouseup={{action "goToDefinition" identifier.locationInfo}}>Go to definition</a></div>
+ <div class="identifier-module">
+ {{#if identifier.locationInfo.modulePath}}
+ Defined in <b> {{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}} </b> <a href="/package/{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}/show/{{identifier.locationInfo.modulePath}}">{{identifier.locationInfo.modulePath}}</a>
+ {{/if}}
+ </div>
+ <div>{{{identifier.doc}}}</div>
+ </li>
+ {{/each}}
+ </ul>
+ {{/paginated-list}}
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/javascript/app/utils/api-urls.js b/javascript/app/utils/api-urls.js
index 2eb2e7c..da8fdcb 100644
--- a/javascript/app/utils/api-urls.js
+++ b/javascript/app/utils/api-urls.js
@@ -28,5 +28,8 @@ export const urls = {
},
globalReferencesUrl : function (externalId) {
return config.APP.apiUrlPrefix + "/globalReferences/"+encodeURIComponent(externalId);
+ },
+ globalIdentifiersUrl : function (query) {
+ return config.APP.apiUrlPrefix + "/globalIdentifiers/"+encodeURIComponent(query).replace(/\./g, '%2E');
}
}