@terminusdb/terminusdb-documents-ui

6.0.10 • Public • Published

terminusdb-documents-ui

SDK to build UI from terminusdb documents

Run playground

Run playground to get a demo.

Create a new data product in TerminusCMS and name it Playground. Go to /product_model page and copy paste the schema from file - playground/src/schema.json.

Make a .env file and add the following

SERVER=https://cloud.terminusdb.com/ 
USER=<your email>
TEAM=<your team>
DATA_PRODUCT="Playground"
TOKEN=<your token>

After adding .env file, run the below command npm run playground

Run test

To connect to a particular data product in TerminusCMS - add the following variables to .env file

SERVER=https://cloud.terminusdb.com/
USER=<your email>
TEAM=<your team>
DATA_PRODUCT=<your data product ID>
TOKEN=<your token>

After adding .env file, run the below command npm run test

Installation

Install the dependancy from npm

npm install @terminusdb/terminusdb-documents-ui

Then import dependancy as shown below

import {FrameViewer} from '@terminusdb/terminusdb-documents-ui'

Usage

Create

    let frame = "Person": {
	  "@key": {
		"@fields": [
		  "name",
		  "works_as"
		],
		"@type": "Lexical"
	  },
	  "@type": "Class",
	  "likes": {
		"@class": {
		  "@id": "Color",
		  "@type": "Enum",
		  "@values": [
			"red",
			"blue",
			"green"
		  ]
		},
		"@type": "Optional"
	  },
	  "name": "xsd:string"
	}

    return <FrameViewer
        frame={frame}
        mode={"Create"}
        type={"Person"}/>

View

Note - make sure filled document is provided in View mode

    let frame = "Person": {
	  "@key": {
		"@fields": [
		  "name",
		  "works_as"
		],
		"@type": "Lexical"
	  },
	  "@type": "Class",
	  "likes": {
		"@class": {
		  "@id": "Color",
		  "@type": "Enum",
		  "@values": [
			"red",
			"blue",
			"green"
		  ]
		},
		"@type": "Optional"
	  },
	  "name": "xsd:string"
	}

    let data = {
        "@id": "Person/Peter%20+terminusdb%3A%2F%2F%2Fdata%2FJob%2Fadmin",
        "@type": "Person",
        "likes": "blue",
        "name": "Peter "
    }

    return <FrameViewer
        frame={frame}
        mode={"View"}
        formData={data}
        type={"Person"}/>

Package Sidebar

Install

npm i @terminusdb/terminusdb-documents-ui

Weekly Downloads

3

Version

6.0.10

License

Apache-2.0

Unpacked Size

7.69 MB

Total Files

317

Last publish

Collaborators

  • gavin.mendel.gleason
  • matko-tdb
  • f-bit
  • robinterminus