diff --git a/.gitignore b/.gitignore index bf4bf6a5d58e1537b31211c8e2f4db5199aea72b..97fa0051a0b417a05a9077ce42fb974cfb3ec6ef 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ test_card.sdcard export_server/local export_server/local/ + +#Configuration file +config/config.js diff --git a/.watchmanconfig b/.watchmanconfig index 9e26dfeeb6e641a33dae4961196235bdb965b21b..0967ef424bce6791893e9a57bb952f80fd536e93 100644 --- a/.watchmanconfig +++ b/.watchmanconfig @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/android/gradlew b/android/gradlew old mode 100644 new mode 100755 diff --git a/app/stores/allStores.js b/app/stores/allStores.js index 4e9faeb8ecf0114e2669d690a39ca64c7018d710..8f8520aeb7727ed7afa35685bcfe118187addc8a 100644 --- a/app/stores/allStores.js +++ b/app/stores/allStores.js @@ -3,10 +3,11 @@ import getNavStore from './navStore'; import getDataStore$ from './dataStore'; import Kefir from 'kefir'; import U from '../utils/utils'; +import config from '../../config/config'; export default (actions, routes, entities) => { const nav = getNavStore(actions.nav, routes); - const data = getDataStore$(actions.data, 5984, 'admin', 'password', 'http://localhost:5984/', 'blocpower'); + const data = getDataStore$(actions.data, config.cb_local_port, config.cb_local_user, config.cb_local_password, config.cb_local_host, config.cb_local_bucket); const load$ = data.map(db => { //This action is used for debugging actions.data.deleteDatabase.raw.flatMap(() => db.deleteDatabase()).onValue(U.popJson); @@ -17,7 +18,7 @@ export default (actions, routes, entities) => { nav: nav, db: db, changes: db.changes$, - //This stream contains a actions that can be applied to a map to keep the map in sync to the data in the datbase + //This stream contains a actions that can be applied to a map to keep the map in sync to the data in the database //The original object is included so it can be use to apply filters. change_actions: db.changes$ .flatten(e => e.results) @@ -32,7 +33,7 @@ export default (actions, routes, entities) => { // // store.change_actions.log('change-actions'); - store.replication = db.setupReplication('', '', 'http://couchbase1.sbdev.io:4984', 'blocpoweraudit' + (__DEV__ ? 'dev' : '')) + store.replication = db.setupReplication(config.cb_replication_user, config.cb_replication_password, config.cb_replication_host, config.cb_replication_port, config.cb_replication_bucket) // store.replication.onError(x => U.popMsg('Unexpected Error', 'Replication Error')); store.replication.onError(U.popJsonMap('Replication Error')); diff --git a/app/stores/dataStore.js b/app/stores/dataStore.js index cfa10f9927b22aad44e3a2df466511e211bc3b5d..5237f5aa77144b887c06e1c50bfa7b70a65bda3e 100644 --- a/app/stores/dataStore.js +++ b/app/stores/dataStore.js @@ -5,6 +5,6 @@ import mainDesignDoc from './mainDesignDoc'; export default (actions, port, username, password, url, bucketName) => { return kc.getListener$(port, username, password) - .flatMap(listener => listener.getDatabase(url, bucketName, { name: 'main', doc: mainDesignDoc})) + .flatMap(listener => listener.getDatabase(url+":"+port+"/", bucketName, { name: 'main', doc: mainDesignDoc})) .map(data => { data.cb.startListen(data.info); return data.cb; }); -} \ No newline at end of file +} diff --git a/app/utils/kefirCouchbase.js b/app/utils/kefirCouchbase.js index e1115b145e0c9a49089a11de0550bf65830bfee3..3bdf7f10fd5829e2b71fa41120cf0b6729fe0ae8 100644 --- a/app/utils/kefirCouchbase.js +++ b/app/utils/kefirCouchbase.js @@ -57,8 +57,8 @@ class KefirCouchbase { this.compact = () => { return Kefir.fromCallback( cb => database.makeRequest("POST", database.databaseUrl + database.databaseName + "/_compact", null, cb)); }; } - setupReplication(userId, password, remoteServerUrl , remoteBucketName) { - const remoteDbUrl = `${remoteServerUrl}/${remoteBucketName}`; + setupReplication(userId, password, remoteServerUrl , port ,remoteBucketName) { + const remoteDbUrl = `${remoteServerUrl}:${port}/${remoteBucketName}`; const sessionUrl = `${remoteDbUrl}/_session`; const self = this; diff --git a/config/config.default.js b/config/config.default.js new file mode 100644 index 0000000000000000000000000000000000000000..9ce820f220a1da8a95de583e4eb8f7e8acd2a1bc --- /dev/null +++ b/config/config.default.js @@ -0,0 +1,12 @@ +module.exports = { + cb_replication_host: "$REPLICATION_HOST", + cb_replication_port : $REPLICATION_PORT, + cb_replication_user : "$REPLICATION_USER", + cb_replication_password : "$REPLICATION_PASSWORD", + cb_replication_bucket : "$REPLICATION_BUCKET", + cb_local_host : "$LOCAL_HOST", + cb_local_port : $LOCAL_PORT, + cb_local_user : "$LOCAL_USER", + cb_local_password : "$LOCAL_PASSWORD", + cb_local_bucket : "$LOCAL_BUCKET" +};