Skip to content

Commit f979eaf

Browse files
authored
Merge pull request #19 from iammangod96/master
Added request start and tentative end datetime feature
2 parents d045daf + ec438d5 commit f979eaf

23 files changed

+168
-65
lines changed

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@
115115
<artifactId>jjwt</artifactId>
116116
<version>0.2</version>
117117
</dependency>
118-
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-security -->
119-
<dependency>
120-
<groupId>org.springframework.cloud</groupId>
121-
<artifactId>spring-cloud-security</artifactId>
122-
<version>2.0.0.RELEASE</version>
123-
</dependency>
124118

125119
<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
126120
<dependency>

src/main/java/com/sba6/srm/controller/RequestController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.sba6.srm.controller;
22

33
import java.security.Principal;
4+
import java.time.temporal.ChronoUnit;
5+
import java.util.Date;
46
import java.util.List;
57

68
import javax.transaction.Transactional;
@@ -21,7 +23,6 @@
2123
import com.sba6.srm.entity.Employee;
2224
import com.sba6.srm.entity.Request;
2325

24-
import com.sba6.srm.enumsconstants.RequestStatus;
2526
import com.sba6.srm.service.CommentService;
2627
import com.sba6.srm.service.EmailService;
2728
import com.sba6.srm.service.EmployeeService;
@@ -62,6 +63,7 @@ public ResponseEntity updateRequestStatus(@RequestBody Request updateRequest) {
6263
if (updateRequest.getComment() != null && updateRequest.getComment() != "") {
6364
req.setComment(updateRequest.getComment());
6465
}
66+
req.setTentativeEndDtm(updateRequest.getTentativeEndDtm());
6567
requestService.updateRequest(req);
6668
emailService.mailRequestStatusUpdate(req, "ps2@gmail.com");
6769
return new ResponseEntity<>(HttpStatus.OK);
@@ -79,6 +81,9 @@ public ResponseEntity createRequest(@RequestBody Request newRequest) {
7981
Employee emp = employeeService.getEmployee(newRequest.getEmployee().getId());
8082
Request req = newRequest;
8183
req.setEmployee(emp);
84+
Date dt = new Date();
85+
req.setStartDtm(dt);
86+
req.setTentativeEndDtm( Date.from( dt.toInstant().plus(10, ChronoUnit.DAYS) ) );
8287
requestService.addRequest(req);
8388
emailService.mailAddRequest(req, "ps2@gmail.com");
8489
return new ResponseEntity<>(HttpStatus.OK);

src/main/java/com/sba6/srm/entity/Request.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.sba6.srm.entity;
22

33

4+
import java.util.Date;
5+
46
import javax.persistence.Column;
57
import javax.persistence.Entity;
68
import javax.persistence.EnumType;
@@ -11,6 +13,8 @@
1113
import javax.persistence.JoinColumn;
1214
import javax.persistence.ManyToOne;
1315
import javax.persistence.Table;
16+
import javax.persistence.Temporal;
17+
import javax.persistence.TemporalType;
1418

1519
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
1620
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -45,5 +49,11 @@
4549

4650
@Column(name="COMMENT")
4751
private String comment;
48-
52+
53+
@Column(name="START_DTM")
54+
private Date startDtm;
55+
56+
@Column(name="TENTATIVE_END_DTM")
57+
private Date tentativeEndDtm;
58+
4959
}

src/main/resources/application.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ spring.datasource.hikari.connection-test-query=SELECT 1
1515
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
1616
#To execute data.sql
1717
#spring.datasource.initialization-mode=always
18-
spring.datasource.username=
19-
spring.datasource.password=
18+
spring.datasource.username=root
19+
spring.datasource.password=password
2020
#JWT
2121
app.jwtSecret= JWTSuperSecretKey
2222
app.jwtExpirationInMs = 604800000
@@ -39,8 +39,8 @@ spring.mail.properties.mail.smtp.auth=true
3939
spring.mail.properties.mail.smtp.starttls.enable=true
4040

4141
#Google Login
42-
security.oauth2.client.clientId =
43-
security.oauth2.client.clientSecret =
42+
security.oauth2.client.clientId = 698682231712-gbno37u3fdovq1rjrhurj4o6bo00okg9.apps.googleusercontent.com
43+
security.oauth2.client.clientSecret = IImw1dZ0P1tm2tq82QeXPW19
4444
security.oauth2.client.accessTokenUri = https://www.googleapis.com/oauth2/v3/token
4545
security.oauth2.client.userAuthorizationUri = https://accounts.google.com/o/oauth2/auth
4646
security.oauth2.client.tokenName = oauth_token

src/main/resources/data.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ values(1,1001,'sp','sp','MANAGER'),
1010
(3,1003,'bw','bw','EMPLOYEE'),
1111
(4,1004,'ck','ck','EMPLOYEE');
1212

13-
insert into request (ID, EMP_ID, REQUEST_DESCRIPTION, STATUS,COMMENT)
14-
values(1, 1001, 'Need a PS Vita.', 'OPEN','NA'),
15-
(2, 1002, 'Need iPhone X', 'OPEN','NA'),
16-
(3, 1003, 'Need Oppo', 'OPEN','NA');
13+
insert into request (ID, EMP_ID, REQUEST_DESCRIPTION, STATUS,COMMENT, START_DTM, TENTATIVE_END_DTM)
14+
values(1, 1001, 'Need a PS Vita.', 'OPEN','NA', NOW(), NOW()),
15+
(2, 1002, 'Need iPhone X', 'OPEN','NA', NOW(), NOW()),
16+
(3, 1003, 'Need Oppo', 'OPEN','NA', NOW(), NOW());
1717

1818

1919

src/main/web-app/src/app/app-routing.module.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ import { BaseViewComponent } from './base-view/base-view.component';
55
import { RequestComponent } from './request/request.component';
66
import { ManagerDashboardComponent } from './manager-dashboard/manager-dashboard.component';
77
import { LoginComponent } from './login/login.component';
8-
import {AuthGuard} from './auth.guard';
8+
import { AuthGuard } from './auth.guard';
9+
import { ManagerGuard } from './manager.guard';
10+
911

1012
const routes: Routes = [
11-
{path:'',redirectTo:'dashboard',pathMatch:'full'},
12-
{path:'login',component:LoginComponent},
13-
{path:'empdetails',component:EmployeeDetailComponent,canActivate:[AuthGuard]},
14-
{path:'dashboard',component:BaseViewComponent,
15-
children:[
16-
{path:'',redirectTo:'mgrdashboard',pathMatch:'full'},
17-
{path:'mgrdashboard',component:ManagerDashboardComponent},
18-
{path:'request', component:RequestComponent},
13+
{path: '', redirectTo: 'dashboard', pathMatch:'full'},
14+
{path: 'login', component: LoginComponent},
15+
{path: 'empdetails', component: EmployeeDetailComponent, canActivate:[AuthGuard]},
16+
{path: 'dashboard', component: BaseViewComponent,
17+
children: [
18+
{path: '', redirectTo: 'request', pathMatch: 'full'},
19+
{path: 'mgrdashboard', component: ManagerDashboardComponent, canActivate: [ManagerGuard]},
20+
{path: 'request', component: RequestComponent},
1921
],
2022
canActivate:[AuthGuard]
2123
},
22-
{path:'**',component:BaseViewComponent}
23-
24+
{path: '**', component: BaseViewComponent}
25+
2426
];
2527

2628
@NgModule({

src/main/web-app/src/app/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { DiscussionDialogComponent } from './discussion-dialog/discussion-dialog
2323
import {TokenInterceptorService} from './token-interceptor.service';
2424

2525

26+
2627
@NgModule({
2728
declarations: [
2829
AppComponent,
@@ -34,7 +35,7 @@ import {TokenInterceptorService} from './token-interceptor.service';
3435
DisplayDataDialogComponent,
3536
RequestDialogComponent,
3637
LoginComponent,
37-
DiscussionDialogComponent
38+
DiscussionDialogComponent,
3839
],
3940
imports: [
4041
BrowserModule,

src/main/web-app/src/app/base-view/base-view.component.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
</mat-sidenav>
1616
<mat-sidenav-content>
1717
<nav mat-tab-nav-bar color="primary" backgroundColor="warn">
18-
<a mat-tab-link
19-
*ngFor="let link of navLinks"
20-
[routerLink]="link.path"
21-
routerLinkActive #rla="routerLinkActive"
22-
[active]="rla.isActive">
23-
{{link.label}}
24-
</a>
18+
<ng-container *ngFor="let link of navLinks">
19+
<a mat-tab-link
20+
[routerLink]="link.path"
21+
routerLinkActive #rla="routerLinkActive"
22+
[active]="rla.isActive">
23+
{{link.label}}
24+
</a>
25+
</ng-container>
2526
</nav>
2627

2728
<router-outlet></router-outlet>

src/main/web-app/src/app/base-view/base-view.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { AuthService } from '../auth.service';
23

34
@Component({
45
selector: 'app-base-view',
@@ -7,10 +8,19 @@ import { Component, OnInit } from '@angular/core';
78
})
89
export class BaseViewComponent implements OnInit {
910

10-
constructor() { }
11+
constructor(
12+
public authService: AuthService
13+
) {
14+
if (authService.securityContext.role === 'EMPLOYEE') {
15+
this.navLinks.shift();
16+
}
17+
}
18+
19+
navLinks = [
20+
{path: './mgrdashboard', label: 'Manager Dashboard'},
21+
{path: './request', label: 'Request'}
22+
];
1123

12-
navLinks=[{path:'./mgrdashboard',label:'Manager Dashboard'},
13-
{path:'./request',label:'Request'}];
1424
ngOnInit() {
1525
}
1626

src/main/web-app/src/app/discussion-dialog/discussion-dialog.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class DiscussionDialogComponent implements OnInit {
2424
this.commentService.getCommentsForRequest(this.requestId).subscribe(result =>{
2525
if (result) {
2626
this.comments = result;
27-
console.log(this.comments);
2827
}
2928
});
3029
}

0 commit comments

Comments
 (0)