Skip to content

Commit

Permalink
Merge pull request #134 from amitmalakariitb/master
Browse files Browse the repository at this point in the history
Events with e-mail to users
  • Loading branch information
amitmalakariitb authored Aug 11, 2024
2 parents 3ef649c + 4235f18 commit b003e09
Show file tree
Hide file tree
Showing 16 changed files with 643 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"url": "10.198.49.150",
"webRoot": "${workspaceFolder}"
}
]
Expand Down
530 changes: 392 additions & 138 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@angular/cdk": "^9.0.0",
"@angular/common": "^10.0.7",
"@angular/compiler": "^10.0.7",
"@angular/core": "^10.0.7",
"@angular/core": "^10.2.5",
"@angular/forms": "^10.0.7",
"@angular/material": "^9.0.0",
"@angular/platform-browser": "^10.0.7",
Expand Down
2 changes: 1 addition & 1 deletion server_proxy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/api/**": {
"target": {
"host": "10.105.177.19",
"host": "10.198.49.150",
"protocol": "http:",
"port": 8080
},
Expand Down
3 changes: 3 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const API = {
Events: 'api/events',
EventsFiltered: 'api/events{?start,end}',
Event: 'api/events/{uuid}',
EventApproveMail: 'api/events/{uuid}/approve-mail',
EventRejectMail: 'api/events/{uuid}/reject-mail',
EventVerificationBodies: 'api/bodies-with-privilege/',

Bodies: 'api/bodies',
Body: 'api/bodies/{uuid}',
Expand Down
3 changes: 2 additions & 1 deletion src/app/comp/update-role/update-role.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ export class UpdateRoleComponent implements OnInit {
{ name: 'Add Event', code: 'AddE' },
{ name: 'Edit Event', code: 'UpdE' },
{ name: 'Delete Event', code: 'DelE' },
{ name: 'Verify Event', code: 'VerE' },
{ name: 'Update Body', code: 'UpdB' },
{ name: 'Modify Roles', code: 'Role' },
{ name: 'Verify Achievements', code: 'VerA' },
{ name: 'Moderate Post', code: 'AppP' },
{ name: 'Moderate Comment', code: 'ModC' },
];

constructor(public dataService: DataService, public snackBar: MatSnackBar) {}
constructor(public dataService: DataService, public snackBar: MatSnackBar) { }

ngOnInit() {
if (this.minrole.editing) {
Expand Down
42 changes: 39 additions & 3 deletions src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ export class DataService {
}
);
}
/** Gets the current user if logged in
* The result is cached
*/
/** Gets the current user if logged in
* The result is cached
*/
GetFillCurrentUser(): Observable<IUserProfile> {
return new Observable((observer) => {
if (!this._currentUser) {
Expand Down Expand Up @@ -542,6 +542,11 @@ export class DataService {
return bodies;
}

GetVerificationBodies(): Observable<IBody[]> {
return this.FireGET<IBody[]>(`${API.EventVerificationBodies}`);
}


/** Returns true if the user has the permission for institute */
HasInstitutePermission(permission: string): boolean {
if (!this.isLoggedIn()) {
Expand Down Expand Up @@ -590,6 +595,16 @@ export class DataService {
return true;
}

/** Return true if the current user can view the max content of the event and push email */
canViewMaxContent(): boolean {
for (const role of this._currentUser.roles) {
if (role.permissions.includes("VerE")) {
return true;
}
}

}

/** Mark a UNR for the current user */
MarkUNR(news: INewsEntry, reaction: number) {
return this.FireGET(API.NewsFeedReaction, {
Expand Down Expand Up @@ -744,4 +759,25 @@ export class DataService {
}
});
}

/**
* Approve email for a specific event
* @param eventId ID of the event
*/
approveEmail(eventId: string): Observable<any> {
const url = `${API.Events}/${eventId}/approve-mail`;
console.log('Constructed URL:', url);
return this.FirePOST(url, {});
}

/**
* Reject email for a specific event
* @param eventId ID of the event
*/
rejectEmail(eventId: string): Observable<any> {
const url = `${API.Events}/${eventId}/reject-mail`;

return this.FirePOST(url, {});
}

}
4 changes: 4 additions & 0 deletions src/app/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface IEvent {
str_id: string;
name: string;
description: string;
longdescription: string;
email_verified: boolean,
image_url: string;
website_url: string;
start_time: Date;
Expand All @@ -43,6 +45,8 @@ export interface IEvent {
venue_names: string[];
venues_str: string;
bodies: IBody[];
verification_bodies: IBody[];
verification_bodies_id: string[];
bodies_id: string[];
interested: IUserProfile[];
interested_count: number;
Expand Down
28 changes: 24 additions & 4 deletions src/app/page/add-event/add-event.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,26 @@
</mat-form-field>
</div>

<div>
<mat-form-field class="full-width-details">
<mat-select [(ngModel)]="event.verification_bodies_id" placeholder="Verification Bodies" multiple>
<mat-option *ngFor="let verification_body of verification_bodies" [value]="verification_body.id">
{{ verification_body.name }}
</mat-option>
<mat-option *ngFor="let body of disabledBodies" [value]="body.id" disabled>
{{ body.name }}
</mat-option>
</mat-select>
</mat-form-field>
</div>

<div class="full-width-details">
<app-search-box exploreProp="interests" displayProp="title" placeholder="Notify according to interests"
hint="Enter a Interest" (change)="setInterest($event)">
</app-search-box>
<app-search-box exploreProp="interests" displayProp="title" placeholder="Notify according to interests"
hint="Enter a Interest" (change)="setInterest($event)">
</app-search-box>

<app-interest-card *ngFor="let interest of event.event_interest" [interest]=interest [canDelete]=true [deleteMethod]="deleteInterestFunc">
<app-interest-card *ngFor="let interest of event.event_interest" [interest]=interest [canDelete]=true
[deleteMethod]="deleteInterestFunc">

</app-interest-card>

Expand All @@ -101,6 +115,12 @@
</mat-form-field>
</div>

<div>
<mat-form-field class="full-width-details">
<textarea matInput placeholder="Email Content" [(ngModel)]="event.longdescription" rows=8></textarea>
</mat-form-field>
</div>

<div class="audience-panel" *ngIf="tagCategoryList">
<div class="full-width-details">
<div class="label tag-category">
Expand Down
53 changes: 49 additions & 4 deletions src/app/page/add-event/add-event.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class AddEventComponent implements OnInit {
public networkBusy = false;

public bodies: IBody[] = [] as IBody[];
public verification_bodies: IBody[] = [] as IBody[];
public disabledBodies: IBody[] = [] as IBody[];

public editing = false;
Expand Down Expand Up @@ -69,7 +70,7 @@ export class AddEventComponent implements OnInit {
public router: Router,
public activatedRoute: ActivatedRoute,
public snackBar: MatSnackBar
) {}
) { }

/** Filter venues with name */
filterVenues(name: string): ILocation[] {
Expand Down Expand Up @@ -117,6 +118,16 @@ export class AddEventComponent implements OnInit {
);
this.sortBodies();

this.dataService.GetVerificationBodies().subscribe(
(bodies: IBody[]) => {
this.verification_bodies = this.verification_bodies.concat(bodies);
},
(error) => {
console.error('Error fetching verification bodies:', error);
})

this.sortBodies();

this.activatedRoute.params.subscribe((params: Params) => {
this.eventId = params['id'];
this.refresh();
Expand Down Expand Up @@ -175,6 +186,7 @@ export class AddEventComponent implements OnInit {
/* Initialize things */
this.initializeEvent();
this.initializeBodiesExisting();
this.initializeVerificationBodiesExisting();
this.sortBodies();
this.updateReach();

Expand Down Expand Up @@ -250,11 +262,31 @@ export class AddEventComponent implements OnInit {
}
}

initializeVerificationBodiesExisting() {
for (const verification_body of this.event.verification_bodies) {
/* Remove if already present */
const currIndex = this.verification_bodies.map((m) => m.id).indexOf(verification_body.id);
if (currIndex !== -1) {
this.bodies.splice(currIndex, 1);
}

/* Add according to privilege */
if (this.dataService.HasBodyPermission(verification_body.id, 'VerE')) {
this.bodies.push(verification_body);
} else {
this.disabledBodies.push(verification_body);
}
}
}


/* Initialize a blank event */
initializeBlank() {
this.event = {} as IEvent;
this.event.notify = true;
this.event.bodies_id = [];
this.event.interests_id = [];
this.event.verification_bodies_id = [];
this.event.venues = [] as ILocation[];
this.event.user_tags = [];
this.AddVenue();
Expand All @@ -265,9 +297,13 @@ export class AddEventComponent implements OnInit {
/** Initializes defaults from query parameters */
initializeQueryDefaults() {
const params = this.activatedRoute.snapshot.queryParams;
console.log("hi", params.hasOwnProperty('body'))
if (params.hasOwnProperty('body')) {
this.event.bodies_id.push(params['body']);
}
if (params.hasOwnProperty('verification_bodies')) {
this.event.verification_bodies_id = params['verification_bodies'];
}
if (params.hasOwnProperty('date')) {
const date = new Date(params['date']);
this.event.start_time = date;
Expand Down Expand Up @@ -348,12 +384,21 @@ export class AddEventComponent implements OnInit {
return;
}

if (
this.assertValidation(
this.event.verification_bodies_id.length > 0,
'No verification bodies selected!'
)
) {
return;
}

/* Validate name length */
if (
this.assertValidation(
this.event.name &&
this.event.name.length > 0 &&
this.event.name.length <= 50,
this.event.name.length > 0 &&
this.event.name.length <= 50,
'Event name too long/short'
)
) {
Expand All @@ -370,6 +415,7 @@ export class AddEventComponent implements OnInit {
return;
}


/* Create observable for POST/PUT */
let obs: Observable<IEvent>;
if (!this.editing) {
Expand All @@ -394,7 +440,6 @@ export class AddEventComponent implements OnInit {
} else {
this.close(result);
}

/* Set editing to true */
this.event.id = result.id;
this.event.str_id = result.id;
Expand Down
42 changes: 38 additions & 4 deletions src/app/page/event-details/event-details.component.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.event-image {
width:100%;
height:auto;
width: 100%;
height: auto;
}

.card-header {
Expand All @@ -21,7 +21,7 @@
}

.u-actions {
text-align:center;
text-align: center;
margin-top: 5px;
}

Expand All @@ -45,6 +45,12 @@
word-wrap: break-word;
}

.longdescription {
padding-left: 10px;
padding-right: 10px;
word-wrap: break-word;
}

.event-body {
max-width: 500px;
margin: 0 auto;
Expand Down Expand Up @@ -88,6 +94,34 @@
color: black;
}

.verify-email-popup {
position: fixed;
top: 50%;
left: 60%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
z-index: 100000;
transition: background-color 0.3s;
}

.verify-email-popup button {
margin-top: 10px;
margin-left: 10px;
padding: 10px;
cursor: pointer;
background-color: white;
border: 1px solid #3498db;
color: #3498db;
transition: background-color 0.3s, color 0.3s;

&:hover {
background-color: #3498db;
color: white;
}
}

span.badge {
font-size: 0.8em;
}
Expand Down Expand Up @@ -125,4 +159,4 @@ span.badge {
.section {
margin-left: 10px;
}
}
}
Loading

0 comments on commit b003e09

Please sign in to comment.