From 50bfbbd4ed62eb519963584d339fbe8d5892f134 Mon Sep 17 00:00:00 2001 From: Oludare Oludare Date: Thu, 1 Jun 2017 11:18:13 -0400 Subject: [PATCH 01/88] Starting Template for Harvest log! --- app/router.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/app/router.js b/app/router.js index df24902f..0ce5b115 100644 --- a/app/router.js +++ b/app/router.js @@ -21,22 +21,23 @@ const Router = Ember.Router.extend({ }); Router.map(function() { - this.route('changes'); - this.route('discover'); - this.route('profile'); - this.route('settings'); - this.route('sources'); - this.route('registration', function() { - this.route('form', { path: '/' }); - this.route('confirmation', { path: '/confirmation/' }); - }); - - this.route('detail', { path: '/:type/:id' }); - this.route('curate', { path: '/curate/:type/:id' }); - - this.route('elastic-down'); - this.route('notfound', { path: '/*path' }); - this.route('notfound'); + this.route('changes'); + this.route('discover'); + this.route('profile'); + this.route('settings'); + this.route('sources'); + this.route('registration', function() { + this.route('form', { path: '/' }); + this.route('confirmation', { path: '/confirmation/' }); + }); + + this.route('detail', { path: '/:type/:id' }); + this.route('curate', { path: '/curate/:type/:id' }); + + this.route('elastic-down'); + this.route('notfound', { path: '/*path' }); + this.route('notfound'); + this.route('harvest'); }); export default Router; From 0abc8c0196cfdd8bb4f8a22b58fe6aec24429b6f Mon Sep 17 00:00:00 2001 From: Oludare Oludare Date: Thu, 1 Jun 2017 11:23:26 -0400 Subject: [PATCH 02/88] Follow up! --- app/controllers/harvest.js | 98 ++++++++++++++++++++++++++ app/routes/harvest.js | 4 ++ app/templates/harvest.hbs | 25 +++++++ tests/unit/controllers/harvest-test.js | 12 ++++ tests/unit/routes/harvest-test.js | 11 +++ 5 files changed, 150 insertions(+) create mode 100644 app/controllers/harvest.js create mode 100644 app/routes/harvest.js create mode 100644 app/templates/harvest.hbs create mode 100644 tests/unit/controllers/harvest-test.js create mode 100644 tests/unit/routes/harvest-test.js diff --git a/app/controllers/harvest.js b/app/controllers/harvest.js new file mode 100644 index 00000000..dfcc0bc8 --- /dev/null +++ b/app/controllers/harvest.js @@ -0,0 +1,98 @@ +import Ember from 'ember'; +import ENV from '../config/environment'; +import { getUniqueList, encodeParams } from 'ember-share/utils/elastic-query'; + +export default Ember.Controller.extend({ + + metrics: Ember.inject.service(), + + numberOfSources: 0, + sources: [], + numberOfEvents: 0, + sourcesLastUpdated: Date().toString(), + placeholder: 'Search aggregated sources', + loading: true, + source_selected: '', + + init() { + this._super(...arguments); + this.loadPage(); + }, + + loadPage(url=null) { + url = url || ENV.apiUrl + '/sources/?sort=long_title'; + this.set('loading', true); + return Ember.$.ajax({ + url: url, + crossDomain: true, + type: 'GET', + contentType: 'application/json', + }).then((json) => { + this.set('numberOfSources', json.meta.pagination.count); + this.get('sources').addObjects(json.data); + + if (json.links.next) { + return this.loadPage(json.links.next); + } + Ember.run(() => { + this.set('loading', false); + }); + }); + }, + + typeaheadQueryUrl() { + return `${ENV.apiUrl}/search/sources/_search`; + }, + + buildTypeaheadQuery(text) { + return { + size: 10, + query: { + match: { + 'name.autocomplete': { + query: text, + operator: 'and', + fuzziness: 'AUTO' + } + } + } + }; + }, + + handleTypeaheadResponse(response) { + return getUniqueList(response.hits.hits.mapBy('_source.name')); + }, + actions: { + changeFilter(selected) { + const category = 'sources'; + const action = 'filter'; + const label = selected; + + this.get('metrics').trackEvent({ category, action, label }); + + this.transitionToRoute('discover', { queryParams: { sources: encodeParams(selected) } }); + }, + + elasticSearch(term) { + if (Ember.isBlank(term)) { return []; } + + const category = 'sources'; + const action = 'search'; + const label = term; + + this.get('metrics').trackEvent({ category, action, label }); + + var data = JSON.stringify(this.buildTypeaheadQuery(term)); + + return Ember.$.ajax({ + url: this.typeaheadQueryUrl(), + crossDomain: true, + type: 'POST', + contentType: 'application/json', + data: data + }).then(json => + this.handleTypeaheadResponse(json) + ); + } + } +}); diff --git a/app/routes/harvest.js b/app/routes/harvest.js new file mode 100644 index 00000000..26d9f312 --- /dev/null +++ b/app/routes/harvest.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/app/templates/harvest.hbs b/app/templates/harvest.hbs new file mode 100644 index 00000000..c8a58629 --- /dev/null +++ b/app/templates/harvest.hbs @@ -0,0 +1,25 @@ +{{outlet}} +
+ {{search-header}} +
+
+
+
+ {{#power-select-multiple + search=(action "elasticSearch") + placeholder=placeholder + onchange=(action "changeFilter") + as |option| + }} + {{option}} + {{/power-select-multiple}} +
+
+ + + +
+
+
+
+
diff --git a/tests/unit/controllers/harvest-test.js b/tests/unit/controllers/harvest-test.js new file mode 100644 index 00000000..176915fa --- /dev/null +++ b/tests/unit/controllers/harvest-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('controller:harvest', 'Unit | Controller | harvest', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let controller = this.subject(); + assert.ok(controller); +}); diff --git a/tests/unit/routes/harvest-test.js b/tests/unit/routes/harvest-test.js new file mode 100644 index 00000000..42ac2db9 --- /dev/null +++ b/tests/unit/routes/harvest-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:harvest', 'Unit | Route | harvest', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); From 47d05aa576a24de5281e6fabb69730c2f4eb8e6a Mon Sep 17 00:00:00 2001 From: Emily Carden Date: Thu, 1 Jun 2017 11:44:54 -0400 Subject: [PATCH 03/88] Template edits --- app/templates/harvest.hbs | 24 +++++++++--------------- app/templates/sources.hbs | 2 ++ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/templates/harvest.hbs b/app/templates/harvest.hbs index c8a58629..4d1416cb 100644 --- a/app/templates/harvest.hbs +++ b/app/templates/harvest.hbs @@ -1,25 +1,19 @@ {{outlet}} +
{{search-header}} +
-
- {{#power-select-multiple - search=(action "elasticSearch") - placeholder=placeholder - onchange=(action "changeFilter") - as |option| - }} - {{option}} - {{/power-select-multiple}} + + +
+

Share Harvester Status Board

+
-
- - - -
-
+
+
diff --git a/app/templates/sources.hbs b/app/templates/sources.hbs index 4bfbd6c3..af40e0f0 100644 --- a/app/templates/sources.hbs +++ b/app/templates/sources.hbs @@ -30,6 +30,7 @@ {{else}}
-
- {{numberOfharvests}} -
+
    {{#each harvests as |harvest|}} -
  • {{harvest.id}}
  • + +
    + {{#if (equals harvest.attributes.status 0)}} + Status: Created + {{/if}} + + {{#if (equals harvest.attributes.status 1)}} + Status: Started + {{/if}} + + {{#if (equals harvest.attributes.status 2)}} + Status: Failed + {{/if}} + + {{#if (equals harvest.attributes.status 3)}} + Status: Succeded + {{/if}} + + {{#if (equals harvest.attributes.status 4)}} + Status: Rescheduled + {{/if}} + + {{#if (equals harvest.attributes.status 6)}} + Status: Forced + {{/if}} + + {{#if (equals harvest.attributes.status 7)}} + Status: Skipped + {{/if}} + + {{#if (equals harvest.attributes.status 8)}} + Status: Retried + {{/if}} + +
    + {{harvest.id}} + + {{log harvest}} + {{log "Status is" harvest.attributes.status}} {{/each}}
From 744ce08a24da63b781fe95d541b8c40d78a2a26d Mon Sep 17 00:00:00 2001 From: Emily Carden Date: Mon, 5 Jun 2017 11:59:13 -0400 Subject: [PATCH 08/88] rendering id and status --- tests/unit/helpers/equals-test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/unit/helpers/equals-test.js diff --git a/tests/unit/helpers/equals-test.js b/tests/unit/helpers/equals-test.js new file mode 100644 index 00000000..e7854205 --- /dev/null +++ b/tests/unit/helpers/equals-test.js @@ -0,0 +1,10 @@ +import { equals } from 'ember-share/helpers/equals'; +import { module, test } from 'qunit'; + +module('Unit | Helper | equals'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = equals([42]); + assert.ok(result); +}); From f2ea1363919a0b33a0b8928d0fae7ffebecffb79 Mon Sep 17 00:00:00 2001 From: Emily Carden Date: Mon, 5 Jun 2017 12:31:12 -0400 Subject: [PATCH 09/88] render id and status --- app/templates/harvest.hbs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/templates/harvest.hbs b/app/templates/harvest.hbs index b30fefbf..b5ec2e32 100644 --- a/app/templates/harvest.hbs +++ b/app/templates/harvest.hbs @@ -7,6 +7,8 @@
+ +