Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from HospitalRun/master
Browse files Browse the repository at this point in the history
Updating fork
  • Loading branch information
brunorrr authored Aug 29, 2018
2 parents 16956cf + f1329eb commit d9087ec
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'Bloodhound': true,
'dymo': true,
'Filer': true,
'goog': true,
'logDebug': true,
'Pikaday': true,
'PouchDB': true,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ newrelic.js

/async-disk-cache
c9-couch.js

.python-version
# ember-try
.node_modules.ember-try/
bower.json.ember-try
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ Is your server (still) running? Is CouchDB running? If not, that's probably the

Try a browser refresh `cmd + r`.

**ERR! stack python2: command not found**

`npm install` requires Python 2 to build some dependencies.
Make sure `python2` is accessible from the current working directory.

If you're using [pyenv](https://github.com/pyenv/pyenv), you can run the following to override the Python version used in the current working directory:
```
$ pyenv install 2.7.15
$ pyenv local 2.7.15
```

## Loading sample data
If you would like to load sample data, you can do so by navigating to **Load DB** under the Administration menu. You should see the following screen:

Expand Down
24 changes: 23 additions & 1 deletion app/router.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
import { get } from '@ember/object';
import { inject as service } from '@ember/service';
import { scheduleOnce } from '@ember/runloop';

const REGEX_UUID_URL_PART = /\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g;
const REGEX_SEARCH_URL_PART = /(\/search)\/.+/;

const Router = EmberRouter.extend({
metrics: service(),

location: config.locationType,
rootURL: config.rootURL
rootURL: config.rootURL,

didTransition() {
this._super(...arguments);
this._trackPage();
},

_trackPage() {
scheduleOnce('afterRender', this, () => {
let page = this.get('url').replace(REGEX_UUID_URL_PART, '').replace(REGEX_SEARCH_URL_PART, '$1');
let title = this.getWithDefault('currentRouteName', 'unknown');

get(this, 'metrics').trackPage({ page, title });
});
}
});

Router.map(function() {
Expand Down
1 change: 1 addition & 0 deletions app/serviceworkers/google-analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
goog.offlineGoogleAnalytics.initialize();
26 changes: 22 additions & 4 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ module.exports = function(environment) {
environment,
rootURL: process.env.EMBER_CLI_ELECTRON ? null : '/',
locationType: 'hash', // Using hash location type because it is more friendly for offline.
metricsAdapters: [
{
name: 'GoogleAnalytics',
environments: ['development', 'production'],
config: {
id: 'UA-98265531-2',
// Use `analytics_debug.js` in development
debug: environment === 'development',
// Use verbose tracing of GA events
trace: environment === 'development',
// Ensure development env hits aren't sent to GA
sendHitTask: environment !== 'development',
// Specify Google Analytics plugins
require: []
}
}
],
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
Expand All @@ -24,11 +41,11 @@ module.exports = function(environment) {
};

ENV.contentSecurityPolicy = {
'connect-src': "'self'",
'connect-src': "'self' www.google-analytics.com",
'default-src': "'self'",
'frame-src': "'self'",
'img-src': "'self' filesystem: data: blob:",
'script-src': "'self' 'unsafe-inline' 'unsafe-eval'",
'img-src': "'self' filesystem: data: blob: www.google-analytics.com",
'script-src': "'self' 'unsafe-inline' 'unsafe-eval' www.google-analytics.com",
'style-src': "'self' 'unsafe-inline'"
};

Expand Down Expand Up @@ -74,7 +91,8 @@ module.exports = function(environment) {
debug: true,
excludePaths: ['manifest.appcache'],
swIncludeFiles: [
'vendor/pouchdb-for-sw.js'
'vendor/pouchdb-for-sw.js',
require.resolve('sw-offline-google-analytics')
]
};
if (environment === 'production') {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"ember-inspector": "^3.0.0",
"ember-keyboard": "3.0.2",
"ember-load-initializers": "^1.0.0",
"ember-metrics": "^0.12.1",
"ember-pouch": "4.3.0",
"ember-radio-buttons": "^4.0.1",
"ember-rapid-forms": "^1.2.5",
Expand All @@ -88,7 +89,7 @@
"eslint-plugin-ember": "^5.1.0",
"eslint-plugin-ember-suave": "^1.0.0",
"express": "^4.8.5",
"hospitalrun-dblisteners": "1.0.1",
"hospitalrun-dblisteners": "1.0.4",
"hospitalrun-server-routes": "1.0.0-beta",
"loader.js": "^4.2.3",
"minimatch": "^3.0.2",
Expand All @@ -110,7 +111,8 @@
"electron-compile": "^6.4.2",
"electron-localshortcut": "^3.0.4",
"electron-protocol-serve": "^1.3.0",
"electron-squirrel-startup": "^1.0.0"
"electron-squirrel-startup": "^1.0.0",
"sw-offline-google-analytics": "0.0.25"
},
"ember-addon": {
"paths": [
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/controllers/abstract-delete-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import DS from 'ember-data';

moduleFor('controller:abstract-delete-controller', 'Unit | Controller | abstract-delete-controller', {
unit: true,
needs: [
'service:metrics'
],
testModel(attrs) {
return run(() => {
this.register('model:test', DS.Model);
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controllers/abstract-edit-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ moduleFor('controller:abstract-edit-controller', 'Unit | Controller | abstract-e
'service:i18n',
'service:session',
'service:lookupLists',
'service:metrics',
'locale:en/translations',
'locale:en/config',
'util:i18n/missing-message',
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controllers/abstract-paged-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DS from 'ember-data';

moduleFor('controller:abstract-paged-controller', 'Unit | Controller | abstract-paged-controller', {
needs: [
'service:metrics',
'service:session'
],
unit: true,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controllers/abstract-report-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { moduleFor, test } from 'ember-qunit';
moduleFor('controller:abstract-report-controller', 'Unit | Controller | abstract-report-controller', {
needs: [
'service:i18n',
'service:metrics',
'locale:en/translations',
'locale:en/config',
'util:i18n/missing-message',
Expand Down
17 changes: 15 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5010,7 +5010,7 @@ ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6
ember-cli-version-checker "^2.1.0"
semver "^5.4.1"

ember-cli-babel@^6.16.0:
ember-cli-babel@^6.1.0, ember-cli-babel@^6.16.0:
version "6.16.0"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.16.0.tgz#623b4a2764ece72b65f1572fc8aeb5714a450228"
dependencies:
Expand Down Expand Up @@ -5590,7 +5590,7 @@ ember-fullcalendar@1.8.0:
fullcalendar "^3.6.0"
fullcalendar-scheduler "^1.8.0"

"ember-getowner-polyfill@^1.1.0 || ^2.0.0":
"ember-getowner-polyfill@^1.1.0 || ^2.0.0", ember-getowner-polyfill@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/ember-getowner-polyfill/-/ember-getowner-polyfill-2.2.0.tgz#38e7dccbcac69d5ec694000329ec0b2be651d2b2"
dependencies:
Expand Down Expand Up @@ -5657,6 +5657,15 @@ ember-maybe-import-regenerator@^0.1.5:
ember-cli-babel "^6.0.0-beta.4"
regenerator-runtime "^0.9.5"

ember-metrics@^0.12.1:
version "0.12.1"
resolved "https://registry.yarnpkg.com/ember-metrics/-/ember-metrics-0.12.1.tgz#8659343bf7b8bda403e70d482ff59cc9714d89f6"
dependencies:
broccoli-funnel "^1.0.1"
ember-cli-babel "^6.1.0"
ember-getowner-polyfill "^2.0.0"
ember-runtime-enumerable-includes-polyfill "^2.0.0"

ember-new-computed@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/ember-new-computed/-/ember-new-computed-1.0.3.tgz#592af8a778e0260ce7e812687c3aedface1622bf"
Expand Down Expand Up @@ -14886,6 +14895,10 @@ svgo@^0.7.0:
sax "~1.2.1"
whet.extend "~0.9.9"

sw-offline-google-analytics@0.0.25:
version "0.0.25"
resolved "https://registry.yarnpkg.com/sw-offline-google-analytics/-/sw-offline-google-analytics-0.0.25.tgz#5dc3f52117d207584eb3541935a2d413e1308d58"

sw-toolbox@3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/sw-toolbox/-/sw-toolbox-3.4.0.tgz#a16efecf4a79ed32191cf1923525f2ee89bc76dc"
Expand Down

0 comments on commit d9087ec

Please sign in to comment.