From 1de7833d896fb3107fa435b9a645c14b8ea3e58f Mon Sep 17 00:00:00 2001 From: Seyi Adebajo Date: Mon, 13 Feb 2017 14:11:41 -0800 Subject: [PATCH] DSS-5869 Adds search and advanced search feature routes, templates --- wherehows-web/app/routes/advsearch.js | 5 + wherehows-web/app/routes/search.js | 64 +++ wherehows-web/app/templates/advsearch.hbs | 109 +++++ .../app/templates/navbar-advsearch.hbs | 413 ++++++++++++++++++ wherehows-web/app/templates/search.hbs | 188 ++++++++ 5 files changed, 779 insertions(+) create mode 100644 wherehows-web/app/routes/advsearch.js create mode 100644 wherehows-web/app/routes/search.js create mode 100644 wherehows-web/app/templates/advsearch.hbs create mode 100644 wherehows-web/app/templates/navbar-advsearch.hbs create mode 100644 wherehows-web/app/templates/search.hbs diff --git a/wherehows-web/app/routes/advsearch.js b/wherehows-web/app/routes/advsearch.js new file mode 100644 index 0000000000..98cac6e0fe --- /dev/null +++ b/wherehows-web/app/routes/advsearch.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; +import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; + +export default Ember.Route.extend(AuthenticatedRouteMixin, { +}) diff --git a/wherehows-web/app/routes/search.js b/wherehows-web/app/routes/search.js new file mode 100644 index 0000000000..9171b17218 --- /dev/null +++ b/wherehows-web/app/routes/search.js @@ -0,0 +1,64 @@ +import Ember from 'ember'; +import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; + +export default Ember.Route.extend(AuthenticatedRouteMixin, { + queryParams: { + category: { + refreshModel: true + }, + keywords: { + refreshModel: true + }, + source: { + refreshModel: true + }, + page: { + refreshModel: true + } + }, + model: function (params) { + this.controller.set('loading', true); + var q; + if (params) { + q = params; + } + else { + q = convertQueryStringToObject(); + } + + var keyword = atob(q.keywords); + var url = 'api/v1/search' + '?page=' + params.page + "&keyword=" + keyword; + if (q.category) { + url += ("&category=" + q.category.toLowerCase()); + currentTab = q.category.toProperCase(); + updateActiveTab(); + } + if (q.source) { + url += '&source=' + q.source; + } + $.get(url, data => { + if (data && data.status == "ok") { + var result = data.result; + var keywords = result.keywords; + window.g_currentCategory = result.category; + updateSearchCategories(result.category); + for (var index = 0; index < result.data.length; index++) { + var schema = result.data[index].schema; + if (schema) { + result.data[index].originalSchema = schema; + highlightResults(result.data, index, keyword); + } + } + this.controller.set('model', result); + this.controller.set('keyword', keyword); + this.controller.set('isMetric', false); + if (result.data.length > 0) { + this.controller.set('showNoResult', false); + } else { + this.controller.set('showNoResult', true); + } + this.controller.set('loading', false) + } + }); + } +}); \ No newline at end of file diff --git a/wherehows-web/app/templates/advsearch.hbs b/wherehows-web/app/templates/advsearch.hbs new file mode 100644 index 0000000000..b3d2be5c9c --- /dev/null +++ b/wherehows-web/app/templates/advsearch.hbs @@ -0,0 +1,109 @@ +
+
+
+ {{#if model.count}} +
+
    + {{#unless first}} + + {{/unless}} +
  • + {{ model.count }} results - page {{ model.page }} of {{ model.totalPages }} +
  • + {{#unless last}} + + {{/unless}} +
+
+ {{/if}} + {{#if loading}} +
+
+ +
+
+ {{/if}} + {{#if model.count}} + {{#if model.isFlowJob}} + + + {{#each model.data as |flowJob|}} + + + + {{/each}} + +
+ +

+ {{{ flowJob.path }}} +

+

source: {{{ flowJob.appCode }}}

+
+ {{{ flowJob.schema }}} +
+
+ {{else}} + + + {{#each model.data as |dataset|}} + + + + {{/each}} + +
+
+ {{#if model.isMetrics}} + + {{#link-to 'metric' dataset.id}} + {{{dataset.name}}} + {{/link-to}} + {{else}} + + {{#link-to 'dataset' dataset.id}} + {{{dataset.name}}} + {{/link-to}} + {{/if}} +
+

{{{ dataset.urn }}}

+ {{#if model.isMetrics}} + {{#if dataset.source}} +

source: {{{ dataset.source }}}

+ {{else}} +

source: Metric

+ {{/if}} + {{else}} +

source: {{{ dataset.source }}}

+ {{/if}} +
+ {{{ dataset.schema }}} +
+
+ {{/if}} + {{else}} + {{#if showNoResult}} +

No items found

+ {{/if}} + {{/if}} +
+
+ {{outlet}} +
+
+
\ No newline at end of file diff --git a/wherehows-web/app/templates/navbar-advsearch.hbs b/wherehows-web/app/templates/navbar-advsearch.hbs new file mode 100644 index 0000000000..32e373cfa3 --- /dev/null +++ b/wherehows-web/app/templates/navbar-advsearch.hbs @@ -0,0 +1,413 @@ + \ No newline at end of file diff --git a/wherehows-web/app/templates/search.hbs b/wherehows-web/app/templates/search.hbs new file mode 100644 index 0000000000..43dff7f07c --- /dev/null +++ b/wherehows-web/app/templates/search.hbs @@ -0,0 +1,188 @@ +
+

Filter By:

+
+ + +
+ + + + +
+ +
+
+
+ {{#if model.count}} +
+
    + {{#unless first}} + + {{/unless}} +
  • + {{ model.count }} results - page {{ model.page }} of {{ model.totalPages }} +
  • + {{#unless last}} + + {{/unless}} +
+
+ {{/if}} + {{#if loading}} +
+
+ +
+
+ {{/if}} + {{#if model.count}} + {{#if model.isFlowJob}} + + + {{#each model.data as |flowJob|}} + + + + {{/each}} + +
+ +

{{ flowJob.path }}

+

source: {{ flowJob.appCode }}

+
+ {{ flowJob.schema }} +
+
+ {{else}} + + + {{#each model.data as |dataset|}} + + + + {{/each}} + +
+
+ {{#if model.isMetrics}} + + {{#link-to 'metrics.metric' dataset.id}} + {{{dataset.name}}} + {{/link-to}} + {{else}} + + {{#link-to 'dataset' dataset.id}} + {{{dataset.name}}} + {{/link-to}} + {{/if}} +
+

+ {{{ dataset.urn }}} +

+ {{#if dataset.source}} +

source: {{{ dataset.source }}}

+ {{else}} +

source: Metric

+ {{/if}} +
+ {{{ dataset.schema }}} +
+
+ {{/if}} + {{else}} + {{#if showNoResult}} +

No items found

+ {{/if}} + {{/if}} +
+
+ {{outlet}} +
+
+
\ No newline at end of file