From 50bfbbd4ed62eb519963584d339fbe8d5892f134 Mon Sep 17 00:00:00 2001 From: Oludare Oludare Date: Thu, 1 Jun 2017 11:18:13 -0400 Subject: [PATCH 001/104] 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 002/104] 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 003/104] 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 008/104] 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 009/104] 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 @@
+ + -

{{model.id}}

+

{{model.id}}

-

+

{{#status-emoji status=model.status}}{{/status-emoji}}

-

+

{{#status-context status=model.status}}{{/status-context}}

-

+

{{model.context}}

From 71815f1132d6e1794a00163d30308b2d4c7059c4 Mon Sep 17 00:00:00 2001 From: COS-Oludare Date: Sun, 15 Oct 2017 16:34:41 -0400 Subject: [PATCH 103/104] creation of new routes --- app/adapters/raw-datum.js | 7 +++++ app/router.js | 43 ++++++++++++++------------- app/routes/raw-data.js | 12 ++++++++ app/serializers/raw-datum.js | 6 ++-- app/templates/raw-data.hbs | 12 ++++++++ tests/unit/adapters/raw-datum-test.js | 12 ++++++++ tests/unit/routes/raw-data-test.js | 11 +++++++ 7 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 app/adapters/raw-datum.js create mode 100644 app/routes/raw-data.js create mode 100644 app/templates/raw-data.hbs create mode 100644 tests/unit/adapters/raw-datum-test.js create mode 100644 tests/unit/routes/raw-data-test.js diff --git a/app/adapters/raw-datum.js b/app/adapters/raw-datum.js new file mode 100644 index 00000000..b39c3ecb --- /dev/null +++ b/app/adapters/raw-datum.js @@ -0,0 +1,7 @@ +import ApplicationAdapter from './application'; + +export default ApplicationAdapter.extend({ + pathForType() { + return 'rawdata'; + } +}); diff --git a/app/router.js b/app/router.js index cad2ac26..77574972 100644 --- a/app/router.js +++ b/app/router.js @@ -21,29 +21,30 @@ 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('status', function() { - this.route('source-detail', { path: '/:label' }, function() { - this.route('log-detail', { path: '/:log_id'}); - }); + 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('status', function() { + this.route('source-detail', { path: '/:label' }, function() { + this.route('log-detail', { path: '/:log_id'}); }); }); + this.route('raw-data'); +}); export default Router; diff --git a/app/routes/raw-data.js b/app/routes/raw-data.js new file mode 100644 index 00000000..bff17fb4 --- /dev/null +++ b/app/routes/raw-data.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + queryParams: { + page: { + refreshModel: true + } + }, + model(params) { + return this.get('store').query('raw-datum', params); + }, +}); diff --git a/app/serializers/raw-datum.js b/app/serializers/raw-datum.js index 413615e8..d9a9fc7f 100644 --- a/app/serializers/raw-datum.js +++ b/app/serializers/raw-datum.js @@ -1,7 +1,7 @@ import ApplicationSerializer from './application'; export default ApplicationSerializer.extend({ - keyForAttribute: function(attr) { - return attr === 'datum' ? 'data' : this._super(...arguments); - } + // keyForAttribute: function(attr) { + // return attr === 'datum' ? 'data' : this._super(...arguments); + // } }); diff --git a/app/templates/raw-data.hbs b/app/templates/raw-data.hbs new file mode 100644 index 00000000..7a6e0e93 --- /dev/null +++ b/app/templates/raw-data.hbs @@ -0,0 +1,12 @@ +
+ Datum + + + {{#each model as |rd|}} + + + + {{/each}} +
dateHarvested
{{rd.datum}}{{rd.dateHarvested}}
+
diff --git a/tests/unit/adapters/raw-datum-test.js b/tests/unit/adapters/raw-datum-test.js new file mode 100644 index 00000000..62ed29c3 --- /dev/null +++ b/tests/unit/adapters/raw-datum-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:raw-datum', 'Unit | Adapter | raw datum', { + // Specify the other units that are required for this test. + // needs: ['serializer:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let adapter = this.subject(); + assert.ok(adapter); +}); diff --git a/tests/unit/routes/raw-data-test.js b/tests/unit/routes/raw-data-test.js new file mode 100644 index 00000000..07a59a8a --- /dev/null +++ b/tests/unit/routes/raw-data-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:raw-data', 'Unit | Route | raw data', { + // 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 87eb5e9f01d878b6ed20581cd22b842d486c5af1 Mon Sep 17 00:00:00 2001 From: COS-Oludare Date: Tue, 24 Oct 2017 11:29:55 -0400 Subject: [PATCH 104/104] creation of raw-datum and normalized-datum routes --- app/adapters/normalized-datum.js | 7 +++++++ app/models/harvest-log.js | 8 ++++---- app/models/normalized-datum.js | 8 ++++++++ app/models/raw-datum.js | 1 - app/router.js | 1 + app/routes/normalized-data.js | 12 ++++++++++++ app/templates/normalized-data.hbs | 14 ++++++++++++++ app/templates/raw-data.hbs | 19 ++++++++++--------- tests/unit/adapters/normalized-data-test.js | 12 ++++++++++++ tests/unit/models/normilized-data-test.js | 12 ++++++++++++ tests/unit/routes/normalized-data-test.js | 11 +++++++++++ 11 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 app/adapters/normalized-datum.js create mode 100644 app/models/normalized-datum.js create mode 100644 app/routes/normalized-data.js create mode 100644 app/templates/normalized-data.hbs create mode 100644 tests/unit/adapters/normalized-data-test.js create mode 100644 tests/unit/models/normilized-data-test.js create mode 100644 tests/unit/routes/normalized-data-test.js diff --git a/app/adapters/normalized-datum.js b/app/adapters/normalized-datum.js new file mode 100644 index 00000000..b0fd7e76 --- /dev/null +++ b/app/adapters/normalized-datum.js @@ -0,0 +1,7 @@ +import ApplicationAdapter from './application'; + +export default ApplicationAdapter.extend({ + pathForType(){ + return 'normalizeddata' + } +}); diff --git a/app/models/harvest-log.js b/app/models/harvest-log.js index 61db1dff..cb06a88c 100644 --- a/app/models/harvest-log.js +++ b/app/models/harvest-log.js @@ -5,10 +5,10 @@ export default Model.extend({ sourceConfig: DS.belongsTo('source-config', {async: true}), status: DS.attr('string'), - context: DS.attr('string'), - completions: DS.attr('string'), + context: DS.attr('string'), + completions: DS.attr('string'), dateStarted: DS.attr('string'), endDate: DS.attr('string'), - startDate: DS.attr('string'), - harvesterVersion: DS.attr('string'), + startDate: DS.attr('string'), + harvesterVersion: DS.attr('string'), }); diff --git a/app/models/normalized-datum.js b/app/models/normalized-datum.js new file mode 100644 index 00000000..913ae4e3 --- /dev/null +++ b/app/models/normalized-datum.js @@ -0,0 +1,8 @@ +import DS from 'ember-data'; + +export default DS.Model.extend({ + + type: DS.attr('string'), + graph: DS.attr('string'), + +}); diff --git a/app/models/raw-datum.js b/app/models/raw-datum.js index d7c19830..e580a85d 100644 --- a/app/models/raw-datum.js +++ b/app/models/raw-datum.js @@ -3,7 +3,6 @@ import DS from 'ember-data'; export default DS.Model.extend({ // TODO add source model source: DS.attr(), - appLabel: DS.attr('string'), providerDocId: DS.attr('string'), datum: DS.attr('string'), sha256: DS.attr('string'), diff --git a/app/router.js b/app/router.js index 77574972..fae46fe8 100644 --- a/app/router.js +++ b/app/router.js @@ -44,6 +44,7 @@ Router.map(function() { }); }); this.route('raw-data'); + this.route('normalized-data'); }); diff --git a/app/routes/normalized-data.js b/app/routes/normalized-data.js new file mode 100644 index 00000000..681cef05 --- /dev/null +++ b/app/routes/normalized-data.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + queryParams: { + page: { + refreshModel: true + } + }, + model(params) { + return this.get('store').query('normalized-datum', params); + }, +}); diff --git a/app/templates/normalized-data.hbs b/app/templates/normalized-data.hbs new file mode 100644 index 00000000..4856f631 --- /dev/null +++ b/app/templates/normalized-data.hbs @@ -0,0 +1,14 @@ +
+ + + + + {{#each model as |nd|}} + + + data type + + {{/each}} +
Data Id
{{nd.id}} {{nd.type}}
+
+ diff --git a/app/templates/raw-data.hbs b/app/templates/raw-data.hbs index 7a6e0e93..e13cc865 100644 --- a/app/templates/raw-data.hbs +++ b/app/templates/raw-data.hbs @@ -1,12 +1,13 @@
- Datum - - - {{#each model as |rd|}} - - +
dateHarvested
{{rd.datum}}{{rd.dateHarvested}}
+ + + + + {{#each model as |rd|}} + + Datums: - {{/each}} -
DatumDateHarvested
{{rd.datum}}
+ {{/each}} +
diff --git a/tests/unit/adapters/normalized-data-test.js b/tests/unit/adapters/normalized-data-test.js new file mode 100644 index 00000000..c3d0202e --- /dev/null +++ b/tests/unit/adapters/normalized-data-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:normalized-data', 'Unit | Adapter | normalized data', { + // Specify the other units that are required for this test. + // needs: ['serializer:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let adapter = this.subject(); + assert.ok(adapter); +}); diff --git a/tests/unit/models/normilized-data-test.js b/tests/unit/models/normilized-data-test.js new file mode 100644 index 00000000..102cb897 --- /dev/null +++ b/tests/unit/models/normilized-data-test.js @@ -0,0 +1,12 @@ +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('normilized-data', 'Unit | Model | normilized data', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('it exists', function(assert) { + let model = this.subject(); + // let store = this.store(); + assert.ok(!!model); +}); diff --git a/tests/unit/routes/normalized-data-test.js b/tests/unit/routes/normalized-data-test.js new file mode 100644 index 00000000..08c083ec --- /dev/null +++ b/tests/unit/routes/normalized-data-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:normalized-data', 'Unit | Route | normalized data', { + // 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); +});