Skip to content

Commit

Permalink
Updating angular. Fixing some styling. Fixes #201.
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Sep 17, 2018
1 parent e30ac38 commit fa0a150
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 174 deletions.
28 changes: 14 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# FlowChat

[Recently fixed issues](https://github.com/tchoulihan/flowchat/issues?q=is%3Aissue+is%3Aclosed)
[Recently fixed issues](https://github.com/dessalines/flowchat/issues?q=is%3Aissue+is%3Aclosed)

# [Release 0.4.0](https://github.com/tchoulihan/flowchat/milestone/3)
- Communities! [#27](https://github.com/tchoulihan/flowchat/issues/27)
- User pages [#29](https://github.com/tchoulihan/flowchat/issues/29)
# [Release 0.4.0](https://github.com/dessalines/flowchat/milestone/3)
- Communities! [#27](https://github.com/dessalines/flowchat/issues/27)
- User pages [#29](https://github.com/dessalines/flowchat/issues/29)
- Community and user modlog pages.
- Loading indicators. [#44](https://github.com/tchoulihan/flowchat/issues/44)
- Loading indicators. [#44](https://github.com/dessalines/flowchat/issues/44)

# Release 0.3.0
- Custom discussion sorting. [#9](https://github.com/tchoulihan/flowchat/issues/9).
- Added emoji support. [#8](https://github.com/tchoulihan/flowchat/issues/8).
- Added embedded videos. [#7](https://github.com/tchoulihan/flowchat/issues/7).
- Fixed non-image type links from being in a discussion component. [#14](https://github.com/tchoulihan/flowchat/issues/14).
- Figured out sub-comment bug. [#11](https://github.com/tchoulihan/flowchat/issues/11).
- Figured out markdown-refresh bug. [#10](https://github.com/tchoulihan/flowchat/issues/10).
- Custom discussion sorting. [#9](https://github.com/dessalines/flowchat/issues/9).
- Added emoji support. [#8](https://github.com/dessalines/flowchat/issues/8).
- Added embedded videos. [#7](https://github.com/dessalines/flowchat/issues/7).
- Fixed non-image type links from being in a discussion component. [#14](https://github.com/dessalines/flowchat/issues/14).
- Figured out sub-comment bug. [#11](https://github.com/dessalines/flowchat/issues/11).
- Figured out markdown-refresh bug. [#10](https://github.com/dessalines/flowchat/issues/10).

# Release 0.2.0
- Fixing tab Refetching.[1](https://github.com/tchoulihan/flowchat/commit/96558421bef042c167acaa709d6e36cd30701b3c)
- Using angular rc4.[1](https://github.com/tchoulihan/flowchat/commit/bc7f6379691659fe8da20c01eb3c947ffe19d98b)
- When you log back in, repull your favorite discussions.[1](https://github.com/tchoulihan/flowchat/commit/fca846fe2ce6861d0c31da65ea9445241470cd3e)
- Fixing tab Refetching.[1](https://github.com/dessalines/flowchat/commit/96558421bef042c167acaa709d6e36cd30701b3c)
- Using angular rc4.[1](https://github.com/dessalines/flowchat/commit/bc7f6379691659fe8da20c01eb3c947ffe19d98b)
- When you log back in, repull your favorite discussions.[1](https://github.com/dessalines/flowchat/commit/fca846fe2ce6861d0c31da65ea9445241470cd3e)


# Finished
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@
Hey /r/blank, leftist programmer here. I've made a reddit alternative called Flowchat, featuring communities, and live updating threaded conversations. Self-hostable, open-source, explicitly anti-racist.
Description from the [github](https://github.com/dessalines/flowchat)
Description from the [github](https://github.com/dessalines/flowchat):
> [FlowChat](http://flow-chat.com) is an open-source, self-hostable reddit alternative. It has communities, hashtags, **live-updating** threaded conversations, and voting.
> Flowchat tries to solve the problem of having a fluid, free-feeling group chat, while allowing for side conversations so that every comment isn't at the top level, and doesn't disrupt the flow.
> Multiple conversations can take place **at once**, without interrupting the flow of the chatroom.
> Check out the default community, [vanilla](http://flow-chat.com/#/community/1), or create your own.
> It features:
- Private or public discussions and communities.
- Sorting by recentness, hotness, or popularity.
- Antiracist policies including a global slur filter (No racism will be allowed on the main Flowchat instance).
- Image and video focused, with auto-zoom.
- Moderation including blocking users, appointing moderators, or deleting comments.
- NSFW filtering.
- Stickied posts.
- Hashtags.
I'd also like to invite the moderators of this sub to take over the equivalent leftist community on it. Message my reddit user if your community's already been created and I'll gladly do this.
-->
Expand Down
2 changes: 1 addition & 1 deletion service/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.tchoulihan</groupId>
<groupId>com.github.dessalines</groupId>
<artifactId>flowchat</artifactId>
<version>0.4.0</version>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion service/src/main/java/com/chat/db/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public static User signup(Long loggedInUserId, String userName, String password,
UserSetting.createIt("user_id", user.getLongId());
return createUserObj(user, true);

} else if (loggedInUserId == uv.getId()) {
} else if (loggedInUserId.equals(uv.getLongId())) {

String encryptedPassword = Tools.PASS_ENCRYPT.encryptPassword(password);
uv.set("password_encrypted", encryptedPassword, "email", email).saveIt();
Expand Down
22 changes: 11 additions & 11 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^6.0.1",
"@angular/common": "^6.0.1",
"@angular/compiler": "^6.0.1",
"@angular/core": "^6.0.1",
"@angular/forms": "^6.0.1",
"@angular/http": "^6.0.1",
"@angular/platform-browser": "^6.0.1",
"@angular/platform-browser-dynamic": "^6.0.1",
"@angular/router": "^6.0.1",
"@angular/animations": "^6.1.7",
"@angular/common": "^6.1.7",
"@angular/compiler": "^6.1.7",
"@angular/core": "^6.1.7",
"@angular/forms": "^6.1.7",
"@angular/http": "^6.1.7",
"@angular/platform-browser": "^6.1.7",
"@angular/platform-browser-dynamic": "^6.1.7",
"@angular/router": "^6.1.7",
"@auth0/angular-jwt": "^2.0.0",
"angular2-toaster": "^4.0.1",
"autosize": "^3.0.15",
Expand All @@ -44,8 +44,8 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.1",
"@angular/cli": "^6.0.7",
"@angular/compiler-cli": "^6.0.1",
"@angular/cli": "^6.2.2",
"@angular/compiler-cli": "^6.1.7",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@
<div *ngIf="!discussion.deleted">
<div *ngIf="!editing">
<div class="row">
<div class="px-1 col-xs-2 text-center vote-width" [ngClass]="{'col-sm-2': isCard(),
'col-sm-1': !isCard()}">
<div class="px-1 col-sm-1 col-1 text-center vote-width">
<ng-template #voteTemplate>
<div [innerHtml]="voteHtml()"></div>
</ng-template>
<div class="fa fa-fw fa-arrow-up vote-thumb" [class.pointer]="!this.isCreator"[class.text-success]="discussion.userRank > 50" (click)="upvote()"></div>
<div class="pointer vote-number" placement="bottom" placement="right" [tooltip]="voteTemplate" container="body" (click)="toggleShowVoteSlider()">{{avgVote()}}</div>
<div class="fa fa-fw fa-arrow-down vote-thumb" [class.pointer]="!this.isCreator" [class.text-danger]="voteExists() && discussion.userRank < 50" (click)="downvote()"></div>
<div class="fa fa-fw fa-arrow-up vote-thumb" [class.pointer]="!this.isCreator"[class.text-success]="discussion.userRank > 50" (click)="upvote()" placement="right" [tooltip]="voteTemplate" container="body"></div>
<div class="pointer vote-number" placement="bottom" placement="right" [class.pointer]="!this.isCreator" [tooltip]="voteTemplate" container="body" (click)="toggleShowVoteSlider()">{{avgVote()}}</div>
<div class="fa fa-fw fa-arrow-down vote-thumb" [class.pointer]="!this.isCreator" [class.text-danger]="voteExists() && discussion.userRank < 50" (click)="downvote()" placement="right" [tooltip]="voteTemplate" container="body"></div>
</div>
<div *ngIf="!isCard() && hasImage()" class="col-xs-2 col-sm-2">
<div *ngIf="hasImage()" [ngClass]="{'col-sm-1 col-11': !isCard(),
'col-sm-11': isCard()}">
<div [innerHTML]="discussion.link | markdown:true"></div>
</div>
<div [ngClass]="{'col-xs-8 col-sm-9': hasImage() && !isCard(),
'col-xs-10 col-sm-10': isCard() ,
'col-xs-10 col-sm-11': !hasImage() && !isCard()}">
<div [ngClass]="{'col-sm-10': hasImage() && !isCard(),
'col-sm-12': isCard() ,
'col-sm-11': !hasImage() && !isCard()}">
<div [ngClass]="{
'card-body-no-bottom': isCard()}">
<h5 [class.card-title]="isCard()" class="card-body-no-bottom">
<a [routerLink]="['/discussion', discussion.id]" class="link-unstyled">{{discussion.title}} </a>
</h5>
</div>
<div *ngIf="isCard() && hasImage()">
<div [innerHTML]="discussion.link | markdown:true"></div>
</div>

<div [ngClass]="{
'card-body-no-top': isCard()}">
<p *ngIf="discussion.text" class="card-text" [innerHTML]="discussion.text | markdown"></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class DiscussionCardComponent implements OnInit {
private showVoteSlider: boolean = false;

@Input() editing: boolean = false;
@Input() card: boolean = false;
@Output() editingChange = new EventEmitter();

private isCreator: boolean = false;
Expand Down Expand Up @@ -324,7 +325,7 @@ export class DiscussionCardComponent implements OnInit {
}

isCard(): boolean {
return this.userService.getUserSettings().defaultViewTypeRadioValue === 'card';
return this.card;
}

hasImage(): boolean {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/components/discussion/discussion.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row bottom-margin" (window:scroll)="onScroll($event)">
<div *ngIf="discussion" class="col-xs-12 col-lg-10">
<app-discussion-card [discussion]="discussion" [editing]="editing" (editingChange)="editingChanged($event)"></app-discussion-card>
<app-discussion-card [discussion]="discussion" [card]="true" [editing]="editing" (editingChange)="editingChanged($event)"></app-discussion-card>
<div *ngIf="!editing" class="my-2">
<div *ngFor="let comment of comments" class="mb-1">
<app-comment [comment]="comment" [discussion]="discussion" (replyingEvent)="setIsReplying($event)"></app-comment>
Expand Down Expand Up @@ -31,8 +31,8 @@ <h4 *ngIf="comments?.length == 0">Comment on the bottom bar...</h4>
</div>
<nav *ngIf="!topParentId && !clearTopReply && !isReplying && !discussion?.deleted && !editing" class="navbar fixed-bottom navbar-dark bg-dark">
<div class="row col-sm-12">
<app-markdown-edit class="col-sm-10 col-md-11" (textEvent)="setTopReply($event)" [rows]="1"></app-markdown-edit>
<button (click)="sendTopReply()" class="btn btn-outline-primary col-sm-2 col-md-1 special-nav-button" type="submit">Send</button>
<app-markdown-edit class="col-10 col-md-11" (textEvent)="setTopReply($event)" [rows]="1"></app-markdown-edit>
<button (click)="sendTopReply()" class="btn btn-sm btn-outline-primary col-2 col-md-1 special-nav-button" type="submit">Send</button>
</div>
</nav>
<div bsModal #reconnectModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
Expand Down
6 changes: 1 addition & 5 deletions ui/src/app/components/discussion/discussion.component.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.special-nav-button {
height: 39px;
}

@media (min-width: 576px) {
.special-nav-button {
margin-top: 28px;
margin-top: 39px;
}
}

Expand Down
13 changes: 2 additions & 11 deletions ui/src/app/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
<i class="fa fa-fw fa-comment-o"></i>&nbsp;FlowChat</a>
<div [class.collapse]="collapseNavbar" class="collapse navbar-collapse">
<ul class="navbar-nav">

<form [formGroup]="discussionSearchForm" class="form-inline">
<input formControlName="discussionSearchControl" [(ngModel)]="discussionSearchSelected" [typeahead]="discussionSearchResultsObservable"
(typeaheadOnSelect)="discussionTypeaheadOnSelect($event.item)" [typeaheadOptionField]="'title'" (typeaheadLoading)="discussionChangeTypeaheadLoading($event)"
(typeaheadNoResults)="discussionChangeTypeaheadNoResults($event)" [typeaheadWaitMs]="200" class="form-control mr-sm-2 search-box"
(typeaheadNoResults)="discussionChangeTypeaheadNoResults($event)" [typeaheadWaitMs]="200" class="form-control mr-sm-2"
type="text" placeholder="Search" name="discussion_form" autocomplete="off">
<button class="btn btn-outline-primary my-2 my-sm-0" type="submit">
<i class="fa fa-search"></i>
</button>
</form>
</ul>
<ul class="navbar-nav ml-2 mr-auto">
Expand All @@ -26,18 +22,13 @@
<button role="button" class="btn btn-outline-primary mr-2" (click)="createCommunity()">Create a community</button>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/tchoulihan/flowchat" target="_blank">about</a>
<a class="nav-link" href="https://github.com/dessalines/flowchat" target="_blank">about</a>
</li>
<li class="nav-item">
<a role="button" class="nav-link" href="https://github.com/dessalines/flowchat" placement="bottom" target="_blank">
github
</a>
</li>
<li class="nav-item">
<a role="button" class="nav-link" href="https://github.com/dessalines/flowchat/issues" placement="bottom" target="_blank">
bugs / features
</a>
</li>
<li class="nav-item">
<a role="button" class="nav-link" placement="bottom" tooltip="Donate to the developer" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2XTHDEBUNQ47U&lc=US&item_name=FlowChat&item_number=flowchat_02&amount=5%2e00&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"
target="_blank">
Expand Down
69 changes: 32 additions & 37 deletions ui/src/app/services/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable } from '@angular/core';
import {User, UserSettings, Discussion, Discussions, Tools, Community, Communities} from '../shared';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import { User, UserSettings, Discussion, Discussions, Tools, Community, Communities } from '../shared';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Headers, RequestOptions, Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
import {environment} from '../../environments/environment';
import { environment } from '../../environments/environment';
import { JwtHelperService } from '@auth0/angular-jwt';
import { ToasterService } from 'angular2-toaster';

Expand All @@ -22,7 +22,6 @@ export class UserService {
private favoriteCommunities: Array<Community> = [];

private userSource = new BehaviorSubject<User>(this.user);

public userObservable = this.userSource.asObservable();

private userSearchUrl: string = environment.endpoint + 'user_search/';
Expand All @@ -49,41 +48,37 @@ export class UserService {
this.setUserFromCookie();
}

public setUserFromCookie() {
let jwt = Tools.readCookie('jwt');
if (jwt) {
public setUserFromCookie() {
let jwt = Tools.readCookie('jwt');
if (jwt) {
this.setUser(jwt);
}
}

private setUser(jwt: string) {
let dJWT = this.jwtHelper.decodeToken(jwt);
this.user = {
id: dJWT.user_id,
name: dJWT.user_name,
}
}

private setUser(jwt: string) {
let dJWT = this.jwtHelper.decodeToken(jwt);
this.user = {
id: dJWT.user_id,
name: dJWT.user_name,
jwt: jwt,
fullUser: dJWT.full_user
};
this.fetchFavoriteDiscussions();
this.fetchFavoriteCommunities();
this.fetchUserSettings();

}

public setUserAndCookie(jwt: string) {

}

public getUser(): User {
return this.user;
}
public getUser(): User {
return this.user;
}

createNewUser(nameStr: string): Observable<string> {
let name = JSON.stringify({ name: nameStr });
createNewUser(nameStr: string): Observable<string> {
let name = JSON.stringify({ name: nameStr });

return this.http.post(this.userUrl, name)
.map(r => r.text())
.catch(this.handleError);
return this.http.post(this.userUrl, name)
.map(r => r.text())
.catch(this.handleError);
}

logout() {
Expand Down Expand Up @@ -124,13 +119,13 @@ export class UserService {
Tools.eraseCookie("jwt");
}

getOptions(): RequestOptions {
let headers = new Headers({
// 'Content-Type': 'application/json',
'token': this.getUser().jwt
});
return new RequestOptions({ headers: headers });
}
getOptions(): RequestOptions {
let headers = new Headers({
// 'Content-Type': 'application/json',
'token': this.getUser().jwt
});
return new RequestOptions({ headers: headers });
}


searchUsers(query: string): Observable<Array<User>> {
Expand Down Expand Up @@ -208,7 +203,7 @@ export class UserService {
}

private removeFavoriteCommunityObjs(communityId: number) {
return this.http.delete(this.favoriteCommunityUrl + '/' + communityId, this.getOptions())
return this.http.delete(this.favoriteCommunityUrl + '/' + communityId, this.getOptions())
.map(this.extractData)
.catch(this.handleError);
}
Expand All @@ -224,7 +219,7 @@ export class UserService {
}

private saveFavoriteCommunityObjs(communityId: number) {
return this.http.post(this.favoriteCommunityUrl + '/' + communityId, null, this.getOptions())
return this.http.post(this.favoriteCommunityUrl + '/' + communityId, null, this.getOptions())
.map(this.extractData)
.catch(this.handleError);
}
Expand All @@ -236,7 +231,7 @@ export class UserService {

fetchUserSettings() {
this.fetchUserSettingsObs().subscribe(d => {

this.user.settings = {
defaultSortTypeRadioValue: d["defaultSortTypeRadioValue"],
defaultViewTypeRadioValue: d["defaultViewTypeRadioValue"],
Expand Down
Loading

0 comments on commit fa0a150

Please sign in to comment.