Skip to content

Commit

Permalink
SERVICE.FUCKING.ACCOUNTS
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRoddy committed Jun 14, 2017
1 parent ea2bf10 commit 3b7ab91
Show file tree
Hide file tree
Showing 16 changed files with 434 additions and 159 deletions.
19 changes: 19 additions & 0 deletions ServiceAccount.js
@@ -0,0 +1,19 @@
import * as admin from "firebase-admin";

exports.getAdmin = (serviceAccount) => {
if (!serviceAccount) {
return admin;
}
initializeApp(serviceAccount);
}

exports.initializeDb = (serviceAccount) => {
if (typeof variable === 'undefined' || !serviceAccount) { return;}

console.log("serviceAccount.initializeDB:", serviceAccount.project_id);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
return admin;
}
133 changes: 128 additions & 5 deletions app/assets/stylesheets/base.scss
Expand Up @@ -41,6 +41,7 @@
// border-collapse: collapse;
// border-spacing: 0;
// }
//^was part of original proj, not sure if neccessary for electron

$lavender: #9370DB;
$turq:#0fb8ad;
Expand Down Expand Up @@ -139,6 +140,63 @@ body {
}
}

.detailText{
color: #7b879e;
font-size:14px;
font-family: Lato,sans-serif;
&.sm{
font-size: 12px;
}
}
.AddDatabase{
h5{
display: flex;
span{
margin-top:8px;
margin-left:8px;
}
small{
margin-left: 4px;
font-size: 12px;
font-style: italic;
}
}
a{
color: #0000EE !important;
text-decoration: underline !important;
cursor: pointer;
}
.bt,.white{
margin-right:15px;
}
}
.DatabaseConfig{
.serviceAcctEdit{
display: flex;
button{
margin-right:10px;
}
margin-bottom: 20px;
}
.nameEdit{
display: flex;
input{
margin-left: 10px;
margin-bottom: 8px;
}
margin-bottom: 16px;
}
.red{
margin-left: 10px;
}
}

b{
font-weight: bold;
}
i{
font-style: italic;
}
.Sidemenu {
height: 100%;
width: 250px;
Expand Down Expand Up @@ -264,15 +322,18 @@ h4 {
}

//// BUTTON CSS ////
.closeBtn {
i.fa-times{
cursor: pointer;
&:hover{
color:red;
}
}

.closeBtn {
color: #aaa;
float: right;
font-size: 16px;
font-weight: bold;
&:hover {
color: red;
}
}

.bt {
Expand Down Expand Up @@ -469,4 +530,66 @@ h4 {
}
}

//// END - OBJECT TREE ////
//// END - OBJECT TREE ////

//// SLIDER TOGGLE CSS ////
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}

/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: $turq;
}

input:focus + .slider {
box-shadow: 0 0 1px $turqhover;
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}

//// END: SLIDER TOGGLE ////
44 changes: 0 additions & 44 deletions app/components/AddDatabase.jsx

This file was deleted.

37 changes: 20 additions & 17 deletions app/components/App.jsx
Expand Up @@ -5,13 +5,13 @@ import Workstation from './Workstation';
import firebase from 'firebase';
import Demo from './Demo';
import CacheHelper from '../helpers/CacheHelper';
import AddDatabase from './AddDatabase';
import Navbar from './Navbar';
import Landing from './Landing';
import QueryHelper from '../helpers/QueryHelper';
import Modal from './Modal';
import Modal from './modals/Modal';
// import { Router, Route, browserHistory, Link } from 'react-router';
import { inject, observer } from 'mobx-react';
const ServiceAccount = require('electron').remote.require('./ServiceAccount');

// @inject('routing')
@observer
Expand All @@ -34,18 +34,18 @@ export default class App extends Component {
this.startFirebaseForDb(currentDatabase);
this.props.store.setCurrentDatabase(currentDatabase);
const that = this;
QueryHelper.getRootKeysPromise(currentDatabase).then(rootKeys => {
console.log(rootKeys)
this.props.store.rootKeys = rootKeys;
})
// QueryHelper.getRootKeysPromise(currentDatabase).then(rootKeys => {
// console.log(rootKeys)
// this.props.store.rootKeys = rootKeys;
// })
CacheHelper.updateLocalStore("currentDatabase", currentDatabase);
}

updateSavedQueries(db) {
// const dbUrl = db.config.databaseURL;
// let queriesByDb = CacheHelper.getFromLocalStore("savedQueriesByDb");
// let savedQueries = (!queriesByDb || !queriesByDb[dbUrl]) ? null : queriesByDb[dbUrl];
// this.setState({ savedQueries });
const dbUrl = db.config.databaseURL;
let queriesByDb = CacheHelper.getFromLocalStore("savedQueriesByDb");
let savedQueries = (!queriesByDb || !queriesByDb[url]) ? null : queriesByDb[url];
this.setState({ savedQueries });
}

createDb(database) {
Expand All @@ -60,12 +60,14 @@ export default class App extends Component {
}

startFirebaseForDb(db) {
if (!db || !db.config || !db.config.databaseURL) { return; }
let apps = firebase.apps;
for (let i = 0; i < apps.length; i++) {
if (apps[i].name_ === db.config.databaseURL) { return; }
}
firebase.initializeApp(db.config, db.config.databaseURL)
// ServiceAccount.initializeDb(db.serviceAccount);

// if (!db || !db.config || !db.config.databaseURL) { return; }
// let apps = firebase.apps;
// for (let i = 0; i < apps.length; i++) {
// if (apps[i].name_ === db.config.databaseURL) { return; }
// }
// firebase.initializeApp(db.config, db.config.databaseURL)
}

executeQuery(query) {
Expand Down Expand Up @@ -123,7 +125,8 @@ export default class App extends Component {
cancelCommit: this.cancelCommit,
savedQueries: savedQueries,
updateSavedQueries: this.updateSavedQueries,
store: this.props.store
store: this.props.store,
newDb: this.props.store.newDb
// routing: this.props.routing
}

Expand Down
36 changes: 0 additions & 36 deletions app/components/DatabaseConfig.jsx

This file was deleted.

20 changes: 0 additions & 20 deletions app/components/Modal.jsx

This file was deleted.

0 comments on commit 3b7ab91

Please sign in to comment.