From 68d693307db015817600eb5525cfea8f5cf306bf Mon Sep 17 00:00:00 2001 From: kiswa Date: Sat, 16 Jul 2016 12:09:31 +0000 Subject: [PATCH] Reorganize app files, setup initial routing and auth checks Log in/out is functional with notifications (modified from recipes project). Shared resources are now organized as such, with barrels to make imports simple. --- package.json | 1 + src/.htaccess | 8 + src/api/controllers/Auth.php | 5 + src/app/app.component.html | 2 + src/app/app.component.ts | 4 +- src/app/app.routes.ts | 22 ++- src/app/board/board.component.html | 153 +++++++++++------- src/app/board/board.component.ts | 2 +- src/app/dashboard/dashboard.component.html | 2 + src/app/dashboard/dashboard.component.ts | 3 +- src/app/login/login.component.html | 16 +- src/app/login/login.component.ts | 33 +++- src/app/main.ts | 17 +- src/app/settings/settings.component.html | 4 +- src/app/settings/settings.component.ts | 5 +- src/app/shared/auth/auth.guard.ts | 20 +++ src/app/shared/auth/auth.service.ts | 57 +++++++ src/app/shared/auth/index.ts | 3 + src/app/shared/index.ts | 5 + src/app/shared/models/api-response.model.ts | 8 + src/app/shared/models/index.ts | 4 + src/app/shared/models/notification.model.ts | 10 ++ src/app/shared/models/user.model.ts | 10 ++ src/app/shared/notifications/index.ts | 3 + .../notifications.component.html | 7 + .../notifications/notifications.component.ts | 34 ++++ .../notifications/notifications.service.ts | 17 ++ src/app/shared/top-nav/top-nav.component.html | 23 +++ src/app/shared/top-nav/top-nav.component.ts | 34 ++++ src/app/top-nav/top-nav.component.html | 19 --- src/app/top-nav/top-nav.component.ts | 18 --- src/scss/_board.scss | 49 ++++-- src/scss/_login.scss | 8 +- src/scss/_nav-top.scss | 4 + src/scss/_notifications.scss | 54 +++++++ src/scss/main.scss | 1 + system.config.js | 1 + 37 files changed, 533 insertions(+), 133 deletions(-) create mode 100644 src/app/shared/auth/auth.guard.ts create mode 100644 src/app/shared/auth/auth.service.ts create mode 100644 src/app/shared/auth/index.ts create mode 100644 src/app/shared/index.ts create mode 100644 src/app/shared/models/api-response.model.ts create mode 100644 src/app/shared/models/index.ts create mode 100644 src/app/shared/models/notification.model.ts create mode 100644 src/app/shared/models/user.model.ts create mode 100644 src/app/shared/notifications/index.ts create mode 100644 src/app/shared/notifications/notifications.component.html create mode 100644 src/app/shared/notifications/notifications.component.ts create mode 100644 src/app/shared/notifications/notifications.service.ts create mode 100644 src/app/shared/top-nav/top-nav.component.html create mode 100644 src/app/shared/top-nav/top-nav.component.ts delete mode 100644 src/app/top-nav/top-nav.component.html delete mode 100644 src/app/top-nav/top-nav.component.ts create mode 100644 src/scss/_notifications.scss diff --git a/package.json b/package.json index 8b0fefe..3cbb216 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@angular/common": "^2.0.0-rc.4", "@angular/compiler": "^2.0.0-rc.4", "@angular/core": "^2.0.0-rc.4", + "@angular/forms": "^0.2.0", "@angular/http": "^2.0.0-rc.4", "@angular/platform-browser": "^2.0.0-rc.4", "@angular/platform-browser-dynamic": "^2.0.0-rc.4", diff --git a/src/.htaccess b/src/.htaccess index 0aeead9..0deaa95 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -5,3 +5,11 @@ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript +RewriteEngine On + +RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ +RewriteRule ^(.*)$ - [E=BASE:%1] + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^(.*)$ %{ENV:BASE}index.html [QSA,L] + diff --git a/src/api/controllers/Auth.php b/src/api/controllers/Auth.php index 44c9e02..5695ad4 100644 --- a/src/api/controllers/Auth.php +++ b/src/api/controllers/Auth.php @@ -124,8 +124,13 @@ class Auth extends BaseController { $user->last_login = time(); $user->save(); + $user->security_level = $user->security_level->getValue(); + unset($user->password_hash); + unset($user->active_token); + $this->apiJson->setSuccess(); $this->apiJson->addData($jwt); + $this->apiJson->addData($user); return $this->jsonResponse($response); } diff --git a/src/app/app.component.html b/src/app/app.component.html index 6a164d6..8718213 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,2 +1,4 @@ + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e6f77ab..877565a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,11 @@ import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; +import { Notifications } from './shared/index'; + @Component({ selector: 'app-component', - directives: [ ROUTER_DIRECTIVES ], + directives: [ ROUTER_DIRECTIVES, Notifications ], templateUrl: 'app/app.component.html' }) export class AppComponent { diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 5e67134..9c900d7 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,16 +1,36 @@ import { RouterConfig, provideRouter } from '@angular/router'; +import { AuthGuard, AuthService } from './shared/index'; import { Login } from './login/login.component'; import { Board } from './board/board.component'; +import { Settings } from './settings/settings.component'; +import { Dashboard } from './dashboard/dashboard.component'; const ROUTES: RouterConfig = [ { path: '', component: Login + }, + { + path: 'boards', + component: Board, + canActivate: [ AuthGuard ] + }, + { + path: 'settings', + component: Settings, + canActivate: [ AuthGuard ] + }, + { + path: 'dashboard', + component: Dashboard, + canActivate: [ AuthGuard ] } ]; export const APP_ROUTER_PROVIDERS = [ - provideRouter(ROUTES) + provideRouter(ROUTES), + AuthGuard, + AuthService ]; diff --git a/src/app/board/board.component.html b/src/app/board/board.component.html index ed03b87..8eb5b5a 100644 --- a/src/app/board/board.component.html +++ b/src/app/board/board.component.html @@ -38,45 +38,53 @@ -
-

- - Something to Get Done - 3 -

-
-

This is the thing that needs to get done.

+ +
+
+

+ + Something to Get Done + 3 +

+
+

This is the thing that needs to get done.

+
+
+ Assigned To: admin + + + + + +
-
- Assigned To: admin - - - - - +
+

+ + A Task With a Very Long Title to Test How it Wraps + 3 +

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+

Fusce ut commodo urna, vitae lacinia quam. Cras eleifend magna massa, vitae porttitor dolor lacinia quis.

+

Nam tortor risus, faucibus nec lacinia ac, laoreet vitae diam.

+

Nullam viverra elementum mi, at tincidunt nisl pretium a. Fusce risus risus, ornare facilisis leo a, dictum porta nibh.

+

Quisque ut augue tortor. Phasellus hendrerit placerat molestie.

+
+
+ Assigned To: admin + + + + Front End + +
-
-

- - A Task With a Very Long Title to Test How it Wraps - 3 -

-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

-

Fusce ut commodo urna, vitae lacinia quam. Cras eleifend magna massa, vitae porttitor dolor lacinia quis.

-

Nam tortor risus, faucibus nec lacinia ac, laoreet vitae diam.

-

Nullam viverra elementum mi, at tincidunt nisl pretium a. Fusce risus risus, ornare facilisis leo a, dictum porta nibh.

-

Quisque ut augue tortor. Phasellus hendrerit placerat molestie.

-
-
- Assigned To: admin - - - - Front End - -
+ +
+ +
@@ -90,23 +98,31 @@ -
-

- - Something Else to Get Done - 5 -

-
-

This really needs to be taken care of as well.

-

But probably not as quickly as the other one. Maybe.

-
-
- Assigned To: Unassigned - - API - + +
+
+

+ + Something Else to Get Done + 5 +

+
+

This really needs to be taken care of as well.

+

But probably not as quickly as the other one. Maybe.

+
+
+ Assigned To: Unassigned + + API + +
+ +
+ + +
@@ -118,6 +134,11 @@ + +
+ + +