Skip to content

Commit

Permalink
Merge pull request #9 from SDOS-Winter2021/feature-external-feed-akshyta
Browse files Browse the repository at this point in the history
flagging-posts and filtering for latest and popular posts
  • Loading branch information
akshyta authored May 5, 2021
2 parents e43d713 + 31bd651 commit f343bb7
Show file tree
Hide file tree
Showing 28 changed files with 407 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

.home-events-date {
position: absolute;
height: 56px;
width: 56px;
height: 58px;
width: 58px;
top: 120px;
right: 12px;
border-radius: $border-8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div>
<nb-select placeholder="Source*" fullWidth formControlName="source" status="primary" size="small" (selectedChange)="updateValidators()">

<nb-option *ngIf="[1, 74, 116, 118, 119, 121].includes(community.id)" [value]="EEmbeddedVideoStreamSources.COMMUDLE">
<nb-option *ngIf="[1, 74, 116, 118, 119, 121, 124].includes(community.id)" [value]="EEmbeddedVideoStreamSources.COMMUDLE">
<div>
Commudle Stage
<br/>
Expand All @@ -14,6 +14,9 @@
<br/>
</div>
</nb-option>
<nb-option [value]="EEmbeddedVideoStreamSources.ZOOM">
ZOOM (embedded into browser)
</nb-option>
<nb-option [value]="EEmbeddedVideoStreamSources.EXTERNAL_LINK">
External Link (to platforms like Google Meet)
</nb-option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h3>{{ event.name }}</h3>
type="text"
fullWidth
fieldSize="tiny"
placeholder="{{ isLoading ? 'Still Loading' : 'Filter by Name' }}"
placeholder="{{ isLoading ? 'Still Loading' : 'Search by name or email' }}"
formControlName="name"
[disabled]="isLoading"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
<nb-card class="tag-checkboxes">
<div class="header">Popular Tags</div>
<div class="tag-checkbox" *ngFor="let tag of tags">
<input
type="checkbox"
name="tags"
value="{{ tag }}"
id="#{{ tag }}"
[checked]="false"
(change)="updateCheckedTags(tag, $event)"
/>
<input type="checkbox" name="tags" value="{{ tag }}" id="#{{ tag }}" [checked]="false" (change)="updateCheckedTags(tag, $event)" />
<label for="#{{ tag }}"> #{{ tag }} </label>
<br />
<br />
Expand All @@ -28,36 +21,26 @@ <h1>
<p>Some links from around the world!</p>
</nb-card-body>
</nb-card>

<nb-card>
<div class="sorting d-flex justify-content-center">
<button (click)="getLatestPosts()">
<button (click)="getLatestPosts()" [ngClass]="{'white' : !toggleLatestButton, 'light-purple': toggleLatestButton}">
<nb-icon icon="sun" status="warning"></nb-icon>
Latest
</button>
<button (click)="getPopularPosts()">
<button (click)="getPopularPosts()" [ngClass]="{'white' : !togglePopularButton, 'light-purple': togglePopularButton}">
<nb-icon icon="flash" status="warning"></nb-icon>
Hot
</button>
<hr>
</div>
</nb-card>

<div class="external-feed-list">
<div *ngFor="let post of externalPosts">
<app-external-feed-hlist-item
[feedItem]="post"
></app-external-feed-hlist-item>
<app-external-feed-hlist-item [feedItem]="post"></app-external-feed-hlist-item>
</div>
</div>
<div class="load-more-button" *ngIf="canLoadMore && total">
<button
(click)="getFeedPosts()"
fullWidth
nbButton
status="primary"
size="small"
outline
>
<button (click)="getFeedPosts()" fullWidth nbButton status="primary" size="small" outline>
Load More!
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,22 @@
border: $border-1;
border-radius: $border-10;
box-shadow: none;

button {
margin: 10px;
background-color: white;
font-size: 16px;
border: none;
text-align: center;
width: 500px;
width: 100px;
}

.white {
background-color: white;
}

.light-purple {
background-color: $light-purple;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class ExternalFeedComponent implements OnInit {
tagsMap:any = {};
tagsChecked = [];
sortingCriterion = "published_at";
toggleLatestButton = false;
togglePopularButton = false;

constructor(
private feedItemService: FeedItemService,
Expand Down Expand Up @@ -48,6 +50,7 @@ export class ExternalFeedComponent implements OnInit {
}
});
}

updateCheckedTags(tag, event) {
this.page = 1
this.tagsMap[tag] = event.target.checked;
Expand Down Expand Up @@ -102,6 +105,10 @@ export class ExternalFeedComponent implements OnInit {
}

getLatestPosts() {
this.toggleLatestButton = true;
if (this.togglePopularButton) {
this.togglePopularButton = false;
}
this.sortingCriterion = "published_at";
this.page = 1;
this.externalPosts = [];
Expand All @@ -110,6 +117,10 @@ export class ExternalFeedComponent implements OnInit {
}

getPopularPosts() {
this.togglePopularButton = true;
if (this.toggleLatestButton) {
this.toggleLatestButton = false;
}
this.sortingCriterion = "likes";
this.page = 1;
this.externalPosts = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<nb-card>
<nb-card-body>
<div class="image" *ngIf="feedItem.details.image.length > 0">
<img
src="{{ feedItem.details.image }}"
alt="{{ feedItem.details.source }}"
/>
<img src="{{ feedItem.details.image }}" alt="{{ feedItem.details.source }}" />
</div>
<div class="source-details d-flex align-items-center">
<div class="source-info">
Expand All @@ -29,11 +26,7 @@ <h3 class="name">
</p>
<div class="stats d-flex align-items-center">
<p class="stars">
<app-votes-display
[votableType]="'FeedItem'"
[votableId]="feedItem.id"
[icon]="'heart'"
>
<app-votes-display [votableType]="'FeedItem'" [votableId]="feedItem.id" [icon]="'heart'">
</app-votes-display>
</p>
<p class="comments" [routerLink]="['/feed', feedItem.id]">
Expand All @@ -42,24 +35,14 @@ <h3 class="name">
</span>
<nb-icon icon="message-circle-outline"></nb-icon>
</p>
<!--<div (click)="sendFlag(feedItem.id)" class="clickable">
<p
[ngClass]="{ 'error-text': -1 > 0 }"
nbTooltip="Report this message. (3 reports will delete it)"
nbTooltipStatus="warning"
>
<span *ngIf="message.flags_count > 0">{{ feedItem.flags_count }}</span>
<span> 1 </span>
<nb-icon icon="flag"></nb-icon>
</p>
</div> -->
<p class="flags">
<app-flags-display [flaggableType]="'FeedItem'" [flaggableId]="feedItem.id">
</app-flags-display>
</p>
</div>
</nb-card-body>
</nb-card>
</div>
<div class="feed-discussion">
<app-feed-item-discussion
*ngIf="discussionChat"
[discussion]="discussionChat"
></app-feed-item-discussion>
<app-feed-item-discussion *ngIf="discussionChat" [discussion]="discussionChat"></app-feed-item-discussion>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@
}

.stats {
.clickable {

nb-icon {
color: $spanish-gray;
}
}
>p {

margin: 0 16px 0 0;
color: #8080808C;

&.comments {
nb-icon {
color: $spanish-gray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { IFeedItem } from "projects/shared-models/feed-item.model";
import { DiscussionsService } from "projects/commudle-admin/src/app/services/discussions.service";
import { IDiscussion } from "projects/shared-models/discussion.model";
import { DatePipe } from "@angular/common";
import {DiscussionChatChannel} from 'projects/shared-components/services/websockets/discussion-chat.channel';
import {ICurrentUser} from 'projects/shared-models/current_user.model';
import {LibAuthwatchService} from 'projects/shared-services/lib-authwatch.service';

@Component({
selector: "app-feed-item-details",
Expand All @@ -22,10 +25,13 @@ export class FeedItemDetailsComponent implements OnInit {
discussionChat: IDiscussion;

messagesCount: number;
currentUser: ICurrentUser;

constructor(
private discussionsService: DiscussionsService,
private datePipe: DatePipe
private datePipe: DatePipe,
private discussionChatChannel: DiscussionChatChannel,
private authWatchService: LibAuthwatchService,
) {}

ngOnInit() {
Expand All @@ -42,23 +48,4 @@ export class FeedItemDetailsComponent implements OnInit {
.subscribe((data) => (this.discussionChat = data));
}

// // @Output() sendFlag = new EventEmitter();
// }

// // emitFlag(itemId) {
// // console.log("Emitting flag for ");
// // console.log(itemId);
// // this.sendFlag.emit(itemId);
// // }

// sendFlag(itemId) {
// console.log("Emitting flag for ");
// console.log(itemId);
// // this.discussionChatChannel.sendData(
// // this.discussionChatChannel.ACTIONS.FLAG,
// // {
// // feed_item_id: itemId
// // }
// // );
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
gap: $space-16;
min-height: 100vh;
margin: $space-16 auto $space-32;
background-color: $light-purple;

.basic-details {
max-width: 264px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
position: relative;
margin-bottom: $space-40;

&:hover {
.navigation.active {
visibility: visible;
}
}

.header {
width: max-content;
margin: 0 0 $space-24;
Expand All @@ -24,6 +30,7 @@
}

.navigation {
visibility: hidden;
pointer-events: none;
display: flex;
justify-content: space-between;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IFeedItem } from "projects/shared-models/feed-item.model";
providedIn: "root",
})
export class FeedItemService {
private popular_tags_api = "http://15.207.110.193/feed/v2/popular-tags/";
private popular_tags_api = "https://feed.commudle.com/feed/v2/popular-tags/";

constructor(
private http: HttpClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="clickable flags size-{{size}}">
<p>
<span
*ngIf="totalFlags > 0"
class="count">
{{ totalFlags }}
</span>
<span (click)="toggleFlag()">
<nb-icon
[ngClass]="{'flagged': myFlag, 'unflag': !myFlag, 'has-flags': totalFlags > 0}"
class="hear"
icon="flag">
</nb-icon>
</span>
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.flags {
> p {
margin: 0;

.count {
color: grey;
}

nb-icon {
font-size: 1.2rem;
color: #8080808c;
}


nb-icon.flagged {
color: #ff1e1ed6;
}
}

&.size-large {
> p {
font-size: 1.8rem;

nb-icon {
font-size: 1.8rem;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { FlagsDisplayComponent } from './flags-display.component';

describe('FlagsDisplayComponent', () => {
let component: FlagsDisplayComponent;
let fixture: ComponentFixture<FlagsDisplayComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FlagsDisplayComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FlagsDisplayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit f343bb7

Please sign in to comment.