-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding angular2-chat-app example #436
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cf66841
adding angular2-chat-app example
zubair-io 6826a30
moving files to dist
zubair-io 26abb20
Adding Angular2 Chat App link
53981e5
Removing typings
zubair-io 15fffe9
adding horizon config
zubair-io 099d31a
Updating to angular 2.0.0-rc.1
zubair-io 3c25cac
Moving Horizon to a service
zubair-io 74f8082
Merge remote-tracking branch 'rethinkdb/next' into angular2-chat-app
zubair-io 8f24a9f
Fixing missing input to sendChat
zubair-io File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# This is a TOML file | ||
|
||
############################################################################### | ||
# IP options | ||
# 'bind' controls which local interfaces will be listened on | ||
# 'port' controls which port will be listened on | ||
#------------------------------------------------------------------------------ | ||
# bind = [ "localhost" ] | ||
# port = 8181 | ||
|
||
|
||
############################################################################### | ||
# HTTPS Options | ||
# 'secure' will disable HTTPS and use HTTP instead when set to 'false' | ||
# 'key_file' and 'cert_file' are required for serving HTTPS | ||
#------------------------------------------------------------------------------ | ||
# secure = false | ||
# key_file = "horizon-key.pem" | ||
# cert_file = "horizon-cert.pem" | ||
|
||
|
||
############################################################################### | ||
# App Options | ||
# 'project_name' sets the name of the RethinkDB database used to store the | ||
# application state | ||
# 'serve_static' will serve files from the given directory over HTTP/HTTPS | ||
#------------------------------------------------------------------------------ | ||
project_name = "angular2_chat_app" | ||
# serve_static = "dist" | ||
|
||
|
||
############################################################################### | ||
# Data Options | ||
# WARNING: these should probably not be enabled on a publically accessible | ||
# service. Tables and indexes are not lightweight objects, and allowing them | ||
# to be created like this could open the service up to denial-of-service | ||
# attacks. | ||
# 'auto_create_collection' creates a collection when one is needed but does not exist | ||
# 'auto_create_index' creates an index when one is needed but does not exist | ||
#------------------------------------------------------------------------------ | ||
# auto_create_collection = true | ||
# auto_create_index = true | ||
|
||
|
||
############################################################################### | ||
# RethinkDB Options | ||
# These options are mutually exclusive | ||
# 'connect' will connect to an existing RethinkDB instance | ||
# 'start_rethinkdb' will run an internal RethinkDB instance | ||
#------------------------------------------------------------------------------ | ||
# connect = "localhost:28015" | ||
# start_rethinkdb = false | ||
|
||
|
||
############################################################################### | ||
# Debug Options | ||
# 'debug' enables debug log statements | ||
#------------------------------------------------------------------------------ | ||
# debug = true | ||
|
||
|
||
############################################################################### | ||
# Authentication Options | ||
# Each auth subsection will add an endpoint for authenticating through the | ||
# specified provider. | ||
# 'token_secret' is the key used to sign jwts | ||
# 'allow_anonymous' issues new accounts to users without an auth provider | ||
# 'allow_unauthenticated' allows connections that are not tied to a user id | ||
# 'auth_redirect' specifies where users will be redirected to after login | ||
#------------------------------------------------------------------------------ | ||
token_secret = "ST3Z1Bw9SVrHjIe/oA0HOEkJ7yVnh+mupIWcqjnt4woo/m5vAc2BFrt+cWfkVQysXiqfmC7NdrKkoFH4B4HKyA==" | ||
# allow_anonymous = true | ||
# allow_unauthenticated = true | ||
# auth_redirect = "/" | ||
# | ||
# [auth.facebook] | ||
# id = "000000000000000" | ||
# secret = "00000000000000000000000000000000" | ||
# | ||
# [auth.google] | ||
# id = "00000000000-00000000000000000000000000000000.apps.googleusercontent.com" | ||
# secret = "000000000000000000000000" | ||
# | ||
# [auth.twitter] | ||
# id = "0000000000000000000000000" | ||
# secret = "00000000000000000000000000000000000000000000000000" | ||
# | ||
# [auth.github] | ||
# id = "00000000000000000000" | ||
# secret = "0000000000000000000000000000000000000000" | ||
# | ||
# [auth.twitch] | ||
# id = "0000000000000000000000000000000" | ||
# secret = "0000000000000000000000000000000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Horizon Chat example using Angular2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
///<reference path="./horizon.d.ts" /> | ||
|
||
import {Component} from '@angular/core'; | ||
import {ChatComponent} from './components/chat/chat.component' | ||
|
||
@Component({ | ||
selector: 'my-app', | ||
template: '<chat></chat>', | ||
directives: [ChatComponent], | ||
styles:[` chat{ | ||
margin: auto; | ||
max-width: 800px; | ||
width:100%; | ||
display:block; | ||
|
||
} | ||
`] | ||
}) | ||
export class AppComponent { } |
91 changes: 91 additions & 0 deletions
91
examples/angular2-chat-app/dist/app/components/chat/chat.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {ChatService} from './chat.service' | ||
|
||
@Component({ | ||
selector: '<chat></chat>', | ||
styles: [` | ||
ul { | ||
list-style-type: none; | ||
padding:0; | ||
} | ||
|
||
.message { | ||
height: 50px; | ||
padding:5px; | ||
} | ||
|
||
.message img { | ||
vertical-align:middle; | ||
} | ||
.message .text { | ||
vertical-align:middle; | ||
margin-left:5px; | ||
font-size:20px; | ||
} | ||
.message .datetime { | ||
color:darkgrey; | ||
float:right; | ||
} | ||
form{ | ||
|
||
} | ||
input { | ||
width: 90%; | ||
height: 50px; | ||
font-size: 20px; | ||
float: left; | ||
padding: 10px; | ||
} | ||
button{ | ||
width:10%; | ||
height: 50px; | ||
} | ||
`], | ||
template: `<h1>Messages</h1> | ||
<form> | ||
<input [(ngModel)]="newMessage"> | ||
<button type="submit" (click)="addMessage(newMessage)">Send</button> | ||
</form> | ||
<ul> | ||
<li *ngFor="let message of messages; let i = index" class="message"> | ||
<img height="50px" width="50px" src="{{message.url}}" /> | ||
<span> {{message.text}} </span> | ||
<span class="datetime u-pull-right"> | ||
{{message.datetime}} | ||
</span> | ||
</li> | ||
</ul>`, | ||
providers:[ChatService] | ||
}) | ||
export class ChatComponent implements OnInit { | ||
newMessage = ''; | ||
messages = []; | ||
|
||
constructor(private _chatService: ChatService) { | ||
|
||
} | ||
ngOnInit() { | ||
this.getChats() | ||
} | ||
|
||
getChats = function () { | ||
this._chatService | ||
.getChats() | ||
.subscribe((newMessages) => { | ||
this.messages = [...newMessages]; | ||
}); | ||
} | ||
|
||
addMessage = function (text) { | ||
if (text) { | ||
this._chatService | ||
.sendChat(text) | ||
.subscribe(); | ||
this.newMessage = ''; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
examples/angular2-chat-app/dist/app/components/chat/chat.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {Observable} from 'rxjs' | ||
|
||
|
||
export class ChatService { | ||
horizon = Horizon(); | ||
chat = this.horizon('chat'); | ||
avatar_url = `http://api.adorable.io/avatars/50/${new Date().getMilliseconds()}.png`; | ||
|
||
|
||
constructor() { } | ||
getChats = function (): Observable<[any]> { | ||
return this.chat | ||
.order('datetime', 'descending') | ||
.limit(8) | ||
.watch() | ||
} | ||
|
||
sendChat = function (text: string): Observable<[any]> { | ||
return this.chat.store({ | ||
text: text, | ||
datetime: new Date(), | ||
url: this.avatar_url, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare var Horizon: any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { bootstrap } from '@angular/platform-browser-dynamic'; | ||
import { AppComponent } from './app.component'; | ||
|
||
bootstrap(AppComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Angular 2 QuickStart</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script type="text/javascript" src="//localhost:8181/horizon/horizon.js"></script> | ||
<script type="text/javascript" src="/horizon/horizon.js"></script> | ||
|
||
<!-- 1. Load libraries --> | ||
<!-- IE required polyfills, in this exact order --> | ||
<script src="node_modules/typescript/lib/typescript.js"></script> | ||
<script src="node_modules/es6-shim/es6-shim.min.js"></script> | ||
|
||
<script src="node_modules/zone.js/dist/zone.js"></script> | ||
<script src="node_modules/reflect-metadata/Reflect.js"></script> | ||
<script src="node_modules/systemjs/dist/system.src.js"></script> | ||
|
||
<!-- 2. Configure SystemJS --> | ||
<script src="systemjs.config.js"></script> | ||
<script> | ||
System.import('app').catch(function(err){ console.error(err); }); | ||
</script> | ||
</head> | ||
<!-- 3. Display the application --> | ||
|
||
<body> | ||
<my-app>Loading...</my-app> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "angular2-chat-app", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"postinstall": "typings install", | ||
"typings": "typings" | ||
}, | ||
"license": "ISC", | ||
"dependencies": { | ||
"@angular/common": "2.0.0-rc.1", | ||
"@angular/compiler": "2.0.0-rc.1", | ||
"@angular/core": "2.0.0-rc.1", | ||
"@angular/http": "2.0.0-rc.1", | ||
"@angular/platform-browser": "2.0.0-rc.1", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.1", | ||
"systemjs": "0.19.27", | ||
"es6-shim": "^0.35.0", | ||
"reflect-metadata": "^0.1.3", | ||
"rxjs": "5.0.0-beta.6", | ||
"zone.js": "^0.6.12", | ||
"typescript": "^1.8.9" | ||
}, | ||
"devDependencies": { | ||
"typings":"^0.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function(global) { | ||
|
||
// map tells the System loader where to look for things | ||
var map = { | ||
'app': 'app', // 'dist', | ||
'rxjs': 'node_modules/rxjs', | ||
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', | ||
'@angular': 'node_modules/@angular' | ||
}; | ||
// packages tells the System loader how to load when no filename and/or no extension | ||
var packages = { | ||
'app': { main: 'main.ts', defaultExtension: 'ts' }, | ||
'rxjs': { defaultExtension: 'js' }, | ||
'angular2-in-memory-web-api': { defaultExtension: 'js' }, | ||
}; | ||
var packageNames = [ | ||
'@angular/common', | ||
'@angular/compiler', | ||
'@angular/core', | ||
'@angular/http', | ||
'@angular/platform-browser', | ||
'@angular/platform-browser-dynamic', | ||
'@angular/testing', | ||
]; | ||
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' } | ||
packageNames.forEach(function(pkgName) { | ||
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; | ||
}); | ||
var config = { | ||
transpiler: 'typescript', | ||
typescriptOptions: { | ||
emitDecoratorMetadata: true | ||
}, | ||
map: map, | ||
packages: packages | ||
} | ||
System.config(config); | ||
})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "system", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"removeComments": false, | ||
"noImplicitAny": false | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"typings/main", | ||
"typings/main.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ambientDependencies": { | ||
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd", | ||
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to change the title so it's no longer 'Angular 2 QuickStart'. And add <!doctype html> to the top?