Skip to content

Instantly share code, notes, and snippets.

<div *ngIf="user | async as User">
<button mat-raised-button color="accent" (click)="newNote = true">
Create Note
</button>
<h2 *ngIf="User.NumNotes === 0">Looks like there are no notes to display</h2>
<h2 *ngIf="User.NumNotes > 0">You have {{ User.NumNotes }} notes</h2>
<app-note *ngIf="newNote" (update)="createNote($event, User.Id)"></app-note>
@shadow1349
shadow1349 / notes.ts
Last active September 13, 2019 22:09
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import { INote, IUser } from 'firebasenoteapptypes';
export const NoteCreated = functions.firestore
.document('Notes/{NoteId}')
.onCreate((snapshot, context) => {
const note = snapshot.data() as INote;
const userRef = admin
<mat-card *ngIf="user | async as User">
<mat-toolbar color="accent">
Your Profile
</mat-toolbar>
<div layout="column" layout-align="center center">
<img
[style.margin-top.px]="'10'"
[style.margin-bottom.px]="'10'"
class="profilePhoto"
src="{{
import { IModel, IAlgoliaModel, Model } from "./model";
export interface INote extends IModel {
Title: string;
Note: string;
/**
* ID of the user who created the document
*/
Author: string;
Tags?: string[];
export interface IModel {
Id: string;
CreatedOn: number;
}
export interface IAlgoliaModel {
objectID: string;
_tags?: string[];
}
import * as algoliasearch from "algoliasearch";
import * as functions from "firebase-functions";
import { Model } from "firebasenoteapptypes";
const algolia = algoliasearch(
functions.config().algolia.appid,
functions.config().algolia.adminkey
);
type IndexName = "Notes" | "Users" | "Notifications";
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import { INote, IUser, NoteModel } from "firebasenoteapptypes";
import { AlgoliaSearch } from "../algolia";
const index = new AlgoliaSearch("Notes");
export const NoteCreated = functions.firestore
.document("Notes/{NoteId}")
.onCreate(async (snapshot, context) => {
@shadow1349
shadow1349 / notes.component.html
Created September 17, 2019 03:06
Notes page using algolia instant search
<div *ngIf="user | async as User">
<button mat-raised-button color="accent" (click)="newNote = true">
Create Note
</button>
<h2 *ngIf="User.NumNotes === 0">Looks like there are no notes to display</h2>
<h2 *ngIf="User.NumNotes > 0">You have {{ User.NumNotes }} notes</h2>
<app-note *ngIf="newNote" (update)="createNote($event, User.Id)"></app-note>
@shadow1349
shadow1349 / note.component.html
Created September 17, 2019 03:51
Notes with tag inputs
<mat-card class="md-margin">
<mat-toolbar [style.background]="'none'" *ngIf="note !== undefined">
<span flex>{{ note.Title }}</span>
<button mat-icon-button color="warn" (click)="deleteNote()">
<mat-icon>delete</mat-icon>
</button>
</mat-toolbar>
<div layout="column" *ngIf="noteForm.disabled" class="md-padding">
<p>{{ note.Note }}</p>
@shadow1349
shadow1349 / authService.ts
Last active May 1, 2020 07:55
Simple way to separate classes of users with Firebase
/**
* I like Angular, so this is the example I'll give you. It should
* still be relatively easy to read
*/
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { switchMap } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';