diff options
-rw-r--r-- | .firebaserc | 5 | ||||
-rw-r--r-- | firebase.json | 18 | ||||
-rw-r--r-- | firestore.indexes.json | 3 | ||||
-rw-r--r-- | firestore.rules | 11 | ||||
-rw-r--r-- | public/index.html | 65 | ||||
-rw-r--r-- | src/actions/app.js | 8 | ||||
-rw-r--r-- | src/actions/firebase.js | 32 | ||||
-rw-r--r-- | src/components/mao-app.js | 6 | ||||
-rw-r--r-- | src/components/mao-competitions.js | 2 | ||||
-rw-r--r-- | src/components/mao-forums.js (renamed from src/components/mao-fourms.js) | 40 | ||||
-rw-r--r-- | src/components/mao-tutoring.js | 2 | ||||
-rw-r--r-- | src/reducers/firebase.js | 8 | ||||
-rw-r--r-- | storage.rules | 7 |
13 files changed, 153 insertions, 54 deletions
diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..031be06 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "csn-2019-site" + } +} diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..e030694 --- /dev/null +++ b/firebase.json @@ -0,0 +1,18 @@ +{ + "hosting": { + "public": "build/es5-bundled/", + "rewrites": [ + { + "source": "**/!(*.*)", + "destination": "/index.html" + } + ] + }, + "firestore": { + "rules": "firestore.rules", + "indexes": "firestore.indexes.json" + }, + "storage": { + "rules": "storage.rules" + } +} diff --git a/firestore.indexes.json b/firestore.indexes.json new file mode 100644 index 0000000..b19e92b --- /dev/null +++ b/firestore.indexes.json @@ -0,0 +1,3 @@ +{ + "indexes": [] +}
\ No newline at end of file diff --git a/firestore.rules b/firestore.rules new file mode 100644 index 0000000..1ea956c --- /dev/null +++ b/firestore.rules @@ -0,0 +1,11 @@ +service cloud.firestore { + match /databases/{database}/documents { + match /posts/{document=**} { + allow read; + } + + match /{documents=**} { + allow read, write: if request.auth.uid != null; + } + } +}
\ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..45df316 --- /dev/null +++ b/public/index.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Welcome to Firebase Hosting</title> + + <!-- update the version number as needed --> + <script defer src="/__/firebase/5.3.1/firebase-app.js"></script> + <!-- include only the Firebase features as you need --> + <script defer src="/__/firebase/5.3.1/firebase-auth.js"></script> + <script defer src="/__/firebase/5.3.1/firebase-database.js"></script> + <script defer src="/__/firebase/5.3.1/firebase-messaging.js"></script> + <script defer src="/__/firebase/5.3.1/firebase-storage.js"></script> + <!-- initialize the SDK after all desired features are loaded --> + <script defer src="/__/firebase/init.js"></script> + + <style media="screen"> + body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; } + #message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; } + #message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; } + #message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;} + #message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; } + #message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; } + #message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); } + #load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; } + @media (max-width: 600px) { + body, #message { margin-top: 0; background: white; box-shadow: none; } + body { border-top: 16px solid #ffa100; } + } + </style> + </head> + <body> + <div id="message"> + <h2>Welcome</h2> + <h1>Firebase Hosting Setup Complete</h1> + <p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p> + <a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a> + </div> + <p id="load">Firebase SDK Loading…</p> + + <script> + document.addEventListener('DOMContentLoaded', function() { + // // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + // // The Firebase SDK is initialized and available here! + // + // firebase.auth().onAuthStateChanged(user => { }); + // firebase.database().ref('/path/to/ref').on('value', snapshot => { }); + // firebase.messaging().requestPermission().then(() => { }); + // firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { }); + // + // // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + + try { + let app = firebase.app(); + let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function'); + document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`; + } catch (e) { + console.error(e); + document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.'; + } + }); + </script> + </body> +</html> diff --git a/src/actions/app.js b/src/actions/app.js index c60f6e9..849fadb 100644 --- a/src/actions/app.js +++ b/src/actions/app.js @@ -26,7 +26,7 @@ export const navigate = (path) => (dispatch) => { dispatch(updateDrawerState(false)); }; -import {snapshotFourms} from './firebase.js'; +import {snapshotForums} from './firebase.js'; var hasSubscribedPosts = false; const loadPage = (page) => (dispatch) => { @@ -43,10 +43,10 @@ const loadPage = (page) => (dispatch) => { case 'tutor': import('../components/mao-tutoring.js'); break; - case 'fourms': - import('../components/mao-fourms.js').then((module) => { + case 'forums': + import('../components/mao-forums.js').then((module) => { if(!hasSubscribedPosts) { - dispatch(snapshotFourms()); + dispatch(snapshotForums()); hasSubscribedPosts = true; } }); diff --git a/src/actions/firebase.js b/src/actions/firebase.js index 5dca6bf..db6edb0 100644 --- a/src/actions/firebase.js +++ b/src/actions/firebase.js @@ -288,16 +288,6 @@ export const requestHours = (_time, _trainee, _date) => (dispatch, getState) => uid: _uid, email: _email }); - - docRef = firestore.collection('users').doc(_uid); - - docRef.get().then((doc) => { - if(doc.exists) { - docRef.set({ - hours: doc.data().hours - }); - } - }); } export const snapshotAdminRequests = () => (dispatch) => { @@ -351,11 +341,11 @@ export const adminDeleteRequest = (_id) => (dispatch) => { } -export const CREATE_FOURM_POST = 'CREATE_FOURM_POST'; -export const SNAPSHOT_FOURM = 'SNAPSHOT_FOURM'; -export const UPDATE_FOURM_POSTS = 'UPDATE_FOURM_POSTS'; +export const CREATE_FORUM_POST = 'CREATE_FORUM_POST'; +export const SNAPSHOT_FORUM = 'SNAPSHOT_FORUM'; +export const UPDATE_FORUM_POSTS = 'UPDATE_FORUM_POSTS'; -export const createFourmPost = (_subject, _content) => (dispatch, getState) => { +export const createForumPost = (_subject, _content) => (dispatch, getState) => { var docRef = firestore.collection('posts'); const userEmail = getState().firebase.userEmail; @@ -366,22 +356,22 @@ export const createFourmPost = (_subject, _content) => (dispatch, getState) => { }); } -export const snapshotFourms = () => (dispatch) => { +export const snapshotForums = () => (dispatch) => { var docRef = firestore.collection('posts'); docRef.onSnapshot((query) => { - var fourmPosts = []; + var forumPosts = []; query.forEach((doc) => { - fourmPosts.push(doc.data()); + forumPosts.push(doc.data()); }); - dispatch(updateFourmPosts(fourmPosts)); + dispatch(updateForumPosts(forumPosts)); }); } -export const updateFourmPosts = (_fourmPosts) => { +export const updateForumPosts = (_forumPosts) => { return { - type: UPDATE_FOURM_POSTS, - payload: _fourmPosts + type: UPDATE_FORUM_POSTS, + payload: _forumPosts } } //End Firebase Firestore diff --git a/src/components/mao-app.js b/src/components/mao-app.js index 530d460..7fc57f1 100644 --- a/src/components/mao-app.js +++ b/src/components/mao-app.js @@ -205,7 +205,7 @@ class MaoApp extends connect(store)(LitElement) { <a selected?="${_page === 'home'}" href="/home">Home</a> <a selected?="${_page === 'tutor'}" href="/tutor">Tutoring</a> <a selected?="${_page === 'compete'}" href="/compete">Compete</a> - <a selected?="${_page === 'fourms'}" href="/fourms">Fourms</a> + <a selected?="${_page === 'forums'}" href="/forums">Forums</a> <a selected?="${_page === 'account'}" href="/account">Account</a> <a style="display: ${_isAdmin ? 'inline-block' : 'none'};" selected?="${_page === 'admin'}" href="/admin">Admin</a> @@ -219,7 +219,7 @@ class MaoApp extends connect(store)(LitElement) { <a selected?="${_page === 'home'}" href="/home">Home</a> <a selected?="${_page === 'tutor'}" href="/tutor">Tutoring</a> <a selected?="${_page === 'compete'}" href="/compete">Compete</a> - <a selected?="${_page === 'fourms'}" href="/fourms">Fourms</a> + <a selected?="${_page === 'forums'}" href="/forums">Forums</a> <a selected?="${_page === 'account'}" href="/account">Account</a> <a style="display: ${_isAdmin ? 'inline-block' : 'none'};" selected?="${_page === 'admin'}" href="/admin">Admin</a> @@ -232,7 +232,7 @@ class MaoApp extends connect(store)(LitElement) { <mao-tutoring class="page" active?="${_page === 'tutor'}"></mao-tutoring> <mao-competitions class="page" active?="${_page === 'compete'}"></mao-competitions> <mao-account class="page" active?="${_page === 'account'}"></mao-account> - <mao-fourms class="page" active?="${_page === 'fourms'}"></mao-fourms> + <mao-forums class="page" active?="${_page === 'forums'}"></mao-forums> <mao-admin class="page" active?="${_page === 'admin'}"></mao-admin> <my-view404 class="page" active?="${_page === 'view404'}"></my-view404> </main> diff --git a/src/components/mao-competitions.js b/src/components/mao-competitions.js index 9a50d9e..2f3277f 100644 --- a/src/components/mao-competitions.js +++ b/src/components/mao-competitions.js @@ -219,7 +219,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { <competition-element id="dec-competition-element" name="December" - information="Dank ass regional competition" + information="Dank regional competition" location="Miami, American Heritage" initialized="${props.initialized}" isRegistered="${props.registeredComps.includes('December')}" diff --git a/src/components/mao-fourms.js b/src/components/mao-forums.js index 0672da4..d77329a 100644 --- a/src/components/mao-fourms.js +++ b/src/components/mao-forums.js @@ -16,7 +16,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { requestHours, createFourmPost } from '../actions/firebase.js'; +import { requestHours, createForumPost } from '../actions/firebase.js'; // We are lazy loading its reducer. import firebase from '../reducers/firebase.js'; @@ -41,7 +41,7 @@ import '@polymer/paper-button/paper-button.js'; // Import other customElements import '@vaadin/vaadin-date-picker/vaadin-date-picker.js'; -class MaoFourms extends connect(store)(PageViewElement) { +class MaoForums extends connect(store)(PageViewElement) { _render(props) { return html` ${SharedStyles} @@ -96,7 +96,7 @@ class MaoFourms extends connect(store)(PageViewElement) { <paper-card elevation="0"> <div class="card-content"> - <h3>Create Fourm Post</h3> + <h3>Create Forum Post</h3> <paper-input label="Subject" id="subject-field"></paper-input> <paper-textarea label="Content" id="content-field"></paper-textarea> </div> @@ -105,7 +105,7 @@ class MaoFourms extends connect(store)(PageViewElement) { <paper-button raised class ="info" - on-tap ="${() => this.submitFourm()}"> + on-tap ="${() => this.submitForum()}"> Create Post </paper-button> </div> @@ -128,18 +128,18 @@ class MaoFourms extends connect(store)(PageViewElement) { // This is the data from the store. signedIn: Boolean, authMessage: String, - fourmPosts: Array + forumPosts: Array }} _stateChanged(state) { this.signedIn = state.firebase.initialized; this.authMessage = state.firebase.authMessage; - this.fourmPosts = state.firebase.fourmPosts; + this.forumPosts = state.firebase.forumPosts; this.updateSection(); } - submitFourm() { + submitForum() { if(this.shadowRoot) { var subjectElement = this.shadowRoot.getElementById('subject-field'); var contentElement = this.shadowRoot.getElementById('content-field'); @@ -154,8 +154,8 @@ class MaoFourms extends connect(store)(PageViewElement) { { alert("Please fill out all fields when creating a form post."); } else { - if(confirm('Are you sure you want to submit this to the fourm page? It will be public to everyone.')) { - store.dispatch(createFourmPost(subjectElement.value, contentElement.value)); + if(confirm('Are you sure you want to submit this to the forum page? It will be public to everyone.')) { + store.dispatch(createForumPost(subjectElement.value, contentElement.value)); subjectElement.value = ""; contentElement.value = ""; @@ -170,21 +170,21 @@ class MaoFourms extends connect(store)(PageViewElement) { var postsGrid = this.shadowRoot.getElementById('posts-grid'); postsGrid.innerHTML = ""; - for(var i = this.fourmPosts.length-1; i >=0; i--) { + for(var i = this.forumPosts.length-1; i >=0; i--) { var paperCard = document.createElement('paper-card'); var cardContent = document.createElement('div'); - var fourmAuthor = document.createElement('h4'); - var fourmSubject = document.createElement('h3'); - var fourmContent = document.createElement('p'); + var forumAuthor = document.createElement('h4'); + var forumSubject = document.createElement('h3'); + var forumContent = document.createElement('p'); - fourmAuthor.innerHTML = this.fourmPosts[i].email .replace('@communityschoolnaples.org', ''); - fourmSubject.innerHTML = this.fourmPosts[i].subject; - fourmContent.innerHTML = this.fourmPosts[i].content; + forumAuthor.innerHTML = this.forumPosts[i].email .replace('@communityschoolnaples.org', ''); + forumSubject.innerHTML = this.forumPosts[i].subject; + forumContent.innerHTML = this.forumPosts[i].content; cardContent.classList.add('card-content'); - cardContent.appendChild( fourmAuthor); - cardContent.appendChild( fourmSubject); - cardContent.appendChild( fourmContent); + cardContent.appendChild( forumAuthor); + cardContent.appendChild( forumSubject); + cardContent.appendChild( forumContent); paperCard.elevation = 0; paperCard.appendChild( cardContent); @@ -196,4 +196,4 @@ class MaoFourms extends connect(store)(PageViewElement) { } -window.customElements.define('mao-fourms', MaoFourms); +window.customElements.define('mao-forums', MaoForums); diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index c25c570..9bce4a7 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -256,7 +256,7 @@ class MaoTutoring extends connect(store)(PageViewElement) { <div class="card-actions"> <h3>Need Help Finiding A Tutor?</h3> <p>Please meet with your friends to create tutring sessions.</p> - <p>Also, ypu can try the fourm page if you want.</p> + <p>Also, you can try the fourm page if you want.</p> <p>Otherwise, contact our tutoring coordinator <em>Mike Binkowski</em>.</p> </div> diff --git a/src/reducers/firebase.js b/src/reducers/firebase.js index 773f874..6c4e206 100644 --- a/src/reducers/firebase.js +++ b/src/reducers/firebase.js @@ -14,14 +14,14 @@ import { UPDATE_DIVISON, UPDATE_HOURS, UPDATE_REGISTERED_COMPETITIONS, - UPDATE_FOURM_POSTS, + UPDATE_FORUM_POSTS, UPDATE_ADMIN, UPDATE_ADMIN_REQUESTS, UPDATE_ADMIN_COMP_LIST } from '../actions/firebase.js'; -const firebase = (state = {initialized: false, hours: -1, requestedHours: -1, uid: "", userEmail: "", divison: "", registeredComps: [], fourmPosts: [], isAdmin: false, requests: [], compList: []}, action) => { +const firebase = (state = {initialized: false, hours: -1, requestedHours: -1, uid: "", userEmail: "", divison: "", registeredComps: [], forumPosts: [], isAdmin: false, requests: [], compList: []}, action) => { switch (action.type) { case AUTH_SUCCESS: return { @@ -62,10 +62,10 @@ const firebase = (state = {initialized: false, hours: -1, requestedHours: -1, ui } break; - case UPDATE_FOURM_POSTS: + case UPDATE_FORUM_POSTS: return { ...state, - fourmPosts : action.payload + forumPosts : action.payload } break; diff --git a/storage.rules b/storage.rules new file mode 100644 index 0000000..d494542 --- /dev/null +++ b/storage.rules @@ -0,0 +1,7 @@ +service firebase.storage { + match /b/{bucket}/o { + match /{allPaths=**} { + allow read, write: if request.auth!=null; + } + } +} |