Created
February 26, 2017 21:03
-
-
Save machariamarigi/8247fa9bd7b199c3aa4bc17299c7372d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dataBase = firebase.database(); | |
var birthdayRef = dataBase.ref('birthday') | |
var corporateRef = dataBase.ref('corporate') | |
var funeralRef = dataBase.ref('funeral') | |
var getwellRef = dataBase.ref('getwell') | |
var loveRef = dataBase.ref('love') | |
var newbornRef = dataBase.ref('newborn') | |
var valentineRef = dataBase.ref('valentine') | |
var weddingRef = dataBase.ref('wedding') | |
var cartItem = dataBase.ref('selectedCartItem') | |
// Get reference to firebase storage | |
var storage = firebase.storage(); | |
// Create our storage reference for our bucket | |
var storageRef = storage.ref() | |
var app = new Vue({ | |
el: '#fapp', | |
data: { | |
birthdayView: true, | |
corporateView: true, | |
funeralView: true, | |
getwellView: true, | |
loveView: true, | |
newbornView: true, | |
valentineView: true, | |
weddingView: true, | |
newProduct: { | |
title: '', | |
description: '', | |
image: '', | |
price: '', | |
date: new Date() | |
}, | |
orders : [] | |
}, | |
created: function() { | |
orders = cartItem.on('value', (snap) => { | |
let stuff = snap.val() | |
vitu = Object.keys(stuff).map(function(key){ | |
return stuff[key] | |
}); | |
console.log(stuff) | |
console.log(vitu) | |
for(i=0; i<vitu.length; i++){ | |
for(j=0; j<vitu[i].length; j++){ | |
this.orders.unshift(vitu[i][j]) | |
} | |
} | |
console.log(this.orders); | |
}) | |
}, | |
firebase: { | |
birthday: birthdayRef, | |
corporate: corporateRef, | |
funeral: funeralRef, | |
getwell: getwellRef, | |
love: loveRef, | |
newborn: newbornRef, | |
valentine: valentineRef, | |
wedding: weddingRef | |
}, | |
methods: { | |
birthdayHide: function (){ | |
}, | |
deleteFuneral: function (key){ | |
funeralRef.child(key).remove(); | |
}, | |
deleteLove: function (key){ | |
loveRef.child(key).remove(); | |
}, | |
deleteGetwell: function (key){ | |
getwellRef.child(key).remove(); | |
}, | |
deleteNewBorn: function (key){ | |
newbornRef.child(key).remove(); | |
}, | |
deleteValentine: function (key){ | |
valentineRef.child(key).remove(); | |
}, | |
deleteBirhday: function (key){ | |
birthdayRef.child(key).remove(); | |
}, | |
deleteWedding: function (key){ | |
weddingRef.child(key).remove(); | |
}, | |
deleteCorporate: function (key){ | |
corporateRef.child(key).remove(); | |
}, | |
uploadFuneral: function() { | |
funeralRef.push(this.newProduct); | |
clear() | |
}, | |
uploadWedding: function() { | |
weddingRef.push(this.newProduct); | |
clear() | |
}, | |
uploadBirthday: function() { | |
birthdayRef.push(this.newProduct); | |
clear() | |
}, | |
uploadValentine: function() { | |
valentineRef.push(this.newProduct); | |
clear() | |
}, | |
uploadLove: function() { | |
loveRef.push(this.newProduct); | |
clear() | |
}, | |
uploadGetwell: function() { | |
getwellRef.push(this.newProduct); | |
clear() | |
}, | |
uploadNewBorn: function() { | |
newbornRef.push(this.newProduct); | |
clear() | |
}, | |
uploadCorporate: function() { | |
corporateRef.push(this.newProduct); | |
clear() | |
}, | |
clear: function() { | |
this.newProduct.title = ''; | |
this.newProduct.description = ''; | |
this.newProduct.price = ''; | |
}, | |
imageUpload: function(evt) { | |
evt.stopPropagation(); | |
evt.preventDefault(); | |
let file = evt.target.files[0]; | |
let metadata = { | |
'content-type': file.type | |
} | |
// push image to storageRef child | |
storageRef.child('images/' + file.name).put(file, metadata).then((snapshot) => { | |
console.log('Uploaded', snapshot.totalBytes, 'bytes'); | |
console.log(snapshot.metadata); | |
// set url of image | |
let url = snapshot.downloadURL; | |
console.log('File Available At', url); | |
this.newProduct.image = url; | |
}).catch((error) => { | |
console.error('Upload Failed: ', error); | |
}); | |
function progress(percentage){} | |
function complete(){} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment