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

console: Initial version. #376 (WIP) #385

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.cache
/.spago
/node_modules/
/output/
/dist/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
5 changes: 5 additions & 0 deletions console/html/console.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#user {
position: fixed;
z-index: 2;
right: 70px;
}
3 changes: 3 additions & 0 deletions console/html/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "@statebox/style/style.min.css";

@import "./console.css";
23 changes: 23 additions & 0 deletions console/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" class="stbx-app">
<head>
<meta charset="utf-8"/>
<title>Statebox Cloud Console</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="index.css">
</head>
<body>
<div id="user"><span id="email"></span><button id="sign-out">Sign Out</button></div>
<div id="firebaseui-auth-container" class="dialog"></div>

<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/ui/4.5.0/firebase-ui-auth.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.5.0/firebase-ui-auth.css" />

<script src="index.js"></script>
</body>
<html>
63 changes: 63 additions & 0 deletions console/html/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var Main = require("../output/index.js")

////////////////////////////////////////////////////////////////////////////////
//
// initialise Firebase
//
////////////////////////////////////////////////////////////////////////////////

var firebaseConfig = {
apiKey: "AIzaSyAhl4uChdRK_yXiYybtXfqG6uUEk1hAB9A",
authDomain: "statebox-kdmoncat.firebaseapp.com",
databaseURL: "https://statebox-kdmoncat.firebaseio.com",
projectId: "statebox-kdmoncat",
storageBucket: "statebox-kdmoncat.appspot.com",
messagingSenderId: "455902306352",
appId: "1:455902306352:web:6fcdfeb29f583d118d0df5",
measurementId: "G-9FF747MDHW"
}

let firebase = window.firebase

firebase.initializeApp(firebaseConfig)
firebase.analytics()
var db = firebase.firestore()

firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)

var ui = new firebaseui.auth.AuthUI(firebase.auth())
var uiConfig = {
credentialHelper: firebaseui.auth.CredentialHelper.NONE,
signInFlow: 'popup', // use popup for IDP Providers sign-in flow instead of the default, redirect
signInOptions: [
firebase.auth.EmailAuthProvider.PROVIDER_ID,
],
}

var loggedIn = false
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
start(user)
loggedIn = true
} else {
console.log("firebase auth: not logged in.")
if (!loggedIn) {
ui.start('#firebaseui-auth-container', uiConfig)
} else {
location.reload()
}
}
})

function start (user) {
console.log('user =', user)
document.getElementById('email').innerText = user && user.email || ""
document.getElementById('firebaseui-auth-container').style.display = 'none'

console.log("firebase auth: logged in.")

Main.main()
document.getElementById('sign-out').onclick = function () {
firebase.auth().signOut()
}
}
38 changes: 38 additions & 0 deletions console/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "stbx-cloud-console",
"version": "1.0.0",
"description": "Statebox Cloud Admin Console",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"postinstall": "spago install",
"start": "npm run build && concurrently --kill-others --handle-input npm:watch npm:serve",
"build": "spago bundle-module --main Statebox.Console.Main --to output/index.js --purs-args --censor-codes=ImplicitImport,ImplicitQualifiedImport,HidingImport",
"watch": "spago bundle-module --main Statebox.Console.Main --to output/index.js --watch --purs-args --censor-codes=ImplicitImport,ImplicitQualifiedImport,HidingImport",
"test": "spago test",
"docs": "spago docs",
"repl": "spago repl",
"serve": "parcel html/index.html",
"bundle": "npm run build && rm -rf dist && parcel build html/index.html --public-url . --no-source-maps"
},
"keywords": [
"statebox"
],
"author": "Erik Post <[email protected]>",
"license": "Commercial",
"devDependencies": {
"concurrently": "^5.0.2",
"parcel-bundler": "^1.12.4",
"purescript": "^0.13.8",
"purescript-psa": "^0.7.3",
"spago": "^0.15.2"
},
"dependencies": {
"@statebox/stbx-js": "0.0.31",
"@statebox/style": "0.0.9",
"dagre": "^0.8.4",
"firebaseui": "^4.5.0"
}
}
19 changes: 19 additions & 0 deletions console/spago.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ name =
"stbx-cloud-console"
, dependencies =
[ "affjax"
, "argonaut"
, "argonaut-codecs"
, "console"
, "debug"
, "effect"
, "halogen"
, "psci-support"
, "routing"
, "routing-duplex"
]
, packages =
../packages.dhall
, sources =
[ "src/**/*.purs", "test/**/*.purs" ]
}
Loading