Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 27 #20

Open
wants to merge 123 commits into
base: lesson-27
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
ebc6ee1
change db config
James007wang Feb 4, 2022
756424f
change title
James007wang Feb 9, 2022
ad29dca
Update index.html
James007wang Feb 9, 2022
18c8a42
Update index.html
James007wang Feb 9, 2022
96922d2
Update index.html
James007wang Feb 9, 2022
2d3a826
change title in vscode
James007wang Feb 10, 2022
d3eceeb
PR
James007wang Feb 10, 2022
99e9550
change...
James007wang Feb 10, 2022
fe68199
4
James007wang Mar 31, 2022
639848c
c
James007wang Mar 31, 2022
3d12201
c
James007wang Mar 31, 2022
03380a5
c
James007wang Mar 31, 2022
36a5f7f
c
James007wang Mar 31, 2022
872da8d
c
James007wang Mar 31, 2022
41310c7
c
James007wang Mar 31, 2022
14acc93
c
James007wang Mar 31, 2022
ba8c352
c
James007wang Mar 31, 2022
35ebc9e
c
James007wang Apr 4, 2022
e0ffc56
c
James007wang Apr 4, 2022
2af38d3
c
James007wang Apr 4, 2022
ac3b1a3
v
James007wang Apr 4, 2022
eb1aebb
c
James007wang Apr 4, 2022
ea848a0
c
James007wang Apr 4, 2022
746953b
c
James007wang Apr 4, 2022
daba545
c
James007wang Apr 4, 2022
5448c85
c
James007wang Apr 4, 2022
af81357
c
James007wang Apr 4, 2022
4783ca6
v
James007wang Apr 4, 2022
87d5f1e
c
James007wang Apr 4, 2022
7b294cb
c
James007wang Apr 4, 2022
315119e
c
James007wang Apr 4, 2022
c53f339
c
James007wang Apr 4, 2022
43a5698
c
James007wang Apr 4, 2022
33b74f3
c
James007wang Apr 4, 2022
e29940d
c
James007wang Apr 4, 2022
546b5ca
c
James007wang Apr 4, 2022
612dafd
c
James007wang Apr 4, 2022
284315d
c
James007wang Apr 5, 2022
e8d2045
c
James007wang Apr 5, 2022
8bb1037
c
James007wang Apr 5, 2022
ce2e19d
c
James007wang Apr 5, 2022
f9dc02f
c
James007wang Apr 5, 2022
f307d61
c
James007wang Apr 5, 2022
d66cccf
c
James007wang Apr 5, 2022
3b878bd
c
James007wang Apr 5, 2022
bb61195
c
James007wang Apr 5, 2022
00497a0
v
James007wang Apr 5, 2022
cfdf44e
c
James007wang Apr 5, 2022
0297efe
c
James007wang Apr 5, 2022
91b44aa
c
James007wang Apr 5, 2022
87a6671
c
James007wang Apr 5, 2022
8c6664b
c
James007wang Apr 5, 2022
2ec1352
c
James007wang Apr 5, 2022
0911415
c
James007wang Apr 5, 2022
39456c1
c
James007wang Apr 5, 2022
02621cb
c
James007wang Apr 5, 2022
ddfa24a
c
James007wang Apr 5, 2022
d0a59fd
c
James007wang Apr 5, 2022
ce98e9e
c
James007wang Apr 5, 2022
ddffcee
c
James007wang Apr 5, 2022
c3d161f
c
James007wang Apr 5, 2022
2403de6
c
James007wang Apr 5, 2022
ae01667
c
James007wang Apr 5, 2022
dc40748
c
James007wang Apr 5, 2022
a6e0984
c
James007wang Apr 5, 2022
89a299a
c
James007wang Apr 5, 2022
13cf714
c
James007wang Apr 5, 2022
24b1779
c
James007wang Apr 5, 2022
ad627de
c
James007wang Apr 5, 2022
49b2872
c
James007wang Apr 5, 2022
32eb590
c
James007wang Apr 5, 2022
1bf3d9f
c
James007wang Apr 6, 2022
513a13e
c
James007wang Apr 6, 2022
b3ef5d1
3
James007wang Apr 6, 2022
88c859a
c
James007wang Apr 6, 2022
f1061f0
c
James007wang Apr 6, 2022
fcbc7b7
c
James007wang Apr 6, 2022
cf04788
c
James007wang Apr 6, 2022
84cd473
c
James007wang Apr 6, 2022
d3557c6
c
James007wang Apr 6, 2022
273d3b8
c
James007wang Apr 6, 2022
7db3c26
c
James007wang Apr 6, 2022
eace059
c
James007wang Apr 6, 2022
715690b
c
James007wang Apr 6, 2022
1a3fd9a
c
James007wang Apr 6, 2022
cd16e56
v
James007wang Apr 6, 2022
cd93967
v
James007wang Apr 6, 2022
e5ef94a
v
James007wang Apr 6, 2022
a6b2a6f
v
James007wang Apr 6, 2022
c6d6bee
c
James007wang Apr 6, 2022
326426f
v
James007wang Apr 6, 2022
d82f691
c
James007wang Apr 6, 2022
2dd1621
v
James007wang Apr 6, 2022
a60c50a
c
James007wang Apr 6, 2022
1a7d06e
v
James007wang Apr 6, 2022
b4fde53
c
James007wang Apr 6, 2022
1529132
c
James007wang Apr 6, 2022
4de68bc
c
James007wang Apr 6, 2022
f65c81d
c
James007wang Apr 6, 2022
ed168db
c
James007wang Apr 6, 2022
5f57862
c
James007wang Apr 6, 2022
dae027b
c
James007wang Apr 6, 2022
3bdc321
v
James007wang Apr 6, 2022
c24cbec
v
James007wang Apr 6, 2022
980c259
c
James007wang Apr 6, 2022
3b1f595
c
James007wang Apr 6, 2022
3887e34
c
James007wang Apr 6, 2022
fb81f5a
c
James007wang Apr 6, 2022
7bb03c8
c
James007wang Apr 6, 2022
074f31d
c
James007wang Apr 7, 2022
74c8242
c
James007wang Apr 7, 2022
d0fef0c
c
James007wang Apr 7, 2022
f32ab9d
c
James007wang Apr 7, 2022
ee90bdf
c
James007wang Apr 7, 2022
88bcb51
c
James007wang Apr 7, 2022
c7813c5
c
James007wang Apr 7, 2022
109b186
self.addEventListener('message', (event) => {
James007wang Apr 7, 2022
44ace62
c
James007wang Apr 7, 2022
da93e9c
c
James007wang Apr 7, 2022
85588ec
c
James007wang Apr 7, 2022
a1d4602
c
James007wang Apr 7, 2022
05ac722
c
James007wang Apr 7, 2022
c8fafca
c
James007wang Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ServiceWorkerUpdateListener.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions _headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
cache-control: max-age=0
cache-control: no-cache
cache-control: no-store
cache-control: must-revalidate
177 changes: 177 additions & 0 deletions afterLogin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Firebase Store and auth PWA </title>
<!-- <script src="https://www.gstatic.com/firebasejs/9.1.3/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.1.3/firebase-auth-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.1.3/firebase-store-compat.js"></script> -->
<!-- *******************************************************************************************
* TODO(DEVELOPER): Paste the initialization snippet from:
* Firebase Console > Overview > Add Firebase to your web app. *
***************************************************************************************** -->
<title>Firebase PWA</title>
<!-- materialize icons, css & js -->
<link type="text/css" href="/css/materialize.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" href="/css/styles.css" rel="stylesheet">
<script type="text/javascript" src="/js/materialize.min.js"></script>
<link rel="manifest" href="/manifest.json">
<!-- ios support -->
<link rel="apple-touch-icon" href="/img/icons/icon-96x96.png">
<meta name="apple-mobile-web-app-status-bar" content="#FFE1C4">
<meta name="theme-color" content="#FFE1C4">

</head>
<body class="grey lighten-4">
<!-- top nav -->
<nav class="z-depth-0">
<div class="nav-wrapper container">
<a href="/">Firebase PWA</a>
<span class="right grey-text text-darken-1">
<i class="material-icons sidenav-trigger" data-target="side-menu">menu</i>
</span>
</div>
</nav>

<!-- side nav -->
<ul id="side-menu" class="sidenav side-menu">
<li><a class="subheader">Firebase PWA</a></li>
<li><a href="" class="waves-effect" id="sign-out">Sign out</a></li>
<li><a href="/" class="waves-effect">Home</a></li>
<li><a href="/pages/about.html" class="waves-effect">About</a></li>
<li><div class="divider"></div></li>
<li><a href="/pages/contact.html" class="waves-effect">
<i class="material-icons">mail_outline</i>Contact</a>
</li>
</ul>

<!-- recipes -->
<div class="recipes container grey-text text-darken-1">

</div>

<div class="center">
<a class="btn-floating btn-small btn-large add-btn sidenav-trigger" data-target="side-form">
<i class="material-icons">add</i>
</a>
</div>

<!-- add recipe side nav -->
<div id="side-form" class="sidenav side-form">
<form class="add-recipe container section">
<h6 >New Recipe</h6>
<div class="divider"></div>
<div class="input-field">
<input placeholder="e.g. Ninja soup" id="title" type="text" class="validate">
<label for="title">Recipe Title</label>
</div>
<div class="input-field">
<input placeholder="e.g. Tofu, mushroom, garlic" id="ingredients" type="text" class="validate">
<label for="ingredients">Ingredients</label>
</div>
<div class="input-field center">
<button class="btn-small">Add</button>
</div>
</form>
</div>



<!-- <div id="sign-in-status"></div>
<div id="sign-in"></div>

<pre id="account-details"></pre> -->
<!-- <button class="btn yellow darken-2 z-depth-0" id="sign-out">Sign Out</button> -->
<script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-firestore.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyDuJe2w5Ptc1AwM-Us-kWb2jYJuCr6UTOw",
authDomain: "angularfire-54a57.firebaseapp.com",
databaseURL: "https://angularfire-54a57.firebaseio.com",
projectId: "angularfire-54a57",
storageBucket: "angularfire-54a57.appspot.com",
messagingSenderId: "160774038322",
appId: "1:160774038322:web:5325bf8caa01ee62cfad2b"
};
firebase.initializeApp(config);

// make auth and firestore references
//const auth = firebase.auth();
const db = firebase.firestore();

// update firestore settings
//db.settings({ timestampsInSnapshots: true });
</script>
<script src="/js/app.js"></script>
<script src="/js/db.js"></script>
<script src="/js/ui.js"></script>

<script type="text/javascript">
initApp = function() {
firebase.auth().onAuthStateChanged(function(user) {
if (user) {

// User is signed in.
//document.getElementById('sign-out').style.display = 'block';
/* var displayName = user.displayName;
var email = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var uid = user.uid;
var phoneNumber = user.phoneNumber;
var providerData = user.providerData;
user.getIdToken().then(function(accessToken) {
document.getElementById('sign-in-status').textContent = 'Signed in';
document.getElementById('sign-in').textContent = 'Sign out';
document.getElementById('account-details').textContent = JSON.stringify({
displayName: displayName,
email: email,
emailVerified: emailVerified,
phoneNumber: phoneNumber,
photoURL: photoURL,
uid: uid,
accessToken: accessToken,
providerData: providerData
}, null, ' ');
}); */


} else {
// User is signed out.
window.location.replace("https://majestic-sable-521f65.netlify.app");
/* document.getElementById('sign-in-status').textContent = 'Signed out';
document.getElementById('sign-in').textContent = 'Sign in';
//document.getElementById('sign-out').style.display = 'null';
document.getElementById('account-details').textContent = 'null'; */
}
}, function(error) {
console.log(error);
});
};

window.addEventListener('load', function() {
initApp()
});

const sign_out = document.getElementById("sign-out");
sign_out.addEventListener('click', () => {
firebase.auth().signOut().then(() => {
// Sign-out successful./
console.log('Sign out.'+window.location.origin);
window.location.replace("https://majestic-sable-521f65.netlify.app");

}).catch((error) => {
// An error happened.
console.log(error);
});
});
</script>



</body>
</html>
148 changes: 148 additions & 0 deletions index-old.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample FirebaseUI App</title>
<!-- <script src="https://www.gstatic.com/firebasejs/9.1.3/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.1.3/firebase-auth-compat.js"></script> -->
<!-- *******************************************************************************************
* TODO(DEVELOPER): Paste the initialization snippet from this dialog box:
* Firebase Console > Project Settings > Add App > Web.
***************************************************************************************** -->

<script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-auth.js"></script>

<script src="https://www.gstatic.com/firebasejs/ui/6.0.1/firebase-ui-auth.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/6.0.1/firebase-ui-auth.css" />

<link type="text/css" href="/css/materialize.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" href="/css/styles.css" rel="stylesheet">
<script type="text/javascript" src="/js/materialize.min.js"></script>
<link rel="manifest" href="/manifest.json">

<!-- ios support -->
<link rel="apple-touch-icon" href="/img/icons/icon-96x96.png">
<meta name="apple-mobile-web-app-status-bar" content="#FFE1C4">
<meta name="theme-color" content="#FFE1C4">

</head class="grey lighten-4">
<body>

<!-- The surrounding HTML is left untouched by FirebaseUI.
Your app may use that space for branding, controls and other customizations.-->

<div class="row center">
<div class="col s12 m5">
<div class="card-panel teal">
<span class="white-text">Firebase PWA Sign in ver.002
</span>
</div>
</div>
</div>
<div class="row">
<div class="col s12 m5">
<div class="card-panel teal">

<div id="firebaseui-auth-container"></div>
</div>
</div>
</div>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyDuJe2w5Ptc1AwM-Us-kWb2jYJuCr6UTOw",
authDomain: "angularfire-54a57.firebaseapp.com",
databaseURL: "https://angularfire-54a57.firebaseio.com",
projectId: "angularfire-54a57",
storageBucket: "angularfire-54a57.appspot.com",
messagingSenderId: "160774038322",
appId: "1:160774038322:web:5325bf8caa01ee62cfad2b"
};
firebase.initializeApp(config);

// make auth and firestore references
//const auth = firebase.auth();
//const db = firebase.firestore();

// update firestore settings
//db.settings({ timestampsInSnapshots: true });
</script>

<script type="text/javascript">
//var provider = new firebase.auth.GoogleAuthProvider();

// FirebaseUI config.
var uiConfig = {
signInSuccessUrl: 'afterLogin.html',
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
firebase.auth.GithubAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID,
firebase.auth.PhoneAuthProvider.PROVIDER_ID,
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
],
// tosUrl and privacyPolicyUrl accept either url string or a callback
// function.
// Terms of service url/callback.
tosUrl: '<your-tos-url>',
// Privacy policy url/callback.
privacyPolicyUrl: function() {
window.location.assign('<your-privacy-policy-url>');
}
};

initApp = function() {
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log('already login'+window.location.origin);
window.location.replace("https://majestic-sable-521f65.netlify.app/afterLogin.html");
// User is signed in.
//document.getElementById('sign-out').style.display = 'block';
/* var displayName = user.displayName;
var email = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var uid = user.uid;
var phoneNumber = user.phoneNumber;
var providerData = user.providerData;
user.getIdToken().then(function(accessToken) {
document.getElementById('sign-in-status').textContent = 'Signed in';
document.getElementById('sign-in').textContent = 'Sign out';
document.getElementById('account-details').textContent = JSON.stringify({
displayName: displayName,
email: email,
emailVerified: emailVerified,
phoneNumber: phoneNumber,
photoURL: photoURL,
uid: uid,
accessToken: accessToken,
providerData: providerData
}, null, ' ');
}); */
} else {
// User is signed out. then show login ui
// Initialize the FirebaseUI Widget using Firebase.
console.log(' to login');
var ui = new firebaseui.auth.AuthUI(firebase.auth());
// The start method will wait until the DOM is loaded.
ui.start('#firebaseui-auth-container', uiConfig);

}
}, function(error) {
console.log(error);
});
};

window.addEventListener('load', function() {
initApp()
});


</script>
</body>
</html>
Loading