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

frontend(profile): Add toast messages when user enters incorrect input #372

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
"browser"
]
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { AppRoutingModule } from './app-routing.module';
AuthModule.forRoot(),
DataModule.forRoot(),
AppConfigModule,
AppRoutingModule,
AppRoutingModule
],
providers: [
StatusBar,
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/app/auth/pages/signin/signin.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';

import { ToastController } from '@ionic/angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';

Expand All @@ -15,7 +17,8 @@ export class SigninPage implements OnInit {

constructor(private formBuilder: FormBuilder, private router: Router, private route: ActivatedRoute,
private authService: AuthService,
private alertController: AlertController) {
private alertController: AlertController,
public toastController: ToastController) {
this.form = this.formBuilder.group(
{
email: ['', [Validators.required, Validators.email]],
Expand All @@ -39,8 +42,15 @@ export class SigninPage implements OnInit {

}, error => {
console.log(error);
this.presentToast();
});
}


async presentToast() {
const toast = await this.toastController.create({
position: 'top',
message: 'Wrong email or password.',
duration: 2000
});
toast.present();
}
}
14 changes: 13 additions & 1 deletion frontend/src/app/events/pages/event-create/event-create.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, FormGroup, Validators, FormArray} from '@angular/forms';
import { Router } from '@angular/router';
import { ToastController } from '@ionic/angular';

import { EventService } from '../../../data/providers/event/event.service';

Expand All @@ -26,7 +27,8 @@ export class EventCreatePage implements OnInit {
private eventService: EventService,
private router: Router,
private alertController: AlertController,
private authService: AuthService) {
private authService: AuthService,
public toastController: ToastController) {
this.form = this.formBuilder.group({
medias: this.formBuilder.array([
this.formBuilder.control('', Validators.required)
Expand Down Expand Up @@ -77,6 +79,7 @@ export class EventCreatePage implements OnInit {
message => {
this.router.navigate(['/feed']);
this.eventPosted = true;
this.presentToast();
},
error => {
this.handleError(error)
Expand All @@ -85,6 +88,15 @@ export class EventCreatePage implements OnInit {

}

async presentToast() {
const toast = await this.toastController.create({
position: 'top',
message: 'Event has been created.',
duration: 2000
});
toast.present();
}


async presentAlert(errMessage ,backendError : boolean) {
let alert;
Expand Down
24 changes: 23 additions & 1 deletion frontend/src/app/profile/pages/public/public.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {User} from '../../../interfaces';
import {ActivatedRoute} from '@angular/router';
import {AuthService} from '../../../auth/providers/auth/auth.service';
import { ToastController } from '@ionic/angular';

@Component({
selector: 'app-public',
Expand All @@ -19,7 +20,7 @@ export class PublicPage implements OnInit {
errorMessage : string;
error : boolean = false;
sameUser : boolean = false;
constructor(private route : ActivatedRoute, private auth : AuthService, private ref: ChangeDetectorRef) { }
constructor(private route : ActivatedRoute, private auth : AuthService, private ref: ChangeDetectorRef,public toastController: ToastController) { }

ngOnInit() {
this.sub = this.route.params.subscribe(params => {
Expand Down Expand Up @@ -56,6 +57,7 @@ export class PublicPage implements OnInit {
console.log(res);
this.isFollowing = true;
this.ref.detectChanges();
this.presentToastFollow();
},
(err)=>{
console.log(err);
Expand All @@ -72,6 +74,7 @@ export class PublicPage implements OnInit {
console.log(res);
this.isFollowing = false;
this.ref.detectChanges();
this.presentToastUnfollow();
},
(err)=>{
console.log(err);
Expand All @@ -80,4 +83,23 @@ export class PublicPage implements OnInit {
}

}

async presentToastFollow() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@didemongu should we need to create separate functions for each message we're going to make? Why not parametrize each toast and utilize a service for doing this.

const toast = await this.toastController.create({
position: 'top',
message: 'User has been followed.',
duration: 2000
});
toast.present();
}

async presentToastUnfollow() {
const toast = await this.toastController.create({
position: 'top',
message: 'User has been unfollowed.',
duration: 2000
});
toast.present();
}

}
17 changes: 15 additions & 2 deletions frontend/src/app/profile/pages/settings/settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {Datetime} from '@ionic/angular';
import {Router} from '@angular/router';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';

import { ToastController } from '@ionic/angular';

@Component({
selector: 'profile-settings',
templateUrl: './settings.page.html',
Expand Down Expand Up @@ -42,7 +44,8 @@ export class SettingsPage implements OnInit {
private sub : any;
userId : string | null = null;
constructor(private authController: AuthService, private router:
Router, private formBuilder : FormBuilder, private ref: ChangeDetectorRef) {
Router, private formBuilder : FormBuilder, private ref: ChangeDetectorRef,
public toastController: ToastController) {
this.form = this.formBuilder.group(
{
name: ['', [Validators.required, Validators.pattern('[ a-zA-Z]*')]],
Expand Down Expand Up @@ -109,7 +112,7 @@ export class SettingsPage implements OnInit {
console.log(this.userId + ': ' + JSON.stringify(newUser));

this.authController.updateUser(this.user._id, newUser).subscribe((res)=>{
alert('Saved');
this.presentToast();
},(err)=>{
console.log(err);
});
Expand All @@ -125,4 +128,14 @@ export class SettingsPage implements OnInit {
updateInterestsLocally(newSelectedInterests: string[]){
this.interestsSelected = newSelectedInterests;
}

async presentToast() {
const toast = await this.toastController.create({
position: 'top',
message: 'Settings have been changed.',
duration: 2000
});
toast.present();
}

}