aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dashboard/index.html55
-rw-r--r--shared/Dashboard.js24
2 files changed, 77 insertions, 2 deletions
diff --git a/dashboard/index.html b/dashboard/index.html
index e4a5f56..c16dcd0 100644
--- a/dashboard/index.html
+++ b/dashboard/index.html
@@ -4,9 +4,60 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Firebase ECommerce Solution</title>
+ <title>Firebase ECommerce Solution</title><style>
+ #snackbar {
+ visibility: hidden;
+ min-width: 250px;
+ background-color: rgb(231, 81, 81);
+ color: #fff;
+ text-align: center;
+ border-radius: 2px;
+ padding: 16px;
+ position: fixed;
+ z-index: 1;
+ top: 30px;
+ right:30px;
+ }
+ #snackbar.show {
+ visibility: visible;
+ -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
+ animation: fadein 0.5s, fadeout 0.5s 2.5s;
+ }
+ @-webkit-keyframes fadein {
+ from {opacity: 0;}
+ to { opacity: 1;}
+ }
+
+ @keyframes fadein {
+ from { opacity: 0;}
+ to { opacity: 1;}
+ }
+
+ @-webkit-keyframes fadeout {
+ from {opacity: 1;}
+ to {opacity: 0;}
+ }
+
+ @keyframes fadeout {
+ from {opacity: 1;}
+ to {opacity: 0;}
+ }
+ .middle {
+ margin: 0 auto;
+ width: 50%;
+ justify-content: center;
+ justify-items: center;
+ align-content: center;
+ align-items: center;
+ }
+ </style>
</head>
<body>
-
+ <div id="snackbar">Some text some message..</div>
+ <button id="signout">Signout</button>
+ <script src="../shared/jquery.js"></script>
+ <script src="https://www.gstatic.com/firebasejs/6.1.0/firebase.js"></script>
+ <script src="../shared/firebaseConfig.js"></script>
+ <script src="../shared/Dashboard.js"></script>
</body>
</html> \ No newline at end of file
diff --git a/shared/Dashboard.js b/shared/Dashboard.js
new file mode 100644
index 0000000..84b8f7e
--- /dev/null
+++ b/shared/Dashboard.js
@@ -0,0 +1,24 @@
+$(document).ready(function(){
+ function showAlert(message) {
+ // Get the snackbar DIV
+ var x = document.getElementById("snackbar");
+ $('#snackbar').text(message)
+ // Add the "show" class to DIV
+ x.className = "show";
+
+ // After 3 seconds, remove the show class from DIV
+ setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
+ }
+ $('#signout').click(function(){
+ firebase.auth().signOut().then(function() {
+ window.location.replace('../')
+ }).catch(function(error) {
+ showAlert("Failed to sign out")
+ });
+ })
+ firebase.auth().onAuthStateChanged(function(user) {
+ if (!user) {
+ window.location.replace('../')
+ }
+ });
+}) \ No newline at end of file