Skip to content

Commit b7fbf65

Browse files
committed
actual version / clean
0 parents  commit b7fbf65

File tree

6,642 files changed

+494087
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,642 files changed

+494087
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"typescript.tsdk": "./node_modules/typescript/lib"
4+
}

app.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
var express = require('express');
2+
var path = require('path');
3+
var favicon = require('serve-favicon');
4+
var logger = require('morgan');
5+
var cookieParser = require('cookie-parser');
6+
var bodyParser = require('body-parser');
7+
var mongoose = require('mongoose');
8+
9+
/* requêtes voyagent top à bottom.
10+
MIDDLEWARE: fonction appliquée sur la requête.
11+
*/
12+
13+
//import les routes de l'app
14+
var appRoutes = require('./routes/app');
15+
var adminRoutes = require('./routes/admins');
16+
var clientRoutes = require('./routes/clients')
17+
18+
//Express framework.
19+
var app = express();
20+
mongoose.connect('localhost:27017/sarahdb2');
21+
22+
//setup du view engine. Le template choisi est HandleBars, syntax html avec embedded variables.
23+
app.set('views', path.join(__dirname, 'views'));
24+
app.set('view engine', 'hbs');
25+
26+
// décommenter après placer favicon dans /public
27+
app.use(favicon(path.join(__dirname, 'public', 'img', 'favicon.ico')));
28+
app.use(logger('dev'));
29+
//parser le body de la requête. Extract Json data ou url-encoded data.
30+
app.use(bodyParser.json());
31+
app.use(bodyParser.urlencoded({
32+
extended: false
33+
}));
34+
app.use(cookieParser());
35+
//exposer le dossier public au browser.
36+
app.use(express.static(path.join(__dirname, 'public')));
37+
38+
//si client, serveur ne sont pas servis sur le même port.
39+
app.use(function (req, res, next) {
40+
res.setHeader('Access-Control-Allow-Origin', '*');
41+
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, PATCH, DELETE');
42+
next();
43+
});
44+
45+
//Routing: diriger les requêtes au bon routeur.
46+
app.use('/admin', adminRoutes);
47+
app.use('/client', clientRoutes);
48+
app.use('/', appRoutes);
49+
50+
//catch 404 et passe au error handler.
51+
app.use(function (req, res, next) {
52+
var err = new Error('Not Found');
53+
err.status = 404;
54+
next(err);
55+
});
56+
57+
//error handlers.
58+
59+
//error handler développement.
60+
if (app.get('env') === 'development') {
61+
app.use(function (err, req, res, next) {
62+
res.status(err.status || 500);
63+
res.json({
64+
message: err.message,
65+
error: err
66+
});
67+
});
68+
}
69+
70+
//error handler production.
71+
app.use(function (err, req, res, next) {
72+
res.status(err.status || 500);
73+
res.render('erreur', {
74+
message: err.message,
75+
error: {}
76+
});
77+
});
78+
79+
module.exports = app;

assets/app/app.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
moduleId: module.id,
5+
selector: 'my-app',
6+
template: `
7+
<my-header></my-header>
8+
<my-login></my-login>
9+
<router-outlet></router-outlet>
10+
<my-error></my-error>
11+
`,
12+
styles:[`
13+
`]
14+
})
15+
export class AppComponent {
16+
17+
18+
}

assets/app/app.environment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: false
3+
};

assets/app/app.module.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4+
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
5+
import { provide } from '@angular/core';
6+
import { HttpModule } from '@angular/http';
7+
8+
import { AppComponent } from './app.component';
9+
import { HeaderComponent } from './header/header.component';
10+
import { LogoComponent } from './header/header.logo.component';
11+
import { LoginComponent } from './login/login.component';
12+
import { HomeComponent } from './login/home.component';
13+
14+
import { routing } from './app.routes';
15+
16+
//auth
17+
import { AuthComponent } from './auth/auth.component';
18+
import { SigninComponent } from './auth/signin.component';
19+
import { LogoutComponent } from './auth/logout.component';
20+
import { SignupComponent } from './auth/signup.component';
21+
import { AuthService } from './auth/auth.service';
22+
23+
//errors
24+
import { ErrorComponent } from './errors/error.component';
25+
import { ErrorService } from './errors/error.service';
26+
27+
//client
28+
import { ClientComponent } from './clients/client.component';
29+
import { ClientsComponent } from './clients/clients.component';
30+
import { CreerClientComponent } from './clients/client-creer.component';
31+
import { ClientWidgetsComponent } from './clients/client-widgets.component';
32+
import { ClientListComponent } from './clients/client-list.component';
33+
import { ClientService } from './clients/client.service';
34+
35+
//pipes
36+
import { CapitalizePipe } from './pipes/capitalize.pipe';
37+
38+
//nouvelles
39+
import { NouvellesComponent } from './login/nouvelles.component';
40+
41+
@NgModule({
42+
declarations: [AppComponent, HeaderComponent, LogoComponent, LoginComponent, HomeComponent, SigninComponent, LogoutComponent,
43+
SignupComponent, AuthComponent, ErrorComponent, ClientComponent, ClientsComponent, CreerClientComponent, ClientWidgetsComponent,
44+
ClientListComponent, NouvellesComponent, CapitalizePipe],
45+
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule, routing],
46+
bootstrap: [AppComponent],
47+
providers: [provide(LocationStrategy, {useClass: HashLocationStrategy}), AuthService, ErrorService, ClientService]
48+
})
49+
export class AppModule {}

assets/app/app.routes.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { RouterConfig, RouterModule, Routes } from '@angular/router';
2+
import { HomeComponent } from './login/home.component';
3+
4+
import { AuthComponent } from './auth/auth.component';
5+
import { ADMIN_ROUTES } from './auth/admin.routes';
6+
7+
import { ClientsComponent } from './clients/clients.component';
8+
import { CLIENT_ROUTES } from './clients/client.routes';
9+
10+
11+
const routes: RouterConfig = ([
12+
{ path: '', component: HomeComponent},
13+
{ path: 'auth', component: AuthComponent, children: ADMIN_ROUTES },
14+
{ path: 'clients', component: ClientsComponent, children: CLIENT_ROUTES}
15+
]);
16+
17+
export const routing = RouterModule.forRoot(routes);

assets/app/auth/admin.routes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RouterConfig, Routes, RouterModule } from '@angular/router';
2+
import { SignupComponent } from './signup.component';
3+
import { SigninComponent } from './signin.component';
4+
import { LogoutComponent } from './logout.component';
5+
6+
export const ADMIN_ROUTES: RouterConfig = [
7+
{ path: '', component: SignupComponent },
8+
{ path: 'signup', component: SignupComponent},
9+
{ path: 'signin', component: SigninComponent},
10+
{ path: 'logout', component: LogoutComponent}
11+
];

assets/app/auth/auth.component.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { AuthService } from './auth.service';
3+
4+
@Component({
5+
moduleId: module.id,
6+
selector: 'my-auth',
7+
template: `
8+
<div class="row spacing">
9+
<nav class="col-md-8 col-md-offset-2">
10+
<ul class="nav nav-tabs">
11+
<li routerLinkActive="router-link-active" *ngIf="!estLogIn()"><a [routerLink]="['signup']">Signup</a></li>
12+
<li routerLinkActive="router-link-active" *ngIf="!estLogIn()"><a [routerLink]="['signin']">Signin</a></li>
13+
<li routerLinkActive="router-link-active" *ngIf="estLogIn()"><a [routerLink]="['logout']">Logout</a></li>
14+
</ul>
15+
</nav>
16+
</div>
17+
<div class="row spacing">
18+
<router-outlet></router-outlet>
19+
</div>
20+
`,
21+
styles: [`
22+
.router-link-active, a:active{
23+
color:#555;
24+
cursor: pointer;
25+
background-color: #fff;
26+
border: #px solid #ddd;
27+
border-bottom-color: transparent;
28+
}
29+
30+
a{
31+
font-size: 1vw;
32+
}
33+
34+
`]
35+
})
36+
export class AuthComponent implements OnInit {
37+
constructor(private _authService: AuthService) { }
38+
39+
ngOnInit() { }
40+
41+
estLogIn(){
42+
return this._authService.estLogIn();
43+
}
44+
}

0 commit comments

Comments
 (0)