Skip to content

Commit 96508de

Browse files
Merge pull request #222 from terminusdb/newDoc
make subdocuments expanded for geo coordinates in VIEW mode
2 parents 974f28c + bacb5f5 commit 96508de

File tree

10 files changed

+56
-32
lines changed

10 files changed

+56
-32
lines changed

packages/tdb-dashboard/src/App.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,3 +1487,18 @@ button.graphiql-tab-add>svg
14871487
padding: 10px;
14881488
color: white !important;
14891489
}
1490+
1491+
.pre--error {
1492+
padding: 10px;
1493+
box-sizing:border-box;
1494+
-moz-box-sizing:border-box;
1495+
webkit-box-sizing:border-box;
1496+
display:block;
1497+
white-space: pre-wrap;
1498+
white-space: -moz-pre-wrap;
1499+
white-space: -pre-wrap;
1500+
white-space: -o-pre-wrap;
1501+
word-wrap: break-word;
1502+
width:100%;
1503+
overflow-x:auto;
1504+
}

packages/tdb-dashboard/src/components/Alerts.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const Alerts = ({message, type, onCancel, time}) => {
4848
<div>
4949
<AiOutlineWarning className="me-1" />
5050
<strong>Warning: </strong>
51-
<div className="text-wrap">{message}</div>
51+
<pre className="pre--error">{message}</pre>
5252
</div>
5353
<Button variant="close" size="xs" onClick={() => onClose("warning")} />
5454
</div>
@@ -66,7 +66,7 @@ export const Alerts = ({message, type, onCancel, time}) => {
6666
<div className="w-100">
6767
<FaExclamationTriangle className="me-1 mb-1" />
6868
<strong>ERROR: </strong>
69-
<div className="text-wrap">{message}</div>
69+
<pre className="pre--error">{message}</pre>
7070
</div>
7171
<AlertCloseButton className={"alert_btn_close alert_danger_text"} onClick={() => onClose("danger")}/>
7272
</div>
@@ -83,7 +83,7 @@ export const Alerts = ({message, type, onCancel, time}) => {
8383
<div>
8484
<AiOutlineCheckCircle className="me-1" />
8585
<strong>Success: </strong>
86-
<div className="text-wrap">{message}</div>
86+
<pre className="pre--error">{message}</pre>
8787
{time && ` ${queryTimeDisplay(updateTime)}`}
8888
</div>
8989
<Button variant="close" size="xs" onClick={() => onClose("success")} />
@@ -93,15 +93,14 @@ export const Alerts = ({message, type, onCancel, time}) => {
9393
if(type == TERMINUS_MESSAGE)
9494
return <Alert
9595
variant="light"
96-
className="text-break"
9796
show={shouldShowAlert("light")}
9897
onClose={() => onClose("light")}>
9998

10099
<div className="d-flex justify-content-between">
101100
<div>
102101
<BsInfoCircle className="me-1" />
103102
<strong>Info: </strong>
104-
<div className="text-wrap">{message}</div>
103+
<pre className="pre--error">{message}</pre>
105104
</div>
106105
<Button variant="close" size="xs" onClick={() => onClose("light")} />
107106
</div>

packages/tdb-dashboard/src/components/ErrorDisplay.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ export const DisplayErrorPerProperty = ({ propertyName, errorType, message }) =>
4343
expandComponent={<MdKeyboardArrowRight/>}
4444
hideComponent={<MdKeyboardArrowDown/>}/>
4545
{errorType}
46-
<pre className="alert_danger_border ml-1 p-1 rounded">{propertyName}</pre>
46+
47+
<pre className="alert_danger_border ml-1 p-1 rounded text-break">{propertyName}</pre>
4748
</div>
4849
</div>
4950
</Accordion.Item>
5051
<Accordion.Collapse eventKey={propertyName} className={"bg-transparent"}>
51-
<div style={{ whiteSpace: "pre-wrap" }}>{message}</div>
52+
<pre className="pre--error">{message}</pre>
5253
</Accordion.Collapse>
5354
</Accordion>
5455
}
@@ -59,13 +60,14 @@ export const ErrorDisplay = ({ errorData, message, css }) => {
5960
return <Accordion className="bg-transparent border-0 w-100">
6061
<Card className="bg-transparent border-0">
6162
<Card.Header className="bg-transparent">
62-
<span className="text-uppercase">{message} </span>
63+
<span>{message} </span>
6364
<ToggleErrorDisplay eventKey="0" expandComponent={"More Info" } hideComponent={"Hide"} css={css}/>
6465
</Card.Header>
6566
<Accordion.Collapse eventKey="0">
6667
<Card.Body>
68+
6769
{/*<pre>{JSON.stringify(errorData, null, 2)}</pre>*/}
68-
{errorData}
70+
<pre className="pre--error">{errorData}</pre>
6971
</Card.Body>
7072
</Accordion.Collapse>
7173
</Card>

packages/tdb-dashboard/src/components/ErrorMessageReport.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const FormatErrorMessages = ({error, setError}) => {
4949
let errorElements = []
5050
if(error["api:error"]) {
5151
if(Array.isArray(error["api:error"]["api:witnesses"])) {
52-
error["api:error"]["api:witnesses"].map(err => {
52+
error["api:error"]["api:witnesses"].map((err,index) => {
5353

5454
if(err.hasOwnProperty("constraint_name")) {
5555
// CONSTRAINT ERRORS
@@ -58,14 +58,14 @@ export const FormatErrorMessages = ({error, setError}) => {
5858
let message = err.message
5959

6060
errorElements.push(
61-
<DisplayErrorPerProperty propertyName={propertyName} message={message} errorType={errorType}/>
61+
<DisplayErrorPerProperty key={`error__${index}`} propertyName={propertyName} message={message} errorType={errorType}/>
6262
)
6363
}
6464
else {
6565
if(err.hasOwnProperty("@type")) {
6666
checkType(err)
6767
errorElements.push(
68-
<pre>{JSON.stringify(err, null, 2)}</pre>
68+
JSON.stringify(err, null, 2)
6969
)
7070
}
7171
else {
@@ -75,7 +75,7 @@ export const FormatErrorMessages = ({error, setError}) => {
7575
let errorType = err[propertyName].hasOwnProperty("@type") ? `${err[propertyName]["@type"]} on ` : `Error occured on`
7676
let message = JSON.stringify(err[propertyName], null, 2)
7777
errorElements.push(
78-
<DisplayErrorPerProperty propertyName={propertyName} message={message} errorType={errorType}/>
78+
<DisplayErrorPerProperty key={`error__${index}`} propertyName={propertyName} message={message} errorType={errorType}/>
7979
)
8080
}
8181
}
@@ -86,7 +86,7 @@ export const FormatErrorMessages = ({error, setError}) => {
8686
if(errorObj.hasOwnProperty("@type")) {
8787
checkType(errorObj)
8888
errorElements.push(
89-
<pre>{JSON.stringify(errorObj, null, 2)}</pre>
89+
JSON.stringify(errorObj, null, 2)
9090
)
9191
}
9292
}

packages/tdb-dashboard/src/components/JSONModelBuilder.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {Alert} from "react-bootstrap"
1313
import {MODEL_BUILDER_EDITOR_OPTIONS} from "./constants"
1414
import { BiUndo } from "react-icons/bi"
1515
import {FaRegEdit} from 'react-icons/fa'
16-
//import {Alerts} from "./Alerts"
1716
import {TERMINUS_DANGER,DOCUMENT_PREFIX} from "./constants"
1817
import {GRAPH_TAB} from "../pages/constants"
1918
import {GraphContextObj} from "@terminusdb-live/tdb-react-components"

packages/tdb-dashboard/src/pages/GraphIqlEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function GraphIqlEditor({}) {
2626
<Layout mainClassName={layoutClass} showLeftSideBar={false}>
2727
<GraphiQL
2828
editorTheme="shadowfox"
29-
defaultQuery={'query{}'}
29+
defaultQuery={'query()'}
3030
fetcher={fetcher}
3131

3232
/>

packages/tdb-documents-ui-template/src/components/DocumentsGraphqlTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const DocumentsGraphqlTable = ({gqlQuery,apolloClient,tableConfig, type,
116116

117117
return <div>
118118
{error && <Alert onClose={() => setError(false)} dismissible className="text-break" variant="danger">
119-
GraphQL query error <div className="text-wrap">{errorMessage}</div> </Alert>}
119+
GraphQL query error <pre className="pre--error">{errorMessage}</pre> </Alert>}
120120
{advSearchFields &&
121121
<Accordion className="mb-4">
122122
<Accordion.Item eventKey="0">

packages/tdb-documents-ui-template/src/hook/useTDBGraphqlQuery.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ export function useTDBGraphqlQuery (apolloClient, graphqlQuery, documentType, op
6767
const callFetchMore = async (currentlimit,currentpage,currentOrderBy,currentFilter) =>{
6868
setLoading(true)
6969
setError(false)
70+
let result
7071
try{
71-
const result = await apolloClient.query({query:graphqlQuery,
72-
variables:{"offset":currentpage , "limit":currentlimit+1,
72+
result = await apolloClient.query({query:graphqlQuery,
73+
variables:{"offset":currentpage , "limit":currentlimit+1,
7374
"orderBy":currentOrderBy || {}, "filter":currentFilter || {}}})
7475

7576
if(result.errors) {
@@ -91,7 +92,13 @@ export function useTDBGraphqlQuery (apolloClient, graphqlQuery, documentType, op
9192
setExtractedData(extractedData)
9293
}
9394
}catch(err){
94-
console.log("ERRORRRRR",err)
95+
//console.log("ERRORCALL",err.graphQLErrors,err.networkError.result.errors)
96+
const errorMessage = err.networkError && err.networkError.result ? err.networkError.result.errors : ""
97+
setRowCount(0)
98+
setData([])
99+
setExtractedData([])
100+
setError(errorMessage)
101+
95102
}finally{
96103
setLoading(false)
97104
}

packages/tdb-documents-ui/src/widgets/subDocumentWidget.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ export const SubDocumentProperties = ({ subDocumentPropertyName, props, order_by
105105
{update && getSubDocumentFields(subDocumentData)}
106106
</Card.Body>
107107
}
108+
109+
// function returns expanded for subdocuments
110+
// if a location is deascribed & geometry_location return true always
111+
// we do this as a temporary fix so that maps in geo locations are loaded correctly
112+
function getExpanded(expanded, linked_to, frame) {
113+
if(frame.hasOwnProperty(linked_to) && frame[linked_to].hasOwnProperty("geometry_location")) return true
114+
return expanded
115+
}
108116

109117
export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props, index, hideFieldLabel, linked_to, propertyDocumentation, id, reference, subDocumentData, setSubDocumentData, args }) => {
110-
const [open, setOpen] = useState(expanded);
118+
const [open, setOpen] = useState(args.mode === CONST.VIEW ? getExpanded(expanded, linked_to, args.fullFrame) : expanded);
111119
//const [open, setOpen] = useState(true);
112120
let uiFrame = args.uiFrame, mode = args.mode
113121

packages/tdb-react-table/src/AdvancedSearch.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import React, {useState} from 'react';
22
import { BasicConfig,Query, Builder, Utils as QbUtils } from '@react-awesome-query-builder/ui';
3-
//import {BootstrapConfig} from '@react-awesome-query-builder/bootstrap'
43
import '@react-awesome-query-builder/ui/css/styles.css';
5-
//import "bootstrap/dist/css/bootstrap.css";
6-
//import '@react-awesome-query-builder/bootstrap/css/styles.css';
7-
//import '@react-awesome-query-builder/ui/css/styles.css';
8-
//import {Query, Builder, BasicConfig, Utils as QbUtils} from 'react-awesome-query-builder';
94
import {Button} from 'react-bootstrap'
10-
//import './style.css';
11-
125

136
// Choose your skin (ant/material/vanilla):
147
const InitialConfig = BasicConfig //BootstrapConfig // AntdConfig; // or MaterialConfig or MuiConfig or BootstrapConfig or BasicConfig
@@ -131,12 +124,13 @@ export const AdvancedSearch = (props) =>{
131124
const checkValueFormat = (fieldOptions, value, operator )=>{
132125
if(!fieldOptions) return {[operator]:value}
133126
let tmpValue = value
134-
switch(fieldOptions.typevalue){
135-
case "Datetime" :
127+
const typeValue = typeof fieldOptions.typevalue === "string" ? fieldOptions.typevalue.toUpperCase() : fieldOptions.typevalue
128+
switch(typeValue){
129+
case "DATETIME" :
136130
tmpValue = `${value.replace(' ','T')}Z`
137131
break
138-
case "Int":
139-
case "BigInt":
132+
case "INT":
133+
case "BIGINT":
140134
tmpValue = `${value}`
141135
break;
142136
}

0 commit comments

Comments
 (0)