Skip to content

Commit

Permalink
updated task-service and task-model
Browse files Browse the repository at this point in the history
  • Loading branch information
albindavidc committed Dec 28, 2024
1 parent f80e9c2 commit 98d6fe5
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 3 deletions.
2 changes: 2 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}
],
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.css"
],
"scripts": [],
Expand Down Expand Up @@ -90,6 +91,7 @@
}
],
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.css"
],
"scripts": []
Expand Down
41 changes: 39 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"private": true,
"dependencies": {
"@angular/animations": "^19.0.0",
"@angular/cdk": "^19.0.4",
"@angular/common": "^19.0.0",
"@angular/compiler": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/material": "^19.0.4",
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/platform-server": "^19.0.0",
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/app/tasks/task-form/task-form.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>task-form works!</p>
11 changes: 11 additions & 0 deletions src/app/tasks/task-form/task-form.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-task-form',
imports: [],
templateUrl: './task-form.component.html',
styleUrl: './task-form.component.css'
})
export class TaskFormComponent {

}
Empty file.
1 change: 1 addition & 0 deletions src/app/tasks/task-item/task-item.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>task-item works!</p>
11 changes: 11 additions & 0 deletions src/app/tasks/task-item/task-item.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-task-item',
imports: [],
templateUrl: './task-item.component.html',
styleUrl: './task-item.component.css'
})
export class TaskItemComponent {

}
Empty file.
1 change: 1 addition & 0 deletions src/app/tasks/task-list/task-list.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>task-list works!</p>
11 changes: 11 additions & 0 deletions src/app/tasks/task-list/task-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-task-list',
imports: [],
templateUrl: './task-list.component.html',
styleUrl: './task-list.component.css'
})
export class TaskListComponent {

}
6 changes: 6 additions & 0 deletions src/app/tasks/task.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Task {
id: string;
title: string;
description: string;
completed: boolean;
}
36 changes: 36 additions & 0 deletions src/app/tasks/task.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from '@angular/core';
import { Task } from './task.model';

@Injectable({
providedIn: 'root',
})
export class TasksService {
private storageKey = 'taskManager';

getTasks(): Task[] {
const tasks = localStorage.getItem(this.storageKey);
return tasks ? JSON.parse(tasks) : [];
}

saveTasks(tasks: Task[]): void {
localStorage.setItem(this.storageKey, JSON.stringify(tasks));
}

addTasks(task: Task): void {
const tasks = this.getTasks();
tasks.push(task);
this.saveTasks(tasks);
}

updateTasks(updateTask: Task): void {
const tasks = this.getTasks().map((task) =>
task.id === updateTask.id ? updateTask : task
);
this.saveTasks(tasks);
}

deleteTasks(taskId: string):void{
const tasks = this.getTasks().filter((task) => task.id !== taskId)
this.saveTasks(tasks);
}
}
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<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/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';

bootstrapApplication(AppComponent, {
...appConfig,
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }],
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }, provideAnimationsAsync()],
}).catch((err) => console.error(err));
3 changes: 3 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/* You can add global styles to this file, and also import other style files */

html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

0 comments on commit 98d6fe5

Please sign in to comment.