From 51ccc779192bbb31c864ccc98ff9580854f60b76 Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Wed, 1 Aug 2018 17:29:57 -0400 Subject: Working on admin framework. Allows for certain uids to have extra controls if they use a key command and enter a password pulled from a database. --- src/components/mao-account.js | 72 +++++++++++++++++++++++++++++++++++------- src/components/mao-app.js | 1 - src/components/mao-fourms.js | 4 +-- src/components/mao-tutoring.js | 22 +++++++++---- 4 files changed, 78 insertions(+), 21 deletions(-) (limited to 'src/components') diff --git a/src/components/mao-account.js b/src/components/mao-account.js index f6f32c6..72eb8b8 100644 --- a/src/components/mao-account.js +++ b/src/components/mao-account.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 { signIn, signOut, requestHours } from '../actions/firebase.js'; +import { signIn, signOut, requestHours, createAccount } from '../actions/firebase.js'; // We are lazy loading its reducer. import firebase from '../reducers/firebase.js'; @@ -43,7 +43,7 @@ class MaoAccount extends connect(store)(PageViewElement) { @@ -113,6 +117,29 @@ class MaoAccount extends connect(store)(PageViewElement) { + + `; } @@ -134,17 +161,19 @@ class MaoAccount extends connect(store)(PageViewElement) { } logIn() { - var emailElement = this.shadowRoot.getElementById('emailField'); - var passwordElement = this.shadowRoot.getElementById('passwordField'); + if(this.shadowRoot) { + var emailElement = this.shadowRoot.getElementById('emailField'); + var passwordElement = this.shadowRoot.getElementById('passwordField'); - const email = emailElement.value - + "@communityschoolnaples.org"; - const password = passwordElement.value; + const email = emailElement.value + + "@communityschoolnaples.org"; + const password = passwordElement.value; - store.dispatch(signIn(email,password)); + store.dispatch(signIn(email,password)); - emailElement.value = ""; - passwordElement.value = ""; + emailElement.value = ""; + passwordElement.value = ""; + } } createCompetitionList(comps) { @@ -166,6 +195,27 @@ class MaoAccount extends connect(store)(PageViewElement) { } } + makeAccount() { + var emailElement = this.shadowRoot.getElementById('createEmailField'); + var passwordElement = this.shadowRoot.getElementById('createPasswordField'); + + if( emailElement.value.includes('2019') || + emailElement.value.includes('2020') + ) + { + const email = emailElement.value + + "@communityschoolnaples.org"; + const password = passwordElement.value; + + store.dispatch(createAccount(email,password)); + } else { + alert('Please use a validated email.'); + } + + emailElement.value = ""; + passwordElement.value = ""; + } + } window.customElements.define('mao-account', MaoAccount); diff --git a/src/components/mao-app.js b/src/components/mao-app.js index 5a02542..55e27b6 100644 --- a/src/components/mao-app.js +++ b/src/components/mao-app.js @@ -210,7 +210,6 @@ class MaoApp extends connect(store)(LitElement) { Home Tutoring Compete - Compete Fourms Account diff --git a/src/components/mao-fourms.js b/src/components/mao-fourms.js index 78f0192..4aa9873 100644 --- a/src/components/mao-fourms.js +++ b/src/components/mao-fourms.js @@ -170,13 +170,13 @@ class MaoFourms extends connect(store)(PageViewElement) { var postsGrid = this.shadowRoot.getElementById('posts-grid'); postsGrid.innerHTML = ""; - for(var i = 0; i < this.fourmPosts.length; i++) { + for(var i = this.fourmPosts.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'); - + fourmAuthor.innerHTML = this.fourmPosts[i].email .replace('@communityschoolnaples.org', ''); fourmSubject.innerHTML = this.fourmPosts[i].subject; fourmContent.innerHTML = this.fourmPosts[i].content; diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index 3a833c6..bca76c1 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -95,8 +95,8 @@ class MaoTutoring extends connect(store)(PageViewElement) { display: block; } - .hopeCard { - --paper-card-background-color: #58d68d; + .subjectCard, .hopeCard { + --paper-card-background-color: #ffffff; } paper-item { @@ -147,12 +147,11 @@ class MaoTutoring extends connect(store)(PageViewElement) { -
+