diff --git a/src/components/FlameLinkImage.js b/src/components/FlameLinkImage.js new file mode 100644 index 0000000..08a4d03 --- /dev/null +++ b/src/components/FlameLinkImage.js @@ -0,0 +1,30 @@ +import React, { Component } from 'react'; +import flamelinkApp from '../flamelink.js'; + +class FlameLinkImage extends Component { + constructor() { + super(); + + this.state = { + mediaURL: '', + } + } + + getImage(imagePath){ + flamelinkApp.storage.getURL(imagePath) + .then(url => this.setState({ + mediaURL: url + })) + return + } + + render() { + return( +
+ {this.getImage(this.props.content)} +
+ ); + } +} + +export default FlameLinkImage; \ No newline at end of file diff --git a/src/components/FlameLinkStructure.js b/src/components/FlameLinkStructure.js index ccf4c7d..028190a 100644 --- a/src/components/FlameLinkStructure.js +++ b/src/components/FlameLinkStructure.js @@ -1,8 +1,9 @@ -import React, { Component, Fragment} from 'react'; +import React, { Component} from 'react'; import Grid from '@material-ui/core/Grid'; -import Paper from '@material-ui/core/Paper'; import Typography from '@material-ui/core/Typography'; import flamelinkApp from '../flamelink.js'; +import FlameLinkImage from './FlameLinkImage'; + class FlameLinkStructure extends Component { constructor() { @@ -16,18 +17,37 @@ class FlameLinkStructure extends Component { .then(result => this.setState({ schemaContent: result })) + } - getContent(key, type){ - if (type == 'text'){ - return this.state.schemaContent[key] - } - if (type == 'media'){ - for (var val in this.state.schemaContent[key]){ - console.log(this.state.schemaContent[key][val]); - flamelinkApp.storage.getURL(this.state.schemaContent[key][val]) - .then(url => console.log('File URL:', url)) + getContent(key, type, description){ + if (type === 'text'){ + if(description === 'h1'){ + return ( + + {this.state.schemaContent[key]} + + ) } + if(description === 'h2'){ + return ( + + {this.state.schemaContent[key]} + + ) + } + else{ + return ( + + {this.state.schemaContent[key]} + + ) + } + } + if (type === 'media'){ + for (var val in this.state.schemaContent[key]){ + return + } } } @@ -38,14 +58,7 @@ class FlameLinkStructure extends Component { const xs = this.props.field.gridColumns.xs; return( - - - HEADER - - - {this.getContent(this.props.field.key, this.props.type)} - - + {this.getContent(this.props.field.key, this.props.type, this.props.field.description)} ); } diff --git a/src/components/Layout.js b/src/components/Layout.js index c53272a..7d9ebca 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -1,7 +1,6 @@ import React, { Component} from 'react'; import FlameLinkStructure from './FlameLinkStructure'; import Grid from '@material-ui/core/Grid'; -import flamelinkApp from '../flamelink.js'; class Layout extends Component { @@ -14,7 +13,7 @@ class Layout extends Component { } createComponents(num){ - return + return } render() { diff --git a/src/firebase.js b/src/firebase.js index 2dee48a..6e6b6b2 100644 --- a/src/firebase.js +++ b/src/firebase.js @@ -1,13 +1,16 @@ -import * as admin from 'firebase-admin'; +import firebase from 'firebase/app'; +import 'firebase/database'; +import 'firebase/storage'; -var serviceAccount = require('./keys/marten-application-firebase-adminsdk-zvjmp-c177ac648f.json'); - -const firebaseConfig = { - credential: admin.credential.cert(serviceAccount), - databaseURL: "https://marten-application.firebaseio.com", - storageBucket: "marten-application.appspot.com" +const config = { + apiKey: "AIzaSyAYf9AbeYwLY892NRiQfn0AMtG9xIFAJbo", + authDomain: "marten-application.firebaseapp.com", + databaseURL: "https://marten-application.firebaseio.com", + projectId: "marten-application", + storageBucket: "marten-application.appspot.com", + messagingSenderId: "659856510832" }; -const firebaseApp = admin.initializeApp(firebaseConfig); +firebase.initializeApp(config); -export default 'firebase-admin'; \ No newline at end of file +export default firebase; \ No newline at end of file diff --git a/src/flamelink.js b/src/flamelink.js index 2e22f1d..4ac805f 100644 --- a/src/flamelink.js +++ b/src/flamelink.js @@ -1,6 +1,6 @@ import firebaseApp from './firebase.js'; import flamelink from 'flamelink'; -const flamelinkApp = flamelink({ firebaseApp, isAdminApp: true }); +const flamelinkApp = flamelink({ firebaseApp }); export default flamelinkApp; \ No newline at end of file diff --git a/src/pages/Info.js b/src/pages/Info.js index 72fa1cd..62edbe0 100644 --- a/src/pages/Info.js +++ b/src/pages/Info.js @@ -11,7 +11,7 @@ class Info extends Component { schemaDetails: '', } - flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key', 'type', 'gridColumns' ] }) + flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key', 'type', 'gridColumns', 'description' ] }) .then(result => this.setState({ schemaDetails: result }))