Skip to content

Commit

Permalink
Merge pull request #130 from Krishna-Baldwa/idf2
Browse files Browse the repository at this point in the history
Acad Discussion Forum
  • Loading branch information
Krishna-Baldwa authored Dec 10, 2023
2 parents fe8874e + e058eda commit 34f8129
Show file tree
Hide file tree
Showing 11 changed files with 3,284 additions and 15,576 deletions.
18,533 changes: 3,094 additions & 15,439 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const API = {

Communities: 'api/communities',
Community: 'api/communities/{uuid}',
CommunityAddPost: 'api/communityposts{?status}',
CommunityAddPost: 'api/communityposts{?status,community}',
CommunityPost: 'api/communityposts/{uuid}',
CommunityPostReaction: 'api/user-me/ucpr/{uuid}{?reaction}',
CommunityModeration: 'api/communityposts/moderator/{uuid}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@
</button>

<button
*ngIf="posted_by_current_user || (is_approval_moderator && is_rank_one) || (is_comment_moderator && !is_rank_one)"
*ngIf="(posted_by_current_user || (is_approval_moderator && is_rank_one) || (is_comment_moderator && !is_rank_one))
&& !post.deleted
"

(click)=onDeleteClicked() mat-menu-item>
<mat-icon>delete</mat-icon>
<span>{{ is_rank_one ? 'Delete Post' : 'Delete Comment' }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export class CommunityPostCardComponent implements OnInit {
dialogConfig.data = { community: this.post.community, post: this.post };
this.dialog.open(AddPostComponent, dialogConfig);
}

}
onDeleteClicked(): void {
if (this.posted_by_current_user || this.is_comment_moderator) {
Expand Down
6 changes: 4 additions & 2 deletions src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { Location } from '@angular/common';
import { Helpers } from './helpers';
import { Title } from '@angular/platform-browser';
import { WinRT } from './windows';
// import { setWithCredentials } from 'ol/featureloader';
// import { error } from 'console';
/** Headers for injection for quick use */
let JSON_HEADERS = new HttpHeaders();
JSON_HEADERS = JSON_HEADERS.set('Content-Type', 'application/json');
Expand Down Expand Up @@ -268,14 +270,14 @@ export class DataService {
/* Construct upload request */
const formData = new FormData();
formData.append('picture', image);
const uploadReq = new HttpRequest('POST', API.PostImage, formData);
const uploadReq = new HttpRequest('POST', HOST + API.PostImage, formData);

/* Make upload request and return */
return new Observable((observer) => {
this.http.request(uploadReq).subscribe(
(event) => {
if (event.type === HttpEventType.Response) {
observer.next(event.body);
observer.next(event.body['picture']);
observer.complete();
}
},
Expand Down
162 changes: 95 additions & 67 deletions src/app/layout/navmenu/navmenu.component.html
Original file line number Diff line number Diff line change
@@ -1,69 +1,97 @@
<div class="main-menu">
<div class="head-card primary-background-color" (click)="OpenMyProfile()">
<img class="profile-pic img-circle object-cover" [src]="profilePic" src-fallback="assets/useravatar.svg">
<div class="overflow-ellipsis">
{{ userName }}
<div id="ldap">{{ ldap }}</div>
</div>
<div class="head-card primary-background-color" (click)="OpenMyProfile()">
<img
class="profile-pic img-circle object-cover"
[src]="profilePic"
src-fallback="assets/useravatar.svg"
/>
<div class="overflow-ellipsis">
{{ userName }}
<div id="ldap">{{ ldap }}</div>
</div>

<a [routerLink]="['/feed']" routerLinkActive="active-link" mat-list-item>
<mat-icon>list</mat-icon> &nbsp; Feed
</a>

<a [routerLink]="['/news/']" routerLinkActive="active-link" mat-list-item>
<mat-icon>rss_feed</mat-icon> &nbsp; News
</a>

<a mat-list-item [routerLink]="['/explore/']" routerLinkActive="active-link">
<mat-icon>search</mat-icon> &nbsp; Explore
</a>

<a mat-list-item [routerLink]="['/mess/']" routerLinkActive="active-link">
<mat-icon>restaurant</mat-icon> &nbsp; Mess Menu
</a>

<a [routerLink]="['/blog/' + dataService.EncodeObject(api.PlacementBlog)]" routerLinkActive="active-link"
mat-list-item>
<mat-icon>work</mat-icon> &nbsp; Placement Blog
</a>

<a [routerLink]="['/blog/' + dataService.EncodeObject(api.TrainingBlog)]" routerLinkActive="active-link"
mat-list-item>
<mat-icon>work</mat-icon> &nbsp; Internship Blog
</a>

<a [routerLink]="['/blog/' + dataService.EncodeObject(api.external)]" routerLinkActive="active-link" mat-list-item>
<mat-icon>work</mat-icon> &nbsp; External Blog
</a>

<a [routerLink]="['/discussions']" routerLinkActive="active-link" mat-list-item>
<mat-icon>forum</mat-icon> &nbsp; Insight Discussion Forum
</a>

<a [routerLink]="['/query-search/']" routerLinkActive="active-link" mat-list-item>
<mat-icon>help</mat-icon> &nbsp; Find Answers
</a>


<a [routerLink]="['/calendar']" routerLinkActive="active-link" mat-list-item>
<mat-icon>event_available</mat-icon> &nbsp; Calendar
</a>

<a [routerLink]="['/map']" routerLinkActive="active-link" mat-list-item>
<mat-icon>map</mat-icon> &nbsp; Map
</a>

<a [routerLink]="['/achievements']" routerLinkActive="active-link" mat-list-item>
<mat-icon>done_all</mat-icon> &nbsp; Achievements
</a>

<a [routerLink]="['/quick-links']" routerLinkActive="active-link" mat-list-item>
<mat-icon>link</mat-icon> &nbsp; Quick Links
</a>

<a [routerLink]="['/settings']" routerLinkActive="active-link" mat-list-item>
<mat-icon>settings</mat-icon> &nbsp; Settings
</a>

</div>
</div>

<a [routerLink]="['/feed']" routerLinkActive="active-link" mat-list-item>
<mat-icon>list</mat-icon> &nbsp; Feed
</a>

<a [routerLink]="['/news/']" routerLinkActive="active-link" mat-list-item>
<mat-icon>rss_feed</mat-icon> &nbsp; News
</a>

<a mat-list-item [routerLink]="['/explore/']" routerLinkActive="active-link">
<mat-icon>search</mat-icon> &nbsp; Explore
</a>

<a mat-list-item [routerLink]="['/mess/']" routerLinkActive="active-link">
<mat-icon>restaurant</mat-icon> &nbsp; Mess Menu
</a>

<a
[routerLink]="['/blog/' + dataService.EncodeObject(api.PlacementBlog)]"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>work</mat-icon> &nbsp; Placement Blog
</a>

<a
[routerLink]="['/blog/' + dataService.EncodeObject(api.TrainingBlog)]"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>work</mat-icon> &nbsp; Internship Blog
</a>

<a
[routerLink]="['/blog/' + dataService.EncodeObject(api.external)]"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>work</mat-icon> &nbsp; External Blog
</a>

<a
[routerLink]="['/discussions']"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>forum</mat-icon> &nbsp; Communities
</a>

<a
[routerLink]="['/query-search/']"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>help</mat-icon> &nbsp; Find Answers
</a>

<a [routerLink]="['/calendar']" routerLinkActive="active-link" mat-list-item>
<mat-icon>event_available</mat-icon> &nbsp; Calendar
</a>

<a [routerLink]="['/map']" routerLinkActive="active-link" mat-list-item>
<mat-icon>map</mat-icon> &nbsp; Map
</a>

<a
[routerLink]="['/achievements']"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>done_all</mat-icon> &nbsp; Achievements
</a>

<a
[routerLink]="['/quick-links']"
routerLinkActive="active-link"
mat-list-item
>
<mat-icon>link</mat-icon> &nbsp; Quick Links
</a>

<a [routerLink]="['/settings']" routerLinkActive="active-link" mat-list-item>
<mat-icon>settings</mat-icon> &nbsp; Settings
</a>
</div>
19 changes: 8 additions & 11 deletions src/app/page/discussions/add-post/add-post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ export class AddPostComponent implements OnInit {
if (data.post) {
this.addpost = data.post;
this.images = this.addpost.image_url;
if (!this.images) { this.images = []; }
if (!this.images) {
this.images = [];
}
this.tagged = [...this.addpost.tag_body, ...this.addpost.tag_user];
this.tagged_bodies = this.addpost.tag_body;
this.tagged_users = this.addpost.tag_user;
this.tagged_interests = this.addpost.interests;
if (!this.tagged_interests) { this.tagged_interests = []; }
if (!this.tagged_interests) {
this.tagged_interests = [];
}
}
}

Expand Down Expand Up @@ -168,7 +172,6 @@ export class AddPostComponent implements OnInit {
}
}


removeTag(target_tag: any) {
const target_index = this.searchTagInTaggedI(target_tag);

Expand All @@ -179,7 +182,6 @@ export class AddPostComponent implements OnInit {
}

removeTagBodyUsers(target_tag: any) {

let target_index = this.searchInPool(this.tagged_bodies, target_tag);
if (target_index !== -1) {
this.tagged_bodies.splice(target_index, 1);
Expand All @@ -190,12 +192,10 @@ export class AddPostComponent implements OnInit {
this.tagged_users.splice(target_index, 1);
}


target_index = this.searchInPool(this.tagged, target_tag);
if (target_index !== -1) {
this.tagged.splice(target_index, 1);
}

}

searchInPool(pool: any, toSearch: any) {
Expand All @@ -209,9 +209,6 @@ export class AddPostComponent implements OnInit {
return target_index;
}




removeImage(target_image: string) {
const target_index = this.searchImageInImages(target_image);

Expand All @@ -232,7 +229,6 @@ export class AddPostComponent implements OnInit {
return target_index;
}
searchTagInTagged(tag: any): number {

let target_index = -1;
for (let i = 0; i < this.tagged.length; i++) {
if (tag.id === this.tagged[i].id && tag.type === this.tagged[i].type) {
Expand Down Expand Up @@ -276,10 +272,11 @@ export class AddPostComponent implements OnInit {

this.dataService.UploadImage(files[0]).subscribe(
(result) => {
this.images.push(result.picture);
this.images.push(result);
this.networkBusy = false;
},
(error) => {
console.log(this.networkBusy);
this.networkBusy = false;
this.snackBar.open(`Upload Failed - ${error.message}`, 'Dismiss', {
duration: 2000,
Expand Down
1 change: 0 additions & 1 deletion src/app/page/discussions/discussions.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<app-xunk-spinner *ngIf="!groups"></app-xunk-spinner>

<div class="main">
<app-desktop-split *ngIf="groups" center_width_percentage="62.5">
<div center>
Expand Down
3 changes: 2 additions & 1 deletion src/app/page/discussions/discussions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ export class DiscussionsComponent implements OnInit {
(result) => {
if (result.length > 0) {
// TODO: Remove this if more communities
this.router.navigate(['group-feed', result[0].str_id]);
// this.router.navigate(['group-feed', result[0].str_id]);
}

this.groups = result;
this.allgroups = result;
this.selected_group = this.groups[1];
},
(e) => {
this.error = e.status;
Expand Down
Loading

0 comments on commit 34f8129

Please sign in to comment.