Skip to content

Commit

Permalink
Merge pull request #2 from solocommand/updates
Browse files Browse the repository at this point in the history
Support listing and counting submissions
  • Loading branch information
solocommand authored Oct 30, 2018
2 parents 7fc4431 + 893d54a commit a8706a3
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
node {
def nodeBuilder = docker.image("node:8")
nodeBuilder.pull()
def nodeBuilder = docker.image("node:8.11.3")
def emberBuilder = docker.image("danlynn/ember-cli:3.4.3")

// Test
try {
stage('Checkout') {
checkout scm
}

nodeBuilder.inside("-v ${env.WORKSPACE}/app:/var/www/html -u 0:0 --entrypoint=''") {
emberBuilder.inside("-v ${env.WORKSPACE}/app:/var/www/html -u 0:0 --entrypoint=''") {
stage('Build App') {
sh "cd /var/www/html && yarn"
}
Expand Down
4 changes: 4 additions & 0 deletions app/app/controllers/display/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Controller from '@ember/controller';

export default Controller.extend({
});
10 changes: 10 additions & 0 deletions app/app/gql/queries/submissions.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query ListSubmissions {
submissions {
id
submitted
companyName
hash
name
email
}
}
1 change: 1 addition & 0 deletions app/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Router.map(function() {
this.route('review', { path: ':id' });
this.route('thanks');
});
this.route('list');
});
});

Expand Down
21 changes: 21 additions & 0 deletions app/app/routes/display/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Route from '@ember/routing/route';
import { RouteQueryManager } from 'ember-apollo-client';

import query from 'cuf/gql/queries/submissions';

export default Route.extend(RouteQueryManager, {
model() {
return this.get('apollo').watchQuery({ query, fetchPolicy: 'cache-and-network' }, 'submissions');
},
actions: {
loading(transition) {
const controller = this.controllerFor(this.get('routeName'));
controller.set('isLoading', true);
transition.promise.finally(() => setTimeout(() => controller.set('isLoading', false), 250));
},
refresh() {
this.refresh();
return false;
},
},
});
50 changes: 50 additions & 0 deletions app/app/templates/display/list.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<div class="row mb-5">
<div class="col">
<div class="card list-index">
<div class="card-header"></div>
<div class="card-body">
</div>

<div>
<ul class="list-group list-group-flush">
<li class="list-group-item pt-0"><h5 class="mb-0 text-muted">Total Results: {{model.length}}</h5></li>
{{#each model as |item|}}

{{#link-to
"display.company.review"
item.hash
item.id
class="list-group-item list-group-item-action flex-column align-items-start"
}}
<div class="d-flex w-100 justify-content-between">
<div class="d-flex flex-column">
<h4 class="mb-1">{{ item.companyName }}</h4>
<small>{{ item.name }} &lt;{{ item.email }}&gt;</small>
</div>
<div class="d-none d-md-flex flex-column align-items-end text-right">
<div class="mt-auto small">
{{entypo-icon "clock"}}
<span title={{moment-format item.submitted "MMM Do, YYYY @ h:mma"}}>
{{moment-from-now item.submitted}}
</span>
</div>
</div>
</div>
{{/link-to}}

{{/each}}
</ul>

<div class="card-footer border-0">
<button
class="btn btn-block btn-primary"
disabled={{isLoading}}
{{ action (route-action "refresh") }}>
{{entypo-icon "cycle"}} {{#if isLoading}}Loading...{{else}}Check for new submissions{{/if}}
</button>
</div>
</div>

</div>
</div>
</div>
3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-jstree": "^1.0.12",
"ember-cli-moment-shim": "^3.7.1",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sass": "^8.0.1",
"ember-cli-sri": "^2.1.1",
Expand All @@ -51,8 +52,10 @@
"ember-froala-editor": "^2.8.5",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-moment": "^7.8.0",
"ember-notify": "^5.3.0",
"ember-resolver": "^5.0.1",
"ember-route-action-helper": "^2.0.6",
"ember-source": "~3.4.0",
"ember-wormhole": "^0.5.5",
"eslint-plugin-ember": "^5.2.0",
Expand Down
82 changes: 80 additions & 2 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"

browserslist@^3.2.6:
browserslist@^3.1.1, browserslist@^3.2.6:
version "3.2.8"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6"
dependencies:
Expand Down Expand Up @@ -2864,7 +2864,7 @@ ember-cli-babel-plugin-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.0.0.tgz#19f3142a2272adb1cc61dfe0dce360e2909a0b07"

ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.10.0, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.17.0, ember-cli-babel@^6.3.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2:
ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.10.0, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.17.0, ember-cli-babel@^6.3.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.7.2, ember-cli-babel@^6.8.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2:
version "6.17.2"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.17.2.tgz#f0d53d2fb95e70c15d8db84760d045f88f458f69"
dependencies:
Expand Down Expand Up @@ -2953,6 +2953,10 @@ ember-cli-htmlbars@^3.0.0:
json-stable-stringify "^1.0.0"
strip-bom "^3.0.0"

ember-cli-import-polyfill@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/ember-cli-import-polyfill/-/ember-cli-import-polyfill-0.2.0.tgz#c1a08a8affb45c97b675926272fe78cf4ca166f2"

ember-cli-inject-live-reload@^1.8.2:
version "1.8.2"
resolved "https://registry.yarnpkg.com/ember-cli-inject-live-reload/-/ember-cli-inject-live-reload-1.8.2.tgz#29f875ad921e9a1dec65d2d75018891972d240bc"
Expand Down Expand Up @@ -2982,6 +2986,21 @@ ember-cli-lodash-subset@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/ember-cli-lodash-subset/-/ember-cli-lodash-subset-2.0.1.tgz#20cb68a790fe0fde2488ddfd8efbb7df6fe766f2"

ember-cli-moment-shim@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/ember-cli-moment-shim/-/ember-cli-moment-shim-3.7.1.tgz#3ad691c5027c1f38a4890fe47d74b5224cc98e32"
dependencies:
broccoli-funnel "^2.0.0"
broccoli-merge-trees "^2.0.0"
broccoli-source "^1.1.0"
broccoli-stew "^1.5.0"
chalk "^1.1.3"
ember-cli-babel "^6.6.0"
ember-cli-import-polyfill "^0.2.0"
lodash.defaults "^4.2.0"
moment "^2.19.3"
moment-timezone "^0.5.13"

ember-cli-node-assets@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/ember-cli-node-assets/-/ember-cli-node-assets-0.2.2.tgz#d2d55626e7cc6619f882d7fe55751f9266022708"
Expand Down Expand Up @@ -3247,6 +3266,12 @@ ember-export-application-global@^2.0.0:
dependencies:
ember-cli-babel "^6.0.0-beta.7"

ember-factory-for-polyfill@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/ember-factory-for-polyfill/-/ember-factory-for-polyfill-1.3.1.tgz#b446ed64916d293c847a4955240eb2c993b86eae"
dependencies:
ember-cli-version-checker "^2.1.0"

ember-fetch@^5.1.1:
version "5.1.3"
resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-5.1.3.tgz#f649c60d523bf1949125a4c497751df3b0c9f587"
Expand Down Expand Up @@ -3304,6 +3329,13 @@ ember-get-config@^0.2.3:
broccoli-file-creator "^1.1.1"
ember-cli-babel "^6.3.0"

ember-getowner-polyfill@^2.0.0, ember-getowner-polyfill@^2.0.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/ember-getowner-polyfill/-/ember-getowner-polyfill-2.2.0.tgz#38e7dccbcac69d5ec694000329ec0b2be651d2b2"
dependencies:
ember-cli-version-checker "^2.1.0"
ember-factory-for-polyfill "^1.3.1"

ember-inflector@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-3.0.0.tgz#7e1ee8aaa0fa773ba0905d8b7c0786354d890ee1"
Expand All @@ -3316,6 +3348,15 @@ ember-load-initializers@^1.1.0:
dependencies:
ember-cli-babel "^6.6.0"

ember-macro-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ember-macro-helpers/-/ember-macro-helpers-1.0.0.tgz#bdb875f5752814f3e0c886e2ed650f01cc302712"
dependencies:
ember-cli-babel "^6.6.0"
ember-cli-string-utils "^1.1.0"
ember-cli-test-info "^1.0.0"
ember-weakmap "^3.0.0"

ember-maybe-import-regenerator@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/ember-maybe-import-regenerator/-/ember-maybe-import-regenerator-0.1.6.tgz#35d41828afa6d6a59bc0da3ce47f34c573d776ca"
Expand All @@ -3331,6 +3372,14 @@ ember-maybe-in-element@^0.1.3:
dependencies:
ember-cli-babel "^6.11.0"

ember-moment@^7.8.0:
version "7.8.0"
resolved "https://registry.yarnpkg.com/ember-moment/-/ember-moment-7.8.0.tgz#12f33f786b9b8b08d7ca46314b8a59d38cc39048"
dependencies:
ember-cli-babel "^6.7.2"
ember-getowner-polyfill "^2.0.1"
ember-macro-helpers "^1.0.0"

ember-notify@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/ember-notify/-/ember-notify-5.3.0.tgz#8f798b7e8bbb9cca2511a15c34838c1afdc53cf3"
Expand Down Expand Up @@ -3367,6 +3416,13 @@ ember-rfc176-data@^0.3.3, ember-rfc176-data@^0.3.5:
version "0.3.5"
resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.5.tgz#f630e550572c81a5e5c7220f864c0f06eee9e977"

ember-route-action-helper@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/ember-route-action-helper/-/ember-route-action-helper-2.0.6.tgz#1d50454350d7112be326ab44058f06cf291d5fd9"
dependencies:
ember-cli-babel "^6.8.1"
ember-getowner-polyfill "^2.0.0"

ember-router-generator@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/ember-router-generator/-/ember-router-generator-1.2.3.tgz#8ed2ca86ff323363120fc14278191e9e8f1315ee"
Expand Down Expand Up @@ -3403,6 +3459,14 @@ ember-template-lint@^1.0.0-beta.5:
resolve "^1.1.3"
strip-bom "^3.0.0"

ember-weakmap@^3.0.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/ember-weakmap/-/ember-weakmap-3.3.1.tgz#5188b035f5bfb17397067ea635300ae4e1205e11"
dependencies:
browserslist "^3.1.1"
debug "^3.1.0"
ember-cli-babel "^6.6.0"

ember-wormhole@^0.5.5:
version "0.5.5"
resolved "https://registry.yarnpkg.com/ember-wormhole/-/ember-wormhole-0.5.5.tgz#db417ff748cb21e574cd5f233889897bc27096cb"
Expand Down Expand Up @@ -5319,6 +5383,10 @@ lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"

lodash.defaults@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-2.3.0.tgz#a832b001f138f3bb9721c2819a2a7cc5ae21ed25"
Expand Down Expand Up @@ -5790,6 +5858,16 @@ mktemp@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/mktemp/-/mktemp-0.4.0.tgz#6d0515611c8a8c84e484aa2000129b98e981ff0b"

moment-timezone@^0.5.13:
version "0.5.23"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463"
dependencies:
moment ">= 2.9.0"

"moment@>= 2.9.0", moment@^2.19.3:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"

morgan@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.1.tgz#0a8d16734a1d9afbc824b99df87e738e58e2da59"
Expand Down
4 changes: 4 additions & 0 deletions graph/src/definitions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = gql`
ping: String!
config: Configuration!
submission(id: String!): CompanyUpdateSubmission!
submissions: [CompanyUpdateSubmission!]!
submissionCount: Int!
}
type Mutation {
Expand Down Expand Up @@ -53,7 +55,9 @@ module.exports = gql`
submitted: Date!
reviewed: Boolean!
name: String!
hash: String!
email: String!
companyName: String
payload: String!
}
Expand Down
2 changes: 2 additions & 0 deletions graph/src/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ module.exports = {
retrieve: id => client.db().collection('submission').findOne({ _id: new ObjectId(id) }),
insert: payload => client.db().collection('submission').insertOne(payload),
complete: id => client.db().collection('submission').updateOne({ _id: new ObjectId(id) }, { $set: { reviewed: true } }),
submissions: ({ reviewed = false } = { reviewed: false }) => client.db().collection('submission').find({ reviewed }).toArray(),
submissionCount: () => client.db().collection('submission').countDocuments({ reviewed: false }),
};
11 changes: 10 additions & 1 deletion graph/src/resolvers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const { DateType } = require('@limit0/graphql-custom-types');
const { GraphQLUpload } = require('apollo-server');
const uuid = require('uuid/v4');
const { retrieve, insert, complete } = require('../mongodb');
const { notify, thank } = require('../mailer');
const env = require('../env');
const s3Client = require('../s3-client');
const {
retrieve,
insert,
complete,
submissions,
submissionCount,
} = require('../mongodb');

const {
PLATFORM_URI,
Expand All @@ -28,11 +34,14 @@ module.exports = {
id: ({ _id }) => _id.toString(),
submitted: ({ _id }) => _id.getTimestamp(),
payload: ({ payload }) => JSON.stringify(payload),
companyName: ({ payload: { name } }) => name,
},

Query: {
config: () => config,
submission: (_, { id }) => retrieve(id),
submissions: () => submissions(),
submissionCount: () => submissionCount(),
},
Mutation: {
company: async (_, { input }) => {
Expand Down

0 comments on commit a8706a3

Please sign in to comment.