Skip to content

Commit

Permalink
Prod build for 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jkleinsc committed Mar 30, 2016
1 parent 537f763 commit 5f4505d
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 151 deletions.
4 changes: 3 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = function(environment) {
}
};


ENV.contentSecurityPolicy = {
'connect-src': "'self'",
'default-src': "'self'",
Expand Down Expand Up @@ -60,6 +59,9 @@ module.exports = function(environment) {
'bower_components/pouchdb/dist/pouchdb.js'
]
};
if (environment === 'production') {
ENV.serviceWorker.debug = false;
}

return ENV;
};
Expand Down
6 changes: 6 additions & 0 deletions prod/assets/hospitalrun-5597b10d9b3989644768cdf048da1cad.css

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions prod/assets/hospitalrun-9b80c3a7e4645e1aae9abbc5e1b8b20c.js

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions prod/assets/hospitalrun-a28c893d100a9ee55ca12b9bf5781f5f.css

This file was deleted.

43 changes: 0 additions & 43 deletions prod/assets/hospitalrun-ed3bc43f0d41606d73ccbbfdaca783a8.js

This file was deleted.

46 changes: 0 additions & 46 deletions prod/assets/vendor-549a937bf8f39574af4b8f4d9daf6254.js

This file was deleted.

46 changes: 46 additions & 0 deletions prod/assets/vendor-b57517d0e9737f65a1aa2c92104e9858.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions prod/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />


<meta name="hospitalrun/config/environment" content="%7B%22modulePrefix%22%3A%22hospitalrun%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22hospitalrun%22%2C%22version%22%3A%220.9.1+0bbb2a23%22%7D%2C%22i18n%22%3A%7B%22defaultLocale%22%3A%22en%22%7D%2C%22manifest%22%3A%7B%22enabled%22%3Atrue%2C%22appcacheFile%22%3A%22/manifest.appcache%22%2C%22excludePaths%22%3A%5B%22index.html%22%2C%22tests/index.html%22%2C%22robots.txt%22%2C%22crossdomain.xml%22%2C%22testem.js%22%5D%2C%22showCreateDate%22%3Atrue%2C%22includePaths%22%3A%5B%5D%2C%22network%22%3A%5B%22*%22%5D%7D%2C%22serviceWorker%22%3A%7B%22enabled%22%3Atrue%2C%22debug%22%3Atrue%2C%22excludePaths%22%3A%5B%22manifest.appcache%22%5D%2C%22swIncludeFiles%22%3A%5B%22bower_components/pouchdb/dist/pouchdb.js%22%5D%7D%2C%22exportApplicationGlobal%22%3Afalse%7D" />
<meta name="hospitalrun/config/environment" content="%7B%22modulePrefix%22%3A%22hospitalrun%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22hospitalrun%22%2C%22version%22%3A%220.9.2+537f763d%22%7D%2C%22contentSecurityPolicy%22%3A%7B%22connect-src%22%3A%22%27self%27%22%2C%22default-src%22%3A%22%27self%27%22%2C%22frame-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%20filesystem%3A%20data%3A%22%2C%22script-src%22%3A%22%27self%27%20%27unsafe-inline%27%20%27unsafe-eval%27%22%2C%22style-src%22%3A%22%27self%27%20%27unsafe-inline%27%22%2C%22font-src%22%3A%5B%22%27self%27%22%5D%2C%22media-src%22%3A%5B%22%27self%27%22%5D%7D%2C%22i18n%22%3A%7B%22defaultLocale%22%3A%22en%22%7D%2C%22manifest%22%3A%7B%22enabled%22%3Atrue%2C%22appcacheFile%22%3A%22/manifest.appcache%22%2C%22excludePaths%22%3A%5B%22index.html%22%2C%22tests/index.html%22%2C%22robots.txt%22%2C%22crossdomain.xml%22%2C%22testem.js%22%5D%2C%22showCreateDate%22%3Atrue%2C%22includePaths%22%3A%5B%5D%2C%22network%22%3A%5B%22*%22%5D%7D%2C%22serviceWorker%22%3A%7B%22enabled%22%3Atrue%2C%22debug%22%3Afalse%2C%22excludePaths%22%3A%5B%22manifest.appcache%22%5D%2C%22swIncludeFiles%22%3A%5B%22bower_components/pouchdb/dist/pouchdb.js%22%5D%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22exportApplicationGlobal%22%3Afalse%7D" />

<link rel="stylesheet" href="assets/vendor-ed8acd5f4063b4b83b5df16f6da9e8b0.css" integrity="sha256-8SEzsmD/Yu0KXXOOfKz1o2a7UPfUg0z/idfuC6vxZWY= sha512-rBdZdkJyfXTenDbP1KZYS3FLalUji+IE+vxyRjp0xrjs0jI7NO4zKk6EkPAC3XGwtiVf3Fy/PnJpQM3VOZd7Pg==" >
<link rel="stylesheet" href="assets/hospitalrun-a28c893d100a9ee55ca12b9bf5781f5f.css" integrity="sha256-3itoqAAvzcd6eQ+c169y0sHLyn3wFe/7JoX7OEhfheI= sha512-8KAjSeQRnjhVVajx2v402GxYrA8V4g9L3Gs1CjKTH9FRetoV9tlXBU68d6U3FbZ6OagIscRNXKIohP79yPXDfg==" >
<link rel="stylesheet" href="assets/hospitalrun-5597b10d9b3989644768cdf048da1cad.css" integrity="sha256-8bxyBbzhF9E1E5vqUPqyCznLC52U89cip7JnMId0ObM= sha512-IEwfCIpGVnLqVQoTrMIuOCcxBl/19OeJa8vhaQOzaJ3z0fxU4gGWCktA5VqwZUQc7qtLVV7/XsqFYXK1vPTFGw==" >


</head>
Expand Down Expand Up @@ -44,8 +44,8 @@
</script>


<script src="assets/vendor-549a937bf8f39574af4b8f4d9daf6254.js" integrity="sha256-loAluZKMOYkmWuo52Iu5rYWJWRmUHMbjBZFF8CSJtTw= sha512-C/aXO1VmtZ6/OjMl9d/pkpLD33c+GPxP5MnvZGN8VZkdv5xIfJTQ5Ns8efA2K0BSaj1Vrpe3OyQbQ4jIXAACvw==" ></script>
<script src="assets/hospitalrun-ed3bc43f0d41606d73ccbbfdaca783a8.js" integrity="sha256-1tDc2uJU/oLIdFXBvOVMRrEMATgqzA9GWZKG2DIKbUg= sha512-r7WxF5r15tkD/evDQ5UrphYXP8GbJewpT4irPR+Uj9ad6y0i31nqrYrlLwCE8FxvSyxajtDLlpNbSUlHrgXAMQ==" ></script>
<script src="assets/vendor-b57517d0e9737f65a1aa2c92104e9858.js" integrity="sha256-Xzh/YEDiPMUsWD9m9XJoQWTCbsp7G2gZACwf1TrkS30= sha512-nndg44mqy9TfbH5v2Mg/NNsvQbRwfn5IjkMkorA62QS8glTUV0FaiSiyzFj/Mpli6uX/1GNcL98hSyKjNNx8nQ==" ></script>
<script src="assets/hospitalrun-9b80c3a7e4645e1aae9abbc5e1b8b20c.js" integrity="sha256-kc7w/nkHBc6+ZAu4lBDcZrYE92ja0nkXZfxc+cq6GG4= sha512-LwmuIbNZ+9+KJlIvP06Il3VZTFFkFW9QNy6CztR6ysovHXASD5mOrLOaOsM/RD2v2tIFFKvsezXhCnCvPl4OqA==" ></script>

<script>if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./service-worker.js', {scope: './'})
Expand Down
8 changes: 4 additions & 4 deletions prod/manifest.appcache
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CACHE MANIFEST
# created 2016-03-03T14:43:45.640Z
# created 2016-03-30T18:37:58.853Z

CACHE:
assets/hospitalrun-a28c893d100a9ee55ca12b9bf5781f5f.css
assets/hospitalrun-ed3bc43f0d41606d73ccbbfdaca783a8.js
assets/vendor-549a937bf8f39574af4b8f4d9daf6254.js
assets/hospitalrun-5597b10d9b3989644768cdf048da1cad.css
assets/hospitalrun-9b80c3a7e4645e1aae9abbc5e1b8b20c.js
assets/vendor-b57517d0e9737f65a1aa2c92104e9858.js
assets/vendor-ed8acd5f4063b4b83b5df16f6da9e8b0.css
dymo/BarcodeAsImage.label
favicon-7440091f4e8bd83e23e4d5824c2c3da4.png
Expand Down
118 changes: 77 additions & 41 deletions prod/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
importScripts('sw-toolbox.js');
var CACHE_PREFIX = 'brocsw-v';
var CACHE_VERSION = CACHE_PREFIX+'1457016225727';
var CACHE_VERSION = CACHE_PREFIX+'1459363078940';
toolbox.options.cache.name = CACHE_VERSION;
toolbox.options.debug = true;
var urlsToPrefetch = [
'/',
"assets/hospitalrun-a28c893d100a9ee55ca12b9bf5781f5f.css",
"assets/hospitalrun-ed3bc43f0d41606d73ccbbfdaca783a8.js",
"assets/vendor-549a937bf8f39574af4b8f4d9daf6254.js",
"assets/hospitalrun-5597b10d9b3989644768cdf048da1cad.css",
"assets/hospitalrun-9b80c3a7e4645e1aae9abbc5e1b8b20c.js",
"assets/vendor-b57517d0e9737f65a1aa2c92104e9858.js",
"assets/vendor-ed8acd5f4063b4b83b5df16f6da9e8b0.css",
"crossdomain.xml",
"dymo/BarcodeAsImage.label",
Expand Down Expand Up @@ -13141,9 +13140,9 @@ module.exports = PouchDB;
},{"1":1,"10":10,"12":12,"13":13,"14":14,"15":15,"16":16,"2":2,"4":4,"6":6,"7":7,"8":8}]},{},[17])(17)
});
var configDB;
var configs = false;
var localMainDB;
var syncingRemote = false;
var useGoogleAuth = true;

new PouchDB('config', function(err, db) {
configDB = db;
Expand All @@ -13153,18 +13152,6 @@ new PouchDB('localMainDB', function(err, db) {
localMainDB = db;
});

self.addEventListener('activate', function(event) {
event.waitUntil(
configDB.get('config_use_google_auth', function(useGoogleAuthConfig) {
if (useGoogleAuthConfig === true) {
useGoogleAuth = true;
} else {
useGoogleAuth = false;
}
})
);
});

toolbox.router.get('/db/main/_all_docs', function(request, values, options) {
logDebug('request for all docs:', request.url);
return couchDBResponse(request, values, options, function(request) {
Expand Down Expand Up @@ -13199,37 +13186,73 @@ toolbox.router.post('/db/main/_bulk_docs', function(request, values, options) {

function setupRemoteSync() {
if (!syncingRemote) {
var pouchOptions = {
ajax: {
headers: {},
timeout: 30000
}
};
if (configs.config_consumer_secret && configs.config_token_secret &&
configs.config_consumer_key && configs.config_oauth_token) {
pouchOptions.ajax.headers['x-oauth-consumer-secret'] = configs.config_consumer_secret;
pouchOptions.ajax.headers['x-oauth-consumer-key'] = configs.config_consumer_key;
pouchOptions.ajax.headers['x-oauth-token-secret'] = configs.config_token_secret;
pouchOptions.ajax.headers['x-oauth-token'] = configs.config_oauth_token;
}
var remoteURL = self.location.protocol + '//' + self.location.host + '/db/main';
syncingRemote = localMainDB.sync(remoteURL, {
live: true,
retry: true
}).on('change', function(info) {
logDebug('local sync change', info);
}).on('paused', function() {
logDebug('local sync paused');
// replication paused (e.g. user went offline)
}).on('active', function() {
logDebug('local sync active');
// replicate resumed (e.g. user went back online)
}).on('denied', function(info) {
logDebug('local sync denied:', info);
// a document failed to replicate, e.g. due to permissions
}).on('complete', function(info) {
logDebug('local sync complete:', info);
// handle complete
}).on('error', function(err) {
logDebug('local sync error:', err);
new PouchDB(remoteURL, pouchOptions, function(err, db) {
syncingRemote = localMainDB.sync(db, {
live: true,
retry: true
}).on('change', function(info) {
logDebug('local sync change', info);
}).on('paused', function() {
logDebug('local sync paused');
// replication paused (e.g. user went offline)
}).on('active', function() {
logDebug('local sync active');
// replicate resumed (e.g. user went back online)
}).on('denied', function(info) {
logDebug('local sync denied:', info);
// a document failed to replicate, e.g. due to permissions
}).on('complete', function(info) {
logDebug('local sync complete:', info);
// handle complete
}).on('error', function(err) {
logDebug('local sync error:', err);
});
});
}
}

function setupConfigs() {
return new Promise(function(resolve, reject) {
if (configs) {
resolve();
} else {
configDB.allDocs({
include_docs: true
}).then((result) => {
configs = {};
result.rows.forEach((row) => {
configs[row.id] = row.doc.value;
});
resolve();
}, reject);
}
});
}

function couchDBResponse(request, values, options, pouchDBFn) {
setupRemoteSync();
setupConfigs().then(setupRemoteSync);
logDebug('Looking for couchdb response for:', request.url);
return new Promise(function(resolve, reject) {
var startTime = performance.now();
toolbox.networkOnly(request, values, options).then(function(response) {
if (response) {
var elapsedTime = performance.now() - startTime;
resolve(response);
logPerformance(elapsedTime, request.url);
} else {
logDebug('Network first returned no response, get data from local pouch db.');
runPouchFn(pouchDBFn, request, resolve, reject);
Expand Down Expand Up @@ -13263,6 +13286,18 @@ function getDBOptions(url) {
return returnParams;
}

function logPerformance(elapsedTime, requestUrl) {
if (configs.config_log_metrics && configs.current_user) {
var now = Date.now();
var timingId = 'timing_' + configs.current_user.toLowerCase() + '_' + now;
localMainDB.put({
_id: timingId,
elapsed: elapsedTime,
url: requestUrl
});
}
}

function runPouchFn(pouchDBFn, request, resolve, reject) {
pouchDBFn(request).then(function(response) {
resolve(convertPouchToResponse(response));
Expand All @@ -13273,7 +13308,6 @@ function runPouchFn(pouchDBFn, request, resolve, reject) {
}

self.addEventListener('install', function(event) {
console.log('Handling install event. Resources to pre-fetch:', urlsToPrefetch);
if (self.skipWaiting) { self.skipWaiting(); }
});

Expand All @@ -13290,7 +13324,9 @@ self.addEventListener('activate', function(event) {
return caches.delete(cacheName);
})
);
}).then(() => self.clients.claim())
}).then(function() {
self.clients.claim();
})
);
});

Expand All @@ -13303,7 +13339,7 @@ function logDebug() {
}
console.log(arguments[0], consoleArgs);
} else {
console.log(arguments);
console.log(arguments[0]);
}
}
}
1 change: 0 additions & 1 deletion prod/sw-toolbox.map.json

This file was deleted.

0 comments on commit 5f4505d

Please sign in to comment.