This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {FormControl} from '@angular/forms'; | |
export class EmailValidator { | |
static isValid(control: FormControl){ | |
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(control.value); | |
if (re){ | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is there any performance difference on this 2 approaches: | |
// Injecting on the Page itself: | |
import { Component } from '@angular/core'; | |
import { NavController } from 'ionic-angular'; | |
import { AngularFire, FirebaseListObservable } from 'angularfire2'; | |
@Component({ | |
templateUrl: 'build/pages/home/home.html', | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before: When the alert gets called it interrupts the loading component, so it causes a navigation issue: | |
export class LoginPage { | |
loginUser(){ | |
this.submitAttempt = true; | |
if (!this.loginForm.valid){ | |
console.log(this.loginForm.value); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ngTemplate = require('../dist/plugins/ng-template').ngTemplate; | |
var nodeResolve = require('rollup-plugin-node-resolve'); | |
var commonjs = require('rollup-plugin-commonjs'); | |
// https://github.com/rollup/rollup/wiki/JavaScript-API | |
module.exports = { | |
/** | |
* entry: The bundle's starting point. This file will | |
* be included, along with the minimum necessary code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { Platform } from 'ionic-angular'; | |
import { StatusBar } from 'ionic-native'; | |
import { HomePage } from '../pages/home/home'; | |
import { LoginPage } from '../pages/login/login'; | |
import firebase from 'firebase'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You create a reference for the picture: | |
this.profilePictureRef.child(newGuest.key).child('profilePicture.png') | |
// Then you upload it: | |
.putString(guestPicture, 'base64', {contentType: 'image/png'}) | |
// Since it returns a promise, you save the downloadURL somewhere to use later: | |
.then((savedPicture) => { | |
this.eventList.child(eventId).child('guestList').child(newGuest.key).child('profilePicture') | |
.set(savedPicture.downloadURL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a reference to Firebase Storage | |
this.driverProfilePictureRef = firebase.storage().ref('/driverProfilePicture/'); | |
// Upload the picture to Firebase Storage | |
const uploadPicture = this.driverProfilePictureRef.child("driver's id") | |
.child('profilePicture.png').putString(pictureInBase64StringHere, 'base64', {contentType: 'image/png'}); | |
// After the picture successfully uploads, you'll want to add that picture's url to the drivers node | |
uploadPicture.then( profilePicture => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can create a function in your authentication provider that resolves the value of admin: | |
isAsdmin(): Promise<any> { | |
return new Promise( (resolve, reject ) => { | |
firebase.database().ref(`userProfile/${userId}/admin`).once('value', adminSnapshot => { | |
resolve(adminSnapshot.val()); | |
}); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FUNCTION 1 | |
createEvent(eventName: string, other_params, eventMainPicture = null): any { | |
return this.eventList.push({ | |
name: eventName, | |
... // All the other information you're adding. | |
... | |
... | |
}).then( newEvent => { | |
// When the event is created we pass in the base64 string that represents the picture to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The pictures I'm guessing are in Firebase Storage, but they need to be linked (through the download URL) to the database, | |
// so something like: | |
userProfile: { | |
user1: { | |
name: "Jorge", | |
profilePicture: "https://link_to_picture" | |
} | |
} |
OlderNewer