-
Notifications
You must be signed in to change notification settings - Fork 2
integrate emplyee with backend #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nada257
wants to merge
8
commits into
main
Choose a base branch
from
#116-integrate-emplyee-data-with-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce80f00
integrate emplyee with backend
Nada257 106b12f
(del un need fun,line) (edit update function)
Nada257 7173c60
edit name to be cammel Case
Nada257 99bd841
adding company names , fix employee component
Nada257 0c84567
addingcompany
Nada257 a62f72f
adding Reset function,edit file name
Nada257 b2fec61
edit in message service
Nada257 e069755
change the interface name in component file
Nada257 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "api": { | ||
| "baseUrl": "http://41.38.83.137:8080/" | ||
| "baseUrl": "http://41.65.11.55:8080/" | ||
|
|
||
|
|
||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,78 +1,127 @@ | ||
| <div class="candidate-Laytout"> | ||
| <fieldset> | ||
| <fieldset> | ||
| <h1 fxLayoutAlign="center center">All Employees</h1> | ||
| <div fxLayoutAlign="center center"> | ||
| <table | ||
| mat-table | ||
| class="mat-elevation-z8 table" | ||
| [dataSource]="allEmployees" | ||
| > | ||
| <ng-container matColumnDef="id"> | ||
| <th mat-header-cell *matHeaderCellDef>No.</th> | ||
| <td mat-cell *matCellDef="let i = index">{{ i + 1 }}</td> | ||
| </ng-container> | ||
|
|
||
| <h1 fxLayoutAlign="center center">All Employees | ||
| </h1> | ||
| <div fxLayoutAlign="center center"> | ||
| <table mat-table class="mat-elevation-z8 table"> | ||
| <ng-container matColumnDef="Question"> | ||
| <th mat-header-cell *matHeaderCellDef> No. </th> | ||
| <td mat-cell></td> | ||
| </ng-container> | ||
|
|
||
| <ng-container matColumnDef="description"> | ||
| <th mat-header-cell *matHeaderCellDef> Name </th> | ||
| <td mat-cell></td> | ||
| </ng-container> | ||
| <ng-container matColumnDef="name"> | ||
| <th mat-header-cell *matHeaderCellDef>Name</th> | ||
| <td mat-cell *matCellDef="let element">{{ element.name }}</td> | ||
| </ng-container> | ||
| <ng-container matColumnDef="update"> | ||
| <th mat-header-cell *matHeaderCellDef></th> | ||
| <td | ||
| mat-cell | ||
| *matCellDef="let element" | ||
| class="update-icon" | ||
| (click)="fetchData(element)" | ||
| > | ||
| <mat-icon>edit</mat-icon> | ||
| </td> | ||
| </ng-container> | ||
| <ng-container matColumnDef="delete"> | ||
| <th mat-header-cell *matHeaderCellDef></th> | ||
| <td | ||
| mat-cell | ||
| *matCellDef="let element" | ||
| class="delete-icon" | ||
| (click)="deleteEmployee(element)" | ||
| > | ||
| <mat-icon>person_remove</mat-icon> | ||
| </td> | ||
| </ng-container> | ||
|
|
||
| <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
| <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr> | ||
| </table> | ||
| </div> | ||
| <div | ||
| fxLayoutAlign.lt-sm="start start" | ||
| (click)="changeVisibility()" | ||
| class="show-btn" | ||
| > | ||
| <button type="submit" mat-raised-button color="primary" fxFlex="50"> | ||
| <mat-icon>add</mat-icon> | ||
| </button> | ||
| </div> | ||
| </fieldset> | ||
| <br /> | ||
| <br /><br /> | ||
|
|
||
| <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
| <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
| </table> | ||
| </div> | ||
| <div fxLayoutAlign.lt-sm="start start" (click)="changeVisibility()" class="show-btn"> | ||
| <button type="submit" mat-raised-button color="primary" fxFlex="50"><mat-icon>add</mat-icon></button> | ||
| </div> | ||
| </fieldset> | ||
| <div *ngIf="isVisible"> | ||
| <br /> | ||
| <br /><br /> | ||
|
|
||
| <div *ngIf="isVisible;"> | ||
| <br> | ||
| <hr /> | ||
| <br> | ||
| <br> | ||
| <form [formGroup]="employeeForm" (ngSubmit)="onSubmit()"> | ||
| <fieldset> | ||
| <legend>Employee Info</legend> | ||
| <div class="all-Inpt"> | ||
| <div fxLayoutAlign="center center"> | ||
| <mat-form-field appearance="outline" fxFlex.lt-lg="80%" fxFlex="60"> | ||
| <mat-label>Employee Name</mat-label> | ||
| <input formControlName="name" type="text" matInput placeholder="enter your Employee Name"> | ||
| <mat-error *ngIf="employeeForm.controls['name'].hasError('name') && !employeeForm.controls['name'].hasError('required')"> | ||
| Please enter a Employee Name | ||
| </mat-error> | ||
| <mat-error *ngIf="employeeForm.controls['name'].hasError('required')"> | ||
| Employee Name is <strong>required</strong> | ||
| </mat-error> | ||
| </mat-form-field> | ||
| </div> | ||
|
|
||
|
|
||
|
|
||
| <div fxLayoutAlign="center center"> | ||
| <mat-form-field appearance="outline" fxFlex.lt-lg="80%" fxFlex="60"> | ||
| <mat-label>Choose Company</mat-label> | ||
| <mat-select #mode value="side" formControlName="companyId"> | ||
| <mat-option value="side">Side</mat-option> | ||
| <mat-option value="over">Over</mat-option> | ||
| <mat-option value="push">Push</mat-option> | ||
| </mat-select> | ||
| </mat-form-field> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
|
|
||
| <div fxLayoutAlign="center center"> | ||
| <button type="submit" class="addbtn" mat-raised-button color="primary" fxFlex.lt-lg="80%" fxFlex="40" class="addbtn">Add Employee</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| </fieldset> | ||
| <hr /> | ||
| <br /> | ||
| <br /> | ||
| <!-- (ngSubmit)="onSubmit()" --> | ||
| <form [formGroup]="employeeForm" > | ||
| <fieldset> | ||
| <legend>Employee Info</legend> | ||
| <div class="all-Inpt"> | ||
| <div fxLayoutAlign="center center"> | ||
| <mat-form-field appearance="outline" fxFlex.lt-lg="80%" fxFlex="60"(click)="appearRest()" > | ||
| <mat-label>Employee Name</mat-label> | ||
| <input | ||
| formControlName="name" | ||
| type="text" | ||
| matInput | ||
| placeholder="enter your Employee Name" | ||
| /> | ||
| <mat-error | ||
| *ngIf=" | ||
| employeeForm.controls['name'].hasError('name') && | ||
| !employeeForm.controls['name'].hasError('required') | ||
| " | ||
| > | ||
| Please enter a Employee Name | ||
| </mat-error> | ||
| <mat-error | ||
| *ngIf="employeeForm.controls['name'].hasError('required')" | ||
| > | ||
| Employee Name is <strong>required</strong> | ||
| </mat-error> | ||
| </mat-form-field> | ||
| </div> | ||
|
|
||
| </form> | ||
| </div> | ||
| <div fxLayoutAlign="center center"> | ||
| <mat-form-field appearance="outline" fxFlex.lt-lg="80%" fxFlex="60"> | ||
| <mat-label>Choose Company</mat-label> | ||
| <mat-select #mode value="side" formControlName="company"> | ||
| <mat-option [value]="''"></mat-option> | ||
| <mat-option [value]="companyData" *ngFor="let companyData of company">{{companyData.name}}</mat-option> | ||
|
|
||
| </mat-select> | ||
| </mat-form-field> | ||
| </div> | ||
|
|
||
| <div fxLayoutAlign="center center"> | ||
| <button | ||
| type="button" | ||
| (click)="SaveData()" | ||
| [disabled]="!employeeForm.valid" | ||
| class="addbtn" | ||
| mat-raised-button | ||
| color="primary" | ||
| fxFlex.lt-lg="80%" | ||
| fxFlex="40">{{employeeForm.controls['id'].value?'update Employee':'add Employee'}} | ||
| </button> | ||
| <div *ngIf="isRestButtonAppear;"> | ||
| <button (click)='resetTheForm()' type="button" mat-raised-button color="primary" class="rest-Icon" | ||
| fxFlex.lt-lg="2%" fxFlex="2" [disabled]="submit"> | ||
| <mat-icon>restart_alt</mat-icon> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,110 @@ | ||
| import { Component, OnInit } from '@angular/core'; | ||
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
| import { MessageService } from 'src/app/core/services/config/message.service'; | ||
| import { Company } from 'src/app/domain/company/models/company'; | ||
| import { EmployeeRepository } from 'src/app/domain/employee/employee.repository'; | ||
| import { Emplyee } from 'src/app/domain/employee/models/emplyee'; | ||
| import { CompanyRepository } from 'src/app/domain/company/company.repository'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-employee', | ||
| templateUrl: './employee.component.html' | ||
| templateUrl: './employee.component.html', | ||
| }) | ||
| export class EmployeeComponent implements OnInit { | ||
| employeeForm!:FormGroup; | ||
| displayedColumns: string[] = ['Question', 'description']; | ||
| isVisible:boolean = false; | ||
| constructor(private formBuilder:FormBuilder) { } | ||
| employeeForm!: FormGroup; | ||
| displayedColumns: string[] = ['id','name','delete','update']; | ||
| isVisible: boolean = false; | ||
| page: number = 0; | ||
| size: number = 10; | ||
| totalItems: number = 0; | ||
| allEmployees: Emplyee[] = []; | ||
| company:Company[]=[]; | ||
| isRestButtonAppear: boolean; | ||
|
|
||
|
|
||
| constructor( | ||
| private formBuilder: FormBuilder, | ||
| private employeeRepository: EmployeeRepository, | ||
| private message: MessageService , | ||
| private companyRepositiory:CompanyRepository ) {} | ||
| ngOnInit(): void { | ||
| this.employForm(); | ||
| this.getAllEmplyees(); | ||
| this.getCompany(); | ||
| } | ||
| employForm() { | ||
| this.employeeForm = this.formBuilder.group({ | ||
| id: [''], | ||
| name: ['', [Validators.required]], | ||
| company: ['', [Validators.required]], | ||
| }); | ||
| } | ||
| SaveData(){ | ||
| if(this.employeeForm.valid){ | ||
| this.employeeForm.controls['id'].value? this.updateEmployee():this.addEmployee(); | ||
| this.employeeForm.reset(); | ||
| } | ||
| } | ||
| employForm(){ | ||
| this.employeeForm=this.formBuilder.group({ | ||
| id:[''], | ||
| name:['', [Validators.required]], | ||
| companyId:['', [Validators.required]] | ||
| addEmployee(){ | ||
|
|
||
| this.employeeRepository.add(this.employeeForm.value).subscribe(()=>{ | ||
| this.getAllEmplyees();this.changeVisibility(); | ||
|
|
||
| }) | ||
| } | ||
| onSubmit(){ | ||
| getAllEmplyees(): void { | ||
| this.employeeRepository | ||
| .getList({ | ||
| page: this.page, | ||
| size: this.size, | ||
| }) | ||
| .subscribe((result) => { | ||
| this.allEmployees = result.data; | ||
| this.totalItems = result.pagination.itemCount; | ||
| }); | ||
| } | ||
| getCompany(): void { | ||
| this.companyRepositiory | ||
| .getList() | ||
| .subscribe((result) => { | ||
| this.company = result.data; | ||
|
|
||
| console.log(this.company) | ||
| }); | ||
| } | ||
| fetchData(employeeData:Emplyee):void{ | ||
| this.employeeForm.reset(); | ||
| this.isVisible=true; | ||
|
|
||
| this.employeeForm.patchValue({ | ||
| id:employeeData.id, | ||
| name:employeeData.name | ||
|
|
||
| }) | ||
|
|
||
| } | ||
| changeVisibility(){ | ||
| this.isVisible = !this.isVisible | ||
| updateEmployee(){ | ||
| this.employeeRepository.update(this.employeeForm.value).subscribe(()=>{ | ||
| this.getAllEmplyees(); | ||
| this.changeVisibility(); | ||
| }) | ||
| } | ||
| deleteEmployee(employeeData:Emplyee){ | ||
| this.message.deleteConfirmation('','Are you sure want to delete this employee ? ').subscribe(res =>{ | ||
| if(res.success) | ||
| this.employeeRepository.delete(employeeData.id).subscribe(()=>{ | ||
| this.getAllEmplyees(); | ||
| }) | ||
| }) | ||
| } | ||
| changeVisibility() { | ||
| this.isVisible = !this.isVisible; | ||
| } | ||
| appearRest() { | ||
| this.isRestButtonAppear = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you need this function? |
||
| } | ||
| resetTheForm(){ | ||
| this.employeeForm.reset(); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ export interface Company{ | |
| id:number; | ||
| name:string; | ||
| description:string; | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { HttpClient } from "@angular/common/http"; | ||
| import { Injectable } from "@angular/core"; | ||
| import { ResourceService } from "src/app/core/services/config/resource.service"; | ||
| import { Emplyee } from "./models/emplyee"; | ||
| @Injectable({ | ||
| providedIn: 'root' | ||
| }) | ||
|
|
||
| export class EmployeeRepository extends ResourceService<Emplyee>{ | ||
| constructor(httpClient: HttpClient) { | ||
| super(httpClient); | ||
| } | ||
| getResourceUrl(): string { | ||
| return 'employee'; | ||
| }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { Company } from "../../company/models/company"; | ||
|
|
||
| export interface Emplyee{ | ||
| id:number; | ||
| name:string; | ||
| company:Company; | ||
|
|
||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete un need property