Skip to content

Instantly share code, notes, and snippets.

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[];
<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="{{
<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>
<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 / 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
@shadow1349
shadow1349 / main.component.html
Created September 13, 2019 15:35
This shows how the main router placeholder is setup to load our routes into a nice looking template with a side nav and toolbar
<div class="main-container">
<!-- SIDENAV CONTAINER -->
<mat-sidenav-container class="sidenav-container" *ngIf="user | async as User">
<!-- SIDENAV -->
<mat-sidenav
#mainSidenav
class="sidenav-shadow"
[opened]="windowWidth > breakWidth"
[mode]="windowWidth >= breakWidth ? 'side' : 'over'"
position="start"
@shadow1349
shadow1349 / users.ts
Created September 13, 2019 05:04
Firestore trigger functions for users
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import { IUser } from "firebasenoteapptypes";
import { checkStorageItemsAndDeleteOldFile } from "../utilities/storage";
export const UserCreated = functions.firestore
.document("Users/{UserId}")
.onCreate((snapshot, context) => {
const user = snapshot.data() as IUser;
import * as admin from "firebase-admin";
export const DeleteStorageBucketItem = function(url: string) {
// We want to make sure we have a proper file path, rather than a URL normalized file path
const filePath = url
.split("/o/")[1]
.split("?")[0]
.replace(/%2F/g, "/");
// Make sure that we delete the file
import { Component, OnInit } from '@angular/core';
import {
FormBuilder,
FormControl,
FormGroup,
Validators
} from '@angular/forms';
import { IUser } from 'firebasenoteapptypes';
import { AuthService } from 'src/app/services';
.auth-container {
flex: 1 1 100%;
box-sizing: border-box;
flex-direction: column;
display: flex;
max-width: 50%;
// this will catch tablets
@media only screen and (max-width: 960px) {
flex: 1 1 100%;