Commit c6b80aff authored by Simhadri Guntreddi's avatar Simhadri Guntreddi

Added Update Delete Operations

parent 4848f10c
button{ button{
background: rgb(1, 29, 51); background: rgb(247, 250, 246);
border-color: transparent; border-color: transparent;
color: rosybrown ; color: rgb(56, 32, 32) ;
cursor: pointer; cursor: pointer;
} }
#customers { #customers {
...@@ -13,11 +13,12 @@ button{ ...@@ -13,11 +13,12 @@ button{
#customers td, #customers th { #customers td, #customers th {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 8px; padding: 8px;
color: whitesmoke;;
} }
#customers tr:nth-child(even){background-color: #f2f2f2;} #customers tr:nth-child{background-color: #f2f2f2;}
#customers tr:hover {background-color: #ddd;} #customers tr:hover {background-color: royalblue;}
#customers th { #customers th {
padding-top: 12px; padding-top: 12px;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</button> </button>
</p> </p>
<div style="text-align:center"> <div style="text-align:center">
<h1> <h1 style="color: #FFF;">
Welcome {{name}} Welcome {{name}}
</h1> </h1>
</div> </div>
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<th>Password</th> <th>Password</th>
<th>Role</th> <th>Role</th>
<th>Description</th> <th>Description</th>
<th>ID</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
...@@ -28,8 +29,9 @@ ...@@ -28,8 +29,9 @@
<td>{{item.password}}</td> <td>{{item.password}}</td>
<td>{{item.role}}</td> <td>{{item.role}}</td>
<td>{{item.description}}</td> <td>{{item.description}}</td>
<td>{{item.id}}</td>
<td><a (click)="getData(item)" ><i class='fas fa-edit' style='font-size:24px'></i> </a> &nbsp; <td><a (click)="getData(item)" ><i class='fas fa-edit' style='font-size:24px'></i> </a> &nbsp;
<a (click)="deleteData(item)" ><i class='fas fa-trash-alt' style='font-size:24px'></i></a> <a (click)="deleteData(item.id)" ><i class='fas fa-trash-alt' style='font-size:24px'></i></a>
</td> </td>
</tr> </tr>
</ng-container> </ng-container>
...@@ -41,6 +43,7 @@ ...@@ -41,6 +43,7 @@
<h2 class="login-header">Update</h2> <h2 class="login-header">Update</h2>
<form [formGroup]="userUpdateForm" class="login-container" (ngSubmit)="update()"> <form [formGroup]="userUpdateForm" class="login-container" (ngSubmit)="update()">
<p [ngClass]="{ 'has-error': isSubmitted && formControls.userId.errors }" > <p [ngClass]="{ 'has-error': isSubmitted && formControls.userId.errors }" >
<input type="text" placeholder="userId" formControlName="userId" ngModel="{{userInfo.userId}}" disabled> <input type="text" placeholder="userId" formControlName="userId" ngModel="{{userInfo.userId}}" disabled>
</p> </p>
......
...@@ -20,6 +20,11 @@ export class HomeComponent implements OnInit { ...@@ -20,6 +20,11 @@ export class HomeComponent implements OnInit {
showMsg = false; showMsg = false;
userUpdateForm: FormGroup; userUpdateForm: FormGroup;
isSubmitted: boolean; isSubmitted: boolean;
code:any;
showModal: boolean = false;
successMsg: any;
taskTitle: any;
deleteCheckModal: boolean = false;
constructor(private authService: AuthService, private router: Router, private formBuilder: FormBuilder) { } constructor(private authService: AuthService, private router: Router, private formBuilder: FormBuilder) { }
ngOnInit() { ngOnInit() {
...@@ -46,8 +51,20 @@ export class HomeComponent implements OnInit { ...@@ -46,8 +51,20 @@ export class HomeComponent implements OnInit {
this.showData = true; this.showData = true;
this.userInfo = data; this.userInfo = data;
} }
deleteData(data) { taskId:any
console.log(data); dat:any = {};
deleteData(id): void {
console.log(id);
this.taskId = id;
this.authService.deleteData(this.taskId).subscribe(dat => {
this.showModal = true;
window.location.reload();
},
error => {
console.log("error", error);
});
} }
logout() { logout() {
this.authService.logout(); this.authService.logout();
......
export interface User { export interface User {
id: string;
userId: bigint; userId: bigint;
email: string; email: string;
password: string; password: string;
......
...@@ -25,8 +25,8 @@ export class AuthService { ...@@ -25,8 +25,8 @@ export class AuthService {
return this.http.get(this.baseUrl + 'users'); return this.http.get(this.baseUrl + 'users');
} }
public deleteData(): Observable<any> { public deleteData(taskId): Observable<any> {
return this.http.get(this.baseUrl + 'users'); return this.http.delete(this.baseUrl + 'delete/'+taskId);
} }
public isLoggedIn() { public isLoggedIn() {
return localStorage.getItem('token') !== null; return localStorage.getItem('token') !== null;
...@@ -38,7 +38,7 @@ export class AuthService { ...@@ -38,7 +38,7 @@ export class AuthService {
} }
public update(userInfo: User): Observable<any> { public update(userInfo: User): Observable<any> {
return this.http.post(this.baseUrl + 'update', userInfo); return this.http.put(this.baseUrl + 'update', userInfo);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment