Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added user-app.zip
Binary file not shown.
20 changes: 19 additions & 1 deletion user-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ import { UserDetailComponent } from './pages/user-detail/user-detail.component';
import { CreateUserComponent } from './pages/create-user/create-user.component';
import { AuthGuard } from './guards/auth.guard';

const routes: Routes = [];
const routes: Routes = [
{
path: '',
component: UserListComponent,
},
{
path: 'about-us',
component: AboutUsComponent,
},
{
path: 'contact',
component: ContactComponent,
},
{
path: 'create-user',
component: CreateUserComponent,
canActivate: [AuthGuard],
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
1 change: 1 addition & 0 deletions user-app/src/app/interceptors/log.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class LogInterceptor implements HttpInterceptor {
next: HttpHandler
): Observable<HttpEvent<unknown>> {
const requestCopy = request.clone();
console.log('Request URL:');
return next.handle(requestCopy);
}
}
8 changes: 2 additions & 6 deletions user-app/src/app/pages/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
<h2>
Congratulations! Angular set up is complete.
<br />
<br />
You are ready to begin the workshop3.
</h2>
<app-header [title]="name" (changeValue)="changeName()"></app-header>
<router-outlet></router-outlet>
48 changes: 48 additions & 0 deletions user-app/src/app/pages/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
color: #fff;
}

h2 {
background: #59C173; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #5D26C1, #a17fe0, #59C173); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #5D26C1, #a17fe0, #59C173); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
text-align: center;
transition: all 0.5s;
cursor: pointer;
}

h2:hover {
color: white;
transform: translateX(10px);
}

span {
font-size: 2.5rem;
text-align: center;
}

.normal {
font-size: 2rem;
color: blue;
}

.error {
font-size: 2rem;
color: red;
}

button {
width: 200px;
height: 30px;
background-color: rgb(65, 166, 212);
color: white;
border-radius: 5px;
border: solid 1px white;
margin-top: 20px;
cursor: pointer;
}
29 changes: 28 additions & 1 deletion user-app/src/app/pages/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,31 @@ import { Component } from '@angular/core';
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {}
export class AppComponent {
name : string = 'Jenison Monteiro';
show : boolean = true;
names = ['Arun', 'Mark', 'Smith', 'Jack'];
userName : string = "";
isError : boolean = true;

constructor() {
console.log('Constructor called');
}

changeName() {
this.name = 'Jenison';
console.log(this.userName);
}

ngOnChanges() {
console.log('on changes called');
}

ngOnInit() {
console.log('on init called');
}

ngOnDestroy() {
console.log('on destroy called');
}
}
48 changes: 40 additions & 8 deletions user-app/src/app/pages/create-user/create-user.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
<div class="container">
<form>
<div class="form">
<h2>Enter Details</h2>
<div class="input-form">
<label>Name </label>
<input placeholder="Enter the name" formControlName="name" />
</div>
<form [formGroup]="userFormBuilder" (keydown.enter)="addUser()">
<div class="form">
<h2>Enter Details</h2>
<div class="input-form">
<label>Name </label>
<input placeholder="Enter the name" formControlName="name" />
</div>
<div class="input-form">
<label>Email</label>
<input placeholder="Enter the email id" formControlName="emailId" />
</div>
<div class="input-form">
<label>Phone</label>
<input placeholder="Enter the phone number" formControlName="phoneNumber" />
</div>
<div class="input-form">
<label>Company</label>
<input placeholder="Enter the company name" formControlName="companyName" />
</div>
<div class="input-form">
<label>Street</label>
<input placeholder="Enter the street" formControlName="street" />
</div>
<div class="input-form">
<label>City</label>
<input placeholder="Enter the city" formControlName="city" />
</div>
<div class="input-form">
<label>Zipcode</label>
<input placeholder="Enter the zipcode" formControlName="zipCode" />
</div>
<div class="error" *ngIf="hasError">
<span>Please enter all the details</span>
</div>
<div class="form-btn">
<button (click)="addUser()">Add User</button>
</div>
</div>
</form>
</div>
</div>


36 changes: 35 additions & 1 deletion user-app/src/app/pages/create-user/create-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,38 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
templateUrl: './create-user.component.html',
styleUrls: ['./create-user.component.scss'],
})
export class CreateUserComponent {}
export class CreateUserComponent {
hasError: boolean = false;
userFormBuilder: FormGroup;

constructor(private readonly formBuilder: FormBuilder,private userService: UserService) {
this.userFormBuilder = this.formBuilder.group({
emailId: formBuilder.control("", [Validators.required, Validators.email]),
name: formBuilder.control("", [Validators.required]),
phoneNumber: formBuilder.control("", [Validators.required]),
companyName: formBuilder.control("", [Validators.required]),
city: formBuilder.control("", [Validators.required]),
street: formBuilder.control("", [Validators.required]),
zipCode: formBuilder.control("", [Validators.required]),
});
}

addUser() {
this.hasError = false;
if (this.userFormBuilder.valid) {
this.userService.addUser({
id: Math.floor(Math.random() * 10),
name: this.userFormBuilder.controls['name'].value,
emailId: this.userFormBuilder.controls['emailId'].value,
phoneNumber: this.userFormBuilder.controls['phoneNumber'].value,
companyName: this.userFormBuilder.controls['companyName'].value,
street: this.userFormBuilder.controls['street'].value,
city: this.userFormBuilder.controls['city'].value,
zipCode: this.userFormBuilder.controls['zipCode'].value,
});
} else {
this.hasError = true;
}
}

}
9 changes: 8 additions & 1 deletion user-app/src/app/pages/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<p>Header Works</p>
<div class="header">
<img routerLink="" routerLinkActive="router-link-active" src="../../../assets/unicourt-logo.png" alt="logo">
<div class="menu">
<label routerLink="/">Home</label>
<label routerLink="/about-us">About Us</label>
<label routerLink="/contact">Contact</label>
</div>
</div>
9 changes: 9 additions & 0 deletions user-app/src/app/pages/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@
cursor: pointer;
color: rgb(65, 166, 212);
}

button {
color: black;
background-color: rgb(37, 175, 220);
padding: 10px;
border-radius: 18px;
border: 1px solid #fff;
cursor: pointer;
}
11 changes: 9 additions & 2 deletions user-app/src/app/pages/header/header.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Component } from '@angular/core';
import { Component,Input,Output,EventEmitter } from '@angular/core';

@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss'],
})
export class HeaderComponent {}
export class HeaderComponent {
@Input() title: string;
@Output() changeValue = new EventEmitter<any>();

onClick() {
this.changeValue.emit();
}
}
9 changes: 8 additions & 1 deletion user-app/src/app/pages/user-card/user-card.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<div class="user-card">
<p>User Card works</p>
<label>{{ name }}</label> <br /><br/>
<span>{{ emailId }}</span> <br /> <br>
<span>{{ city }}</span> <br />
<button class="detail-btn" routerLink="/user-detail" (click)="setUserId(id)">
DETAIL
</button>
<button class="delete-btn" (click)="deleteUserById(id)">DELETE</button>
</div>

5 changes: 3 additions & 2 deletions user-app/src/app/pages/user-card/user-card.component.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.user-card {
padding: 10px;
margin: 5px;
border: solid 1px rgb(83, 163, 168);
border: solid 1px /*rgb(83, 163, 168)*/ rgb(5, 244, 101);
width: 200px;
height: 200px;
height: 220px;
border-radius: 18px;
}

.user-card > label {
Expand Down
19 changes: 18 additions & 1 deletion user-app/src/app/pages/user-card/user-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@ import { UserService } from 'src/app/services/user.service';
templateUrl: './user-card.component.html',
styleUrls: ['./user-card.component.scss'],
})
export class UserCardComponent {}
export class UserCardComponent {
@Input() id: number;
@Input() name: string;
@Input() emailId: string;
@Input() city: string;

@Output() deleteUser = new EventEmitter<Number>();

constructor(public userService: UserService) {}

setUserId(id: number) {
this.userService.userId = id;
}

deleteUserById(id) {
this.deleteUser.emit(id);
}
}
20 changes: 19 additions & 1 deletion user-app/src/app/pages/user-detail/user-detail.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<div class="user-detail">
<p>User Detail Works</p>
<div *ngIf="!hasError" class="card">
<h2>{{ userDetail.name }}</h2>
<label>Emaild Id : {{ userDetail.emailId }}</label>
<label> Phone Number : {{ userDetail.phone }}</label>
<label>Company Name : {{ userDetail.companyName }}</label>
<div>
<h3>Address</h3>
<label>{{ userDetail.street }}</label
><br />
<label>{{ userDetail.city }}</label
><br />
<label>{{ userDetail.zipCode }}</label
><br />
</div>
</div>
<div *ngIf="hasError" class="error">
<span>Unable to show the data</span>
</div>
</div>

19 changes: 18 additions & 1 deletion user-app/src/app/pages/user-detail/user-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,21 @@ import { UserService } from 'src/app/services/user.service';
templateUrl: './user-detail.component.html',
styleUrls: ['./user-detail.component.scss'],
})
export class UserDetailComponent {}
export class UserDetailComponent {
userDetail: UserDetail = {
id: this.userService.userId,
name: '',
city: '',
companyName: '',
emailId: '',
phoneNumber: '',
street: '',
zipCode: '',
};

hasError: boolean = false;

constructor(public userService: UserService) {}


}
16 changes: 15 additions & 1 deletion user-app/src/app/pages/user-list/user-list.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<div class="container">
<p>User List Works</p>
<div class="header">
<h2>User List</h2>
<button routerLink="create-user">Create User</button>
</div>

<div class="user-card-container">
<app-user-card
*ngFor="let user of userService.users"
[id]="user.id"
[name]="user.name"
[city]="user.city"
[emailId]="user.emailId"
(deleteUser)="deleteUser($event)"
></app-user-card>
</div>
</div>
1 change: 1 addition & 0 deletions user-app/src/app/pages/user-list/user-list.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
display: flex;
flex-direction: column;
justify-content: space-between;
font-family: 'Poppins', sans-serif;
}

.header {
Expand Down
Loading