Skip to content

Instantly share code, notes, and snippets.

@joebordes
Last active May 14, 2020 21:42
Show Gist options
  • Save joebordes/4d1a8201b95f5c44a6b0e20536fbe97d to your computer and use it in GitHub Desktop.
Save joebordes/4d1a8201b95f5c44a6b0e20536fbe97d to your computer and use it in GitHub Desktop.
react number corebos question
Name Text Question No Type Status SQL Query Collection Module Page Size Assigned To Created By Created Time Modified Time Columns Condition Description Order by Column Group by Column Type Properties Main Table Alias Unique ID Field Materialized View Cron Map Id Materialized View Workflow Conditions in Filter Format CRM Entity Alias Update View when Related Changes Related Module List Unique Identifier
filter test2 cbQ-0000005 Number Active 0 Quotes 0.00 admin admin 2020-04-19 15:06:03 2020-04-19 15:15:05 [{"fieldname":"pl_gross_total","operation":"is","value":"round(sum(pl_gross_total), 2)","valuetype":"expression","joincondition":"sum","groupid":0,"groupjoin":"pl_gross_total"}] [{"fieldname":"subject","operation":"contains","value":"an","valuetype":"rawtext","joincondition":"or","groupid":"0","groupjoin":""},{"fieldname":"pl_gross_total","operation":"greater than","value":"20","valuetype":"rawtext","joincondition":"and","groupid":"0","groupjoin":""}] 0 0 0 0 c61aac362338aa6c5f82621b9f5032017b4c5204
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as cbconn from 'corebos-ws-lib/WSClientm';
import MainLayout from 'Hoc/MainLayout'
import H1 from 'Components/H1'
import mermaid from 'mermaid';
import debounce from 'debounce';
const apiUrl = 'http://localhost/coreBOSwork';
cbconn.setURL(apiUrl);
class Home extends Component {
static propTypes = {}
/**
* Debounce the code first. When the function
* fires, take the value and attempt to update
* the Mermaid chart.
*
* @memberof App
*/
handleChange = debounce(
(value) => {
console.log(value);
var output = document.getElementById('output');
try {
mermaid.parse(value);
output.innerHTML = '';
mermaid.render('theGraph', value, function(svgCode) {
console.log(svgCode);
output.innerHTML = svgCode;
});
} catch (err) {
console.error(err);
}
},
600,
false
);
/**
* Render an initial chart on mount.
*
* @memberof App
*/
componentDidMount() {
var output = document.getElementById('output');
mermaid.initialize({ startOnLoad: true });
cbconn.doLogin('admin', 'admin', true)
.then(()=> {
cbconn.doInvoke('cbQuestionAnswer', { qid: '48x47031', params: [] }, 'GET')
.then(data => {
/*
data.answer array with numeric values
data.title
*/
let response = `<H1>${data.title}</H1><span style="font-size:bigger;font-weight:bold">${data.answer[0].pl_gross_total}</span>`
output.innerHTML = response;
//});
});
});
}
render() {
return (
<MainLayout>
<H1>This is a secondary page</H1>
<textarea
rows="4"
onChange={(e) => this.handleChange(e.target.value)}
/>
<div id="output" />
</MainLayout>
)
}
}
const mapStateToProps = state => ({})
const mapDispatchToProps = dispatch => ({})
export default connect(mapStateToProps, mapDispatchToProps)(Home)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment