Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #21 from Viestinta/develop
Browse files Browse the repository at this point in the history
Develop to Master
  • Loading branch information
oleast authored Mar 13, 2017
2 parents b8124e6 + b827e64 commit a53ff55
Show file tree
Hide file tree
Showing 44 changed files with 1,108 additions and 313 deletions.
35 changes: 33 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
pipeline:
test:
image: node:7.5.0
image: viestinta/node:viestinta-test
when:
event: [push,pull_request]
branches: [master, react-start]
environment:
DATABASE_URL: postgres://postgres:[email protected]:5432
NODE_ENV: test
COVERALLS_REPO_TOKEN: $$COVERALLS_TOKEN
COVERALLS_TOKEN: $$COVERALLS_TOKEN
CODECOV_TOKEN: $$CODECOV_TOKEN

commands:
- npm install --silent
- cp -a /drone/node_modules /root
- npm install --depth=0 --quiet
- npm install standard -g
- npm install codecov -g
- npm run test
- cat ./coverage/lcov.info | codecov
- cp -a /root/node_modules /drone
volumes:
- "/drone/node_modules"

deploy:
image: plugins/ssh
when:
Expand All @@ -18,3 +32,20 @@ pipeline:
commands:
- bash /scripts/deploy-viestinta-prod.sh

services:
postgres:
image: postgres:9.6
container_name: viestinta_postgres
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: viestintacentos
POSTGRES_DB: viestintadb_dev

cache:
mount:
- /drone/node_modules



2 changes: 1 addition & 1 deletion .drone.yml.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdDogCiAgICBpbWFnZTogbm9kZTo3LjUuMAogICAgd2hlbjoKICAgICAgZXZlbnQ6IFtwdXNoLHB1bGxfcmVxdWVzdF0KICAgICAgYnJhbmNoZXM6IFttYXN0ZXIsIHJlYWN0LXN0YXJ0XQogICAgY29tbWFuZHM6CiAgICAgIC0gbnBtIGluc3RhbGwgLS1zaWxlbnQKICAgICAgLSBucG0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dAogICAgICAtIGNhdCAuL2NvdmVyYWdlL2xjb3YuaW5mbyB8IGNvZGVjb3YKICAgICAgLSBjcCAtYSAvcm9vdC9ub2RlX21vZHVsZXMgL2Ryb25lCiAgICB2b2x1bWVzOgogICAgICAtICIvZHJvbmUvbm9kZV9tb2R1bGVzIgoKICBkZXBsb3k6CiAgICBpbWFnZTogcGx1Z2lucy9zc2gKICAgIHdoZW46CiAgICAgIGV2ZW50OiBwdXNoCiAgICAgIGJyYW5jaDogcHJvZHVjdGlvbgogICAgaG9zdDogc3Rva2tlcnMubm8KICAgIHBvcnQ6IDIyMDE0CiAgICBjb21tYW5kczoKICAgICAgLSBiYXNoIC9zY3JpcHRzL2RlcGxveS12aWVzdGludGEtcHJvZC5zaAoKc2VydmljZXM6CiAgICBwb3N0Z3JlczoKICAgICAgaW1hZ2U6IHBvc3RncmVzOjkuNgogICAgICBjb250YWluZXJfbmFtZTogdmllc3RpbnRhX3Bvc3RncmVzCiAgICAgIHBvcnRzOgogICAgICAgIC0gIjU0MzI6NTQzMiIKICAgICAgZW52aXJvbm1lbnQ6CiAgICAgICAgUE9TVEdSRVNfVVNFUjogcG9zdGdyZXMKICAgICAgICBQT1NUR1JFU19QQVNTV09SRDogdmllc3RpbnRhY2VudG9zCiAgICAgICAgUE9TVEdSRVNfREI6IHZpZXN0aW50YWRiX2RldgoKY2FjaGU6CiAgbW91bnQ6CiAgICAtIC9kcm9uZS9ub2RlX21vZHVsZXMKCgoK.Rs-UC3geCk_5gYUXlbmTIsNXGdBYZIsgEVQdYj_TZn0
15 changes: 6 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
src/server/etc/config.json
src/server/config.json
*bundle.js
npm-debug.log


### Linux ###
*~

Expand Down Expand Up @@ -97,11 +91,14 @@ $RECYCLE.BIN/
*.lnk

#Pycharm settingsfile
.idea/*
.idea/
workspace.xml

# End of https://www.gitignore.io/api/linux,windows,node
.idea/
src/server/etc/
*config.json
*bundle.js
npm-debug.log
src/server/database/migrations/
src/server/database/seeders/


10 changes: 5 additions & 5 deletions .sequelizesrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var path = require('path');

module.exports = {
'config': path.resolve('./', 'config/config.js'),
'migrations-path': path.resolve('./', 'server/migrations'),
'seeders-path': path.resolve('./', 'server/seeders'),
'models-path': path.resolve('./', 'server/models')
};
'config': path.resolve('./', 'src/server/database/config/config.js'),
'migrations-path': path.resolve('./', 'src/server/database/migrations'),
'seeders-path': path.resolve('./', 'src/server/database/seeders'),
'models-path': path.resolve('./', 'src/server/database/models')
};
34 changes: 34 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'

services:
postgres:
image: postgres:9.6
container_name: viestinta_postgres
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: viestintacentos
POSTGRES_DB: viestintadb_dev
tty: true
stdin_open: true

nodejs:
build: .
image: node:viestinta
container_name: viestinta_node
depends_on:
- postgres
command: ["./wait-for-postgres.sh", "--", "npm" , "test"]
links:
- postgres
ports:
- "8000:8000"
volumes:
- .:/srv/app/
- /arv/app/node_modules
environment:
DATABASE_URL: postgres://postgres:viestintacentos@postgres:5432/viestintadb_dev
NODE_ENV: test
tty: true
stdin_open: true
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ services:

nodejs:
build: .
image: nodetest:viestinta
image: node:viestinta
container_name: viestinta_node
depends_on:
- postgres
command: ["./wait-for-postgres.sh", "--", "npm" , "start"]
command: bash -c "npm install && ./node_modules/.bin/webpack && sleep 5 && npm start"

links:
- postgres
Expand Down
26 changes: 24 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "grunt && sequelize db:migrate && sequelize db:seed:all && node src/server/app.js",
"test-client": "node src/server/app.js && mocha --compilers js:babel-core/register ./src/client/test",
"test-server": "node src/server/app.js && node src/tests/init.js",
"test": "node src/server/app.js && nyc --check-coverage --lines 60 mocha src/test/server/**.js && nyc report --reporter=text-lcov > ./coverage/lcov.info",
"start": "node src/server/app.js",
"lint": "standard ./server/* ./client/*",
"webpack": "./node_modules/.bin/webpack"
Expand Down Expand Up @@ -40,21 +40,30 @@
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"body-parser": "^1.16.0",
"codecov": "^1.0.1",
"cookie-parser": "^1.4.3",
"express": "^4.14.1",
"express-session": "^1.15.0",
"fs": "0.0.1-security",
"istanbul": "^0.4.5",
"latest-version": "^3.0.0",
"loadash": "0.0.1",
"mocha": "^3.2.0",
"morgan": "^1.7.0",
"nconf": "^0.8.4",
"nyc": "^10.1.2",
"passport": "^0.3.2",
"passport-dataporten": "^1.1.3",
"passport-openid-connect": "^0.1.0",
"path": "^0.12.7",
"pg": "^6.1.2",
"pg-hstore": "^2.3.2",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-tap-event-plugin": "^2.0.1",
"sequelize": "^3.30.2",
"sequelize-cli": "^2.5.1",
"socket.io-client": "^1.7.3",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0"
},
Expand All @@ -65,13 +74,19 @@
"babel-preset-react": "^6.23.0",
"chai": "^3.5.0",
"check-dependencies": "^1.0.1",
"codecov": "^1.0.1",
"coveralls": "^2.11.16",
"enzyme": "^2.7.1",
"eslint": "^3.15.0",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"http": "0.0.0",
"material-ui": "^0.17.0",
"istanbul": "^0.4.5",
"istanbul-coveralls": "^1.0.3",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"react-addons-test-utils": "^15.4.2",
"should": "^11.2.0",
"socket.io": "^1.7.2",
Expand All @@ -83,7 +98,14 @@
"presets": [
"es2015",
"react"
]
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
},
"standard": {
"globals": [
Expand Down
9 changes: 8 additions & 1 deletion src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import ReactDOM from 'react-dom'

import ChatApp from './components/ChatApp'

import injectTapEventPlugin from 'react-tap-event-plugin';

// Needed for onTouchTap
injectTapEventPlugin();

if (typeof window !== 'undefined') {
ReactDOM.render(
<ChatApp />, document.getElementById('app'))
<ChatApp id='chat-app' />,
document.getElementById('app')
)
}
77 changes: 43 additions & 34 deletions src/client/components/ChatApp.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,67 @@
import React, { Component } from 'react'
import socket from '../../server/socket'

// Theme
import {deepOrange500} from 'material-ui/styles/colors'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'

// Components
import ChatBox from './ChatBox'
import ChatField from './ChatField'
import MessageList from './MessageList'
import Header from './Header'
import Login from './Login'
import FeedbackBox from './FeedbackBox'

const styles = {
container: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
paddingTop: 0,
height: 'auto',
},
element: {
display: 'flex',
}
};

const muiTheme = getMuiTheme({
palette: {
primary1Color: '#ec7c2f', // Orange
accent1Color: '#2daae4', // Blue
}
})

export default class ChatApp extends Component {
// At beginning there is no msg and the text-field is empty
constructor (props) {
super(props)
this.state = {
messages: [],
text: '',
socket: io.connect()
}

this.sendMessage = this.sendMessage.bind(this)
this.join = this.join.bind(this)
this.receiveMessage = this.receiveMessage.bind(this)
}

componentDidMount () {
this.state.socket.on('join', this.join)
this.state.socket.on('send-message', this.sendMessage)
this.state.socket.on('receive-message', this.receiveMessage)
socket.on('join', this.join)
}

join () {
console.log('join')
this.state.socket.emit('join', 'Hello world from client')
}

receiveMessage (msg) {
console.log('receiveMessage: ', msg.text)
this.state.messages.push(msg)
this.setState({ messages: this.state.messages })
}

// When a message is submitted
sendMessage (msg) {
console.log('sendMessage: ', msg.text)
this.state.socket.emit('new-message', msg)
socket.emit('join', 'Hello world from client')
}

render () {
return (
<div id='content'>
<Header />
<Login />
<ChatField
messages={this.state.messages} />
<ChatBox
sendMessage={this.sendMessage} />
</div>
<MuiThemeProvider muiTheme={muiTheme}>
<div style={styles.container}>
<Header />
<Login />
{/* List of messages */}
<MessageList />
{/* Inputfield for user */}
<ChatBox />
{/* Sidebar with feedback-options */}
<FeedbackBox />
</div>
</MuiThemeProvider>
)
}
}
Loading

0 comments on commit a53ff55

Please sign in to comment.