Published
Edited
Aug 24, 2020
1 fork
Importers
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
firebase = require.alias({
"@firebase/app": "https://www.gstatic.com/firebasejs/7.8.0/firebase-app.js",
"@firebase/auth": "https://www.gstatic.com/firebasejs/7.8.0/firebase-auth.js",
"@firebase/database":
"https://www.gstatic.com/firebasejs/7.8.0/firebase-database.js",
"@firebase/storage":
"https://www.gstatic.com/firebasejs/7.8.0/firebase-storage.js"
})("@firebase/app", "@firebase/auth", "@firebase/database", "@firebase/storage")
Insert cell
Insert cell
Insert cell
Insert cell
app = {
let a = firebase.initializeApp(firebaseConfig);
invalidation.then(() => {
//Delete the app when invalidating the observable cell
a.delete();
});

return a;
}
Insert cell
Insert cell
Insert cell
Insert cell
viewof login = {
var dom = html`<button>Login`;
dom.onclick = () => {
console.log('log in');
firebase
.auth(app)
.signInWithEmailAndPassword(user_name, password)
.catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
};

return dom;
}
Insert cell
viewof signout = {
var dom = html`<button>Sign out`;
dom.onclick = () => {
console.log('sign out');
firebase
.auth()
.signOut()
.then(function() {
// Sign-out successful.
})
.catch(function(error) {
// An error happened.
});
};

return dom;
}
Insert cell
Insert cell
database = firebase.database(app)
Insert cell
/*
database
.ref('observable')
.push()
.set({
ua: navigator.userAgent,
time: new Date().toString()
})
*/
Insert cell
Insert cell
viewof file = html`<input type='file' accept='text/plain' >`
Insert cell
upload = firebase
.storage()
.ref()
.child(file.name)
.put(file, {
contentType: file.type
})
Insert cell
upload.ref.getDownloadURL().then(url => url)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more