aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/routes
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/app/routes')
-rw-r--r--javascript/app/routes/application.js3
-rw-r--r--javascript/app/routes/package.js38
-rw-r--r--javascript/app/routes/package/index.js7
-rw-r--r--javascript/app/routes/package/search.js36
-rw-r--r--javascript/app/routes/package/show/file.js27
-rw-r--r--javascript/app/routes/package/show/index.js7
-rw-r--r--javascript/app/routes/packages.js16
7 files changed, 134 insertions, 0 deletions
diff --git a/javascript/app/routes/application.js b/javascript/app/routes/application.js
new file mode 100644
index 0000000..279bd32
--- /dev/null
+++ b/javascript/app/routes/application.js
@@ -0,0 +1,3 @@
+import Ember from 'ember';
+export default Ember.Route.extend({
+});
diff --git a/javascript/app/routes/package.js b/javascript/app/routes/package.js
new file mode 100644
index 0000000..92fea03
--- /dev/null
+++ b/javascript/app/routes/package.js
@@ -0,0 +1,38 @@
+import Ember from 'ember';
+import {urls} from '../utils/api-urls';
+
+export default Ember.Route.extend({
+ store : Ember.inject.service('store'),
+ model (params) {
+ return this.get('store').loadPackage(params.packageId)
+ .catch((e) => {console.log(e);this.transitionTo("/package-not-found");});
+ },
+ afterModel(model) {
+ document.title = model.id;
+ },
+ setupController(controller, model) {
+ this._super(controller, model);
+ const packageId = this.modelFor('package').id;
+ controller.set('bottomPanelVisible',false);
+ controller.set('createSearchUrlFunction',(query) => {
+ return urls.identifierSearchUrl(packageId,query);
+ });
+ },
+ actions : {
+ openFile (filePath) {
+ this.transitionTo('package.show.file',filePath);
+ },
+ fileOpened (filePath) {
+ if(this.get('controller')) {
+ this.set('controller.currentFile',filePath);
+ }
+ },
+ updateReferences(packageId,externalId,occName) {
+ this.set('controller.packageId',packageId);
+ this.set('controller.externalId',externalId);
+ this.set('controller.occName',occName);
+ this.set('controller.bottomPanelVisible',true);
+ this.set('controller.referencesUrl',urls.referencesUrl(packageId,externalId)+"?per_page=50");
+ }
+ }
+});
diff --git a/javascript/app/routes/package/index.js b/javascript/app/routes/package/index.js
new file mode 100644
index 0000000..e36abd5
--- /dev/null
+++ b/javascript/app/routes/package/index.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ afterModel : function (model,transition) {
+ transition.send("fileOpened",null);
+ }
+});
diff --git a/javascript/app/routes/package/search.js b/javascript/app/routes/package/search.js
new file mode 100644
index 0000000..7bc711b
--- /dev/null
+++ b/javascript/app/routes/package/search.js
@@ -0,0 +1,36 @@
+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.identifierSearchUrl(this.modelFor('package').id,params.query)+"?per_page=20"
+ };
+ },
+ 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/routes/package/show/file.js b/javascript/app/routes/package/show/file.js
new file mode 100644
index 0000000..ead6ee8
--- /dev/null
+++ b/javascript/app/routes/package/show/file.js
@@ -0,0 +1,27 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ store : Ember.inject.service(),
+ model : function (params) {
+ const packageInfo = this.modelFor('package');
+ if(packageInfo.modules[params.filePath]) {
+ return this.get('store').loadHaskellModule(packageInfo.id,params.filePath)
+ .catch((e) => {console.log(e);this.transitionTo("/not-found");});
+ } else {
+ return this.get('store').loadFile(packageInfo.id,params.filePath)
+ .then((result) => {
+ document.title = packageInfo.id;
+ return result;
+ })
+ .catch((e) => {console.log(e);this.transitionTo("/not-found");});
+ }
+ },
+ afterModel (model) {
+ document.title = model.id + " - " + this.modelFor('package').id;
+ },
+ actions : {
+ didTransition : function () {
+ this.send("fileOpened",this.currentModel.id);
+ }
+ }
+});
diff --git a/javascript/app/routes/package/show/index.js b/javascript/app/routes/package/show/index.js
new file mode 100644
index 0000000..e36abd5
--- /dev/null
+++ b/javascript/app/routes/package/show/index.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+ afterModel : function (model,transition) {
+ transition.send("fileOpened",null);
+ }
+});
diff --git a/javascript/app/routes/packages.js b/javascript/app/routes/packages.js
new file mode 100644
index 0000000..2bbf9bc
--- /dev/null
+++ b/javascript/app/routes/packages.js
@@ -0,0 +1,16 @@
+import Ember from 'ember';
+import {urls} from '../utils/api-urls';
+import config from '../config/environment';
+
+export default Ember.Route.extend({
+ model () {
+ return Ember.$.getJSON(urls.packagesUrl);
+ },
+ setupController(controller, model) {
+ this._super(controller, model);
+ controller.set('packages',model);
+ },
+ afterModel () {
+ document.title = config.APP.title;
+ }
+});