aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Foiani <mfoiani2019@communiyschoolnaples.org>2018-08-13 14:48:13 -0400
committerMichael Foiani <mfoiani2019@communiyschoolnaples.org>2018-08-13 14:48:13 -0400
commitf32d184caca594c71fa7b947ae12ea991b1fc031 (patch)
treefa05567ce7fc1bddf317161e91eb00ed90e7c68b
parent63fc9b25815da079f3559d6b794b57e57db0040f (diff)
Created own store for firebaseStorage. Added basic upload method.
-rw-r--r--src/actions/firebaseStorage.js15
-rw-r--r--src/components/mao-tutoring.js8
-rw-r--r--src/firebase.js3
-rw-r--r--src/reducers/firebaseStorage.js23
-rw-r--r--src/store.js4
5 files changed, 48 insertions, 5 deletions
diff --git a/src/actions/firebaseStorage.js b/src/actions/firebaseStorage.js
new file mode 100644
index 0000000..950dfda
--- /dev/null
+++ b/src/actions/firebaseStorage.js
@@ -0,0 +1,15 @@
+import { storage } from '../firebase.js';
+
+export const UPLOAD_PICTURE = 'UPLOAD_PICTURE';
+
+export const uploadPicture = (picutreFile, uploader) => (dispatch, getState) => {
+ var storageRef = storage.ref('requests/' + getState().firebaseAuth.uid + '/' + file.name);
+
+ var task = storageRef.put(file);
+
+ task.on('state_changed', function(snapshot) {
+ var percentage = (snapshot.bytedTransferred /
+ snapshot.totalBytes) * 100;
+ uploader.value = percentage;
+ });
+} \ No newline at end of file
diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js
index 8acac5b..936773a 100644
--- a/src/components/mao-tutoring.js
+++ b/src/components/mao-tutoring.js
@@ -17,8 +17,9 @@ import { store } from '../store.js';
//These are the actions needed by this element.
import { requestHours } from '../actions/firebaseFirestore.js';
+import { uploadPicture} from '../actions/firebaseStorage.js'
-// These are the shared styles needed by this element.
+// These are the }shared styles needed by this element.
import { SharedStyles } from './shared-styles.js';
import { ButtonSharedStyles } from './button-shared-styles.js';
@@ -342,7 +343,7 @@ class MaoTutoring extends connect(store)(PageViewElement) {
}
}
} else {
- alert("You must upload an image.")
+ alert("You must upload an image to submit hours.")
}
}
@@ -351,8 +352,7 @@ class MaoTutoring extends connect(store)(PageViewElement) {
var uploader = this.shadowRoot.getElementById('uploader');
var file = this.shadowRoot.getElementById('pictureField').files[0];
- uploader.value = 100;
- console.log(file);
+ store.dispatch()
}
}
diff --git a/src/firebase.js b/src/firebase.js
index 26ae172..995e96f 100644
--- a/src/firebase.js
+++ b/src/firebase.js
@@ -17,3 +17,6 @@ export const auth = firebase.auth();
export const firestore = firebase.firestore();
const settings = {timestampsInSnapshots: true};
firestore.settings(settings);
+
+//export storage
+export const storage = firebase.storage(); \ No newline at end of file
diff --git a/src/reducers/firebaseStorage.js b/src/reducers/firebaseStorage.js
new file mode 100644
index 0000000..f58bad5
--- /dev/null
+++ b/src/reducers/firebaseStorage.js
@@ -0,0 +1,23 @@
+/**
+@license
+Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+*/
+
+import {
+ }
+ from '../actions/firebaseStorage.js';
+
+ const firebaseFirestore = (state = {}, action) => {
+ switch (action.type) {
+ default:
+ return state;
+ }
+ };
+
+ export default firebaseStorage;
+ \ No newline at end of file
diff --git a/src/store.js b/src/store.js
index 7f34d84..2ae50c3 100644
--- a/src/store.js
+++ b/src/store.js
@@ -21,6 +21,7 @@ import app from './reducers/app.js';
import firebaseAuth from './reducers/firebaseAuth.js';
import firebaseFirestore from './reducers/firebaseFirestore.js';
import firebaseAdmin from './reducers/firebaseAdmin.js';
+import firebaseStorage from './reducers/firebaseStorage.js';
// Sets up a Chrome extension for time travel debugging.
@@ -42,5 +43,6 @@ store.addReducers({
app,
firebaseAuth,
firebaseFirestore,
- firebaseAdmin
+ firebaseAdmin,
+ firebaseStorage
});