Skip to content

Added Employee detail component, Request component integration with employee and request services, styling, and refactoring #13

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

Merged
merged 13 commits into from
Oct 8, 2018
Merged
Next Next commit
Changed Login detail role to enum type
  • Loading branch information
Manish Sharma committed Oct 5, 2018
commit fac62a8775f58e829b1a5a83b25b660a0615d881
6 changes: 5 additions & 1 deletion src/main/java/com/sba6/srm/entity/LoginDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
Expand All @@ -11,6 +13,7 @@

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.sba6.srm.enumsconstants.LoginDetailRole;

import lombok.*;

Expand All @@ -35,6 +38,7 @@
@Column(name="PASSWORD")
private String password;

@Enumerated(EnumType.STRING)
@Column(name="ROLE")
private Long role;
private LoginDetailRole role;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sba6.srm.enumsconstants;

public enum LoginDetailRole {
EMPLOYEE, MANAGER;
}
7 changes: 4 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ spring.datasource.url=jdbc:mysql://localhost:3306/sba6?characterEncoding=latin1&
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.hikari.connection-test-query=SELECT 1
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
#spring.datasource.initialization-mode=always
spring.datasource.username=root
spring.datasource.password=We1c0me2GgK
#To execute data.sql
#spring.datasource.initialization-mode=always
spring.datasource.username=
spring.datasource.password=

# SQL logging
logging.level.org.hibernate.SQL=DEBUG
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ insert into employee (ID, FIRST_NAME, LAST_NAME, MGR_ID, DESIGNATION, DEPARTMENT
values(1001,'Satya', 'Paidi', null, 'SM', 'IT', null),
(1002,'Manish', 'Sharma', 1001, 'SE', 'IT', null),
(1003, 'Bruce', 'Wayne', 1001, 'SSE', 'IT', null),
(1004, 'Clark', 'Klent', null, 'M', 'HR', null);
(1004,'Clark', 'Kent', 1001, 'HR', 'HR', null);

insert into login_detail (ID, EMP_ID, USERNAME, PASSWORD, ROLE)
values(1,1001,'sp','sp',1),
(2,1002,'ms','ms',0),
(3,1003,'bw','bw',0),
(4,1004,'ck','ck',1);
values(1,1001,'sp','sp','MANAGER'),
(2,1002,'ms','ms','EMPLOYEE'),
(3,1003,'bw','bw','EMPLOYEE'),
(4,1004,'ck','ck','EMPLOYEE');

insert into request (ID, EMP_ID, REQUEST_DESCRIPTION, STATUS,COMMENT)
values(1, 1001, 'Need a PS Vita.', 'OPEN','NA'),
Expand Down
13 changes: 13 additions & 0 deletions src/main/web-app/src/app/request/request.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
table {
width: 100%;
}

.mat-form-field {
font-size: 14px;
width: 100%;
}

td, th {
width: 35%;
}

10 changes: 5 additions & 5 deletions src/main/web-app/src/app/request/request.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="mat-elevation-z8">
<button mat-fab color="primary" (click)="onAddRequest()">
<button mat-fab color="primary" (click)="onAddRequest()" [disabled]="disableAddRequest">
<mat-icon >add</mat-icon>
</button>

Expand All @@ -10,21 +10,21 @@
<!-- Request Description Column -->
<ng-container matColumnDef="reqDesc">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Request Description </th>
<td mat-cell *matCellDef="let row"><button mat-button color="primary" (click)="viewReqDescription(row)"> {{row.reqDesc | slice:0:25}} </button></td>
<td mat-cell *matCellDef="let row"><button mat-button color="primary" (click)="viewReqDescription(row)" > {{row.reqDesc | slice:0:25}} </button></td>
</ng-container>



<!-- Status Column -->
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
<td mat-cell *matCellDef="let row"> {{row.status}} </td>
<td mat-cell *matCellDef="let row"> {{row.status}}</td>
</ng-container>
<!-- Action Column -->
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Action </th>
<td mat-cell *matCellDef="let row" class="manager-icons">
<button mat-icon-button color="primary" (click)="onCancel(row)" [disabled]="!(row.status==='open' || row.status==='pending')">
<td mat-cell *matCellDef="let row" class="manager-icons" >
<button mat-icon-button color="primary" (click)="onCancel(row)" [disabled]="!(row.status==='open' || row.status==='pending')">
<mat-icon >cancel</mat-icon>
</button>
</td>
Expand Down
22 changes: 13 additions & 9 deletions src/main/web-app/src/app/request/request.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface RequestData {
})
export class RequestComponent implements OnInit {

disableAddRequest: boolean; //true if there is any request which is not inactivated
comment: string;
displayedColumns: string[] = ['reqDesc', 'status', 'action'];
dataSource: MatTableDataSource<RequestData>;
Expand All @@ -35,32 +36,30 @@ export class RequestComponent implements OnInit {
constructor(public dialog: MatDialog) {
// Create 100 users
this.reqData = [
{reqDesc: 'Seat change request', status: 'open'},
{reqDesc: 'PC not working.', status: 'inactivated'},
{reqDesc: 'Project discussion.', status: 'inactivated'}
//{reqDesc: 'Seat change request', status: 'open'}
];

// Assign the data to the data source for the table to render
this.dataSource = new MatTableDataSource(this.reqData);
this.dataSource = new MatTableDataSource(this.filterRequestData(this.reqData));
// this.dataSource = this.reqData;
}

ngOnInit() {
this.dataSource.sort = this.sort;
this.disableAddRequest = false;
}

onSubmit(request: RequestData, action: string) {
const dialogRef = this.dialog.open(GenericDialogComponent, {
height: '250px',
width: '600px',
});
this.testinglog = "1";
dialogRef.afterClosed().subscribe((result) => {
dialogRef.componentInstance.onAdd.unsubscribe();
this.testinglog = result;
if (result) {
this.testinglog = result;
request.status = action;
request.status = action;
this.dataSource.data = this.filterRequestData(this.reqData);
this.disableAddRequest = false;
}
});
}
Expand Down Expand Up @@ -93,10 +92,15 @@ export class RequestComponent implements OnInit {
this.testinglog = this.comment;
this.reqData.push({reqDesc: this.comment, status: 'open'});
// this.dataSource = new MatTableDataSource(this.reqData);
this.dataSource.data = this.reqData;
this.disableAddRequest = true;
this.dataSource.data = this.filterRequestData(this.reqData);

}
});
}

filterRequestData(reqData:RequestData[]):RequestData[]{
return reqData.filter(request=>request.status!='inactivated');
}

}