[WIP] Adding Products to Firebase Updated
Learn to send data to the Firebase Realtime Database.
We'll cover the following...
After we set the adapter and serializer, our e-commerce application is ready to save and retrieve data in the Firebase Realtime Database. We will store the product images in Firebase Storage and the links to these pictures in Realtime Database.
First, we need to remove products from our routes coming from the dummy API. This is because they’ll break with our Firebase adapter and serializer.
Removing local store data
Let’s open the category, category/item, admin and admin/edit routes and remove all the code from the model() hooks:
Now to save products in Firebase we need to set up the admin/add route. First, let’s edit our add route template to set up the image input functionality instead of the image link.
Setting up the add route template
Let’s open the app/templates/admin/add.hbs and add the file input functionality:
- Lines 35-43: We created a
divfor our image input functionality:- Line # 39: We created an
imgtag to load the selected image. - Line # 40: We used the
x-file-inputcomponent to input the image.x-file-inputis used to input files by triggering the file selector. It can be installed as an Ember addon. We attached theselectImageaction to it.
- Line # 39: We created an
- Line # 45: We used a bootstrap spinner to notify users when image uploading starts. We set its visibility to hidden in CSS.
- Line # 46: We displayed the uploading progress to