Skip to content

Commit

Permalink
Removing new user component, and allowing automatic login. Change som…
Browse files Browse the repository at this point in the history
…e styling.

Fixes #205
  • Loading branch information
dessalines committed Sep 29, 2018
1 parent 5e93c7a commit 79a087c
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 153 deletions.
4 changes: 1 addition & 3 deletions ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import {
FooterComponent,
MarkdownEditComponent,
OnboardAlertComponent,
LoginModalComponent,
NewUserModalComponent
LoginModalComponent
} from './components';
import {
MomentPipe,
Expand Down Expand Up @@ -75,7 +74,6 @@ window['imagesLoaded'] = require('imagesloaded');
MarkdownEditComponent,
OnboardAlertComponent,
LoginModalComponent,
NewUserModalComponent,

// Pipes
MomentPipe,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
<div *ngIf="!discussion.deleted">
<div *ngIf="!editing">
<div class="row">
<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()" 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>
<ng-template #voteTemplate>
<div [innerHtml]="voteHtml()"></div>
</ng-template>
<div class="px-1 col-sm-1 col-1 text-center vote-width" [class.disabled-pointer]="this.isCreator" [class.pointer]="!this.isCreator" placement="right" [tooltip]="voteTemplate" container="body">
<div class="fa fa-fw fa-arrow-up vote-thumb" [class.text-success]="discussion.userRank > 50"
(click)="upvote()"></div>
<div class="vote-number" (click)="toggleShowVoteSlider()">{{avgVote()}}</div>
<div class="fa fa-fw fa-arrow-down vote-thumb" [class.text-danger]="voteExists() && discussion.userRank < 50"
(click)="downvote()"></div>
</div>
<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-sm-10': hasImage() && !isCard(),
'col-sm-12': isCard() ,
'col-sm-11': !hasImage() && !isCard()}">
'col-sm-12': hasImage() && isCard(),
'col-sm-11': !hasImage()}">
<div [ngClass]="{
'card-body-no-bottom': isCard()}">
<h5 [class.card-title]="isCard()" class="card-body-no-bottom">
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ export * from './sidebar';
export * from './tag';
export * from './user';
export * from './onboard-alert';
export * from './login-modal';
export * from './new-user-modal';
export * from './login-modal';
34 changes: 30 additions & 4 deletions ui/src/app/components/login-modal/login-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class LoginModalComponent implements OnInit {
public login: Login = {};

@ViewChild('loginModal') private loginModal: ModalDirective;
@Input() show: boolean;
@Output() hideEvent = new EventEmitter();

constructor(public userService: UserService,
Expand All @@ -32,11 +33,15 @@ export class LoginModalComponent implements OnInit {

this.loginModal.onShown.subscribe(() => document.getElementById("login-input").focus());

setTimeout(() => {
this.loginModal.show();
// document.getElementById("login-input").focus()
}, 100);
// Create a new user if there is none
if (this.userService.getUser() == null) {
this.createNewUser();
}

}

ngOnChanges() {
this.showModal();
}

signupSubmit() {
Expand Down Expand Up @@ -72,10 +77,31 @@ export class LoginModalComponent implements OnInit {
});
}

showModal() {
if (this.show) {
this.loginModal.show();
this.show = false;
}
}

hiddenEvent() {
this.hideEvent.next(true);
}

createNewUser() {
let obs: Observable<string> = this.userService.createAnonymousUser();
obs.subscribe(rJWT => {
Tools.createCookie('jwt', rJWT, 9999);
this.userService.setUserFromCookie();
},
error => {
console.error(error);
this.toasterService.pop("error", error._body);
});
}



}

interface Signup {
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@ <h6 class="dropdown-header">Messages
</ul>
</div>
</nav>
<app-new-user-modal></app-new-user-modal>
<app-login-modal *ngIf="showLoginModal" (hideEvent)="hiddenEvent()"></app-login-modal>
<app-login-modal [show]="showLoginModal" (hideEvent)="hiddenEvent()"></app-login-modal>
1 change: 0 additions & 1 deletion ui/src/app/components/new-user-modal/index.ts

This file was deleted.

33 changes: 0 additions & 33 deletions ui/src/app/components/new-user-modal/new-user-modal.component.html

This file was deleted.

Empty file.

This file was deleted.

71 changes: 0 additions & 71 deletions ui/src/app/components/new-user-modal/new-user-modal.component.ts

This file was deleted.

4 changes: 4 additions & 0 deletions ui/src/app/styles/extras.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
cursor: pointer;
}

.disabled-pointer {
cursor: not-allowed;
}

.link-unstyled, .link-unstyled:link {
color: inherit;
text-decoration: inherit;
Expand Down

0 comments on commit 79a087c

Please sign in to comment.