Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

713 changes: 687 additions & 26 deletions .idea/workspace.xml

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions client-side-chat/.angular-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "client-side-chat"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
54 changes: 54 additions & 0 deletions client-side-chat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "client-side-chat",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"body-parser": "^1.18.2",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"cors": "^2.8.4",
"file-system": "^2.2.2",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.5.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.2.0",
"express": "^4.16.2",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
18 changes: 18 additions & 0 deletions client-side-chat/server/data/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"username": "Mr. Nice",
"password": 1237
},
{
"username": "leon",
"password": 1
},
{
"username": "aviv",
"password": 1234
},
{
"username": "tealterMashoo",
"password": 5555
}
]
9 changes: 9 additions & 0 deletions client-side-chat/server/routes/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express');
const router = express.Router();

/* GET api listing. */
router.get('/', (req, res) => {
res.send('api works');
});

module.exports = router;
69 changes: 69 additions & 0 deletions client-side-chat/server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Get dependencies

const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
var file = require('file-system');
var fs = require('fs');
var cors = require('cors');

// Get our API routes
const api = require('./routes/api');

const app = express();

app.use(cors());
// Parsers for POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));

// Point static path to dist
app.use(express.static(path.join(__dirname, 'dist')));
// Set our api routes
app.use('/api', api);

// Catch all other routes and return the index file
app.get('/validate/:username', (req, res) => {
if (doesUserExist(req.params.username))
res.send(jsonUsers.find(user => user.username === req.params.username));
else
res.send('user doesnt exist!');
});

app.post('/validate', (req, res) => {

if (doesUserExist(req.body.username)) {
let tempUser = jsonUsers.find(user => user.username === req.body.username);
if (tempUser.password === parseInt(req.body.password))
res.send(tempUser);
else
send('username or password incorrect, please try again');
}
else
res.send('user doesnt exist!');
});

/**
* Get port from environment and store in Express.
*/
const port = process.env.PORT || '3000';
app.set('port', port);

/**
* Create HTTP server.
*/
const server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port, () => console.log(`API running on localhost:${port}`));

var jsonUsers = JSON.parse(fs.readFileSync('C:\\Users\\Jbt\\WebstormProjects\\angular-team-chat-aviv\\client-side-chat\\server\\data\\users.json'), 'utf-8');

function doesUserExist(username) {
return jsonUsers.filter(user => user.username === username).length === 1;
}

//sfsadfgsd
Empty file.
10 changes: 10 additions & 0 deletions client-side-chat/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{title}}!
</h1>
<app-sign-in-component></app-sign-in-component>

<app-rooms-component></app-rooms-component>
</div>
<base href="/">
27 changes: 27 additions & 0 deletions client-side-chat/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
10 changes: 10 additions & 0 deletions client-side-chat/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
46 changes: 46 additions & 0 deletions client-side-chat/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { SignInComponentComponent } from './sign-in-component/sign-in-component.component';
import { RoomsComponentComponent } from './rooms-component/rooms-component.component';

const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'hero/:id', component: HeroDetailComponent },
{
path: 'heroes',
component: HeroListComponent,
data: { title: 'Heroes List' }
},
{ path: '',
redirectTo: '/users',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];


@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
RouterModule,
// RouterModule.forRoot(
// // appRoutes,
// { enableTracing: true } // <-- debugging purposes only
// )
],

declarations: [
AppComponent,
SignInComponentComponent,
RoomsComponentComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
rooms-component works!
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { RoomsComponentComponent } from './rooms-component.component';

describe('RoomsComponentComponent', () => {
let component: RoomsComponentComponent;
let fixture: ComponentFixture<RoomsComponentComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RoomsComponentComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(RoomsComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'app-rooms-component',
templateUrl: './rooms-component.component.html',
styleUrls: ['./rooms-component.component.css'],
encapsulation: ViewEncapsulation.None
})
export class RoomsComponentComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<base href="/">
<div class="container">
<div class="row">
<div class="col-xs-offset-3 col-xs-6">
<div class="panel panel-primary">
<div class="panel-heading ">
<span>Sign In</span>
</div>
<div class="details">
<div>
<label for="UserName">UserName:</label>
<input [(ngModel)]="user.username" id="UserName" type="text" class="form-control" placeholder="UserName"
name="UserName">
</div>
<div>
<label for="PassWord">Password:</label>
<input [(ngModel)]="user.password" id="Password" type="password" class="form-control" placeholder="Password"
name="Password"><br>
</div>
<button (click)="submit()" type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</div>
</div>
</div>

Loading