diff --git a/.gitignore b/.gitignore index 9629e00b643d71e4fb42789d9721d9b9eb805668..3fef9c087532c459f216115e0bbeeaba12a7b407 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,11 @@ ebin/ */webpack-assets.json */.editorconfig */.gitignore +<<<<<<< HEAD +======= +webpack.dev.config.babel.js +webpack.prod.config.babel.js +>>>>>>> wip # Logs logs @@ -19,7 +24,7 @@ logs .editorconfig /node_modules/ -/webpackConfigs/ + /build/ /bundle/ /config/ \ No newline at end of file diff --git a/src/componets/AuthForm/AuthForm.component.js b/src/componets/AuthForm/AuthForm.component.js new file mode 100644 index 0000000000000000000000000000000000000000..78f1762bf7c7bc797af304fdba25e477d28abaa1 --- /dev/null +++ b/src/componets/AuthForm/AuthForm.component.js @@ -0,0 +1,3 @@ +import React from 'react'; + +const \ No newline at end of file diff --git a/src/componets/ChatListItem/ChatListItem.js b/src/componets/ChatListItem/ChatListItem.js index dabbea0f7863e18fccb636b2c3dd5614a3886239..b0425b62cb09edee3b45cfe13a6e493197bd93b7 100644 --- a/src/componets/ChatListItem/ChatListItem.js +++ b/src/componets/ChatListItem/ChatListItem.js @@ -58,7 +58,8 @@ class ChatListItem extends Component { - {handleOpenChat()}} classes={{root: classes.button}}>Quick Reply + /* remove variant caused error*/ + {handleOpenChat()}} classes={{root: classes.button}}>Quick Reply diff --git a/src/componets/PaperWithDrop/PaperWithDrop.js b/src/componets/PaperWithDrop/PaperWithDrop.js index dc409f2ff43eb98c01080ddd5e6d0c0c99d7b1c5..bbaae3179ee2e27c445f0780fed3d2744dd60250 100644 --- a/src/componets/PaperWithDrop/PaperWithDrop.js +++ b/src/componets/PaperWithDrop/PaperWithDrop.js @@ -36,7 +36,8 @@ class PaperWithDrop extends React.Component { { data } - + /* remove variant caused error*/ + diff --git a/src/containers/Auth/AuthForm/AuthForn.container.js b/src/containers/Auth/AuthForm/AuthForn.container.js new file mode 100644 index 0000000000000000000000000000000000000000..759844477c095f3afbc609ecbc407758f76c1773 --- /dev/null +++ b/src/containers/Auth/AuthForm/AuthForn.container.js @@ -0,0 +1,122 @@ +import React, { Component } from 'react'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + + +class AuthForm extends Component { + render() { + return ( + + + + + + + + + + + + + + + Phone Number + + Please choose your country and enter your phone number. + + + + + + + + + + + + + + + + + + + Next + + + + + + + + + + Security Code + + We've sent a security code to your phone. + You should receive it within 60 seconds. + + Haven't received the code? + Haven't received the code? + + + + + + + + + + + + + + + Next + + + + + + + + + + Your Name + + How would you like to be called? + + + + First Name* + + + + Last Name + + + + Done + + + + + + + + + + + By signing in, you acknowledge that you have read and accept our Terms of + Service. + + + + + + + + + ) + } +} \ No newline at end of file diff --git a/src/containers/Auth/CompletionForm/CompletionAuthForm.container.js b/src/containers/Auth/CompletionForm/CompletionAuthForm.container.js new file mode 100644 index 0000000000000000000000000000000000000000..518bd44956c8ffc75c48502bb037379113100195 --- /dev/null +++ b/src/containers/Auth/CompletionForm/CompletionAuthForm.container.js @@ -0,0 +1,7 @@ +import React, { Component } from 'react'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + +class CompletionAuthForm extends Component { + +} \ No newline at end of file diff --git a/src/containers/Auth/VerifyForm/VerifyAuthForm.container.js b/src/containers/Auth/VerifyForm/VerifyAuthForm.container.js new file mode 100644 index 0000000000000000000000000000000000000000..e1879d80245e442a1ee2352d62d8ee1f67692611 --- /dev/null +++ b/src/containers/Auth/VerifyForm/VerifyAuthForm.container.js @@ -0,0 +1,4 @@ +import React, { Component } from 'react'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + diff --git a/src/core/bert/Converter.bert.js b/src/core/bert/Converter.bert.js index 81e7c93a3213799edf3f3a2b8fa312bc84f92b63..a1026ab1cccebeb169c6ac336fed5e31bb8a57b6 100644 --- a/src/core/bert/Converter.bert.js +++ b/src/core/bert/Converter.bert.js @@ -92,4 +92,21 @@ const convertToBert = (payload) => ( ); -export { enc as encode, dec as decode, convertToBert }; \ No newline at end of file +export { + enc as encode, + dec as decode, + convertToBert, + + + uc, + ar, + fl, + bin, + nop, + number, + tuple, + atom, + din, + run, + big +}; \ No newline at end of file diff --git a/src/core/bert/SignatureGenerator.bert.js b/src/core/bert/SignatureGenerator.bert.js index a95e0acf214dddafe524dbfa387831ddeb803cff..434a3ec292fb797fa85534e69e12e48410d07a25 100644 --- a/src/core/bert/SignatureGenerator.bert.js +++ b/src/core/bert/SignatureGenerator.bert.js @@ -1,4 +1,17 @@ import { utf8_dec, utf8_toByteArray } from '../utils/Utf8.util'; +import { + uc, + ar, + fl, + bin, + nop, + number, + tuple, + atom, + din, + run, + big +} from './Converter.bert'; function clean(r) { for(var k in r) if(!r[k]) delete r[k]; return r; } function check_len(x) { try { return (eval('len'+utf8_dec(x.v[0].v))() == x.v.length) ? true : false } diff --git a/src/core/loggers/SentryError.logger b/src/core/loggers/SentryError.logger deleted file mode 100644 index 6e39bd9dec48afaaab6f154f21218524e76103b1..0000000000000000000000000000000000000000 --- a/src/core/loggers/SentryError.logger +++ /dev/null @@ -1,10 +0,0 @@ -import Raven from 'raven-js'; - -export default ( - Raven - .config( - 'https://1febbedf16804e8eb4586fa445f8567c@sentry.io/253546', - { autoBreadcrumbs: false } - ) - .install() -); \ No newline at end of file diff --git a/src/core/protocols/Index.protocol.js b/src/core/protocols/Index.protocol.js index dd85b98aea7073bc56988229ad97cdbc526e1ea1..6227ef44442b30c9d5373ae6a115db960a2995e0 100644 --- a/src/core/protocols/Index.protocol.js +++ b/src/core/protocols/Index.protocol.js @@ -23,35 +23,32 @@ const check = node => { const factory = (name = '', utils = {}, eventFormer = null, ...args) => { - let response; const delimiter = '/'; const eventFormerCopy = eventFormer; const prepareEvent = (pipe = []) => { if(!Array.isArray(pipe)) { return; } - return pipe.join(delimiter) + return pipe.join(delimiter).toUpperCase(); }; if(!eventFormer) { eventFormer = (res = []) => { - response = utils.decode(res); return prepareEvent([ name, - response.status + res.status ]); } } else { eventFormer = (res = []) => { - response = utils.decode(res); - prepareEvent(eventFormerCopy(response)); + return prepareEvent(eventFormerCopy(res)); } } + console.log(name,) return { name, ...utils, eventFormer, - response, ...args } }; diff --git a/src/core/protocols/Topic.protocol.js b/src/core/protocols/Topic.protocol.js index 3d70b2f1a86037f4cefbef34f6990dff05a58ff6..ad93347c2a7da9512c91e7534ed4debce8e04409 100644 --- a/src/core/protocols/Topic.protocol.js +++ b/src/core/protocols/Topic.protocol.js @@ -6,7 +6,7 @@ const generateNumber = () => ( Math.floor((Math.random() * config.NODES) + 1) ); -const topic = (prefix, ...args) => { +const buildTopic = (prefix = 'events', ...args) => { //TODO: ?? let pipe = [ prefix, ...args, @@ -18,4 +18,4 @@ const topic = (prefix, ...args) => { return pipe.join('/') + '/'; }; -export { topic }; \ No newline at end of file +export { buildTopic }; \ No newline at end of file diff --git a/src/core/protocols/Validator.protocol.js b/src/core/protocols/Validator.protocol.js index b86f1ed37c66f6a94c54b9a260ccadabed41067e..2e50d4649b162f344bb0bc3d9f8ce95fd8154d82 100644 --- a/src/core/protocols/Validator.protocol.js +++ b/src/core/protocols/Validator.protocol.js @@ -2,19 +2,21 @@ import * as protocols from './Index.protocol'; const isCorrespond = (x, num, name) => ( x == undefined - ? false - : (x.t == 106 ? false : (x.v.length === num && x.v[0].v.toLowerCase() === name)) + ? false + : (x.t == 106 ? false : (x.v.length === num && x.v[0].v.toLowerCase() === name)) ); const validate = (res) => { - for(let protocol in protocols) { + for(let protocol in protocols) { let node = protocols[protocol](); - if(isCorrespond(res, node.len(), node.name)) { - return { - event: node.eventFormer(res), - response: node.response - }; + if(isCorrespond(res, node.len(), node.name)) { + const response = node.decode(res); + const event = node.eventFormer(response); + return { + response, + event + } } } return; diff --git a/src/core/protocols/index.js b/src/core/protocols/index.js index e168f8dda37b6affe8cb1dcbcdb13d09b14f7551..6d6e3eafc9e25eb305a21a1cac5715c31b5a68b2 100644 --- a/src/core/protocols/index.js +++ b/src/core/protocols/index.js @@ -1,3 +1,3 @@ -import { topic } from './Topic.protocol'; +import { buildTopic } from './Topic.protocol'; -export { topic }; \ No newline at end of file +export { buildTopic }; \ No newline at end of file diff --git a/src/core/resource/Combined.action.js b/src/core/resource/Combined.action.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2c9de8f49b4f7e50f86484ef337a9652f42ab7 --- /dev/null +++ b/src/core/resource/Combined.action.js @@ -0,0 +1,10 @@ +import { authInitActions } from './auth/init'; +import { authVerifyActions } from './auth/verification'; +import { supplierActions } from './supplier'; + +export const combinedActions = { + ...authInitActions, + ...authVerifyActions, + ...supplierActions +}; + diff --git a/src/core/resource/Root.reducer.js b/src/core/resource/Root.reducer.js index d0789f0eb52a17346aa7669bddfbe19001fede4c..c566f795b7ec96564726088b54bcaceb02ab87f8 100644 --- a/src/core/resource/Root.reducer.js +++ b/src/core/resource/Root.reducer.js @@ -1,11 +1,13 @@ import { combineReducers } from 'redux'; import { supplier } from './supplier/data/Supplier.reducer'; import { authInitReducers } from './auth/init'; +import { profile } from './profile' const rootReducer = combineReducers({ supplier, - profile: combineReducers({ - credentials: authInitReducers.credentials + user: combineReducers({ + profile, + auth: authInitReducers.credentials }) }); diff --git a/src/core/resource/auth/completion/index.js b/src/core/resource/auth/completion/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/core/resource/auth/init/index.js b/src/core/resource/auth/init/index.js index b49c12d8d0040fadd766f0787c72d7e84e4cb028..fe8b5be86cec7960f9dd2bd59ad583c194532312 100644 --- a/src/core/resource/auth/init/index.js +++ b/src/core/resource/auth/init/index.js @@ -8,6 +8,7 @@ const authInitReducers = { }; export { + authInitApi, authInitSagas, authInitActions, authInitReducers diff --git a/src/core/resource/auth/login/index.js b/src/core/resource/auth/login/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c71d9f18f516cdda97e6860377d1c06521ebbb5f --- /dev/null +++ b/src/core/resource/auth/login/index.js @@ -0,0 +1,3 @@ +import { login } from './sagas/Login.saga'; + +export { login }; \ No newline at end of file diff --git a/src/core/resource/auth/login/sagas/Login.saga.js b/src/core/resource/auth/login/sagas/Login.saga.js new file mode 100644 index 0000000000000000000000000000000000000000..be2e0f61d24aba2116e2475ea6941f219c286644 --- /dev/null +++ b/src/core/resource/auth/login/sagas/Login.saga.js @@ -0,0 +1,20 @@ +import { take, call } from 'redux-saga/effects'; +import { getSupplier } from 'Core/services'; +import { setupClientEntry } from 'Core/store'; +import { supplierActions } from 'Core/resource/supplier'; + +function * login() { + const supplier = getSupplier(); + yield call(supplier.close); + if(!supplier.connected) { + yield put( + supplierActions.connecting, + { + clientId: setupClientEntry('emqttd_'), + cleanSession: false + } + ) + } +} + +export { login }; \ No newline at end of file diff --git a/src/core/resource/auth/verification/sagas/VerifyCredentials.saga.js b/src/core/resource/auth/verification/sagas/VerifyCredentials.saga.js index 08843c87799e593e0dda471fb812fafb4a7e8e0e..3702356f4a7b3a7ec173272dae5e148600c95d44 100644 --- a/src/core/resource/auth/verification/sagas/VerifyCredentials.saga.js +++ b/src/core/resource/auth/verification/sagas/VerifyCredentials.saga.js @@ -1,12 +1,13 @@ -import { fork, call, put, takeEvery, take, takeLatest } from 'redux-saga/effects'; +import { all, fork, call, put, takeEvery, take, takeLatest } from 'redux-saga/effects'; import { getProvider } from 'Core/services'; -import { api } from '../../init'; +import { authInitApi as api } from '../../init'; import { binPayload } from 'Tools/ErlangDebugger.tools'; import { sagas as logoutSagas } from '../../logout'; -import { getSupplier } from 'Core/services'; import * as actions from '../data/VerifyCredentials.action'; import * as actionsType from '../data/Verification.constant'; import * as selectors from '../data/Credentials.selector'; +import { login } from '../../login'; + function * verifyCodeHandler(data, client) { const request = { @@ -21,7 +22,7 @@ function * verifyCodeHandler(data, client) { try { const encoded = api.codeProcessConverter(request); - yield call(client.onPublish, encoded); + yield call(client.send, encoded); } catch (e) { yield put(actions.verifyCodeError()) @@ -37,11 +38,13 @@ function * verifyCode() { //call specific action and redirects to dashboard return; } - const supplier = getSupplier(); yield call(verifyCodeHandler, data, client); const response = yield take(actionsType.SERVER_CODE_VERFIY); yield put(actions.verifyCodeSuccess(response)); - yield call(supplier.onReopen); + yield all({ + reconnect: login, + + }); } } diff --git a/src/core/resource/index.js b/src/core/resource/index.js index ddecdb65281dbaff6da7a4742a24797231a1cc1b..02b48fabc6772df923542c5b2a8f7d591244ee4a 100644 --- a/src/core/resource/index.js +++ b/src/core/resource/index.js @@ -1,7 +1,9 @@ import { rootSaga } from './Root.saga'; import { rootReducer } from './Root.reducer'; +import { combinedActions } from './Combined.action' export { + combinedActions, rootReducer, rootSaga } \ No newline at end of file diff --git a/src/core/resource/messages/utils/FormatConverter.message.js b/src/core/resource/messages/utils/FormatConverter.message.js index 8d96ff4e1dedfe8a751ce84559156f691f9bfaec..406ee8f0ed2277b7276e3ceb0639c1e0a210bf8a 100644 --- a/src/core/resource/messages/utils/FormatConverter.message.js +++ b/src/core/resource/messages/utils/FormatConverter.message.js @@ -1,12 +1,16 @@ import { decode, convertToBert } from 'Core/bert/Converter.bert'; const formatter = (packet = {}) => { - const bert = convertToBert(packet.payload); - try { - return decode(bert); + const bert = convertToBert(packet.payload); + try { + return decode(bert); } catch(e) { //notify store, user, server } + + + + }; export { formatter }; \ No newline at end of file diff --git a/src/core/resource/profile/data/InitProfile.reducer.js b/src/core/resource/profile/data/InitProfile.reducer.js new file mode 100644 index 0000000000000000000000000000000000000000..5871347da1b6b1b18d91503a7799277d7e85051d --- /dev/null +++ b/src/core/resource/profile/data/InitProfile.reducer.js @@ -0,0 +1,26 @@ +import { createAction, createReducer } from 'redux-act'; + +const profileInit = createAction('PROFILE/INIT/SUCCES'); + +const handleLoad = (state, action) =>{ + console.log('ACTION INIT',state, action); + return { ...state, init: true, data: action } +} ; + +const initialState = { + init: false +}; + +const profile = createReducer(on => { + on(profileInit, handleLoad); +}, initialState); + +export const userActions = { + profileInit +}; + +export default profile; + +export function isLoaded(globalState) { + return globalState.profile && globalState.profile.init; +} \ No newline at end of file diff --git a/src/core/resource/profile/index.js b/src/core/resource/profile/index.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a8e0ac64a99f12dd557f18072890c12b8fd9654e 100644 --- a/src/core/resource/profile/index.js +++ b/src/core/resource/profile/index.js @@ -0,0 +1,6 @@ +import profile, { userActions } from './data/InitProfile.reducer'; + +export { + profile, + userActions +} \ No newline at end of file diff --git a/src/core/resource/profile/sagas/ProfileInit.saga.js b/src/core/resource/profile/sagas/ProfileInit.saga.js new file mode 100644 index 0000000000000000000000000000000000000000..cd12a9b3d96b43165d8fc3fd66dad08b4730de01 --- /dev/null +++ b/src/core/resource/profile/sagas/ProfileInit.saga.js @@ -0,0 +1 @@ +import { } diff --git a/src/core/resource/supplier/data/Initial.state.js b/src/core/resource/supplier/data/Initial.state.js index 173fbaad8e5e33693d4ec9d9020547241ad7b42a..74bf59b1d20d89135594db60bdc7133d035a973b 100644 --- a/src/core/resource/supplier/data/Initial.state.js +++ b/src/core/resource/supplier/data/Initial.state.js @@ -1,11 +1,11 @@ -import { topic } from 'Core/protocols/Topic.protocol'; +import { buildTopic } from 'Core/protocols/Topic.protocol'; const deliveryInfo = (data) => { return Object.assign( {}, { updated: new Date().toLocaleString(), - topic: topic(), + topic: buildTopic(), isError: false, isLoading: false, isSuccess: false diff --git a/src/core/resource/supplier/data/Supplier.action.js b/src/core/resource/supplier/data/Supplier.action.js index a1ec509a0f25886ff2ad77a6774232599d0f4d80..507fe8dbaac979a61b2a93411d56028fc24aae42 100644 --- a/src/core/resource/supplier/data/Supplier.action.js +++ b/src/core/resource/supplier/data/Supplier.action.js @@ -7,9 +7,9 @@ const serverResponse = (action, response, packet = {}) => { } }; -const connecting = (time) =>({ +const connecting = (config) =>({ type: actionTypes.CONNECTING, - time + config }); const connected = () => ({ diff --git a/src/core/resource/supplier/sagas/SupplierConnector.saga.js b/src/core/resource/supplier/sagas/SupplierConnector.saga.js index 6680b4aa118127afebad18c58c69e105ee5d7bcc..2dbee2be12b5f98f3223da83412e204e7c4f4f48 100644 --- a/src/core/resource/supplier/sagas/SupplierConnector.saga.js +++ b/src/core/resource/supplier/sagas/SupplierConnector.saga.js @@ -1,6 +1,6 @@ import { takeEvery, takeLatest, fork } from 'redux-saga/effects'; import { effects } from 'redux-saga' -import { supplierEventChannel } from '../../../services'; +import { supplierEventChannel } from 'Core/services'; import { CONNECTING } from '../data/Supplier.constant'; const { call, put, take } = effects; @@ -14,9 +14,7 @@ const mqttSaga = function* (action) { }; const connectInitiator = function* (params) { - while(true) { - const action = yield take(CONNECTING); - yield call(mqttSaga, action) - }}; + yield takeLatest(CONNECTING, mqttSaga); +} export { connectInitiator }; \ No newline at end of file diff --git a/src/core/services/MqttClient.service.js b/src/core/services/MqttClient.service.js index 2027f6f22c5180eade3e3cdfec92e1da35efb564..16efde2789cb6a968eab4337e09bbd3d75ae6194 100644 --- a/src/core/services/MqttClient.service.js +++ b/src/core/services/MqttClient.service.js @@ -3,51 +3,64 @@ import localForage from 'localforage'; import { encode, decode } from '../bert/Converter.bert'; import { topic } from '../protocols'; import { MqttLocaforageStore } from '../store'; -import { incomeDB, browserStorage } from '../store'; -import { binPayload } from '../../../tools/ErlangDebugger.tools' -import { DEV_KEY, CLIENT } from '../configs/BrowserStorage.config'; -import { setupClientEntry } from '../store/Browser.store'; +import { incomeDB, setupClientEntry, browserStorage } from '../store'; import mqttConfig from '../configs/MqttInit.config'; -let client; +let config, client; -const formatPath = ({ protocol, host, port, supplier }) => { - return `${ protocol }://${ host }:${ port }/${ supplier }`; +const configure = () => { + return config = Object.assign({}, { + clientId: setupClientEntry(), + password: browserStorage.getItem('token') + }, mqttConfig); +}; + +const getConfig = () => { + return config || configure(); }; +const setConfig = (customConfig) => { + return config ? Object.assign(config, customConfig) : customConfig; +}; const getSupplier = () => client ? client : null; const setSupplier = c => client = c; -const initSupplier = () => { - let config = { - clientId: setupClientEntry(), - password: browserStorage.getItem('token'), - ...mqttConfig - }; +const formatPath = ({ protocol, host, port, supplier }) => { + return `${ protocol }://${ host }:${ port }/${ supplier }`; +}; + +const initSupplier = (customConfig, url) => { + let config = configure(); - let client = mqtt.connect(formatPath(mqttConfig), config); + if(customConfig) { + config = setConfig(customConfig); + } + if(!url) { + url = formatPath(config); + } + let client = mqtt.connect(url, config); + + const send = (m, t = 'events', ...args) => { + m = encode(m); + t = topic(t); + binPayload(m); + return client.publish(t, m, ...args) + }; + + const close = () => { + return client.end(); + }; const xtendedClient = Object.assign(client, { - onClose: () => { - - }, - - send: (...args) => { - args[0] = topic(args[0]); - const message = args[1]; - if(message) { - args[1] = encode(message) - } - binPayload(args[1]); - return client.publish(...args); - } + send, + close }); setSupplier(xtendedClient); return xtendedClient; }; -export { initSupplier, getSupplier}; +export { initSupplier, getSupplier, setConfig, getConfig}; diff --git a/src/core/services/MqttEventChannel.service.js b/src/core/services/MqttEventChannel.service.js index b53d503ab3a34aefb82307b6af8eb52f9321f650..df9422fe8def558b3b21741da6cac1c029201cc1 100644 --- a/src/core/services/MqttEventChannel.service.js +++ b/src/core/services/MqttEventChannel.service.js @@ -2,7 +2,6 @@ import mqtt from 'mqtt'; import { buffers, eventChannel } from 'redux-saga' import { put } from 'redux-saga/effects'; import { bindActionCreators } from 'redux' -import { topic } from '../protocols'; //import { Store as MQTTLocalForageStore } from 'mqtt-localforage-store'; import { formatter } from '../resource/messages'; import { validate } from '../protocols/Validator.protocol'; @@ -10,13 +9,14 @@ import { initSupplier } from './MqttClient.service'; import mqttConfig from '../configs/MqttInit.config'; import * as eventTypes from '../configs/MqttEvents.config'; import { supplierActions } from '../resource/supplier'; - const bufferSize = 100; -const supplierEventChannel = () => eventChannel( +const supplierEventChannel = (action) => eventChannel( emitter => { - const client = initSupplier(); + const { config } = action; + const client = initSupplier(config); const boundEventHandlers = bindActionCreators(supplierActions, emitter); + client.on(eventTypes.CONNECT, function() { boundEventHandlers.connected(); //redux log @@ -30,22 +30,26 @@ const supplierEventChannel = () => eventChannel( boundEventHandlers.error(e) }); client.on(eventTypes.MESSAGE, function(topic, message, packet) { - boundEventHandlers.publish(topic, message, packet) + console.log(topic, message, packet); + //boundEventHandlers.publish(topic, message, packet) }); client.on(eventTypes.PACKETRECEIVE, function (packet = {}) { - if(!packet.payload) { + if(!packet.payload) { return; } - const processedResponse = formatter(mockReceivePacket); + const processedResponse = formatter(packet); let { event, response } = validate(processedResponse); boundEventHandlers.serverResponse(event, response, packet); console.log('PACKETRECEIVE', packet); + + boundEventHandlers.serverResponse(event, response, packet); + // put(event,response); + console.log("PACKETRECEIVE", event, response); }); client.on(eventTypes.PACKETSEND, function(packet) { console.log('PACKETSEND', packet); }); - //buffers.expanding(bufferSize); return client.end } diff --git a/src/core/services/index.js b/src/core/services/index.js index 56235ac564c9632106e17e9958bc23c2040f0345..4803bb3d3c5a160a11b69e18ef98cc45118b0684 100644 --- a/src/core/services/index.js +++ b/src/core/services/index.js @@ -1,4 +1,4 @@ import { getSupplier, initSupplier } from './MqttClient.service'; import supplierEventChannel from './MqttEventChannel.service'; -export { initSupplier, supplierEventChannel, getSupplier }; \ No newline at end of file +export { initSupplier, supplierEventChannel, getSupplier }; diff --git a/src/core/store/Browser.store.js b/src/core/store/Browser.store.js index 326e50411255e011712706665ff45555b17220db..633e85cec7f1c0508a481234417bbba1a877f9c5 100644 --- a/src/core/store/Browser.store.js +++ b/src/core/store/Browser.store.js @@ -1,14 +1,13 @@ import { browserStorage } from './index'; import { DEV_KEY, CLIENT} from '../configs/BrowserStorage.config'; -const genClientId = () => ( - Math.random().toString(36).substring(2) - + (new Date()).getTime().toString(36) -); - +const generateClientId = () => { + return Math.random().toString(36).substring(2) + + (new Date()).getTime().toString(36); +}; const setupDevEntry = () => { - let devKey = browserStorage.getItem(DEV_KEY) || genClientId(); + let devKey = browserStorage.getItem(DEV_KEY) || generateClientId(); browserStorage.setItem(DEV_KEY, devKey); diff --git a/src/core/store/Configure.dev.store.js b/src/core/store/Configure.dev.store.js index c24850bd1e5a800aac72fa6e488b22fb777325bc..f7e04abec890a0a5a042a7a8655426baa3d318d9 100644 --- a/src/core/store/Configure.dev.store.js +++ b/src/core/store/Configure.dev.store.js @@ -5,18 +5,21 @@ import reduxImmutableStateInvariant from 'redux-immutable-state-invariant'; import logger from 'redux-logger'; import trottle from 'lodash/throttle'; import { STORAGE_NAME, SAVE_TIME_DELAY } from '../configs/BrowserStorage.config'; -import { browserStorage } from './index'; +import { crashReporter } from '../middlewares' import { rootReducer } from '../resource'; import { rootSaga } from '../resource'; +import { browserStorage } from './index'; + const configureStore = () => { const sagaMiddleware = createSagaMiddleware(); const middlewares = [ + crashReporter, + logger, reduxImmutableStateInvariant(), - sagaMiddleware, - //loadingBarMiddleware({ scope: 'page' }), - logger + sagaMiddleware + //loadingBarMiddleware({ scope: 'page' }) ]; const composeExtenders = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; diff --git a/src/core/store/index.js b/src/core/store/index.js index 99700df55dda5ecb388dc1fc790ab0f2b9f07386..95697c5f71e46aa5bca60d710cc6b9b13b824b57 100644 --- a/src/core/store/index.js +++ b/src/core/store/index.js @@ -2,15 +2,14 @@ import { setupClientEntry, setupDevEntry } from './Browser.store'; import { incomeDB, outcomeDB } from './ConfigureBrowser.store'; import MqttLocaforageStore from './MqttLocaforage.store'; -console.log(process.env.NODE_ENV); - const configureStore = process.env.NODE_ENV === "development" ? require('./Configure.dev.store') - : ''; + : require('./Configure.prod.store'); const browserStorage = localStorage !== 'undefined' ? localStorage : outcomeDB; - export { +export { + setupDevEntry, setupClientEntry, browserStorage, configureStore, diff --git a/src/index.html b/src/index.html deleted file mode 100644 index 0f152d13d6d4836e5957c7d66920b965b38073f5..0000000000000000000000000000000000000000 --- a/src/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/index.js b/src/index.js index f096eaa0a5b600debcaecf034bf908d385cd4044..8091cb13932f6f8ced8a22d777d47e18b4f6bdc2 100644 --- a/src/index.js +++ b/src/index.js @@ -10,11 +10,11 @@ import Reboot from 'material-ui/Reboot'; require('./favicon.ico'); + render( - + , - document.getElementById('app') ); diff --git a/src/modules/index.js b/src/modules/index.js index da96417963e9114254835f26718cdc83a57c0ef1..2e5a0197d92675f1fafbbee81f89c33693dfcee8 100644 --- a/src/modules/index.js +++ b/src/modules/index.js @@ -3,7 +3,6 @@ import { combineReducers } from 'redux'; import Home from './Home/Home'; import Dashboard from './Dashboard/Dashboard'; import Chats from './Chats/Chats'; - import { AuthInit, CompletionAuth, diff --git a/src/pages/App/App.js b/src/pages/App/App.js index eb114ee57af54dfb04b2c617f8475a8768565ddb..ced4fa4f9264076af326f562f14dc9bab45f7865 100644 --- a/src/pages/App/App.js +++ b/src/pages/App/App.js @@ -1,6 +1,6 @@ import React, { Component, PropTypes } from 'react'; import { MuiThemeProvider } from 'material-ui'; -import {createMuiTheme} from "material-ui/styles/index"; +import { createMuiTheme } from "material-ui/styles/index"; export default class App extends Component { @@ -28,10 +28,10 @@ export default class App extends Component { } }, }); - console.log(theme); + return ( - { this.renderChildren(this.props.children, {}) } + { this.renderChildren(this.props.children, {}) } ) } diff --git a/src/pages/NinjaApp/NinjaApp.js b/src/pages/NinjaApp/NinjaApp.js index 7a3fafa259fca50896929936a51f1307ed2690ed..78fec5b1017f2f39f7016c32df20b6672e6451a7 100644 --- a/src/pages/NinjaApp/NinjaApp.js +++ b/src/pages/NinjaApp/NinjaApp.js @@ -14,6 +14,7 @@ const styles = theme => ({ }) + export class Dashboard extends Component { constructor(props) { diff --git a/src/root.js b/src/root.js index 1dc476ee7d20edcfea3ff9be8deeab3a4c408591..ecc34e77fe25de0ad1cf7b6638980506357eab2c 100644 --- a/src/root.js +++ b/src/root.js @@ -17,7 +17,9 @@ class Root extends Component { const history = createHistory(); return ( - test + + { routes() } + ) } diff --git a/src/routes.js b/src/routes.js index b00ba59edb38b784741b5c84702ea580c9ef6afd..5112accaec8a5fea0833e8ff8d78c4421ae5755d 100644 --- a/src/routes.js +++ b/src/routes.js @@ -28,8 +28,6 @@ export default () => { - - ); }; \ No newline at end of file diff --git a/src/template.ejs b/src/template.ejs old mode 100644 new mode 100755
Please choose your country and enter your phone number.
We've sent a security code to your phone.
You should receive it within 60 seconds.
+ Haven't received the code? + Haven't received the code? +
How would you like to be called?