Browse Source

Changed test database to users

Related to commit 8eaf380517
pull/116/head
Ramiro Saenz 9 years ago
parent
commit
f0c9d05a96
  1. 6
      app/store/Services.js
  2. 2
      app/ux/Firebase.js
  3. 4
      app/view/main/MainController.js

6
app/store/Services.js

@ -54,7 +54,7 @@ Ext.define('Rambox.store.Services', {
console.info('Saving into Firebase...', record.data); console.info('Saving into Firebase...', record.data);
var ref = fireRef.database().ref('test/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services'); var ref = fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services');
ref.once('value', function(snap) { ref.once('value', function(snap) {
// Generate Key // Generate Key
@ -83,14 +83,14 @@ Ext.define('Rambox.store.Services', {
obj[prop] = record.get(prop); obj[prop] = record.get(prop);
}); });
fireRef.database().ref('test/' + Ext.decode(localStorage.getItem('profile')).user_id + '/services').child(record.get('firebase_key')).update(obj); fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id + '/services').child(record.get('firebase_key')).update(obj);
} }
} }
,remove: function(store, records, index, isMove) { ,remove: function(store, records, index, isMove) {
if ( !localStorage.getItem('id_token') ) return; if ( !localStorage.getItem('id_token') ) return;
Ext.each(records, function(rec) { Ext.each(records, function(rec) {
fireRef.database().ref('test/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services').child(rec.get('firebase_key')).remove(); fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services').child(rec.get('firebase_key')).remove();
}); });
} }
} }

2
app/ux/Firebase.js

@ -9,7 +9,7 @@ Ext.define('Rambox.ux.Firebase', {
console.log('Define listeners for Firebase'); console.log('Define listeners for Firebase');
var ref = fireRef.database().ref('test/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services'); var ref = fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services');
// Attach an asynchronous callback to read the data at our posts reference // Attach an asynchronous callback to read the data at our posts reference
ref.on("child_changed", function(snapshot, prevChildKey) { ref.on("child_changed", function(snapshot, prevChildKey) {

4
app/view/main/MainController.js

@ -786,7 +786,7 @@ Ext.define('Rambox.view.main.MainController', {
if ( !err ) { if ( !err ) {
// Exchange the delegate token for a Firebase auth token // Exchange the delegate token for a Firebase auth token
firebase.auth().signInWithCustomToken(result.id_token).then(function(snapshot) { firebase.auth().signInWithCustomToken(result.id_token).then(function(snapshot) {
fireRef.database().ref('test/' + profile.user_id).child('services').orderByChild('position').once('value', function(snapshot2) { fireRef.database().ref('users/' + profile.user_id).child('services').orderByChild('position').once('value', function(snapshot2) {
Ext.Msg.hide(); Ext.Msg.hide();
// Import Services function // Import Services function
@ -821,7 +821,7 @@ Ext.define('Rambox.view.main.MainController', {
services.push(data); services.push(data);
}); });
fireRef.database().ref('test/' + profile.user_id).set({ fireRef.database().ref('users/' + profile.user_id).set({
services: services services: services
}); });

Loading…
Cancel
Save