├── .editorconfig ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── angular.json ├── e2e ├── app.e2e-spec.ts ├── app.po.ts └── tsconfig.e2e.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── protractor.conf.js ├── server.js ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── dashboard │ │ ├── dashboard.component.html │ │ └── dashboard.component.ts │ ├── guards │ │ ├── auth.guard.ts │ │ └── not-authenticated.guard.ts │ ├── navbar │ │ ├── navbar.component.html │ │ ├── navbar.component.ts │ │ └── task-search │ │ │ ├── task-search.component.html │ │ │ └── task-search.component.ts │ ├── shared │ │ ├── auth.service.ts │ │ ├── form.utils.ts │ │ ├── token.service.ts │ │ └── user.model.ts │ ├── sign-in-form │ │ ├── sign-in-form.component.html │ │ └── sign-in-form.component.ts │ ├── sign-up-form │ │ ├── sign-up-form.component.html │ │ └── sign-up-form.component.ts │ └── tasks │ │ ├── shared │ │ ├── task.model.ts │ │ └── task.service.ts │ │ ├── task-detail │ │ ├── task-detail.component.html │ │ └── task-detail.component.ts │ │ ├── tasks.component.html │ │ └── tasks.component.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts ├── tsconfig.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "vsicons.presets.angular": true 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TaskmanagerFrontend 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | Before running the tests make sure you are serving the app via `ng serve`. 25 | 26 | ## Further help 27 | 28 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 29 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "taskmanager-frontend": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "architect": { 11 | "build": { 12 | "builder": "@angular-devkit/build-angular:browser", 13 | "options": { 14 | "outputPath": "dist", 15 | "index": "src/index.html", 16 | "main": "src/main.ts", 17 | "tsConfig": "src/tsconfig.app.json", 18 | "polyfills": "src/polyfills.ts", 19 | "assets": [ 20 | "src/assets", 21 | "src/favicon.ico" 22 | ], 23 | "styles": [ 24 | "src/styles.css", 25 | "node_modules/bootstrap/dist/css/bootstrap.min.css", 26 | "node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css" 27 | ], 28 | "scripts": [ 29 | "node_modules/jquery/dist/jquery.min.js", 30 | "node_modules/moment/min/moment-with-locales.min.js", 31 | "node_modules/bootstrap/dist/js/bootstrap.min.js", 32 | "node_modules/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js" 33 | ] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "optimization": true, 38 | "outputHashing": "all", 39 | "sourceMap": false, 40 | "extractCss": true, 41 | "namedChunks": false, 42 | "aot": true, 43 | "extractLicenses": true, 44 | "vendorChunk": false, 45 | "buildOptimizer": true, 46 | "fileReplacements": [ 47 | { 48 | "replace": "src/environments/environment.ts", 49 | "with": "src/environments/environment.prod.ts" 50 | } 51 | ] 52 | } 53 | } 54 | }, 55 | "serve": { 56 | "builder": "@angular-devkit/build-angular:dev-server", 57 | "options": { 58 | "browserTarget": "taskmanager-frontend:build" 59 | }, 60 | "configurations": { 61 | "production": { 62 | "browserTarget": "taskmanager-frontend:build:production" 63 | } 64 | } 65 | }, 66 | "extract-i18n": { 67 | "builder": "@angular-devkit/build-angular:extract-i18n", 68 | "options": { 69 | "browserTarget": "taskmanager-frontend:build" 70 | } 71 | }, 72 | "test": { 73 | "builder": "@angular-devkit/build-angular:karma", 74 | "options": { 75 | "main": "src/test.ts", 76 | "karmaConfig": "./karma.conf.js", 77 | "polyfills": "src/polyfills.ts", 78 | "tsConfig": "src/tsconfig.spec.json", 79 | "scripts": [ 80 | "node_modules/jquery/dist/jquery.min.js", 81 | "node_modules/moment/min/moment-with-locales.min.js", 82 | "node_modules/bootstrap/dist/js/bootstrap.min.js", 83 | "node_modules/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js" 84 | ], 85 | "styles": [ 86 | "src/styles.css", 87 | "node_modules/bootstrap/dist/css/bootstrap.min.css", 88 | "node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css" 89 | ], 90 | "assets": [ 91 | "src/assets", 92 | "src/favicon.ico" 93 | ] 94 | } 95 | }, 96 | "lint": { 97 | "builder": "@angular-devkit/build-angular:tslint", 98 | "options": { 99 | "tsConfig": [ 100 | "src/tsconfig.app.json", 101 | "src/tsconfig.spec.json" 102 | ], 103 | "exclude": [] 104 | } 105 | } 106 | } 107 | }, 108 | "taskmanager-frontend-e2e": { 109 | "root": "", 110 | "sourceRoot": "e2e", 111 | "projectType": "application", 112 | "architect": { 113 | "e2e": { 114 | "builder": "@angular-devkit/build-angular:protractor", 115 | "options": { 116 | "protractorConfig": "./protractor.conf.js", 117 | "devServerTarget": "taskmanager-frontend:serve" 118 | } 119 | }, 120 | "lint": { 121 | "builder": "@angular-devkit/build-angular:tslint", 122 | "options": { 123 | "tsConfig": [ 124 | "e2e/tsconfig.e2e.json" 125 | ], 126 | "exclude": [] 127 | } 128 | } 129 | } 130 | } 131 | }, 132 | "defaultProject": "taskmanager-frontend", 133 | "schematics": { 134 | "@schematics/angular:component": { 135 | "prefix": "app", 136 | "styleext": "css" 137 | }, 138 | "@schematics/angular:directive": { 139 | "prefix": "app" 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { TaskmanagerFrontendPage } from './app.po'; 2 | 3 | describe('taskmanager-frontend App', () => { 4 | let page: TaskmanagerFrontendPage; 5 | 6 | beforeEach(() => { 7 | page = new TaskmanagerFrontendPage(); 8 | }); 9 | 10 | it('should display message saying app works', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('app works!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class TaskmanagerFrontendPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/0.13/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | files: [ 19 | 20 | ], 21 | preprocessors: { 22 | 23 | }, 24 | mime: { 25 | 'text/x-typescript': ['ts','tsx'] 26 | }, 27 | coverageIstanbulReporter: { 28 | dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ], 29 | fixWebpackSourcePaths: true 30 | }, 31 | 32 | reporters: config.angularCli && config.angularCli.codeCoverage 33 | ? ['progress', 'coverage-istanbul'] 34 | : ['progress', 'kjhtml'], 35 | port: 9876, 36 | colors: true, 37 | logLevel: config.LOG_INFO, 38 | autoWatch: true, 39 | browsers: ['Chrome'], 40 | singleRun: false 41 | }); 42 | }; 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "taskmanager-frontend", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "node server.js", 8 | "build": "ng build", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e", 12 | "postinstall": "ng build --prod" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/animations": "^6.1.0-rc.0", 17 | "@angular/cli": "^6.0.8", 18 | "@angular/common": "^6.1.0-rc.0", 19 | "@angular/compiler": "^6.1.0-rc.0", 20 | "@angular/compiler-cli": "^6.1.0-rc.0", 21 | "@angular/core": "^6.1.0-rc.0", 22 | "@angular/forms": "^6.1.0-rc.0", 23 | "@angular/http": "^6.1.0-rc.0", 24 | "@angular/platform-browser": "^6.1.0-rc.0", 25 | "@angular/platform-browser-dynamic": "^6.1.0-rc.0", 26 | "@angular/platform-server": "^6.1.0-rc.0", 27 | "@angular/router": "^6.1.0-rc.0", 28 | "angular2-token": "^0.2.0", 29 | "bootstrap": "^3.3.7", 30 | "core-js": "^2.4.1", 31 | "eonasdan-bootstrap-datetimepicker": "^4.17.47", 32 | "express": "^4.16.3", 33 | "jquery": "^3.2.1", 34 | "moment": "^2.18.1", 35 | "rxjs": "^6.2.2", 36 | "typescript": "2.9.2", 37 | "zone.js": "^0.8.4" 38 | }, 39 | "devDependencies": { 40 | "@angular-devkit/build-angular": "^0.6.8", 41 | "@types/eonasdan-bootstrap-datetimepicker": "^4.17.23", 42 | "@types/jasmine": "2.5.38", 43 | "@types/jquery": "^2.0.48", 44 | "@types/node": "~6.0.60", 45 | "codelyzer": "~2.0.0", 46 | "jasmine-core": "~2.5.2", 47 | "jasmine-spec-reporter": "~3.2.0", 48 | "karma": "~1.4.1", 49 | "karma-chrome-launcher": "~2.1.1", 50 | "karma-cli": "~1.0.1", 51 | "karma-coverage-istanbul-reporter": "^0.2.0", 52 | "karma-jasmine": "~1.1.0", 53 | "karma-jasmine-html-reporter": "^0.2.2", 54 | "protractor": "~5.1.0", 55 | "ts-node": "~2.0.0", 56 | "tslint": "~4.5.0" 57 | }, 58 | "engines": { 59 | "node": "8.11.2", 60 | "npm": "6.0.1" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | beforeLaunch: function() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | }, 27 | onPrepare() { 28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const app = express(); 3 | const path = require("path"); 4 | 5 | app.use(express.static(__dirname + '/dist')); 6 | 7 | app.listen(process.env.PORT || 8080); 8 | 9 | 10 | app.get("/*", function(req, res) { 11 | res.sendFile(path.join(__dirname + '/dist/index.html')); 12 | }) 13 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from "@angular/core"; 2 | import { RouterModule } from "@angular/router"; 3 | 4 | import { DashboardComponent } from "./dashboard/dashboard.component"; 5 | import { SignInFormComponent } from "./sign-in-form/sign-in-form.component" 6 | import { SignUpFormComponent } from "./sign-up-form/sign-up-form.component" 7 | import { TasksComponent } from "./tasks/tasks.component"; 8 | import { TaskDetailComponent } from "./tasks/task-detail/task-detail.component"; 9 | 10 | import { AuthGuard } from "./guards/auth.guard"; 11 | import { NotAuthenticatedGuard } from "./guards/not-authenticated.guard"; 12 | 13 | const ROUTES = RouterModule.forRoot([ 14 | { path: 'sign-in', component: SignInFormComponent, canActivate: [NotAuthenticatedGuard] }, 15 | { path: 'sign-up', component: SignUpFormComponent, canActivate: [NotAuthenticatedGuard] }, 16 | { path: 'tasks/:id', component: TaskDetailComponent, canActivate: [AuthGuard] }, 17 | { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard] }, 18 | { path: 'tasks', component: TasksComponent, canActivate: [AuthGuard] }, 19 | { path: '', redirectTo: '/dashboard', pathMatch: 'full' } 20 | ]) 21 | 22 | 23 | @NgModule({ 24 | imports: [ROUTES], 25 | exports: [RouterModule] 26 | }) 27 | 28 | export class AppRoutingModule { 29 | 30 | } -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costanonato/task-manager-angular/8ee83a42331358f801f4020371920fbd719c1922/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
-------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | }).compileComponents(); 12 | })); 13 | 14 | it('should create the app', async(() => { 15 | const fixture = TestBed.createComponent(AppComponent); 16 | const app = fixture.debugElement.componentInstance; 17 | expect(app).toBeTruthy(); 18 | })); 19 | 20 | it(`should have as title 'app works!'`, async(() => { 21 | const fixture = TestBed.createComponent(AppComponent); 22 | const app = fixture.debugElement.componentInstance; 23 | expect(app.title).toEqual('app works!'); 24 | })); 25 | 26 | it('should render title in a h1 tag', async(() => { 27 | const fixture = TestBed.createComponent(AppComponent); 28 | fixture.detectChanges(); 29 | const compiled = fixture.debugElement.nativeElement; 30 | expect(compiled.querySelector('h1').textContent).toContain('app works!'); 31 | })); 32 | }); 33 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { TokenService } from './shared/token.service'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | templateUrl: './app.component.html', 8 | styleUrls: ['./app.component.css'] 9 | }) 10 | 11 | export class AppComponent { 12 | title = 'Gerenciador de Tarefas'; 13 | 14 | public constructor(private tokenService: TokenService){ 15 | this.tokenService.init({ 16 | apiBase: 'https://taskmanager-api-nonato.herokuapp.com', 17 | globalOptions: { 18 | headers: { 19 | 'Content-Type': 'application/json', 20 | 'Accept': 'application/vnd.taskmanager.v2' 21 | } 22 | } 23 | }) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | // angular imports 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { NgModule } from '@angular/core'; 4 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 5 | import { HttpModule } from '@angular/http'; 6 | 7 | // components imports 8 | import { AppComponent } from './app.component'; 9 | import { DashboardComponent } from "./dashboard/dashboard.component"; 10 | import { NavbarComponent } from "./navbar/navbar.component"; 11 | import { SignInFormComponent } from "./sign-in-form/sign-in-form.component"; 12 | import { SignUpFormComponent } from "./sign-up-form/sign-up-form.component"; 13 | import { TaskSearchComponent } from "./navbar/task-search/task-search.component"; 14 | import { TasksComponent } from "./tasks/tasks.component"; 15 | import { TaskDetailComponent } from "./tasks/task-detail/task-detail.component"; 16 | 17 | // services imports 18 | import { AuthService } from "./shared/auth.service"; 19 | import { TaskService } from "./tasks/shared/task.service"; 20 | import { TokenService } from "./shared/token.service"; 21 | 22 | // guards imports 23 | import { AuthGuard } from "./guards/auth.guard"; 24 | import { NotAuthenticatedGuard } from "./guards/not-authenticated.guard"; 25 | 26 | // modules imports 27 | import { AppRoutingModule } from "./app-routing.module"; 28 | 29 | // jquery plugins 30 | import * as $ from 'jquery'; 31 | import * as datetimepicker from 'eonasdan-bootstrap-datetimepicker'; 32 | window['datetimepicker'] = window['datetimepicker'] = datetimepicker; 33 | 34 | @NgModule({ 35 | declarations: [ 36 | AppComponent, 37 | DashboardComponent, 38 | NavbarComponent, 39 | SignInFormComponent, 40 | SignUpFormComponent, 41 | TaskSearchComponent, 42 | TasksComponent, 43 | TaskDetailComponent 44 | ], 45 | imports: [ 46 | BrowserModule, 47 | FormsModule, 48 | ReactiveFormsModule, 49 | HttpModule, 50 | AppRoutingModule 51 | ], 52 | providers: [ 53 | AuthGuard, 54 | AuthService, 55 | NotAuthenticatedGuard, 56 | TaskService, 57 | TokenService 58 | ], 59 | bootstrap: [AppComponent] 60 | }) 61 | export class AppModule { } 62 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 |

Painel de Controle

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 |
TarefaAções
{{task.title}} 14 | Detalhes 15 |
-------------------------------------------------------------------------------- /src/app/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from "@angular/core"; 2 | 3 | import { Task } from "../tasks/shared/task.model"; 4 | import { TaskService } from "../tasks/shared/task.service"; 5 | 6 | @Component({ 7 | selector: 'dashboard', 8 | templateUrl: './dashboard.component.html' 9 | }) 10 | 11 | export class DashboardComponent implements OnInit{ 12 | public tasks: Task[]; 13 | 14 | public constructor(private taskService: TaskService){ 15 | } 16 | 17 | public ngOnInit(){ 18 | this.taskService.getImportant() 19 | .subscribe( 20 | tasks => this.tasks = tasks, 21 | error => alert("Ocorreu um no servidor, tente mais tarde.") 22 | ); 23 | } 24 | } -------------------------------------------------------------------------------- /src/app/guards/auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | 3 | import { CanActivate, Router } from "@angular/router"; 4 | 5 | import { AuthService } from "../shared/auth.service"; 6 | 7 | @Injectable() 8 | 9 | export class AuthGuard implements CanActivate{ 10 | 11 | public constructor(private authService:AuthService, private router: Router){} 12 | 13 | public canActivate(){ 14 | if( this.authService.userSignedIn() ){ 15 | return true; 16 | }else{ 17 | this.router.navigate(['/sign-in']); 18 | return false; 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /src/app/guards/not-authenticated.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | import { CanActivate, Router } from "@angular/router"; 3 | 4 | import { AuthService } from "../shared/auth.service"; 5 | 6 | @Injectable() 7 | 8 | export class NotAuthenticatedGuard implements CanActivate { 9 | public constructor(private authService: AuthService, private router: Router){ 10 | } 11 | 12 | public canActivate(){ 13 | if(this.authService.userSignedIn()){ 14 | this.router.navigate(['/dashboard']) 15 | return false; 16 | }else{ 17 | return true; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Router } from "@angular/router"; 3 | 4 | import { AuthService } from "../shared/auth.service"; 5 | 6 | @Component({ 7 | selector: 'navbar', 8 | templateUrl: './navbar.component.html' 9 | }) 10 | 11 | export class NavbarComponent{ 12 | 13 | public constructor(private authService: AuthService, private router: Router){} 14 | 15 | public signOutUser(){ 16 | this.authService.signOut() 17 | .subscribe( 18 | () => this.router.navigate(['/sign-in']) 19 | ) 20 | } 21 | 22 | public userSignedIn(){ 23 | return this.authService.userSignedIn(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/app/navbar/task-search/task-search.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 |
7 | {{ task.title }} 8 |
9 |
-------------------------------------------------------------------------------- /src/app/navbar/task-search/task-search.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from "@angular/core"; 2 | import { Router } from "@angular/router"; 3 | 4 | import { Task } from "../../tasks/shared/task.model"; 5 | import { TaskService } from "../../tasks/shared/task.service"; 6 | 7 | import { Observable, Subject, of } from "rxjs"; 8 | import { debounceTime, distinctUntilChanged, switchMap } from "rxjs/operators"; 9 | 10 | @Component({ 11 | selector: 'task-search', 12 | templateUrl: './task-search.component.html' 13 | }) 14 | 15 | export class TaskSearchComponent implements OnInit{ 16 | public searchTerms: Subject = new Subject(); 17 | public tasks: Task[] = []; 18 | 19 | public constructor(private taskService: TaskService, private router: Router){} 20 | 21 | public ngOnInit() { 22 | this.searchTerms.pipe( 23 | debounceTime(300), 24 | distinctUntilChanged(), 25 | switchMap( 26 | term => term ? this.taskService.searchByTitle(term) : of([]) 27 | ) 28 | ).subscribe(tasks => this.tasks = tasks) 29 | } 30 | 31 | public search(term: string){ 32 | this.searchTerms.next(term); 33 | } 34 | 35 | public gotoTask(task: Task){ 36 | this.tasks = []; 37 | this.router.navigate(['/tasks', task.id]); 38 | } 39 | 40 | } 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/app/shared/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | import { Response } from "@angular/http"; 3 | 4 | import { Observable, throwError } from "rxjs"; 5 | import { catchError } from "rxjs/operators"; 6 | import { TokenService } from "./token.service"; 7 | 8 | import { User } from "./user.model"; 9 | 10 | @Injectable() 11 | 12 | export class AuthService{ 13 | public constructor(private tokenService: TokenService){ } 14 | 15 | public signUp(user: User): Observable{ 16 | return this.tokenService.registerAccount(user as any).pipe( 17 | catchError(this.handleErrors) 18 | ) 19 | } 20 | 21 | public signIn(uid: string, password: string): Observable{ 22 | let signInData = { 23 | email: uid, 24 | password: password 25 | }; 26 | 27 | return this.tokenService.signIn(signInData).pipe( 28 | catchError(this.handleErrors) 29 | ) 30 | } 31 | 32 | public signOut(): Observable{ 33 | return this.tokenService.signOut().pipe( 34 | catchError(this.handleErrors) 35 | ) 36 | } 37 | 38 | public userSignedIn(): boolean{ 39 | return this.tokenService.userSignedIn(); 40 | } 41 | 42 | 43 | private handleErrors(error: Response){ 44 | console.log("SALVANDO O ERRO NUM ARQUIVO DE LOG - DETALHES DO ERRO => ", error); 45 | return throwError(error); 46 | } 47 | } -------------------------------------------------------------------------------- /src/app/shared/form.utils.ts: -------------------------------------------------------------------------------- 1 | import { FormGroup } from "@angular/forms"; 2 | 3 | export class FormUtils { 4 | public constructor(private form: FormGroup){ 5 | } 6 | 7 | public fieldClassForErrorOrSuccess(fieldName: string){ 8 | return { 9 | "has-error": this.showFieldError(fieldName), 10 | "has-success": this.getField(fieldName).valid 11 | } 12 | } 13 | 14 | public iconClassForErrorOrSuccess(fieldName: string){ 15 | return { 16 | "glyphicon-remove": this.showFieldError(fieldName), 17 | "glyphicon-ok": this.getField(fieldName).valid 18 | } 19 | } 20 | 21 | public showFieldError(fieldName: string): boolean{ 22 | let field = this.getField(fieldName); 23 | return field.invalid && ( field.touched || field.dirty ); 24 | } 25 | 26 | public getField(fieldName: string){ 27 | return this.form.get(fieldName); 28 | } 29 | } -------------------------------------------------------------------------------- /src/app/shared/token.service.ts: -------------------------------------------------------------------------------- 1 | import { Angular2TokenService } from "angular2-token"; 2 | 3 | export class TokenService extends Angular2TokenService { 4 | 5 | } -------------------------------------------------------------------------------- /src/app/shared/user.model.ts: -------------------------------------------------------------------------------- 1 | export class User { 2 | public constructor( 3 | public name: string, 4 | public email: string, 5 | public password: string, 6 | public passwordConfirmation: string, 7 | public id?: number 8 | ){} 9 | } -------------------------------------------------------------------------------- /src/app/sign-in-form/sign-in-form.component.html: -------------------------------------------------------------------------------- 1 |

Faça o seu Login

2 | 3 |
4 |
5 | 6 | 7 | Ocorreu um erro ao tentar entrar no sistema. 8 | 9 | 10 |
    11 |
  • {{ error }}
  • 12 |
13 |
14 | 15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 | 23 | 24 |
25 |
o email é obrigatório
26 |
o email digitado é inválido
27 |
28 |
29 |
30 | 31 |
32 | 33 |
34 | 35 | 36 | 37 |
38 |
a senha é obrigatória
39 |
40 |
41 |
42 | 43 |
44 |
45 | 46 |
47 |
48 | 49 |
50 |
51 | Se você não possui uma conta, 52 | clique aqui 53 |
54 |
55 |
56 |
57 | -------------------------------------------------------------------------------- /src/app/sign-in-form/sign-in-form.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | import { FormBuilder, FormGroup, FormControl, Validators } from "@angular/forms"; 3 | import { Router } from "@angular/router"; 4 | 5 | import { AuthService } from "../shared/auth.service"; 6 | import { FormUtils } from "../shared/form.utils"; 7 | 8 | @Component({ 9 | selector: "sign-in-form", 10 | templateUrl: "./sign-in-form.component.html" 11 | }) 12 | 13 | export class SignInFormComponent{ 14 | public form: FormGroup; 15 | public formUtils: FormUtils; 16 | public submitted: boolean; 17 | public formErrors: Array; 18 | 19 | public constructor(private authService: AuthService, private formBuilder: FormBuilder, private router: Router){ 20 | this.setupForm(); 21 | this.formUtils = new FormUtils(this.form); 22 | this.submitted = false; 23 | this.formErrors = null; 24 | } 25 | 26 | public signInUser(){ 27 | this.submitted = true; 28 | 29 | this.authService.signIn(this.form.get('email').value, this.form.get('password').value) 30 | .subscribe( 31 | () => { 32 | this.router.navigate(['/dashboard']); 33 | this.formErrors = null; 34 | }, 35 | (error) => { 36 | this.submitted = false; 37 | 38 | if( error.status === 401 ) 39 | this.formErrors = JSON.parse(error._body).errors; 40 | else 41 | this.formErrors = ["Não foi possível processar a sua solicitação. Por favor, tente mais tarde."] 42 | } 43 | ) 44 | } 45 | 46 | 47 | private setupForm(){ 48 | this.form = this.formBuilder.group({ 49 | email: [null, [Validators.required, Validators.email]], 50 | password: [null, Validators.required] 51 | }); 52 | } 53 | } -------------------------------------------------------------------------------- /src/app/sign-up-form/sign-up-form.component.html: -------------------------------------------------------------------------------- 1 |

Faça o seu cadastro

2 | 3 |
4 |
5 | 6 | 7 | Ocorreu um erro ao tentar criar a sua conta no sistema. 8 | 9 | 10 |
    11 |
  • {{ error }}
  • 12 |
13 |
14 | 15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 | 23 | 24 |
25 |
o nome é obrigatório
26 |
o nome deve ter no mínimo 5 caracteres
27 |
o nome deve ter no máximo 100 caracteres
28 |
29 |
30 |
31 | 32 |
33 | 34 |
35 | 36 | 37 | 38 |
39 |
o email é obrigatório
40 |
o email digitado é inválido
41 |
42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 | 50 | 51 |
52 |
a senha é obrigatória
53 |
a senha deve ter no mínimo 8 caracteres
54 |
55 |
56 |
57 | 58 |
59 | 60 |
61 | 62 | 63 | 64 |
65 |
a confirmação de senha é obrigatória
66 |
a senha e a confirmação de senha não estão combinando
67 |
68 |
69 |
70 | 71 |
72 |
73 | 74 |
75 |
76 | 77 |
78 |
79 | Se você já possui uma conta, 80 | clique aqui para entrar 81 |
82 |
83 |
84 |
85 | -------------------------------------------------------------------------------- /src/app/sign-up-form/sign-up-form.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms"; 3 | import { Router } from "@angular/router"; 4 | 5 | import { AuthService } from "../shared/auth.service"; 6 | import { FormUtils } from "../shared/form.utils"; 7 | import { User } from "../shared/user.model"; 8 | 9 | 10 | @Component({ 11 | selector: 'sign-up-form', 12 | templateUrl: './sign-up-form.component.html' 13 | }) 14 | 15 | export class SignUpFormComponent { 16 | public form: FormGroup; 17 | public formUtils: FormUtils; 18 | public submitted: boolean; 19 | public formErrors: Array; 20 | 21 | public constructor(private authService: AuthService, private formBuilder: FormBuilder, private router: Router){ 22 | this.setupForm(); 23 | this.formUtils = new FormUtils(this.form); 24 | this.submitted = false; 25 | this.formErrors = null; 26 | } 27 | 28 | public signUpUser(){ 29 | this.submitted = true; 30 | 31 | this.authService.signUp(this.form.value as User) 32 | .subscribe( 33 | () => { 34 | alert('Parabéns, sua conta foi criada com sucesso!'); 35 | this.router.navigate(['/dashboard']); 36 | this.formErrors = null; 37 | }, 38 | (error) => { 39 | this.submitted = false; 40 | 41 | if( error.status === 422 ) 42 | this.formErrors = JSON.parse(error._body).errors.full_messages; 43 | else 44 | this.formErrors = ["Não foi possível processar a sua solicitação. Por favor, tente mais tarde."] 45 | } 46 | ) 47 | } 48 | 49 | public passwordConfirmationValidator(form: FormGroup){ 50 | if(form.get('password').dirty && form.get('password').value === form.get('passwordConfirmation').value) 51 | form.get('passwordConfirmation').setErrors(null) 52 | else 53 | form.get('passwordConfirmation').setErrors({'mismatch': true}) 54 | } 55 | 56 | 57 | private setupForm(){ 58 | this.form = this.formBuilder.group({ 59 | name: [null, [Validators.required, Validators.minLength(5), Validators.maxLength(100)]], 60 | email: [null, [Validators.required, Validators.email]], 61 | password: [null, [Validators.required, Validators.minLength(8)]], 62 | passwordConfirmation: [null, [Validators.required]] 63 | }, { validator: this.passwordConfirmationValidator }) 64 | } 65 | } -------------------------------------------------------------------------------- /src/app/tasks/shared/task.model.ts: -------------------------------------------------------------------------------- 1 | export class Task{ 2 | constructor( 3 | public id: number, 4 | public title: string, 5 | public description?: string, 6 | public done?: boolean, 7 | public deadline?: string 8 | ){} 9 | } -------------------------------------------------------------------------------- /src/app/tasks/shared/task.service.ts: -------------------------------------------------------------------------------- 1 | import { Response } from "@angular/http"; 2 | import { Injectable } from "@angular/core"; 3 | 4 | import { Observable, throwError } from "rxjs"; 5 | import { catchError, map } from "rxjs/operators"; 6 | 7 | import { TokenService } from "../../shared/token.service"; 8 | import { Task } from "./task.model"; 9 | 10 | 11 | @Injectable() 12 | 13 | export class TaskService{ 14 | public tasksUrl = "tasks"; 15 | 16 | public constructor(private tokenHttp: TokenService){} 17 | 18 | 19 | public getAll(): Observable{ 20 | let url = `${this.tasksUrl}?q[s]=updated_at+DESC`; 21 | 22 | return this.tokenHttp.get(url).pipe( 23 | catchError(this.handleErrors), 24 | map((response: Response) => this.responseToTasks(response)) 25 | ) 26 | } 27 | 28 | 29 | public getImportant(): Observable{ 30 | let url = `${this.tasksUrl}?q[s]=deadline+ASC`; 31 | 32 | return this.tokenHttp.get(url).pipe( 33 | catchError(this.handleErrors), 34 | map((response: Response) => this.responseToTasks(response)) 35 | ) 36 | } 37 | 38 | 39 | public getById(id: number): Observable { 40 | let url = `${this.tasksUrl}/${id}`; 41 | 42 | return this.tokenHttp.get(url).pipe( 43 | catchError(this.handleErrors), 44 | map((response: Response) => this.responseToTask(response)) 45 | ) 46 | } 47 | 48 | 49 | public create(task: Task): Observable { 50 | let url = this.tasksUrl; 51 | let body = JSON.stringify(task); 52 | 53 | return this.tokenHttp.post(url, body).pipe( 54 | catchError(this.handleErrors), 55 | map((response: Response) => this.responseToTask(response)) 56 | ) 57 | } 58 | 59 | 60 | public update(task: Task): Observable { 61 | let url = `${this.tasksUrl}/${task.id}`; 62 | let body = JSON.stringify(task); 63 | 64 | return this.tokenHttp.put(url, body).pipe( 65 | catchError(this.handleErrors), 66 | map((response: Response) => this.responseToTask(response)) 67 | ) 68 | } 69 | 70 | 71 | public delete(id: number): Observable { 72 | let url = `${this.tasksUrl}/${id}`; 73 | 74 | return this.tokenHttp.delete(url).pipe( 75 | catchError(this.handleErrors), 76 | map(() => null) 77 | ) 78 | } 79 | 80 | 81 | public searchByTitle(term: string): Observable { 82 | let url = `${this.tasksUrl}?q[title_cont]=${term}`; 83 | 84 | return this.tokenHttp.get(url).pipe( 85 | catchError(this.handleErrors), 86 | map((response: Response) => this.responseToTasks(response)) 87 | ) 88 | } 89 | 90 | 91 | private handleErrors(error: Response){ 92 | console.log("SALVANDO O ERRO NUM ARQUIVO DE LOG - DETALHES DO ERRO => ", error); 93 | return throwError(error); 94 | } 95 | 96 | 97 | private responseToTasks(response: Response): Task[]{ 98 | let collection = response.json().data as Array; 99 | let tasks: Task[] = []; 100 | 101 | collection.forEach(item => { 102 | let task = new Task( 103 | item.id, 104 | item.attributes.title, 105 | item.attributes.description, 106 | item.attributes.done, 107 | item.attributes['deadline-to-br'] 108 | ) 109 | 110 | tasks.push(task) 111 | }) 112 | 113 | return tasks; 114 | } 115 | 116 | 117 | private responseToTask(response: Response): Task { 118 | return new Task( 119 | response.json().data.id, 120 | response.json().data.attributes.title, 121 | response.json().data.attributes.description, 122 | response.json().data.attributes.done, 123 | response.json().data.attributes['deadline-to-br'], 124 | ) 125 | } 126 | } -------------------------------------------------------------------------------- /src/app/tasks/task-detail/task-detail.component.html: -------------------------------------------------------------------------------- 1 |

Detalhes da Tarefa: {{ task.title }}

2 | 3 |
4 |
5 | 6 |
7 | 8 | 9 | 10 | 11 |
12 |
o título é obrigatório
13 |
o título deve ter no mínimo 2 caracteres
14 |
o título deve ter no máximo 255 caracteres
15 |
16 |
17 | 18 | 19 |
20 | 21 | 22 | 23 |
o prazo é obrigatório
24 |
25 | 26 | 27 |
28 | 29 | 32 | 33 |
situação obrigatória
34 |
35 |
36 | 37 |
38 | 39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | 48 |
{{ form.value | json }}
49 |
-------------------------------------------------------------------------------- /src/app/tasks/task-detail/task-detail.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, AfterViewInit } from '@angular/core'; 2 | import { ActivatedRoute, ParamMap } from "@angular/router"; 3 | import { Location } from "@angular/common"; 4 | import { FormGroup, FormControl, FormBuilder, Validators } from "@angular/forms"; 5 | 6 | import { FormUtils } from "../../shared/form.utils"; 7 | import { Task } from '../shared/task.model'; 8 | import { TaskService } from '../shared/task.service'; 9 | 10 | import { switchMap } from "rxjs/operators"; 11 | 12 | @Component({ 13 | selector: 'task-detail', 14 | templateUrl: './task-detail.component.html', 15 | styles: [".form-control-feedback{ margin-right:20px }"] 16 | }) 17 | 18 | export class TaskDetailComponent implements OnInit, AfterViewInit{ 19 | public form: FormGroup; 20 | public task: Task; 21 | public taskDoneOptions: Array; 22 | public formUtils: FormUtils; 23 | 24 | 25 | public constructor( 26 | private taskService: TaskService, 27 | private route: ActivatedRoute, 28 | private location: Location, 29 | private formBuilder: FormBuilder 30 | ){ 31 | this.taskDoneOptions = [ 32 | { value: false, text: "Pendente" }, 33 | { value: true, text: "Feita" } 34 | ]; 35 | 36 | this.form = this.formBuilder.group({ 37 | title: [null, [Validators.required, Validators.minLength(2), Validators.maxLength(255)]], 38 | deadline: [null, Validators.required], 39 | done: [null, Validators.required], 40 | description: [null] 41 | }) 42 | 43 | this.formUtils = new FormUtils(this.form); 44 | } 45 | 46 | 47 | public ngOnInit(){ 48 | this.task = new Task(null, null); 49 | 50 | this.route.paramMap.pipe( 51 | switchMap((params: ParamMap) => this.taskService.getById(+params.get('id'))) 52 | ) 53 | .subscribe( 54 | task => this.setTask(task), 55 | error => alert("Ocorreu um no servidor, tente mais tarde.") 56 | ) 57 | } 58 | 59 | 60 | public setTask(task: Task): void { 61 | this.task = task; 62 | this.form.patchValue(task); 63 | } 64 | 65 | 66 | public ngAfterViewInit(){ 67 | $("#deadline").datetimepicker({ 68 | 'sideBySide': true, 69 | 'locale': 'pt-br' 70 | }).on('dp.change', ()=> this.form.get('deadline').setValue( $("#deadline").val() )); 71 | } 72 | 73 | 74 | public goBack() { 75 | this.location.back(); 76 | } 77 | 78 | 79 | public updateTask(){ 80 | this.task.title = this.form.get('title').value; 81 | this.task.deadline = this.form.get('deadline').value; 82 | this.task.done = this.form.get('done').value; 83 | this.task.description = this.form.get('description').value; 84 | 85 | this.taskService.update(this.task) 86 | .subscribe( 87 | () => alert("Tarefa atualizada com sucesso!"), 88 | () => alert("Ocorreu um no servidor, tente mais tarde.") 89 | ) 90 | } 91 | } -------------------------------------------------------------------------------- /src/app/tasks/tasks.component.html: -------------------------------------------------------------------------------- 1 |

Lista de Tarefas

2 | 3 |
4 |
5 |
6 |
7 | 8 |
9 |
10 | 13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 40 | 41 | 42 |
IDTítuloAções
{{ task.id }}{{ task.title }} 31 | 32 | 33 | Detalhes 34 | 35 | 39 |
-------------------------------------------------------------------------------- /src/app/tasks/tasks.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | import { Task } from './shared/task.model'; 4 | import { TaskService } from './shared/task.service'; 5 | 6 | @Component({ 7 | selector: 'tasks', 8 | templateUrl: './tasks.component.html' 9 | }) 10 | 11 | export class TasksComponent implements OnInit{ 12 | public tasks: Array; 13 | public newTask: Task; 14 | 15 | public constructor(private taskService: TaskService){ 16 | this.newTask = new Task(null, ''); 17 | } 18 | 19 | public ngOnInit(){ 20 | this.taskService.getAll() 21 | .subscribe( 22 | tasks => this.tasks = tasks.sort((a, b) => b.id - a.id), 23 | error => alert("Ocorreu um no servidor, tente mais tarde.") 24 | ) 25 | } 26 | 27 | public createTask(){ 28 | this.newTask.title = this.newTask.title.trim(); 29 | 30 | if(!this.newTask.title){ 31 | alert("A tarefa deve ter um título"); 32 | }else{ 33 | this.taskService.create(this.newTask) 34 | .subscribe( 35 | (task) => { 36 | this.tasks.unshift(task); 37 | this.newTask = new Task(null, ''); 38 | }, 39 | () => alert("Ocorreu um no servidor, tente mais tarde.") 40 | ) 41 | } 42 | } 43 | 44 | public deleteTask(task: Task){ 45 | if ( confirm(`Deseja realmente excluir a tarefa "${task.title}"`) ) { 46 | this.taskService.delete(task.id) 47 | .subscribe( 48 | () => this.tasks = this.tasks.filter(t => t !== task), 49 | () => alert("Ocorreu um no servidor, tente mais tarde.") 50 | ) 51 | } 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costanonato/task-manager-angular/8ee83a42331358f801f4020371920fbd719c1922/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costanonato/task-manager-angular/8ee83a42331358f801f4020371920fbd719c1922/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TaskmanagerFrontend 6 | 7 | 8 | 9 | 10 | 11 | 12 | Loading... 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule); 12 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/set'; 35 | 36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 37 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 38 | 39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */ 40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 41 | 42 | 43 | /** Evergreen browsers require these. **/ 44 | import 'core-js/es6/reflect'; 45 | import 'core-js/es7/reflect'; 46 | 47 | 48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/ 49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 50 | 51 | 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | 59 | 60 | /*************************************************************************************************** 61 | * APPLICATION IMPORTS 62 | */ 63 | 64 | /** 65 | * Date, currency, decimal and percent pipes. 66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 67 | */ 68 | // import 'intl'; // Run `npm install --save intl`. 69 | /** 70 | * Need to import at least one locale-data with intl. 71 | */ 72 | // import 'intl/locale-data/jsonp/en'; 73 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare var __karma__: any; 17 | declare var require: any; 18 | 19 | // Prevent Karma from running prematurely. 20 | __karma__.loaded = function () {}; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment( 24 | BrowserDynamicTestingModule, 25 | platformBrowserDynamicTesting() 26 | ); 27 | // Then we find all the tests. 28 | const context = require.context('./', true, /\.spec\.ts$/); 29 | // And load the modules. 30 | context.keys().map(context); 31 | // Finally, start Karma to run the tests. 32 | __karma__.start(); 33 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "baseUrl": "", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "baseUrl": "", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "files": [ 14 | "test.ts", 15 | "polyfills.ts" 16 | ], 17 | "include": [ 18 | "**/*.spec.ts", 19 | "**/*.d.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "baseUrl": "src", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2016", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "callable-types": true, 7 | "class-name": true, 8 | "comment-format": [ 9 | true, 10 | "check-space" 11 | ], 12 | "curly": true, 13 | "eofline": true, 14 | "forin": true, 15 | "import-blacklist": [ 16 | true 17 | ], 18 | "import-spacing": true, 19 | "indent": [ 20 | true, 21 | "spaces" 22 | ], 23 | "interface-over-type-literal": true, 24 | "label-position": true, 25 | "max-line-length": [ 26 | true, 27 | 140 28 | ], 29 | "member-access": false, 30 | "member-ordering": [ 31 | true, 32 | "static-before-instance", 33 | "variables-before-functions" 34 | ], 35 | "no-arg": true, 36 | "no-bitwise": true, 37 | "no-console": [ 38 | true, 39 | "debug", 40 | "info", 41 | "time", 42 | "timeEnd", 43 | "trace" 44 | ], 45 | "no-construct": true, 46 | "no-debugger": true, 47 | "no-empty": false, 48 | "no-empty-interface": true, 49 | "no-eval": true, 50 | "no-inferrable-types": [ 51 | true, 52 | "ignore-params" 53 | ], 54 | "no-shadowed-variable": true, 55 | "no-string-literal": false, 56 | "no-string-throw": true, 57 | "no-switch-case-fall-through": true, 58 | "no-trailing-whitespace": true, 59 | "no-unused-expression": true, 60 | "no-use-before-declare": true, 61 | "no-var-keyword": true, 62 | "object-literal-sort-keys": false, 63 | "one-line": [ 64 | true, 65 | "check-open-brace", 66 | "check-catch", 67 | "check-else", 68 | "check-whitespace" 69 | ], 70 | "prefer-const": true, 71 | "quotemark": [ 72 | true, 73 | "single" 74 | ], 75 | "radix": true, 76 | "semicolon": [ 77 | "always" 78 | ], 79 | "triple-equals": [ 80 | true, 81 | "allow-null-check" 82 | ], 83 | "typedef-whitespace": [ 84 | true, 85 | { 86 | "call-signature": "nospace", 87 | "index-signature": "nospace", 88 | "parameter": "nospace", 89 | "property-declaration": "nospace", 90 | "variable-declaration": "nospace" 91 | } 92 | ], 93 | "typeof-compare": true, 94 | "unified-signatures": true, 95 | "variable-name": false, 96 | "whitespace": [ 97 | true, 98 | "check-branch", 99 | "check-decl", 100 | "check-operator", 101 | "check-separator", 102 | "check-type" 103 | ], 104 | "directive-selector": [ 105 | true, 106 | "attribute", 107 | "app", 108 | "camelCase" 109 | ], 110 | "component-selector": [ 111 | true, 112 | "element", 113 | "app", 114 | "kebab-case" 115 | ], 116 | "use-input-property-decorator": true, 117 | "use-output-property-decorator": true, 118 | "use-host-property-decorator": true, 119 | "no-input-rename": true, 120 | "no-output-rename": true, 121 | "use-life-cycle-interface": true, 122 | "use-pipe-transform-interface": true, 123 | "component-class-suffix": true, 124 | "directive-class-suffix": true, 125 | "no-access-missing-member": true, 126 | "templates-use-public": true, 127 | "invoke-injectable": true 128 | } 129 | } 130 | --------------------------------------------------------------------------------