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

Cleans up things #62

Open
wants to merge 2 commits into
base: dev
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
6 changes: 3 additions & 3 deletions frontend/ruski-app/src/app/modules/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ export class AuthGuard implements CanActivate {
| boolean
| UrlTree {
const url: string = state.url;
console.log('here');
// console.log('here');
if (this.hundler.getStatus()) {
return true;
}
return this.hundler.checkUserExistsByEmail().pipe(
map((response: any) => {
console.log(response);
// console.log(response);
if (response.length > 0) {
return true;
}
this.router.navigate(['/register']);
return false;
}),
catchError((error: any) => {
console.log(error);
// console.log(error);
return of(null);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class LoginComponent implements OnInit, OnChanges {

ngOnInit() {
this.auth.user$.subscribe((response) => {
// console.log(response);
// // console.log(response);
});
this.checkIfLoggedIn().subscribe((response) => {
// console.log(response);
// // console.log(response);
if (response) {
this.router.navigate(['/main']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<p>register works!</p>
<div>
<h3>This is your first time registering!</h3>
<p>Please select a name from the dropdown</p>
<p>If your name is not in the dropdown, enter your name</p>
</div>
<div class="flex-container">
<div class="form">
<div class="item">
<mat-toolbar color="primary">Registration</mat-toolbar>
<mat-vertical-stepper [linear]="true" #stepper>
<mat-step>
<ng-template matStepLabel>Fill out name</ng-template>
<div class="description">
The dropdown contains names of people already in the database who
are not yet registered. <br /><br />If your name is not in dropdown,
enter your own!
</div>
<div>
<mat-form-field appearance="standard">
<mat-label>Your name:</mat-label>
<input
Expand All @@ -24,7 +25,12 @@ <h3>This is your first time registering!</h3>
</mat-option>
</mat-autocomplete>
</div>
<div class="item">
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</mat-step>
<mat-step>
<ng-template matStepLabel>Fill out handle</ng-template>
<div>
<mat-form-field appearance="standard">
<mat-label>Desired Handle:</mat-label>
<span matPrefix>@ &nbsp;</span>
Expand All @@ -35,13 +41,19 @@ <h3>This is your first time registering!</h3>
/>
</mat-form-field>
</div>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>Fill out handle</ng-template>

<div class="submit">
<button mat-flat-button (click)="submitInfo()" color="primary">
Submit
</button>
</div>
</mat-step>
</mat-vertical-stepper>
<div class="flex-container">
<div class="error">
<p *ngIf="errorFlag">{{ errorMessage }}</p>
</div>
<div class="submit">
<button mat-flat-button (click)="submitInfo()" color="primary">
Submit
</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
}
}

.submit {
width: 550px;
margin: auto;
// .submit {
// width: 550px;
// margin: auto;

button {
font-size: 25px;
height: 50px;
width: 200px;
margin-left: 175px;
}
// button {
// font-size: 25px;
// height: 50px;
// width: 200px;
// margin-left: 175px;
// }
// }

.submit {
margin-top: 40px;
}

.error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class RegisterComponent implements OnInit {

ngOnInit(): void {
this.reg.fetchUnregUsers().subscribe((response) => {
// console.log(response);
// // console.log(response);
this.namesOptions = response.map((user) => user.name);
for (const user of response) {
this.nameIdMap.set(user.name, user.id);
Expand Down Expand Up @@ -86,11 +86,11 @@ export class RegisterComponent implements OnInit {
});
} else {
this.reg.genUser(userName).subscribe((response) => {
// console.log('HERE');
// // console.log('HERE');
const userId = response;
this.reg.submitHandle(userId, userHandle);
this.reg.submitEmail(userId).subscribe((response) => {
// console.log(response);
// // console.log(response);
this.router.navigate(['/main']);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export class HandlerService {
constructor(private apollo: Apollo, public auth: AuthService) {}

changeRegistered() {
// console.log('here');
// // console.log('here');
this.isRegistered = true;
}

getStatus() {
// console.log(this.isRegistered);
// // console.log(this.isRegistered);
return this.isRegistered;
}

Expand All @@ -32,7 +32,7 @@ export class HandlerService {
return this.auth.user$.pipe(
switchMap((response: any) => {
const email = response.email;
// console.log(response);
// // console.log(response);
return this.apollo
.query<any>({
query: GET_USER,
Expand All @@ -43,7 +43,7 @@ export class HandlerService {
})
.pipe(
map((response) => {
// console.log(response);
// // console.log(response);
return response.data.userByEmail;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class RegisterService {
constructor(private apollo: Apollo, public auth: AuthService) {}

fetchUnregUsers() {
console.log('here');
// console.log('here');
return this.apollo
.watchQuery<any>({
query: gql`
Expand Down Expand Up @@ -62,7 +62,7 @@ export class RegisterService {
}

submitHandle(id: string, handle: string) {
console.log(id, handle);
// console.log(id, handle);
const ADD_HANDLE = gql`
mutation ModifyHandle($id: ID!, $handle: String!) {
modifyHandle(id: $id, handle: $handle) {
Expand All @@ -72,7 +72,7 @@ export class RegisterService {
}
}
`;
console.log('here');
// console.log('here');
this.apollo
.mutate({
mutation: ADD_HANDLE,
Expand All @@ -82,13 +82,13 @@ export class RegisterService {
},
})
.subscribe((response) => {
console.log(response);
// console.log(response);
});
}

submitEmail(id: string) {
console.log('here');
console.log(id);
// console.log('here');
// console.log(id);
const ADD_EMAIL = gql`
mutation ModifyEmail($id: ID!, $email: String!) {
modifyEmail(id: $id, email: $email) {
Expand All @@ -101,7 +101,7 @@ export class RegisterService {
return this.auth.user$.pipe(
switchMap((response: any) => {
const email = response.email;
console.log(email);
// console.log(email);

return this.apollo.mutate({
mutation: ADD_EMAIL,
Expand All @@ -115,7 +115,7 @@ export class RegisterService {
}

genUser(name: string) {
console.log(name);
// console.log(name);
const ADD_USER = gql`
mutation AddUser(
$email: String!
Expand All @@ -137,7 +137,7 @@ export class RegisterService {
`;
return this.auth.user$.pipe(
switchMap((response: any) => {
console.log(response);
// console.log(response);
let profile_pic =
'https://d26n5v24zcmg6e.cloudfront.net/profiles/default.jpeg';
if (response.hasOwnProperty('picture')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import { SubmitGameService } from './../services/submit-game.service';
import { CurrentUserService } from './../services/current-user.service';
import { Game } from './../game-template';
import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormControl, Validators, FormBuilder,FormGroup } from '@angular/forms';
import {
AbstractControl,
FormControl,
Validators,
FormBuilder,
FormGroup,
} from '@angular/forms';
import { Router } from '@angular/router';
import { Observable, forkJoin, from } from 'rxjs';
import { map, startWith, switchMap } from 'rxjs/operators';
import { stringify } from '@angular/compiler/src/util';
Expand Down Expand Up @@ -40,14 +47,18 @@ export class EnterGameComponent implements OnInit {
enemy1Elo: number = 0;
enemy2Elo: number =0;


// properties for current user display
userPro: string = '';
userName: string = '';
userHandle: string = '';
usered: boolean;

constructor(private gameSubmitter: SubmitGameService, private _formBuilder: FormBuilder, private current:CurrentUserService, private router:Router) {}
constructor(
private gameSubmitter: SubmitGameService,
private _formBuilder: FormBuilder,
private current: CurrentUserService,
private router: Router
) {}

ngOnInit(): void {
this.gameSubmitter.fetchUsers().valueChanges.subscribe((response) => {
Expand All @@ -58,28 +69,27 @@ export class EnterGameComponent implements OnInit {
});
this.formGroup = this._formBuilder.group({
formArray: this._formBuilder.array([
this._formBuilder.group({
myName : this.myName,
myCups: this.myCups,
myPenalties : this.myPenalties,
partnerName : this.partnerName,
partnerCups : this.partnerCups,
partnerPenalties : this.partnerPenalties,

}),
this._formBuilder.group({
oneName : this.oneName,
oneCups : this.oneCups,
onePenalties : this.onePenalties,
twoName : this.twoName,
twoCups : this.twoCups,
twoPenalties : this.twoPenalties
}),
this._formBuilder.group({
descriptionControl : this.descriptionControl,
}),
])
});
this._formBuilder.group({
myName: this.myName,
myCups: this.myCups,
myPenalties: this.myPenalties,
partnerName: this.partnerName,
partnerCups: this.partnerCups,
partnerPenalties: this.partnerPenalties,
}),
this._formBuilder.group({
oneName: this.oneName,
oneCups: this.oneCups,
onePenalties: this.onePenalties,
twoName: this.twoName,
twoCups: this.twoCups,
twoPenalties: this.twoPenalties,
}),
this._formBuilder.group({
descriptionControl: this.descriptionControl,
}),
]),
});
this.fillUser();
}
get formArray(): AbstractControl | null {
Expand All @@ -94,10 +104,10 @@ export class EnterGameComponent implements OnInit {
}

watchValue(formy: FormControl, flag: number) {
console.log(flag);
// console.log(flag);
formy.valueChanges.subscribe((response) => {
if (response > 10) {
console.log(response);
// console.log(response);
if (flag === 1) {
this.myCups = new FormControl(10, [
Validators.min(1),
Expand Down Expand Up @@ -368,20 +378,17 @@ export class EnterGameComponent implements OnInit {
return returnValue;
}

fillUser(){
this.current.fetchUser()
.subscribe(response => {
fillUser() {
this.current.fetchUser().subscribe((response) => {
const user = response;
this.userPro= user.profile_url;
this.userName= user.name;
this.userHandle= user.handle;
this.usered=true;
this.userPro = user.profile_url;
this.userName = user.name;
this.userHandle = user.handle;
this.usered = true;
});

}

goToProfile(handle: string): void {
this.router.navigate([`/main/user/${handle}`])
this.router.navigate([`/main/user/${handle}`]);
}

}
Loading