Skip to content

Commit 81138c1

Browse files
Merge pull request #49 from terminusdb/dashboard-review
reviewgraph
2 parents 09d0ad2 + d55805c commit 81138c1

File tree

22 files changed

+3731
-1277
lines changed

22 files changed

+3731
-1277
lines changed

package-lock.json

Lines changed: 3334 additions & 1057 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tdb-access-control-component/demo/webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ module.exports = {
3030
resolve: {
3131
alias: {
3232
"@terminusdb/terminusdb-access-control-component": path.join(__dirname, '..', 'src/index.js'),
33-
"@terminusdb/terminusdb-client": path.resolve('../terminusdb-client/index.js'),
34-
"@terminusdb/terminusdb-react-table": path.resolve('../terminusdb-react-table/src/index.js'),
35-
react: path.resolve('./node_modules/react')
33+
"@terminusdb/terminusdb-client": path.resolve('../../../terminusdb-client/index.js'),
34+
"@terminusdb/terminusdb-react-table": path.resolve('../../../terminusdb-react-table/src/index.js'),
35+
react: path.resolve('../../node_modules/react')
3636
},
3737
extensions: ['.js', '.jsx', '.json', '.css'],
3838
},

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@ export const DocumentFrames = () => {
6464
}, [documentObject.frames])
6565

6666

67+
const checkIfPrefix =(id)=>{
68+
if(id.indexOf(":")>-1){
69+
return id
70+
}
71+
return "@schema:"+id
72+
}
73+
6774
const onSelect = async (inp, type) => {
6875
let WOQL = TerminusClient.WOQL
69-
var docType=`@schema:${type}`
76+
var docType=checkIfPrefix(type)
7077
let q = WOQL.isa("v:Documents", docType)
7178
const results = await q.execute(woqlClient)
7279
.then((response) => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const UserMenu = ({organization}) => {
4646
<Button size="sm" className="bg-transparent border-0">
4747
{clientUser.email}
4848
</Button>
49-
<Dropdown.Toggle split className="bg-transparent border-0" vairant="info" id="profile_menu_arrow">
49+
<Dropdown.Toggle split className="bg-transparent border-0" id="profile_menu_arrow">
5050
</Dropdown.Toggle>
5151
<Dropdown.Menu >
5252
{clientUser.user === "admin" && <Dropdown.Item>
@@ -76,7 +76,7 @@ export const UserMenu = ({organization}) => {
7676
className="nav__main__profile__img"
7777
width="50"/>
7878
</Button>
79-
<Dropdown.Toggle split className="bg-transparent border-0" vairant="info" id="profile_menu_arrow">
79+
<Dropdown.Toggle split className="bg-transparent border-0" id="profile_menu_arrow">
8080
</Dropdown.Toggle>
8181
<Dropdown.Menu >
8282
{organization && <Dropdown.Item>

packages/tdb-dashboard/src/hooks/DocumentControlContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const DocumentControlProvider = ({children}) => {
8383
}
8484
}, [documentObject.update])
8585

86-
// on click of submit on create or edit
86+
8787
useEffect(() => {
8888
if(!documentObject.submit) return
8989
if(!Object.keys(documentObject.frames)) return

packages/tdb-dashboard/src/queries/GeneralQueries.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getDocumentClasses = (dataProduct) => {
2020

2121
export const getDocsTypeQuery=(type)=>{
2222
let WOQL = TerminusClient.WOQL
23-
var docType=`@schema:${type}`
23+
var docType=checkIfPrefix(type)
2424
let q = WOQL.isa("v:Documents", docType)
2525
return q
2626
}
@@ -220,12 +220,18 @@ export const getDocumentsOfType = (doctype) => {
220220
).sub(doctype, "v:Type ID")
221221
}*/
222222

223+
const checkIfPrefix =(id)=>{
224+
if(id.indexOf(":")>-1){
225+
return id
226+
}
227+
return "@schema:"+id
228+
}
223229
// get count of document class instance
224230
export const getCountOfDocumentClass = (documentClasses) => {
225231
let WOQL = TerminusClient.WOQL
226232
let CountArray=[]
227233
documentClasses.map(item => { // set type of document
228-
let scmType="@schema:"+item["@id"]
234+
let scmType=checkIfPrefix(item["@id"])
229235
let variable="v:"+item["@id"]
230236
CountArray.push(WOQL.count (variable, WOQL.triple("v:Doc", "rdf:type", scmType)))
231237
})
@@ -239,15 +245,12 @@ export const getTotalNumberOfDocuments = (documentClasses) => {
239245
let CountArray=[]
240246
let variableList = []
241247
documentClasses.map(item => { // set type of document
242-
let scmType="@schema:"+item["@id"]
248+
let scmType= checkIfPrefix(item["@id"])
243249
let variable="v:"+item["@id"]
244250
variableList.push(variable)
245251
CountArray.push(WOQL.count (variable, WOQL.triple("v:Doc", "rdf:type", scmType)))
246252
})
247253

248254
let q = WOQL.and(...CountArray, WOQL.sum(variableList, "v:Count"))
249255
return q
250-
}
251-
252-
253-
//triple("v:Doc", "rdf:type", "@schema:Organization").triple("v:Doc", "v:Properties", "v:Value")
256+
}

packages/tdb-documents-ui/src/constants.js

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,62 @@ export const JSON_TYPE="object"
44
export const NUMBER_TYPE="number"
55
export const BOOLEAN_TYPE="boolean"
66
export const DATE_TYPE="string"
7+
export const RDF_DATA_TYPE_PREFIX = "rdf:"
78
export const XSD_DATA_TYPE_PREFIX = "xsd:"
89
export const XDD_DATA_TYPE_PREFIX = "xdd:"
910
export const SYS_UNIT_TYPE_PREFIX = "sys:"
10-
export const XSD_STRING="xsd:string";;
11+
export const XSD_STRING="xsd:string"
1112
export const XSD_ANY_URI="xsd:anyURI"
13+
export const XSD_NMTOKEN="xsd:NMTOKEN" // XML NMTOKENs
14+
export const XSD_NAME="xsd:Name" // XML Names
15+
export const XSD_NCNAME="xsd:NCName" // XML NCNames
1216
export const XDD_URL="xdd:url"
13-
export const XSD_FLOAT="xsd:float"
17+
export const XSD_NORMALIZED_STRING="xsd:normalizedString"
18+
export const XSD_LANGUAGE="xsd:language"
19+
export const RDF_LANGSTRING ="rdf:langString"
20+
21+
//Encoded binary data
22+
export const XSD_HEXBINARY="xsd:hexBinary" //Hex-encoded binary data
23+
export const XSD_BASE64BINARY="xsd:base64Binary" //Base64-encoded binary data
24+
25+
// Limited-range integer numbers
26+
export const XSD_BYTE = "xsd:byte" // -128…+127 (8 bit)
27+
export const XSD_SHORT = "xsd:short" // -32768…+32767 (16 bit)
28+
export const XSD_INT = "xsd:int" // -2147483648…+2147483647 (32 bit) |
29+
export const XSD_LONG = "xsd:long" // -9223372036854775808…+9223372036854775807 (64 bit) |
30+
export const XSD_UNSINGNEDBYTE = "xsd:unsignedByte"// 0…255 (8 bit) |
31+
export const XSD_UNSIGNEDSHORT = "xsd:unsignedShort" //| 0…65535 (16 bit) |
32+
export const XSD_UNSIGNEDINT = "xsd:unsignedInt" //| 0…4294967295 (32 bit) |
33+
export const XSD_UNSIGNEDLONG = "xsd:unsignedLong"// | 0…18446744073709551615 (64 bit) |
34+
export const XSD_POSITIVE_INTEGER="xsd:positiveInteger" // | Integer numbers >0 |
35+
export const XSD_NONNEGATIVEINTEGER = "xsd:nonNegativeInteger" // | Integer numbers ≥0 |
36+
export const XSD_NEGATIVEINTEGER = "xsd:negativeInteger" // | Integer numbers <0 |
37+
export const XSD_NONPOSITIVEINTEGER = "xsd:nonPositiveInteger" //Integer numbers ≤0
38+
39+
1440
export const XSD_DECIMAL="xsd:decimal"
15-
export const XSD_POSITIVE_INTEGER="xsd:positiveInteger"
41+
export const XSD_DOUBLE = "xsd:double"
42+
export const XSD_FLOAT= "xsd:float "
43+
1644
export const XSD_INTEGER="xsd:integer"
1745
export const XSD_DATE_TIME="xsd:dateTime"
46+
export const XSD_DATE_TIMESTAMP="xsd:dateTimeStamp"
1847
export const XSD_G_YEAR= "xsd:gYear"
48+
export const XSD_TIME= "xsd:time"
49+
export const XSD_G_YEAR_MONTH= "xsd:gYearMonth"
50+
export const XSD_G_YEAR_MONTH_DURACTION= "xsd:yearMonthDuration"
51+
export const XSD_G_DAY_TIME_DURACTION= "xsd:dayTimeDuration"
52+
53+
export const XSD_G_MONTH= "xsd:gMonth"
54+
export const XSD_G_MONTH_DAY= "xsd:gMonthDay"
55+
export const XSD_G_DAY= "xsd:gDay"
56+
export const XSD_TIME_DURATION= "xsd:duration"
1957
export const XSD_DATE= "xsd:date"
2058
export const XSD_BOOLEAN="xsd:boolean"
21-
export const XSD_LANGUAGE="xsd:language"
59+
60+
61+
62+
//rdf:langString
2263

2364
export const SYS_JSON_TYPE="sys:JSON"
2465

packages/tdb-documents-ui/src/dataTypeFrames/widget.js

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
import React from "react"
22
import {Form} from "react-bootstrap"
33
import Stack from 'react-bootstrap/Stack'
4-
import {
5-
XSD_STRING,
6-
XSD_DECIMAL,
7-
XSD_DATE_TIME,
8-
XSD_BOOLEAN,
9-
XSD_INTEGER,
10-
XSD_ANY_URI,
11-
STRING_TYPE,
12-
SYS_JSON_TYPE,
13-
NUMBER_TYPE,
14-
BOOLEAN_TYPE,
15-
DATE_TYPE,
16-
JSON_TYPE,
17-
XSD_G_YEAR,
18-
XSD_DATE,
19-
XDD_URL,
20-
XSD_FLOAT,
21-
XSD_LANGUAGE,
22-
XSD_POSITIVE_INTEGER
23-
} from "../constants"
4+
import * as DATATYPE from "../constants"
245

256

267
// function to provide a ui widget to date
@@ -66,21 +47,47 @@ export function getURIUIWidget(title) {
6647
return uiLayout
6748
}
6849

50+
const matchType ={
51+
[DATATYPE.XSD_STRING] : DATATYPE.STRING_TYPE,
52+
[DATATYPE.XSD_ANY_URI] : DATATYPE.STRING_TYPE,
53+
[DATATYPE.XSD_LANGUAGE] : DATATYPE.STRING_TYPE,
54+
[DATATYPE.RDF_LANGSTRING] :DATATYPE.STRING_TYPE,
55+
[DATATYPE.XDD_URL] : DATATYPE.STRING_TYPE,
56+
[DATATYPE.XSD_NAME] : DATATYPE.STRING_TYPE,
57+
[DATATYPE.XSD_NCNAME] : DATATYPE.STRING_TYPE,
58+
[DATATYPE.XSD_NMTOKEN] : DATATYPE.STRING_TYPE,
59+
[DATATYPE.XSD_NORMALIZED_STRING] :DATATYPE.STRING_TYPE,
60+
61+
[DATATYPE.SYS_JSON_TYPE] : DATATYPE.JSON_TYPE,
62+
63+
[DATATYPE.XSD_BYTE] : DATATYPE.NUMBER_TYPE,
64+
[DATATYPE.XSD_SHORT] : DATATYPE.NUMBER_TYPE,
65+
[DATATYPE.XSD_INT] : DATATYPE.NUMBER_TYPE,
66+
[DATATYPE.XSD_LONG] : DATATYPE.NUMBER_TYPE,
67+
68+
[DATATYPE.XSD_DOUBLE] : DATATYPE.NUMBER_TYPE,
69+
[DATATYPE.XSD_FLOAT] : DATATYPE.NUMBER_TYPE,
70+
[DATATYPE.XSD_POSITIVE_INTEGER] : DATATYPE.NUMBER_TYPE,
71+
[DATATYPE.XSD_NONPOSITIVEINTEGER] : DATATYPE.NUMBER_TYPE,
72+
[DATATYPE.XSD_NONNEGATIVEINTEGER] : DATATYPE.NUMBER_TYPE,
73+
[DATATYPE.XSD_NEGATIVEINTEGER] : DATATYPE.NUMBER_TYPE,
74+
75+
[DATATYPE.XSD_DECIMAL] : DATATYPE.NUMBER_TYPE,
76+
[DATATYPE.XSD_INTEGER] : DATATYPE.NUMBER_TYPE,
77+
78+
[DATATYPE.XSD_UNSINGNEDBYTE] : DATATYPE.NUMBER_TYPE,
79+
[DATATYPE.XSD_UNSIGNEDSHORT] : DATATYPE.NUMBER_TYPE,
80+
[DATATYPE.XSD_UNSIGNEDINT] : DATATYPE.NUMBER_TYPE,
81+
[DATATYPE.XSD_UNSIGNEDLONG] : DATATYPE.NUMBER_TYPE,
82+
83+
[DATATYPE.XSD_BOOLEAN] : DATATYPE.BOOLEAN_TYPE,
84+
[DATATYPE.XSD_DATE_TIME] : DATATYPE.DATE_TYPE,
85+
[DATATYPE.XSD_G_YEAR] : DATATYPE.DATE_TYPE,
86+
[DATATYPE.XSD_DATE] : DATATYPE.STRING_TYPE
87+
}
6988

7089
//get data type xsd: or xdd:
7190
// you can rewrite with an object
7291
export function getDataType(type) {
73-
if(type === XSD_STRING) return STRING_TYPE
74-
else if(type === XSD_FLOAT) return NUMBER_TYPE
75-
else if(type === XSD_ANY_URI) return STRING_TYPE
76-
else if(type === XSD_LANGUAGE) return STRING_TYPE
77-
else if(type === XDD_URL) return STRING_TYPE
78-
else if(type === SYS_JSON_TYPE) return JSON_TYPE
79-
else if(type === XSD_POSITIVE_INTEGER) return NUMBER_TYPE
80-
else if(type === XSD_DECIMAL) return NUMBER_TYPE
81-
else if(type === XSD_INTEGER) return NUMBER_TYPE
82-
else if(type === XSD_BOOLEAN) return BOOLEAN_TYPE
83-
else if(type === XSD_DATE_TIME) return DATE_TYPE
84-
else if(type === XSD_G_YEAR) return DATE_TYPE
85-
else if(type === XSD_DATE) return STRING_TYPE
92+
return matchType[type]
8693
}

packages/tdb-documents-ui/src/utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import React from "react"
33
import {Button, Form} from "react-bootstrap"
44
import {
55
XSD_DATA_TYPE_PREFIX,
6-
XDD_DATA_TYPE_PREFIX,
6+
XDD_DATA_TYPE_PREFIX,
7+
RDF_DATA_TYPE_PREFIX,
78
POINT_TYPE,
89
UI_FRAME_SELECT_STYLE,
910
UI_FRAME_SUBDOCUMENT_STYLE,
@@ -37,10 +38,12 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger'
3738
import Tooltip from 'react-bootstrap/Tooltip'
3839

3940
// returns true for properties which are of data types xsd and xdd
41+
const dataTypePrefix = {[XSD_DATA_TYPE_PREFIX]:true,
42+
[XDD_DATA_TYPE_PREFIX]:true,
43+
[RDF_DATA_TYPE_PREFIX]:true}
4044
export const isDataType = (property) => {
4145
if(typeof property === "object") return false
42-
if(property.substring(0, 4) === XSD_DATA_TYPE_PREFIX) return true
43-
if(property.substring(0, 4) === XDD_DATA_TYPE_PREFIX) return true
46+
return dataTypePrefix[ property.substring(0, 4)] || false
4447
}
4548

4649
export const isSysDataType = (property) => {

packages/tdb-react-components/demo/GraphApp.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, {useState,useEffect} from 'react';
33
import {WOQLGraph} from '@terminusdb/terminusdb-react-components';
44
import TerminusClient from '@terminusdb/terminusdb-client'
55
import person from './person-graph.json';
6-
import bike from './bike-journey.json';
6+
import bike from './bike-data.json';
77
import seshat from './seshat-data.json';
88
/*
99
*
@@ -17,7 +17,7 @@ export const GraphApp= (props) =>{
1717
let resultData={};
1818

1919

20-
const server=process.env.API_URL;
20+
const server=process.env.API_URL;
2121
const key=process.env.API_KEY
2222
const db=process.env.API_DB
2323

@@ -42,7 +42,10 @@ export const GraphApp= (props) =>{
4242
*/
4343
//
4444

45-
//woqlGraphConfig.edges(["v:Start", "v:Duration"], ["v:Duration", "v:End"]).text("v:Duration")
45+
woqlGraphConfig.edges(["v:Start", "v:Duration"], ["v:Duration", "v:End"]).text("v:Duration")
46+
/* woqlGraphConfig.edge("v:Property Domain", "v:Property Range").size(2).text("v:Property Name").arrow({width: 50, height: 20})
47+
.icon({label: true, color: [109,98,100], size: 0.8})*/
48+
4649
woqlGraphConfig.node("Start").text("Start_Label").icon({label: true, color:[0,0,0]}).color([35, 132, 113]).size(30)
4750

4851
woqlGraphConfig.node("End").text("End_Label").icon({label: true, color:[0,0,0]}).color([243, 183, 115]).size(30)
@@ -64,6 +67,10 @@ export const GraphApp= (props) =>{
6467

6568
}else{
6669
resultData=person;
70+
woqlGraphConfig.edge("Mother", "Person").size(2).text("Person").arrow({width: 50, height: 20})
71+
.icon({label: true, color: [109,98,100], size: 0.8})
72+
73+
6774
woqlGraphConfig.node("Mother").text("Mother_Name").color([60, 219, 11])//.size(10)
6875

6976
woqlGraphConfig.node("Mother","Mother_Name").in("motherOfMaria01").color([255, 0, 255])//.size(10)

0 commit comments

Comments
 (0)