first commit

This commit is contained in:
Dhanraj
2024-09-22 10:21:52 +05:30
parent 9c6c3abc32
commit bd5119fc3c
697 changed files with 112184 additions and 10841 deletions

View File

@ -0,0 +1,145 @@
<app-menu></app-menu>
<div class="container mt-4">
<form [formGroup]="eventForm" (ngSubmit)="onSubmit()">
<div class="row">
<div class="col-md-6">
<div class="form-group mb-3">
<label for="code" class="form-label text-primary">Code</label>
<input id="code" formControlName="code" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="year" class="form-label text-primary">Year</label>
<input id="year" formControlName="year" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="subject" class="form-label text-primary">Subject</label>
<input id="subject" formControlName="subject" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="title" class="form-label text-primary">Title</label>
<input id="title" formControlName="title" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="subTitle" class="form-label text-primary">Subtitle</label>
<input id="subTitle" formControlName="subTitle" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="date" class="form-label text-primary">Date</label>
<input id="date" formControlName="date" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="phone" class="form-label text-primary">Phone</label>
<input id="phone" formControlName="phone" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="email" class="form-label text-primary">Email</label>
<input id="email" formControlName="email" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="isActive" class="form-label text-primary">Active</label>
<input id="isActive" type="checkbox" formControlName="isActive" />
</div>
</div>
<div class="col-md-6">
<div class="form-group mb-3">
<label class="form-label text-primary">Venues</label>
<div formArrayName="venues">
<div *ngFor="let venue of venues.controls; let i = index" class="card mb-2">
<div class="card-body">
<div [formGroupName]="i">
<div class="row mb-2">
<div class="col-12">
<input formControlName="title" placeholder="Title" class="form-control" />
</div>
</div>
<div class="row mb-2">
<div class="col-6">
<input formControlName="date" placeholder="Date" class="form-control" />
</div>
<div class="col-6">
<input formControlName="address" placeholder="Address" class="form-control" />
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<input formControlName="info" placeholder="Info" class="form-control" />
</div>
</div>
</div>
<button type="button" class="btn btn-danger btn-sm float-end" (click)="removeVenue(i)">
<!-- <i class="bi bi-trash"></i> -->X
</button>
</div>
</div>
<button type="button" class="btn btn-primary" (click)="addVenue()">
<i class="bi bi-plus"></i> Add Venue
</button>
</div>
</div>
<div class="form-group mb-3">
<label class="form-label text-primary">Highlights</label>
<div formArrayName="highlights">
<div *ngFor="let highlight of highlights.controls; let i = index" class="card mb-2">
<div class="card-body">
<input [formControlName]="i" class="form-control" placeholder="Highlight" />
<button type="button" class="btn btn-danger btn-sm float-end mt-2" (click)="removeHighlight(i)">
<!-- <i class="bi bi-trash"></i> -->X
</button>
</div>
</div>
<button type="button" class="btn btn-primary" (click)="addHighlight()">
<i class="bi bi-plus"></i> Add Highlight
</button>
</div>
</div>
<div class="form-group mb-3">
<label class="form-label text-primary">Organisers</label>
<div formArrayName="organisers">
<div *ngFor="let organiser of organisers.controls; let i = index" class="card mb-2">
<div class="card-body">
<input [formControlName]="i" class="form-control" placeholder="Organiser" />
<button type="button" class="btn btn-danger btn-sm float-end mt-2" (click)="removeOrganiser(i)">
<!-- <i class="bi bi-trash"></i> -->X
</button>
</div>
</div>
<button type="button" class="btn btn-primary" (click)="addOrganiser()">
<i class="bi bi-plus"></i> Add Organiser
</button>
</div>
</div>
<div class="form-group mb-3">
<label class="form-label text-primary">Fees</label>
<div formArrayName="fees">
<div *ngFor="let fee of fees.controls; let i = index" class="card mb-2">
<div class="card-body">
<div [formGroupName]="i">
<div class="row mb-2">
<div class="col-8">
<input formControlName="desc" placeholder="Description" class="form-control" />
</div>
<div class="col-4">
<input formControlName="cost" placeholder="Cost" type="number" class="form-control" />
</div>
</div>
</div>
<button type="button" class="btn btn-danger btn-sm float-end mt-2" (click)="removeFee(i)">
<!-- <i class="bi bi-trash"></i> -->X
</button>
</div>
</div>
<button type="button" class="btn btn-primary" (click)="addFee()">
<i class="bi bi-plus"></i> Add Fee
</button>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EventFormComponent } from './event-form.component';
describe('EventFormComponent', () => {
let component: EventFormComponent;
let fixture: ComponentFixture<EventFormComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EventFormComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(EventFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,135 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, FormArray, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { EventService } from 'src/app/service/event.service';
@Component({
selector: 'app-event-form',
templateUrl: './event-form.component.html',
styleUrls: ['./event-form.component.css']
})
export class EventFormComponent implements OnInit {
eventForm: FormGroup;
constructor(
private fb: FormBuilder,
private eventService: EventService,
private route: ActivatedRoute,
private router: Router
) {}
eventId: number | null;
ngOnInit() {
this.eventForm = this.fb.group({
code: ['', Validators.required],
year: ['', Validators.required],
subject: ['', Validators.required],
title: ['', Validators.required],
subTitle: [''],
date: ['', Validators.required],
venues: this.fb.array([]),
highlights: this.fb.array([]),
organisers: this.fb.array([]),
fees: this.fb.array([]),
phone: ['', Validators.required],
email: ['', [Validators.required, Validators.email]],
isActive: [true]
});
this.route.paramMap.subscribe(params => {
const idParam = params.get('id');
this.eventId = idParam ? +idParam : null;
if (this.eventId !== null) {
this.loadEvent(this.eventId);
}
});
}
loadEvent(id: number): void {
this.eventService.getEvent(id).subscribe(event => {
this.eventForm.patchValue(event);
this.setArrayValues('venues', event.venues);
this.setArrayValues('highlights', event.highlights);
this.setArrayValues('organisers', event.organisers);
this.setArrayValues('fees', event.fees);
});
}
setArrayValues(controlName: string, values: any[]): void {
const array = this.eventForm.get(controlName) as FormArray;
values.forEach(value => array.push(this.fb.group(value)));
}
get venues(): FormArray {
return this.eventForm.get('venues') as FormArray;
}
get highlights(): FormArray {
return this.eventForm.get('highlights') as FormArray;
}
get organisers(): FormArray {
return this.eventForm.get('organisers') as FormArray;
}
get fees(): FormArray {
return this.eventForm.get('fees') as FormArray;
}
addVenue() {
this.venues.push(this.fb.group({
title: [''],
date: [''],
address: [''],
info: ['']
}));
}
removeVenue(index: number) {
this.venues.removeAt(index);
}
addHighlight() {
this.highlights.push(this.fb.control(''));
}
removeHighlight(index: number) {
this.highlights.removeAt(index);
}
addOrganiser() {
this.organisers.push(this.fb.control(''));
}
removeOrganiser(index: number) {
this.organisers.removeAt(index);
}
addFee() {
this.fees.push(this.fb.group({
desc: [''],
cost: ['']
}));
}
removeFee(index: number) {
this.fees.removeAt(index);
}
onSubmit(): void {
if (this.eventForm.valid) {
if (this.eventId) {
this.eventService.updateEvent(this.eventId, this.eventForm.value).subscribe(() => this.router.navigate(['/events']));
} else {
this.eventService.createEvent(this.eventForm.value).subscribe(() => this.router.navigate(['/events']));
}
}
}
}

View File

@ -1,2 +1,47 @@
<app-menu></app-menu>
<div class="container mt-4">
<h2 class="mb-4">Events</h2>
<div class="mb-3">
<a routerLink="/eventForm" class="btn btn-primary">
<i class="bi bi-plus"></i> Add New Event
</a>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>Code</th>
<th>Year</th>
<th>Subject</th>
<th>Title</th>
<th>Subtitle</th>
<th>Date</th>
<th>Phone</th>
<th>Email</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let event of events">
<td>{{ event.code }}</td>
<td>{{ event.year }}</td>
<td>{{ event.subject }}</td>
<td>{{ event.title }}</td>
<td>{{ event.subTitle }}</td>
<td>{{ event.date }}</td>
<td>{{ event.phone }}</td>
<td>{{ event.email }}</td>
<td>{{ event.isActive ? 'Yes' : 'No' }}</td>
<td>
<a [routerLink]="['/eventForm', event.id]" class="btn btn-warning btn-sm">
<i class="bi bi-pencil"></i> Edit
</a>
<button (click)="deleteEvent(event.id)" class="btn btn-danger btn-sm">
<i class="bi bi-trash"></i> Delete
</button>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, FormArray, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { EventService } from 'src/app/service/event.service';
@Component({
selector: 'app-event',
@ -6,13 +9,21 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./event.component.css']
})
export class EventComponent implements OnInit {
events: any[] = []; // Define the type according to your model
constructor() { }
htmlContent: string = '';
constructor(private eventService: EventService, private router: Router) { }
ngOnInit(): void {
this.loadEvents();
}
}
loadEvents(): void {
this.eventService.getEvents().subscribe(events => this.events = events);
}
deleteEvent(id: number): void {
if (confirm('Are you sure you want to delete this event?')) {
// this.eventService.deleteEvent(id).subscribe(() => this.loadEvents());
}
}
}

View File

@ -28,7 +28,7 @@ export class LoginComponent implements OnInit, OnDestroy {
ngOnInit(): void {
if (this.authenticationService.isUserLoggedIn()) {
this.router.navigate(["/user", "management"]);
this.router.navigate(["/dashboard", "userManagement"]);
// this.router.navigate(["/management", "users"]);
this.notificationService.notify(NotificationType.INFO, "You are already logged in");
}
@ -46,8 +46,7 @@ export class LoginComponent implements OnInit, OnDestroy {
this.authenticationService.addUserToLocalStorage(response.body!);
this.router.navigateByUrl('/home');
// this.router.navigateByUrl('/management/users');
this.router.navigateByUrl('/dashboard/home');
this.showLoading = false;
},
(errorResponse: HttpErrorResponse) => {

View File

@ -77,7 +77,7 @@ export class ProfileComponent implements OnInit {
onLogOut() {
this.authenticationService.logout();
this.router.navigate(['/login']);
this.router.navigate(['/dashboard/login']);
this.notificationService.notify(NotificationType.SUCCESS, 'You have been successfully logged out');
}

View File

@ -22,5 +22,6 @@
</fieldset>
</form>
</div>
</div>

View File

@ -56,4 +56,5 @@ export class SettingsComponent implements OnInit, OnDestroy {
}
);
}
}

View File

@ -11,38 +11,38 @@
<nav class="navbar navbar-expand-md breadcrumb">
<div class="collapse navbar-collapse" id="navbarCollapse">
<div class="nav nav-pills">
<a class="nav-item nav-link ml-1" routerLink="/home" routerLinkActive="active" (click)="changeTitle('Home')">
<a class="nav-item nav-link ml-1" routerLink="/dashboard/home" routerLinkActive="active" (click)="changeTitle('Home')">
<i class="fa fa-home"></i>
Home
</a>
<a class="nav-item nav-link ml-1" routerLink="/user/management" routerLinkActive="active" (click)="changeTitle('Users')">
<a class="nav-item nav-link ml-1" routerLink="/dashboard/userManagement" routerLinkActive="active" (click)="changeTitle('Users')">
<i class="fa fa-users"></i>
Users
</a>
<a class="nav-item nav-link ml-1" routerLink="/professor/management" routerLinkActive="active" (click)="changeTitle('Professors')">
<a class="nav-item nav-link ml-1" routerLink="/dashboard/professorManagement" routerLinkActive="active" (click)="changeTitle('Professors')">
<i class="fa fa-chalkboard-teacher"></i>
Professors
</a>
<a class="nav-item nav-link ml-1" routerLink="/blogs" routerLinkActive="active" (click)="changeTitle('Professors')">
<a class="nav-item nav-link ml-1" routerLink="/dashboard/blogs" routerLinkActive="active" (click)="changeTitle('Professors')">
<i class="fa fa-chalkboard-teacher"></i>
Blogs
</a>
<a class="nav-item nav-link ml-1" routerLink="/events" routerLinkActive="active" (click)="changeTitle('Professors')">
<a class="nav-item nav-link ml-1" routerLink="/dashboard/events" routerLinkActive="active" (click)="changeTitle('Professors')">
<i class="fa fa-chalkboard-teacher"></i>
Events
</a>
<a class="nav-item nav-link ml-3" routerLink="/settings" routerLinkActive="active" (click)="changeTitle('Settings')">
<a class="nav-item nav-link ml-3" routerLink="/dashboard/settings" routerLinkActive="active" (click)="changeTitle('Settings')">
<i class="fa fa-cogs"></i>
Settings
</a>
<a class="nav-item nav-link move-right mr-3" routerLink="/profile" routerLinkActive="active" (click)="changeTitle('Profile')">
<a class="nav-item nav-link move-right mr-3" routerLink="/dashboard/profile" routerLinkActive="active" (click)="changeTitle('Profile')">
Welcome, {{ loggedInUser.firstName }} {{ loggedInUser.lastName }}
<i class="fa fa-user"></i>
</a>
<a class="nav-item nav-link ml-1" (click)="logout()">
<!-- <a class="nav-item nav-link ml-1" (click)="logout()">
<i class="fa fa-sign-out-alt"></i>
Logout
</a>
</a> -->
</div>
</div>
</nav>

View File

@ -26,7 +26,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
ngOnInit(): void {
if (this.authenticationService.isUserLoggedIn()) {
this.router.navigateByUrl("/user/management");
this.router.navigateByUrl("/dashboard/userManagement");
this.notificationService.notify(NotificationType.INFO, "You are already logged in");
}
}
@ -39,7 +39,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
.subscribe(user => {
this.notificationService.notify(NotificationType.SUCCESS, `A new account was created for ${user.firstName}.
Please check your email for password to log in`);
this.router.navigateByUrl('/login');
this.router.navigateByUrl('/dashboard/login');
this.showLoading = false;
},
(errorResponse: HttpErrorResponse) => {

View File

@ -22,7 +22,7 @@
<i class="fa fa-users"></i>
Users
</a>
<a class="nav-item nav-link active ml-1" (click)="changeTitle('Professors')" [routerLink]="['/professor/management']" >
<a class="nav-item nav-link active ml-1" (click)="changeTitle('Professors')" [routerLink]="['/dashboard/professorManagement']" >
<i class="fa fa-users"></i>
Professors
</a>

View File

@ -236,7 +236,7 @@ export class UserComponent implements OnInit, OnDestroy {
onLogOut() {
this.authenticationService.logout();
this.router.navigate(['/login']);
this.router.navigate(['/dashboard/login']);
this.sendNotification(NotificationType.SUCCESS, 'You have been successfully logged out');
}