From 7a8e840e1bf28a9a6e28d3a3fdf816328ab9216a Mon Sep 17 00:00:00 2001 From: ajmaley Date: Sat, 27 Oct 2018 12:46:00 -0400 Subject: [PATCH] Added code to handle flamelink data. It handles schema field order, grid sizes and displays text. Getting storage bucket errors when attempting to grab media info. Need to use the firebase-admin package instead of the firebase package. This is a known issue with flamelink. I'll fix this shortly. --- src/components/Flamelink.js | 32 -------------------------- src/components/Layout.js | 46 +++++++++++-------------------------- src/firebase.js | 2 +- src/pages/Info.js | 24 +++++++++++++++---- 4 files changed, 34 insertions(+), 70 deletions(-) delete mode 100644 src/components/Flamelink.js diff --git a/src/components/Flamelink.js b/src/components/Flamelink.js deleted file mode 100644 index d79007e..0000000 --- a/src/components/Flamelink.js +++ /dev/null @@ -1,32 +0,0 @@ -import React, { Component, Fragment } from 'react'; -import Grid from '@material-ui/core/Grid'; -import flamelinkApp from '../flamelink.js'; -import Layout from './Layout'; -class Flamelink extends Component { - constructor() { - super(); - - this.state = { - schemaDetails: '' - } - } - - componentDidMount() { - // fetch the project name, once it retrieves resolve the promsie and update the state. - flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key' ] }) - .then(result => this.setState({ - schemaDetails: result - })) - } - - render() { - - return( - - - - ); - } -} - -export default Flamelink; \ No newline at end of file diff --git a/src/components/Layout.js b/src/components/Layout.js index 760b0dc..c53272a 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -1,47 +1,27 @@ -import React, { Component, Fragment } from 'react'; +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 { - constructor() { - super(); - this.state = { - contentDetails: '' - } - } - - - getData(schemaData){ - for (var val in this.props.schemaDetails){ - this.getMoreData(this.props.schemaDetails[val]); + getSchemaFieldData(schemaData){ + var arr = []; + for (var val in schemaData){ + arr.push(val); } + return arr.map(this.createComponents, schemaData); } - getMoreData(moreData){ - var tArray = document.createElement("H1"); - var kArray = document.createElement("P"); - this.getTitle(moreData.title, tArray); - this.getKey(moreData.key, kArray); - } - - getTitle(title, arr){ - var t = document.createTextNode(title); - arr.appendChild(t); - document.getElementById("demo").appendChild(arr); - } - - - getKey(key, arr){ - var k = document.createTextNode(key); - arr.appendChild(k); - document.getElementById("demo").appendChild(arr); + createComponents(num){ + return } render() { return( -
-

{this.getData(this.props)}

-
+ + {this.getSchemaFieldData(this.props.schemaDetails)} + ); } } diff --git a/src/firebase.js b/src/firebase.js index 8d01e36..51e4393 100644 --- a/src/firebase.js +++ b/src/firebase.js @@ -10,6 +10,6 @@ const config = { messagingSenderId: "659856510832" }; -firebase.initializeApp(config); +const firebaseApp = firebase.initializeApp(config); export default firebase; \ No newline at end of file diff --git a/src/pages/Info.js b/src/pages/Info.js index 3db9d8f..72fa1cd 100644 --- a/src/pages/Info.js +++ b/src/pages/Info.js @@ -1,9 +1,22 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import Typography from '@material-ui/core/Typography'; -import Flamelink from '../components/Flamelink'; - +import Layout from '../components/Layout'; +import flamelinkApp from '../flamelink.js'; class Info extends Component { + constructor() { + super(); + + this.state = { + schemaDetails: '', + } + + flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key', 'type', 'gridColumns' ] }) + .then(result => this.setState({ + schemaDetails: result + })) + } + render() { return ( @@ -12,7 +25,10 @@ class Info extends Component { Info - + + + + );