Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complaints suggestions #49

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
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
11 changes: 10 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,14 @@ export const API = {
WebPushSubscribe: 'api/user-me/subscribe-wp',

UserTags: 'api/user-tags',
UserTagsReach: 'api/user-tags/reach'
UserTagsReach: 'api/user-tags/reach',

Complaints: 'api/venter/complaints',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyComplaints: 'api/venter/complaints?filter=me',
Complaint: 'api/venter/complaints/{complaintId}',
UpVote: 'api/venter/complaints/{complaintId}/upvote{?action}',
CommentPost: 'api/venter/complaints/{complaintId}/comments',
CommentEdit: 'api/venter/comments/{commentId}',
TagCategories: 'api/venter/tags',
SubscribeToComplaint: 'api/venter/complaints/{complaintId}/subscribe{?action}'
};
23 changes: 21 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ import { RedirComponent } from './redir/redir.component';
import { UpdateRoleComponent } from './update-role/update-role.component';
import { CardComponent } from './card/card.component';

import { ComplaintsHomeComponent } from './venter/complaints/complaints-home.component';
import { FileComplaintComponent } from './venter/file/file-complaint.component';
import { DetailedComplaintComponent } from './venter/complaint/detailed-complaint.component';
import { EditCommentComponent } from './venter/edit-comment/edit-comment.component';
import { VenterDataService } from './venter/venter-data.service';
import { ComplaintCardComponent } from './venter/complaint-card/complaint-card.component';

@NgModule({
declarations: [
AppComponent,
Expand Down Expand Up @@ -91,7 +98,12 @@ import { CardComponent } from './card/card.component';
NotifyCardComponent,
RedirComponent,
UpdateRoleComponent,
CardComponent
CardComponent,
ComplaintsHomeComponent,
FileComplaintComponent,
DetailedComplaintComponent,
EditCommentComponent,
ComplaintCardComponent,
],
imports: [
BrowserModule,
Expand Down Expand Up @@ -131,6 +143,11 @@ import { CardComponent } from './card/card.component';

{ path: 'blog/:blog', component: BlogComponent, data: { state: 'base' }, canActivate: [LoginActivate] },
{ path: 'login', component: LoginComponent, data: { state: 'base' } },

{ path: 'venter/complaints', component: ComplaintsHomeComponent, data: { state: 'base' }, canActivate: [LoginActivate] },
{ path: 'venter/file', component: FileComplaintComponent, data: { state: 'base' }, canActivate: [LoginActivate] },
{ path: 'venter/complaint/:id', component: DetailedComplaintComponent, data: { state: 'base' }, canActivate: [LoginActivate] },

{ path: 'feedback', component: RedirComponent, data: { state: 'base' } },
{ path: 'android', component: RedirComponent, data: { state: 'base' } },
{ path: '**', redirectTo: 'feed' },
Expand All @@ -141,10 +158,12 @@ import { CardComponent } from './card/card.component';
LayoutModule,
],
entryComponents: [
NotifyCardComponent
NotifyCardComponent,
EditCommentComponent
],
providers: [
DataService,
VenterDataService,
{ provide: RouteReuseStrategy, useClass: CustomReuseStrategy },
LoginActivate,
],
Expand Down
46 changes: 46 additions & 0 deletions src/app/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,52 @@ export interface IUserTagCategory {
tags: IUserTag[];
}

export interface IComplaintTag {
id: string;
tag_uri: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

export interface IComplaintComment {
id: string;
time: string;
text: string;
commented_by: IUserProfile;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported_date: string;
}

export interface IComplaint {
id: string;
created_by: IUserProfile;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description: string;
suggestions: string;
location_details: string;
report_date: string;
reported_date: string;
status: string;
status_color: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latitude: number;
longitude: number;
location_description: string;
tags: IComplaintTag;
users_up_voted: IUserProfile[];
images: string[];
comments: IComplaintComment[];
vote_count: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_subscribed: number;
upvoted: boolean;
}

export interface IComplaintPost {
description: string;
suggestions: string;
location_details: string;
latitude: number;
longitude: number;
location_description: string;
tags: string[];
images: string[];
}

export interface IInstituteRole {
id: string;
name: string;
Expand Down
16 changes: 14 additions & 2 deletions src/app/material-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { MatExpansionModule } from '@angular/material/expansion';
import { MatBadgeModule } from '@angular/material/badge';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatRippleModule } from '@angular/material/core';
import { MatTabsModule } from '@angular/material/tabs';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatDividerModule } from '@angular/material/divider';
import { MatDialogModule } from '@angular/material/dialog';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';

import { ReactiveFormsModule } from '@angular/forms';
Expand Down Expand Up @@ -46,7 +50,11 @@ import { MatNativeDateModule } from '@angular/material/core';
MatExpansionModule,
MatBadgeModule,
MatSidenavModule,
MatProgressSpinnerModule,
MatTabsModule,
MatFormFieldModule,
MatDividerModule,
MatDialogModule,
MatProgressSpinnerModule
],
exports: [
ReactiveFormsModule,
Expand All @@ -70,7 +78,11 @@ import { MatNativeDateModule } from '@angular/material/core';
MatExpansionModule,
MatBadgeModule,
MatSidenavModule,
MatProgressSpinnerModule,
MatTabsModule,
MatFormFieldModule,
MatDividerModule,
MatDialogModule,
MatProgressSpinnerModule
],
})
export class MyMaterialClass { }
6 changes: 6 additions & 0 deletions src/app/navmenu/navmenu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<mat-icon>map</mat-icon> &nbsp; Map
</a>

<a [routerLink]="['/venter/complaints']"
routerLinkActive="active-link"
mat-list-item>
<mat-icon>announcement</mat-icon> &nbsp; Complaints/ Suggestions
</a>

<a [routerLink]="['/quick-links']"
routerLinkActive="active-link"
mat-list-item>
Expand Down
48 changes: 48 additions & 0 deletions src/app/venter/complaint-card/complaint-card.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.complaint-card {
text-decoration: none;
}

.complaint-divider {
padding: 1%;
}

.complaint-card-content {
font-size: medium;
padding-top: 3%;
}

.complaint-description {
white-space: pre-wrap;
}

.complaint-location-details {
padding-top: 2%;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

.card {
margin: 5%;
width: 80%;
}

.footer {
position: relative;
text-align: center;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

.footer-button-container {
display: inline;
}

.complaint-upvote-active {
color: #536dfe;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

.status {
float: right;
background-color: red;
border-width: medium;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color: white;
padding: 0 2.5%;
font-weight: bold;
text-transform: uppercase;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
73 changes: 73 additions & 0 deletions src/app/venter/complaint-card/complaint-card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<div class="complaint-card">
<mat-card class="card" [routerLink]="['/venter/complaint', complaint.id]">
<div class="status" [style.backgroundColor]="complaint.status_color">
{{ complaint.status }}
</div>
<mat-card-header>
<img mat-card-avatar src="{{complaint.created_by.profile_pic}}"
src-fallback="assets/add_image_placeholder.svg">
<mat-card-title>{{ complaint.created_by.name }}</mat-card-title>
<mat-card-subtitle>
<div>{{ complaint.reported_date }}</div>
<div>{{ complaint.location_description }}</div>
</mat-card-subtitle>
</mat-card-header>
<span class="complaint-divider">
<mat-divider></mat-divider>
</span>
<mat-card-content>
<div>
<div>
<div class="complaint-card-content"><b>Complaint:</b></div>
<pre><div class="complaint-description">{{ complaint.description }}</div></pre>
</div>
<div *ngIf="complaint.suggestions">
<div class="complaint-card-content"><b>Suggestions:</b></div>
<div>{{ complaint.suggestions }}</div>
</div>
<div *ngIf="complaint.location_details">
<div class="complaint-card-content"><b>Location Details:</b></div>
<div class="complaint-location-details">{{ complaint.location_details }}</div>
</div>
</div>
</mat-card-content>
<div class="complaint-divider">
<mat-divider></mat-divider>
</div>
<mat-card-footer>
<div class="footer">
<div class="footer-button-container">
<div *ngIf="complaint.upvoted" class="complaint-upvote-active, footer-button-container">
<button (click)="[upVoteComplaint(complaint.upvoted, complaint.id), onClickEvent($event)]"
class="complaint-upvote-active" mat-icon-button>
<mat-icon>arrow_upward</mat-icon>{{ complaint.users_up_voted.length }}
</button>
</div>
<div *ngIf="!complaint.upvoted" class="footer-button-container">
<button (click)="[upVoteComplaint(complaint.upvoted, complaint.id), onClickEvent($event)]"
mat-icon-button>
<mat-icon>arrow_upward</mat-icon>{{ complaint.users_up_voted.length }}
</button>
</div>
</div>
<button mat-icon-button class="footer-button-container">
<mat-icon>insert_comment</mat-icon>{{ complaint.comments.length }}
</button>
<div class="footer-button-container">
<div *ngIf="complaint.is_subscribed" class="footer-button-container">
<button (click)="[subscribeToComplaint(complaint.complaint_subscribed), onClickEvent($event)]"
mat-icon-button>
<mat-icon>notifications_active</mat-icon>
</button>
</div>
<div *ngIf="!complaint.is_subscribed" class="footer-button-container">
<button (click)="[subscribeToComplaint(complaint.complaint_subscribed), onClickEvent($event)]"
mat-icon-button>
<mat-icon>notifications</mat-icon>
</button>
</div>
</div>
</div>
</mat-card-footer>
</mat-card>
</div>
44 changes: 44 additions & 0 deletions src/app/venter/complaint-card/complaint-card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component, OnInit, Input } from '@angular/core';
import { IComplaint } from '../../interfaces';
import { DataService } from '../../data.service';
import { API } from '../../../api';
import { VenterDataService } from '../venter-data.service';

@Component({
selector: 'app-complaint-card',
templateUrl: './complaint-card.component.html',
styleUrls: ['./complaint-card.component.css']
})
export class ComplaintCardComponent implements OnInit {

@Input() complaint: IComplaint;
constructor(
public dataService: DataService,
public venterDataService: VenterDataService,
) { }

ngOnInit() {
}

refresh() {
/* Get complaint from server*/
this.dataService.FireGET<IComplaint>(API.Complaint, { complaintId: this.complaint.id }).subscribe(result => {
this.complaint = result;
this.venterDataService.getDetailedComplaintInfo(this.complaint);
});
}

onClickEvent(event) {
event.stopPropagation();
}

subscribeToComplaint(complaint_subscribed: number, complaintId: string) {
this.venterDataService.subscribeToComplaint(complaint_subscribed, complaintId);
this.refresh();
}

upVoteComplaint(has_upvoted: boolean, complaintId: string) {
this.venterDataService.upVoteComplaint(has_upvoted, complaintId);
this.refresh();
}
}
Loading