Skip to content

Commit 577d6ad

Browse files
Kitty JoseKitty Jose
authored andcommitted
adding documents-ui to terminusdb-dashboard
1 parent d1c0eaf commit 577d6ad

File tree

121 files changed

+96950
-24623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+96950
-24623
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"./packages/react-worker",
66
"./packages/tdb-react-layout",
77
"./packages/tdb-access-control-component",
8-
"./packages/tdb-dashboard"
8+
"./packages/tdb-dashboard",
9+
"./packages/tdb-documents-ui"
910
]
1011
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useState, useEffect} from "react"
22
import {WOQLClientObj} from '../init-woql-client'
33
import {MenuItem, SubMenu} from 'react-pro-sidebar'
4-
import 'react-pro-sidebar/dist/css/styles.css'
4+
import 'react-pro-sidebar/dist/css/styles.css'
55
import {QueryPaneObj} from "../hooks/queryPaneContext"
66
//import {DatabaseInfoControl} from "../hooks/DatabaseInfoControl"
77
import {getPropertiesOfClass, getPropertyRelation, getDocumentClasses} from '../queries/GeneralQueries'
@@ -52,6 +52,7 @@ export const DataProductDocuments = () => {
5252

5353

5454
async function handleClassClick (id) {
55+
5556
try{
5657
let db=woqlClient.db()
5758
const result = await woqlClient.getSchemaFrame(id, db)
@@ -71,6 +72,7 @@ export const DataProductDocuments = () => {
7172

7273
useEffect(() => { // get count of document classes
7374
if(!documentClasses) return
75+
console.log(" i enter here ")
7476
let q=getCountOfDocumentClass(documentClasses)
7577
setQuery(q)
7678
}, [documentClasses])
@@ -187,10 +189,7 @@ export const DocumentExplorerDocuments = () => {
187189
title={`View documents of type ${item["@id"]}`}
188190
onClick={(e) => handleClassClick(item["@id"])}
189191
disabled={disabled}>
190-
191-
192192
<span className="text-gray">{item["@id"]}</span>
193-
194193
</Button>
195194
{actionControl.write && <Button
196195
className="btn-create-document pro-item-content btn-sm"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const DocumentFrames = () => {
130130
//console.log("documentObject", documentObject.message)
131131

132132
//console.log("refreshedDocumentObject in doc frame", documentObjectWithFrames)
133+
133134
if(loading) return <Loading message={`Fetching frames ...`} type={PROGRESS_BAR_COMPONENT}/>
134135

135136
return <main className="content mr-3 ml-5 w-100">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const DocumentInfo = () => {
7878
}
7979

8080
function onTraverse(clicked) {
81-
console.log("clicked", clicked)
81+
8282
var previous = []
8383
if(Array.isArray(documentObject.previous)) {
8484
previous = documentObject.previous

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {DocumentControlObj} from '../hooks/DocumentControlContext'
2020

2121
export const DocumentSummary = () => {
2222

23-
2423
const {dataProduct,organization} = useParams()
2524

2625
const getUrl = (pageName)=> {

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ export const DocumentView = () => {
8282
if(documentClasses){
8383
setBarLoading(false)
8484
}
85-
}, [documentClasses])
85+
}, [documentClasses])
86+
87+
/*useEffect(() => {
88+
if(!perDocumentCount) return
89+
if(!documentClasses) return
90+
setBarLoading(false)
91+
}, [documentObjectWithFrames.update])*/
8692

8793
useEffect(() => {
8894
setBarLoading(true)
@@ -110,6 +116,7 @@ export const DocumentView = () => {
110116

111117
function extractDocuments(documentResults) {
112118
var extractedResults=[]
119+
113120
documentResults.map(item=> {
114121
var newJson={}
115122
for(var key in item){
@@ -124,15 +131,18 @@ export const DocumentView = () => {
124131
newJson[key]=newArray
125132
}
126133
}
127-
else if(item[key]["@id"]){ // object
128-
newJson[key]=item[key]["@id"]
134+
else if(typeof item[key] === "object"){
135+
if(item[key].hasOwnProperty("@id")){ // object - we do not display sys json data as part of table
136+
newJson[key]=item[key]["@id"]
137+
}
129138
}
130139
else {
131140
newJson[key]=item[key]
132141
}
133142
}
134143
extractedResults.push(newJson)
135144
})
145+
//console.log("extractedResults", extractedResults)
136146
return extractedResults
137147
}
138148

@@ -188,7 +198,6 @@ export const DocumentView = () => {
188198
})
189199
}
190200

191-
192201
if(barloading){
193202
var message
194203
if(!documentObjectWithFrames.action) message = `Fetching documents of ${dataProduct}`
@@ -197,8 +206,6 @@ export const DocumentView = () => {
197206
return <Loading message={message}/>
198207
}
199208

200-
//console.log("documentResults", documentResults)
201-
202209
if(!actionControl.read && !actionControl.write) {
203210
// info reader access control
204211
return <React.Fragment>
@@ -286,6 +293,7 @@ export const DocumentView = () => {
286293
documentObjectWithFrames.update &&
287294
<DocumentFrames/>}
288295

296+
289297
</Row>
290298
</React.Fragment>
291299

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,29 @@ export function displayIDOfLinkedDocuments (results) {
222222
return newResults
223223
}
224224

225+
/**
226+
* Note - maybe should move this logic to client.getDocumentClasses
227+
* @param {*} classRes - document classes
228+
* @returns - returns formatted document classes withour prefixes
229+
*/
230+
export function formatClassResults(classRes) {
231+
if(!Array.isArray(classRes)) return classRes
232+
let formatted=[]
233+
classRes.map(classes => {
234+
let newFormatted={}
235+
for(var item in classes) {
236+
if(item === "@id") {
237+
let variableID=classes["@id"]
238+
let splitWords = classes[item].split(":")
239+
if(splitWords.length > 1) { // prefix included in class name
240+
variableID=splitWords[1]
241+
}
242+
newFormatted["@id"]=variableID
243+
}
244+
else newFormatted[item]=classes[item]
245+
}
246+
formatted.push(newFormatted)
247+
})
248+
return formatted
249+
}
250+

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {executeQueryHook} from "./executeQueryHook"
44
//import {getDocumentClasses, getDocumentsOfType} from "../queries/GeneralQueries"
55
import {SCHEMA_GRAPH_TYPE, TERMINUS_SUCCESS, TERMINUS_DANGER, CREATE_DOCUMENT, EDIT_DOCUMENT,VIEW_DOCUMENT, GET_FRAMES_DOCUMENT, FORM_VIEW} from "../components/constants"
66
import {Alerts} from "../components/Alerts"
7-
import { getTotalNumberOfDocuments } from "../queries/GeneralQueries"
87
import {Loading} from "../components/Loading"
98
import {PROGRESS_BAR_COMPONENT} from "../components/constants"
109
//import {pendoMsgAfterCreateDocument} from "../trackWithPendo"

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,24 @@ import {addNewDocument, updateDocument, getDocumentFrame, getCurrentDocumentInfo
99
export const DocumentControlProvider = ({children}) => {
1010
const {
1111
woqlClient,
12-
// setSelectedDocument,
1312
selectedDocument,
1413
accessControlDashboard
1514
} = WOQLClientObj()
1615

16+
1717
// access control constants based on access control priviliges
1818
const [actionControl, setActionControl]=useState({})
1919

20-
//let tempControl={ read: true, write: true } // admin
21-
//let tempControl={ read: true, write: false } // Data reader
22-
//let tempControl={ read: false, write: false } // info reader
23-
24-
2520
useState(() => {
2621
if(accessControlDashboard) {
2722
let control={
2823
read: false,
2924
write: false
3025
}
3126
if(accessControlDashboard.instanceRead()) {
32-
//if(tempControl.read) {
3327
control.read=true
3428
}
3529
if(accessControlDashboard.instanceWrite()) {
36-
//if(tempControl.write) {
3730
control.write=true
3831
}
3932
setActionControl(control)
@@ -137,6 +130,7 @@ export const DocumentControlProvider = ({children}) => {
137130
}
138131
}, [originalFrames])
139132

133+
140134
return (
141135
<DocumentControlContext.Provider
142136
value={{

0 commit comments

Comments
 (0)