Upload existing code to Task Manager Client

main
Hammy 3 years ago
parent eb50d1a913
commit 7551f3c03a

@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

@ -0,0 +1,141 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"baseHref": "/projects/angular/",
"outputPath": "dist/frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "frontend:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend"
}

@ -0,0 +1,28 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

@ -0,0 +1,23 @@
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to frontend!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});

@ -0,0 +1,11 @@
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get(browser.baseUrl) as Promise<any>;
}
getTitleText() {
return element(by.css('app-root h1')).getText() as Promise<string>;
}
}

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}

22662
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,50 @@
{
"name": "frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"bulma": "^0.9.3",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.10",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginPageComponent } from './pages/login-page/login-page.component';
import { NewListComponent } from './pages/new-list/new-list.component';
import { NewTaskComponent } from './pages/new-task/new-task.component';
import { TaskViewComponent } from './pages/task-view/task-view.component';
const routes: Routes = [
{ path: '', redirectTo: 'lists', pathMatch: 'full' },
{ path: 'new-list', component: NewListComponent },
{ path: 'login', component: LoginPageComponent },
{ path: 'lists', component: TaskViewComponent },
{ path: 'lists/:listId', component: TaskViewComponent },
{ path: 'lists/:listId/new-task', component: NewTaskComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes, /* { useHash: true }*/)],
exports: [RouterModule]
})
export class AppRoutingModule { }

@ -0,0 +1 @@
<router-outlet></router-outlet>

@ -0,0 +1,35 @@
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'frontend'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('frontend');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to frontend!');
});
});

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'frontend';
}

@ -0,0 +1,34 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TaskViewComponent } from './pages/task-view/task-view.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NewListComponent } from './pages/new-list/new-list.component';
import { MatIconModule } from '@angular/material/icon';
import { NewTaskComponent } from './pages/new-task/new-task.component';
import { LoginPageComponent } from './pages/login-page/login-page.component';
import { WebRequestInterceptor } from './web-request-interceptor';
@NgModule({
declarations: [
AppComponent,
TaskViewComponent,
NewListComponent,
NewTaskComponent,
LoginPageComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatIconModule
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: WebRequestInterceptor, multi: true }
],
bootstrap: [AppComponent]
})
export class AppModule { }

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: AuthService = TestBed.get(AuthService);
expect(service).toBeTruthy();
});
});

@ -0,0 +1,72 @@
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { WebRequestService } from './web-request.service';
import { shareReplay, tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(private http: HttpClient, private webRequestService: WebRequestService, private router: Router) { }
private static setSession(userId: string, accessToken: string, refreshToken: string) {
localStorage.setItem('user-id', userId);
localStorage.setItem('x-access-token', accessToken);
localStorage.setItem('x-refresh-token', refreshToken);
}
private static removeSession() {
localStorage.removeItem('user-id');
localStorage.removeItem('x-access-token');
localStorage.removeItem('x-refresh-token');
}
login(email: string, password: string) {
return this.webRequestService.login(email, password).pipe(
shareReplay(),
tap((res: HttpResponse<any>) => {
AuthService.setSession(res.body._id, res.headers.get('x-access-token'), res.headers.get('x-refresh-token'));
console.log('Logged In!');
})
);
}
logout() {
AuthService.removeSession();
this.router.navigate(['/login']);
}
getRefreshToken() {
return localStorage.getItem('x-refresh-token');
}
getUserId() {
return localStorage.getItem('user-id');
}
getAccessToken() {
return localStorage.getItem('x-access-token');
}
getNewAccessToken() {
return this.http.get(`${this.webRequestService.ROOT_URL}/users/me/access-token`, {
headers: {
'x-refresh-token': this.getRefreshToken(),
_id: this.getUserId()
},
observe: 'response'
}).pipe(
tap((res: HttpResponse<any>) => {
this.setAccessToken(res.headers.get('x-access-token'));
})
);
}
setAccessToken(accessToken: string) {
localStorage.setItem('x-access-token', accessToken);
}
}

@ -0,0 +1,4 @@
export class List {
_id: string;
title: string;
}

@ -0,0 +1,6 @@
export class Task {
_id: string;
_listId: string;
title: string;
completed: boolean;
}

@ -0,0 +1,30 @@
<div class="centered-content">
<div class="login-box">
<h1 class="title has-text-white has-text-centered">Login</h1>
<div class="field">
<p class="control has-icons-left has-icons-right">
<input #emailInput class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
</p>
</div>
<div class="field">
<p class="control has-icons-left">
<input #pwInput class="input" type="password" placeholder="Password">
<span class="icon is-small is-left">
<i class="fas fa-lock"></i>
</span>
</p>
</div>
<div class="field is-pulled-right">
<p class="control">
<button class="green has-text-white" (click)="onLoginButtonClicked(emailInput.value, pwInput.value)">
Login
</button>
</p>
</div>
</div>
</div>

@ -0,0 +1,37 @@
@import '../../../main-styles.scss';
.login-box {
min-height: 200px;
width: 100%;
max-width: 580px;
background-color: #060930;
border-radius: 5px;
padding: 35px;
}
button {
border: none;
border-radius: 5px;
background-color: $dark-blue;
transition: box-shadow 0.2s ease, transform 0.2s ease;
text-align: center;
padding: 14px 20px;
font-size: 24px;
margin: 5px;
&:hover {
transform: scale(0.90);
}
}
.green {
&:hover {
box-shadow: 2px 4px rgb(10, 156, 18);
}
}
.red {
&:hover {
box-shadow: 2px 4px rgb(182, 2, 2);
}
}

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginPageComponent } from './login-page.component';
describe('LoginPageComponent', () => {
let component: LoginPageComponent;
let fixture: ComponentFixture<LoginPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,21 @@
import { HttpResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { AuthService } from 'src/app/auth.service';
@Component({
selector: 'app-login-page',
templateUrl: './login-page.component.html',
styleUrls: ['./login-page.component.scss']
})
export class LoginPageComponent implements OnInit {
constructor(private authService: AuthService) { }
ngOnInit() { }
onLoginButtonClicked(email: string, password: string) {
this.authService.login(email, password).subscribe((res: HttpResponse<any>) => {
console.log(res);
});
}
}

@ -0,0 +1,17 @@
<div class="centered-content">
<div class="modal-box">
<h1 class="title has-text-white">
Create New List
</h1>
<input #listTitleInput class="input is-medium" type="text" placeholder="Insult Jade" autofocus>
<br> <br>
<div class="buttons is-right">
<button class="red is-medium has-text-white" routerLink="/">Cancel</button>
<button class="green is-medium has-text-white" (click)="createNewList(listTitleInput.value)">Create</button>
</div>
</div>
</div>

@ -0,0 +1 @@
@import '../../../main-styles.scss';

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NewListComponent } from './new-list.component';
describe('NewListComponent', () => {
let component: NewListComponent;
let fixture: ComponentFixture<NewListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NewListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,23 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { List } from 'src/app/models/list';
import { TaskService } from 'src/app/task.service';
@Component({
selector: 'app-new-list',
templateUrl: './new-list.component.html',
styleUrls: ['./new-list.component.scss']
})
export class NewListComponent implements OnInit {
constructor(private taskService: TaskService, private router: Router) { }
ngOnInit() { }
createNewList(title: string) {
this.taskService.createNewList(title).subscribe((list: List) => {
console.log(list);
this.router.navigate(['/lists', list._id]);
});
}
}

@ -0,0 +1,17 @@
<div class="centered-content">
<div class="modal-box">
<h1 class="title has-text-white">
Create New Task
</h1>
<input #taskTitleInput class="input is-medium" type="text" placeholder="Wash The Dishes..." autofocus>
<br> <br>
<div class="buttons is-right">
<button class="red is-medium has-text-white" routerLink="/">Cancel</button>
<button class="green is-medium has-text-white" (click)="createNewTask(taskTitleInput.value)">Create</button>
</div>
</div>
</div>

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NewTaskComponent } from './new-task.component';
describe('NewTaskComponent', () => {
let component: NewTaskComponent;
let fixture: ComponentFixture<NewTaskComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NewTaskComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewTaskComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,30 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {Task} from 'src/app/models/task';
import {TaskService} from 'src/app/task.service';
@Component({
selector: 'app-new-task',
templateUrl: './new-task.component.html',
styleUrls: ['./new-task.component.scss']
})
export class NewTaskComponent implements OnInit {
listId: string;
constructor(private taskService: TaskService, private route: ActivatedRoute, private router: Router) {
}
ngOnInit() {
this.route.params.subscribe(
(params: Params) => {
this.listId = params.listId;
});
}
createNewTask(title: string) {
this.taskService.createNewTask(title, this.listId).subscribe((newTask: Task) => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
}

@ -0,0 +1,41 @@
<div class="centered-content">
<div class="task-manager-container">
<div class="sidebar">
<h1 class="title has-text-white">Lists</h1>
<div class="list-menu">
<a class="list-menu-item has-text-white" *ngFor="let list of lists" [routerLink]="['/lists', list._id]" routerLinkActive="is-active">
<p>{{ list.title }}</p>
</a>
</div>
<button class="button" routerLink="/new-list">
+ New List
</button>
</div>
<div class="task-list-container">
<div *ngIf="tasks">
<h1 class="title has-text-white">Tasks</h1>
<!-- Task Elements -->
<div class="task" *ngFor="let task of tasks" (click)="onTaskClick(task)" [ngClass]="{ 'completed': task.completed }">
<p>{{ task.title }}</p>
</div>
<h3 class="empty-state-text" *ngIf="tasks.length === 0">No Tasks Here! Click The + Button To Create A New Task!</h3>
<button routerLink="./new-task" class="circle-add-button button">
<mat-icon style="transform: scale(1.8); color: white;">add</mat-icon>
</button>
</div>
<div *ngIf="!tasks">
<h3 class="empty-state-text">Please Select A List From The Sidebar</h3>
</div>
</div>
</div>
</div>

@ -0,0 +1,156 @@
@import '../../../main-styles.scss';
.task-manager-container {
display: flex;
width: 100%;
height: 100%;
max-width: 900px;
max-height: 680px;
}
.task-list-container {
position: relative;
display: flex;
flex-direction: column;
flex-grow: 1;
padding: 42px;
background: #0d1699;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
}
.task {
background: #060930;
padding: 15px 20px;
border-radius: 2px;
margin-top: 10px;
cursor: pointer;
animation: 0.25s ease 0s 1 slideInFromTop;
@keyframes slideInFromTop {
0% {
transform: translateY(-15%);
}
100% {
transform: translateY(0);
}
}
&:not(.completed) {
transition: box-shadow 0.2s ease, transform 0.2s ease;
&:active {
transform: scale(0.95);
}
&:hover {
box-shadow: 3px 4px rgb(182, 2, 2);
}
}
&.completed {
text-decoration: line-through;
text-decoration-color: black;
opacity: 70%;
font-style: italic;
transition: box-shadow 0.2s ease, transform 0.2s ease;
&:active {
transform: scale(0.95);
}
}
}
.list-menu {
display: flex;
flex-direction: column;
margin-top: 15px;
flex-grow: 1;
.list-menu-item {
display: flex;
padding: 12px 15px;
border-radius: 5px;
text-align: center;
width: 100%;
margin-bottom: 5px;
transition: box-shadow 0.25s ease;
&:hover {
box-shadow: 3px 4px rgb(10, 156, 18);
// box-shadow: inset 2px 5px 0 0 #10689b, 2px 5px 0 0 #1674aa;
}
&.is-active {
box-shadow: 3px 4px rgb(182, 2, 2);
// box-shadow: inset 2px 5px 0 0 rgb(10, 156, 18), 2px 5px 0 0 rgb(10, 156, 18);
}
}
}
.sidebar {
display: flex;
flex-direction: column;
width: 250px;
min-width: 250px;
background: #060930;
padding: 42px;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
.button {
background-color: $dark-blue;
border: none;
color: white;
transition: box-shadow 0.2s ease, transform 0.2s ease;
cursor: pointer;
&:hover {
box-shadow: 3px 4px rgb(10, 156, 18);
transform: scale(0.90)
}
}
}
.circle-add-button {
position: absolute;
bottom: 35px;
right: 35px;
height: 50px;
width: 50px;
background: $dark-blue;
border: none;
border-radius: 65%;
transition: box-shadow 0.2s ease, transform 0.2s ease;
&:hover {
box-shadow: 3px 4px rgb(10, 156, 18);
transform: scale(0.90);
}
}
.empty-state-text {
font-size: 20px;
color: rgb(255, 255, 255);
text-align: center;
margin-top: 25px;
animation: 0.25s ease 0s 1 slideInFromTop;
@keyframes slideInFromTop {
0% {
transform: translateY(-15%);
}
100% {
transform: translateY(0);
}
}
}

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TaskViewComponent } from './task-view.component';
describe('TaskViewComponent', () => {
let component: TaskViewComponent;
let fixture: ComponentFixture<TaskViewComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TaskViewComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TaskViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,44 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params} from '@angular/router';
import {List} from 'src/app/models/list';
import {Task} from 'src/app/models/task';
import {TaskService} from 'src/app/task.service';
@Component({
selector: 'app-task-view',
templateUrl: './task-view.component.html',
styleUrls: ['./task-view.component.scss']
})
export class TaskViewComponent implements OnInit {
lists: List[];
tasks: Task[];
constructor(private taskService: TaskService, private route: ActivatedRoute) {
}
ngOnInit() {
this.route.params.subscribe(
(params: Params) => {
if (params.listId) {
this.taskService.getTasks(params.listId).subscribe((tasks: Task[]) => {
this.tasks = tasks;
});
} else {
this.tasks = undefined;
}
}
);
this.taskService.getLists().subscribe((lists: List[]) => {
this.lists = lists;
});
}
onTaskClick(task: Task) {
this.taskService.complete(task).subscribe(() => {
console.log('Completed Successfully');
task.completed = !task.completed;
});
}
}

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { TaskService } from './task.service';
describe('TaskService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: TaskService = TestBed.get(TaskService);
expect(service).toBeTruthy();
});
});

@ -0,0 +1,33 @@
import { Injectable } from '@angular/core';
import { Task } from './models/task';
import { WebRequestService } from './web-request.service';
@Injectable({
providedIn: 'root'
})
export class TaskService {
constructor(private webRequestService: WebRequestService) { }
getLists() {
return this.webRequestService.get('lists');
}
getTasks(listId: string) {
return this.webRequestService.get(`lists/${listId}/tasks`);
}
createNewList(title: string) {
return this.webRequestService.post('lists', { title });
}
createNewTask(title: string, listId: string) {
return this.webRequestService.post(`lists/${listId}/tasks`, { title });
}
complete(task: Task) {
return this.webRequestService.patch(`lists/${task._listId}/tasks/${task._id}`, {
completed: !task.completed
});
}
}

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { WebRequestInterceptor } from './web-request-interceptor';
describe('WebRequestInterceptorService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: WebRequestInterceptor = TestBed.get(WebRequestInterceptor);
expect(service).toBeTruthy();
});
});

@ -0,0 +1,67 @@
import { HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { EMPTY, Observable, throwError } from 'rxjs';
import { catchError, switchMap, tap } from 'rxjs/operators';
import { AuthService } from './auth.service';
@Injectable({
providedIn: 'root'
})
export class WebRequestInterceptor implements HttpInterceptor {
constructor(private authService: AuthService) { }
refreshingAccessToken: boolean;
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<any> {
// Handle Request
request = this.addAuthHeader(request);
// Call next() to handle response
return next.handle(request).pipe(
catchError((error: HttpErrorResponse) => {
console.log(error);
if (error.status === 401 && !this.refreshingAccessToken) {
return this.refreshAccessToken().pipe(
switchMap(() => {
request = this.addAuthHeader(request);
return next.handle(request);
}),
catchError((error: any) => {
console.log(error);
this.authService.logout();
return EMPTY;
})
);
}
return throwError(error);
})
);
}
refreshAccessToken() {
this.refreshingAccessToken = true;
return this.authService.getNewAccessToken().pipe(
tap(() => {
this.refreshingAccessToken = false;
console.log('Access Token Refreshed')
})
);
}
addAuthHeader(request: HttpRequest<any>) {
// Get Access Token
const token = this.authService.getAccessToken();
if (token) {
// Append Access Token To Request Header
return request.clone({
setHeaders: {
'x-access-token': token
}
});
}
return request;
}
}

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { WebRequestService } from './web-request.service';
describe('WebRequestService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: WebRequestService = TestBed.get(WebRequestService);
expect(service).toBeTruthy();
});
});

@ -0,0 +1,38 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class WebRequestService {
readonly ROOT_URL: string;
constructor(private http: HttpClient) {
this.ROOT_URL = 'http://localhost:3000';
}
get(uri: string) {
return this.http.get(`${this.ROOT_URL}/${uri}`);
}
post(uri: string, payload: Object) {
return this.http.post(`${this.ROOT_URL}/${uri}`, payload);
}
patch(uri: string, payload: Object) {
return this.http.patch(`${this.ROOT_URL}/${uri}`, payload);
}
delete(uri: string) {
return this.http.delete(`${this.ROOT_URL}/${uri}`);
}
login(email: string, password: string) {
return this.http.post(`${this.ROOT_URL}/users/login`, {
email,
password
}, {
observe: 'response'
});
}
}

@ -0,0 +1,11 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11

@ -0,0 +1,3 @@
export const environment = {
production: true
};

@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Task Manager</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://kit.fontawesome.com/688b6f6f22.js" crossorigin="anonymous"></script>
</head>
<body>
<app-root></app-root>
</body>
<footer class="footer has-text-white">
<div class="content has-text-centered has-text-white">
<p>© 2020 by <a href="https://goudham.me">Goudham Suresh</a></p>
</div>
<div class="content has-text-centered has-text-white">
<p>Privacy Notice</p>
</div>
</footer>
</html>

@ -0,0 +1,32 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/frontend'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

@ -0,0 +1,92 @@
// This is where we modify global styles and variable values
// Import Fonts
@import url('https://fonts.googleapis.com/css?family=Lato:400,700|Nunito:400,700');
$dark-blue: #000711;
$light-blue: #595B83;
$light-green: #45f6ed;
$blue: rgb(13, 45, 104);
$light: #f8f8f8;
// Update Global Bulma Variables
$family-sans-serif: "Nunito",
"sans-serif";
$primary: $light-blue;
$link: $light-green;
// Update Component Bulma Variables
$control-border-width: 2px;
$input-border-color: transparent;
$input-shadow: none;
// Global Styles
html {
background: $dark-blue
}
html,
body {
height: 100%;
color: $light;
}
.footer {
background: #011024;
}
.centered-content {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.modal-box {
min-height: 200px;
width: 100%;
max-width: 580px;
background-color: #060930;
border-radius: 5px;
padding: 35px;
button {
border: none;
border-radius: 5px;
background-color: $dark-blue;
transition: box-shadow 0.2s ease, transform 0.2s ease;
text-align: center;
padding: 14px 20px;
font-size: 24px;
margin: 5px;
&:hover {
transform: scale(0.90);
}
}
.green {
&:hover {
box-shadow: 2px 4px rgb(10, 156, 18);
}
}
.red {
&:hover {
box-shadow: 2px 4px rgb(182, 2, 2);
}
}
}
// Mobile
$desktop: 960px;
$tablet: 768px;
$mobile-large: 640px;
$mobile: 480px;
$mobile-small: 300px;
@media only screen and (max-width : $desktop/$tablet/$mobile-large/$mobile/$mobile-small) {}

@ -0,0 +1,12 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

@ -0,0 +1,63 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

@ -0,0 +1,4 @@
/* You can add global styles to this file, and also import other style files */
@import '../node_modules/bulma/bulma.sass';
@import 'main-styles.scss'

@ -0,0 +1,20 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

@ -0,0 +1,18 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

@ -0,0 +1,18 @@
{
"extends": "../tslint.json",
"rules": {
"variable-name": false,
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}

@ -0,0 +1,22 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}

@ -0,0 +1,75 @@
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"array-type": false,
"arrow-parens": false,
"deprecation": {
"severity": "warn"
},
"import-blacklist": [
true,
"rxjs/Rx"
],
"interface-name": false,
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-use-before-declare": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"object-literal-sort-keys": false,
"ordered-imports": false,
"quotemark": [
true,
"single"
],
"trailing-comma": false,
"no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}
Loading…
Cancel
Save