mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
lint fixes and formatting
This commit is contained in:
parent
281d28e6ae
commit
868788e614
1752
package-lock.json
generated
1752
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -39,6 +39,7 @@
|
|||||||
"prettier": "^1.16.2",
|
"prettier": "^1.16.2",
|
||||||
"prettier-stylelint": "^0.4.2",
|
"prettier-stylelint": "^0.4.2",
|
||||||
"react-scripts": "2.1.3",
|
"react-scripts": "2.1.3",
|
||||||
|
"stylelint": "^9.10.1",
|
||||||
"stylelint-config-bigchaindb": "^1.2.1",
|
"stylelint-config-bigchaindb": "^1.2.1",
|
||||||
"stylelint-config-css-modules": "^1.3.0",
|
"stylelint-config-css-modules": "^1.3.0",
|
||||||
"stylelint-config-standard": "^18.2.0",
|
"stylelint-config-standard": "^18.2.0",
|
||||||
|
28
src/App.tsx
28
src/App.tsx
@ -6,20 +6,16 @@ import { provideOcean } from './ocean'
|
|||||||
import Routes from './Routes'
|
import Routes from './Routes'
|
||||||
import './styles/global.scss'
|
import './styles/global.scss'
|
||||||
|
|
||||||
import {
|
import { nodeHost, nodePort, nodeScheme } from './config'
|
||||||
nodeHost,
|
|
||||||
nodePort,
|
|
||||||
nodeScheme
|
|
||||||
} from './config'
|
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
isLogged: boolean,
|
isLogged: boolean
|
||||||
web3: any,
|
web3: any
|
||||||
ocean: {},
|
ocean: {}
|
||||||
startLogin: () => void,
|
startLogin: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class App extends Component<{},IState> {
|
class App extends Component<{}, IState> {
|
||||||
public startLogin: () => void
|
public startLogin: () => void
|
||||||
constructor(props: {}) {
|
constructor(props: {}) {
|
||||||
super(props)
|
super(props)
|
||||||
@ -33,7 +29,7 @@ class App extends Component<{},IState> {
|
|||||||
isLogged: false,
|
isLogged: false,
|
||||||
web3: {},
|
web3: {},
|
||||||
ocean: {},
|
ocean: {},
|
||||||
startLogin: this.startLogin,
|
startLogin: this.startLogin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +48,7 @@ class App extends Component<{},IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private startLoginProcess = async () => {
|
private startLoginProcess = async () => {
|
||||||
if((window as any).web3) {
|
if ((window as any).web3) {
|
||||||
const web3 = new Web3((window as any).web3.currentProvider)
|
const web3 = new Web3((window as any).web3.currentProvider)
|
||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
@ -79,7 +75,7 @@ class App extends Component<{},IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bootstrap = async () => {
|
private bootstrap = async () => {
|
||||||
if((window as any).web3) {
|
if ((window as any).web3) {
|
||||||
const web3 = new Web3((window as any).web3.currentProvider)
|
const web3 = new Web3((window as any).web3.currentProvider)
|
||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
@ -102,7 +98,11 @@ class App extends Component<{},IState> {
|
|||||||
private setDefaultProvider = () => {
|
private setDefaultProvider = () => {
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
isLogged: false,
|
isLogged: false,
|
||||||
web3: new Web3(new Web3.providers.HttpProvider(`${nodeScheme}://${nodeHost}:${nodePort}`))
|
web3: new Web3(
|
||||||
|
new Web3.providers.HttpProvider(
|
||||||
|
`${nodeScheme}://${nodeHost}:${nodePort}`
|
||||||
|
)
|
||||||
|
)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,7 @@ export const User = React.createContext({
|
|||||||
isLogged: false,
|
isLogged: false,
|
||||||
web3: {},
|
web3: {},
|
||||||
ocean: {},
|
ocean: {},
|
||||||
startLogin: () => {/* empty */}
|
startLogin: () => {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,40 +1,42 @@
|
|||||||
const AssetModel = {
|
const AssetModel = {
|
||||||
'assetId': null,
|
assetId: null,
|
||||||
'publisherId': null,
|
publisherId: null,
|
||||||
|
|
||||||
// OEP-08 Attributes
|
// OEP-08 Attributes
|
||||||
// https://github.com/oceanprotocol/OEPs/tree/master/8
|
// https://github.com/oceanprotocol/OEPs/tree/master/8
|
||||||
'base': {
|
base: {
|
||||||
'name': null,
|
name: null,
|
||||||
'description': null,
|
description: null,
|
||||||
'dateCreated': null,
|
dateCreated: null,
|
||||||
'size': null,
|
size: null,
|
||||||
'author': null,
|
author: null,
|
||||||
'type': '',
|
type: '',
|
||||||
'license': null,
|
license: null,
|
||||||
'copyrightHolder': null,
|
copyrightHolder: null,
|
||||||
'encoding': null,
|
encoding: null,
|
||||||
'compression': null,
|
compression: null,
|
||||||
'contentType': null,
|
contentType: null,
|
||||||
'workExample': null,
|
workExample: null,
|
||||||
'contentUrls': [],
|
contentUrls: [],
|
||||||
'links': [{
|
links: [
|
||||||
'name': null,
|
{
|
||||||
'type': null,
|
name: null,
|
||||||
'url': null
|
type: null,
|
||||||
}],
|
url: null
|
||||||
'inLanguage': null,
|
}
|
||||||
'tags': [],
|
],
|
||||||
'price': null
|
inLanguage: null,
|
||||||
|
tags: [],
|
||||||
|
price: null
|
||||||
},
|
},
|
||||||
'curation': {
|
curation: {
|
||||||
'rating': null,
|
rating: null,
|
||||||
'numVotes': null,
|
numVotes: null,
|
||||||
'schema': null
|
schema: null
|
||||||
},
|
},
|
||||||
'additionalInformation': {
|
additionalInformation: {
|
||||||
'updateFrequency': null,
|
updateFrequency: null,
|
||||||
'structuredMarkup': []
|
structuredMarkup: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import {
|
import { Ocean } from '@oceanprotocol/squid/dist/node/squid'
|
||||||
Ocean
|
|
||||||
} from '@oceanprotocol/squid/dist/node/squid'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
address,
|
address,
|
||||||
|
@ -6,13 +6,11 @@ class About extends Component {
|
|||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.about}>
|
<div className={styles.about}>
|
||||||
|
|
||||||
<Button>I am a button</Button>
|
<Button>I am a button</Button>
|
||||||
<Button primary={true}>I am a primary button</Button>
|
<Button primary={true}>I am a primary button</Button>
|
||||||
<Button href="https://hello.com">
|
<Button href="https://hello.com">
|
||||||
I am a link disguised as a button
|
I am a link disguised as a button
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -4,29 +4,34 @@ import React, { Component } from 'react'
|
|||||||
import { User } from '../context/User'
|
import { User } from '../context/User'
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
ddo: any,
|
ddo: any
|
||||||
metadata: any
|
metadata: any
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
location: any,
|
location: any
|
||||||
match: any
|
match: any
|
||||||
}
|
}
|
||||||
|
|
||||||
class Details extends Component<IProps, IState> {
|
class Details extends Component<IProps, IState> {
|
||||||
|
|
||||||
public state = { ddo: null, metadata: null }
|
public state = { ddo: null, metadata: null }
|
||||||
|
|
||||||
public async componentDidMount() {
|
public async componentDidMount() {
|
||||||
const ddo = await this.context.ocean.resolveDID(this.props.match.params.did)
|
const ddo = await this.context.ocean.resolveDID(
|
||||||
|
this.props.match.params.did
|
||||||
|
)
|
||||||
const { metadata } = ddo.findServiceByType('Metadata')
|
const { metadata } = ddo.findServiceByType('Metadata')
|
||||||
this.setState({ddo, metadata})
|
this.setState({ ddo, metadata })
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.state.metadata ? (this.showDetails(this.state.ddo)): (<div>Loading</div>)}
|
{this.state.metadata ? (
|
||||||
|
this.showDetails(this.state.ddo)
|
||||||
|
) : (
|
||||||
|
<div>Loading</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -34,29 +39,36 @@ class Details extends Component<IProps, IState> {
|
|||||||
private purchaseAsset = async (ddo: any) => {
|
private purchaseAsset = async (ddo: any) => {
|
||||||
const account = await this.context.ocean.getAccounts()
|
const account = await this.context.ocean.getAccounts()
|
||||||
const service = ddo.findServiceByType('Access')
|
const service = ddo.findServiceByType('Access')
|
||||||
const serviceAgreementSignatureResult: any = await this.context.ocean
|
const serviceAgreementSignatureResult: any = await this.context.ocean.signServiceAgreement(
|
||||||
.signServiceAgreement(
|
ddo.id,
|
||||||
ddo.id,
|
service.serviceDefinitionId,
|
||||||
service.serviceDefinitionId,
|
account[0]
|
||||||
account[0])
|
)
|
||||||
Logger.log('serviceAgreementSignatureResult', serviceAgreementSignatureResult)
|
Logger.log(
|
||||||
|
'serviceAgreementSignatureResult',
|
||||||
|
serviceAgreementSignatureResult
|
||||||
|
)
|
||||||
|
|
||||||
await this.context.ocean
|
await this.context.ocean.initializeServiceAgreement(
|
||||||
.initializeServiceAgreement(
|
ddo.id,
|
||||||
ddo.id,
|
service.serviceDefinitionId,
|
||||||
service.serviceDefinitionId,
|
serviceAgreementSignatureResult.serviceAgreementId,
|
||||||
serviceAgreementSignatureResult.serviceAgreementId,
|
serviceAgreementSignatureResult.serviceAgreementSignature,
|
||||||
serviceAgreementSignatureResult.serviceAgreementSignature,
|
(files: any) =>
|
||||||
(files: any) => Logger.log(`Got files, first files length in bytes: ${files[0].length}`),
|
Logger.log(
|
||||||
account[0],
|
`Got files, first files length in bytes: ${files[0].length}`
|
||||||
)
|
),
|
||||||
|
account[0]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private showDetails = (ddo: any) => {
|
private showDetails = (ddo: any) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>{JSON.stringify(this.state.metadata)}</div>
|
<div>{JSON.stringify(this.state.metadata)}</div>
|
||||||
<button onClick={this.purchaseAsset.bind(this, ddo)}>Purchase asset</button>
|
<button onClick={this.purchaseAsset.bind(this, ddo)}>
|
||||||
|
Purchase asset
|
||||||
|
</button>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Home extends Component<IProps, IState> {
|
class Home extends Component<IProps, IState> {
|
||||||
|
|
||||||
public state = { search: '' }
|
public state = { search: '' }
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
@ -21,11 +20,15 @@ class Home extends Component<IProps, IState> {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={this.searchAssets}>
|
<form onSubmit={this.searchAssets}>
|
||||||
<input type="text" name="search" value={this.state.search} onChange={this.inputChange} />
|
<input
|
||||||
|
type="text"
|
||||||
|
name="search"
|
||||||
|
value={this.state.search}
|
||||||
|
onChange={this.inputChange}
|
||||||
|
/>
|
||||||
<Button>Search</Button>
|
<Button>Search</Button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,20 @@ import AssetModel from '../models/AssetModel'
|
|||||||
type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other'
|
type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other'
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
name?: string,
|
name?: string
|
||||||
dateCreated?: Date,
|
dateCreated?: Date
|
||||||
description?: string,
|
description?: string
|
||||||
files?: string[],
|
files?: string[]
|
||||||
price?: number,
|
price?: number
|
||||||
author?: string,
|
author?: string
|
||||||
type?: AssetType,
|
type?: AssetType
|
||||||
license?: string,
|
license?: string
|
||||||
copyrightHolder?: string,
|
copyrightHolder?: string
|
||||||
categories?: string[],
|
categories?: string[]
|
||||||
tags?: string[]
|
tags?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
class Publish extends Component<{}, IState> {
|
class Publish extends Component<{}, IState> {
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
name: '',
|
name: '',
|
||||||
dateCreated: new Date(),
|
dateCreated: new Date(),
|
||||||
@ -31,7 +30,7 @@ class Publish extends Component<{}, IState> {
|
|||||||
type: 'dataset' as AssetType,
|
type: 'dataset' as AssetType,
|
||||||
license: '',
|
license: '',
|
||||||
copyrightHolder: '',
|
copyrightHolder: '',
|
||||||
categories: [''],
|
categories: ['']
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
@ -39,89 +38,215 @@ class Publish extends Component<{}, IState> {
|
|||||||
<div>
|
<div>
|
||||||
<h1>Publish</h1>
|
<h1>Publish</h1>
|
||||||
<form onSubmit={this.registerAsset}>
|
<form onSubmit={this.registerAsset}>
|
||||||
<div>Name:<input type="text" name="name" value={this.state.name} onChange={this.inputChange} /></div>
|
<div>
|
||||||
<div>Description:<input type="text" name="description" value={this.state.description} onChange={this.inputChange} /></div>
|
Name:
|
||||||
<div>Price:<input type="number" name="price" value={this.state.price} onChange={this.inputChange} /></div>
|
<input
|
||||||
<div>Author:<input type="text" name="author" value={this.state.author} onChange={this.inputChange} /></div>
|
type="text"
|
||||||
<div>Files:<input type="text" name="files" value={this.state.files[0]} onChange={this.inputToArrayChange} /></div>
|
name="name"
|
||||||
<div>Type:
|
value={this.state.name}
|
||||||
<select name="type" value={this.state.type} onChange={this.inputChange}>
|
onChange={this.inputChange}
|
||||||
<option value="dataset">Data set</option>
|
/>
|
||||||
<option value="algorithm">Algorithm</option>
|
</div>
|
||||||
<option value="container">Container</option>
|
<div>
|
||||||
<option value="workflow">Workflow</option>
|
Description:
|
||||||
<option value="other">Other</option>
|
<input
|
||||||
</select>
|
type="text"
|
||||||
</div>
|
name="description"
|
||||||
<div>License:
|
value={this.state.description}
|
||||||
<select name="license" value={this.state.license} onChange={this.inputChange}>
|
onChange={this.inputChange}
|
||||||
<option value="none">No License Specified</option>
|
/>
|
||||||
<option value="Public Domain">Public Domain</option>
|
</div>
|
||||||
<option value="CC BY">CC BY: Attribution</option>
|
<div>
|
||||||
<option value="CC BY-SA">CC BY-SA: Attribution ShareAlike</option>
|
Price:
|
||||||
<option value="CC BY-ND">CC BY-ND: Attribution-NoDerivs</option>
|
<input
|
||||||
<option value="CC BY-NC">CC BY-NC: Attribution-NonCommercial</option>
|
type="number"
|
||||||
<option value="CC BY-NC-SA">CC BY-NC-SA: Attribution-NonCommercial-ShareAlike</option>
|
name="price"
|
||||||
<option value="CC BY-NC-ND">CC BY-NC-ND: Attribution-NonCommercial-NoDerivs</option>
|
value={this.state.price}
|
||||||
</select>
|
onChange={this.inputChange}
|
||||||
</div>
|
/>
|
||||||
<div>Category:
|
</div>
|
||||||
<select name="categories" value={this.state.categories[0]} onChange={this.inputToArrayChange}>
|
<div>
|
||||||
<option value="No Category Specified">No Category Specified</option>
|
Author:
|
||||||
<option value="Image Recognition">Image Recognition</option>
|
<input
|
||||||
<option value="Dataset Of Datasets">Dataset Of Datasets</option>
|
type="text"
|
||||||
<option value="Language">Language</option>
|
name="author"
|
||||||
<option value="Performing Arts">Performing Arts</option>
|
value={this.state.author}
|
||||||
<option value="Visual Arts & Design">Visual Arts & Design</option>
|
onChange={this.inputChange}
|
||||||
<option value="Philosophy">Philosophy</option>
|
/>
|
||||||
<option value="History">History</option>
|
</div>
|
||||||
<option value="Theology">Theology</option>
|
<div>
|
||||||
<option value="Anthropology & Archeology">Anthropology & Archeology</option>
|
Files:
|
||||||
<option value="Sociology">Sociology</option>
|
<input
|
||||||
<option value="Psychology">Psychology</option>
|
type="text"
|
||||||
<option value="Politics">Politics</option>
|
name="files"
|
||||||
<option value="Interdisciplinary">Interdisciplinary</option>
|
value={this.state.files[0]}
|
||||||
<option value="Economics & Finance">Economics & Finance</option>
|
onChange={this.inputToArrayChange}
|
||||||
<option value="Demography">Demography</option>
|
/>
|
||||||
<option value="Biology">Biology</option>
|
</div>
|
||||||
<option value="Chemistry">Chemistry</option>
|
<div>
|
||||||
<option value="Physics & Energy">Physics & Energy</option>
|
Type:
|
||||||
<option value="Earth & Climate">Earth & Climate</option>
|
<select
|
||||||
<option value="Space & Astronomy">Space & Astronomy</option>
|
name="type"
|
||||||
<option value="Mathematics">Mathematics</option>
|
value={this.state.type}
|
||||||
<option value="Computer Technology">Computer Technology</option>
|
onChange={this.inputChange}
|
||||||
<option value="Engineering">Engineering</option>
|
>
|
||||||
<option value="Agriculture & Bio Engineering">Agriculture & Bio Engineering</option>
|
<option value="dataset">Data set</option>
|
||||||
<option value="Transportation">Transportation</option>
|
<option value="algorithm">Algorithm</option>
|
||||||
<option value="Urban Planning">Urban Planning</option>
|
<option value="container">Container</option>
|
||||||
<option value="Medicine">Medicine</option>
|
<option value="workflow">Workflow</option>
|
||||||
<option value="Language">Language</option>
|
<option value="other">Other</option>
|
||||||
<option value="Business & Management">Business & Management</option>
|
</select>
|
||||||
<option value="Sports & Recreation">Sports & Recreation</option>
|
</div>
|
||||||
<option value="Communication & Journalism">Communication & Journalism</option>
|
<div>
|
||||||
<option value="Other">Other</option>
|
License:
|
||||||
</select>
|
<select
|
||||||
</div>
|
name="license"
|
||||||
<div>CopyrightHolder:<input type="text" name="copyrightHolder" value={this.state.copyrightHolder} onChange={this.inputChange} /></div>
|
value={this.state.license}
|
||||||
<User.Consumer>
|
onChange={this.inputChange}
|
||||||
{states => ( /* tslint:disable-next-line */
|
>
|
||||||
<div>
|
<option value="none">No License Specified</option>
|
||||||
{states.isLogged ? (<div><Button>Register asset (we are logged)</Button></div>) : (<div><button onClick={states.startLogin}>Register asset (login first)</button></div>)}
|
<option value="Public Domain">Public Domain</option>
|
||||||
</div>
|
<option value="CC BY">CC BY: Attribution</option>
|
||||||
)}
|
<option value="CC BY-SA">
|
||||||
</User.Consumer>
|
CC BY-SA: Attribution ShareAlike
|
||||||
|
</option>
|
||||||
|
<option value="CC BY-ND">
|
||||||
|
CC BY-ND: Attribution-NoDerivs
|
||||||
|
</option>
|
||||||
|
<option value="CC BY-NC">
|
||||||
|
CC BY-NC: Attribution-NonCommercial
|
||||||
|
</option>
|
||||||
|
<option value="CC BY-NC-SA">
|
||||||
|
CC BY-NC-SA:
|
||||||
|
Attribution-NonCommercial-ShareAlike
|
||||||
|
</option>
|
||||||
|
<option value="CC BY-NC-ND">
|
||||||
|
CC BY-NC-ND: Attribution-NonCommercial-NoDerivs
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Category:
|
||||||
|
<select
|
||||||
|
name="categories"
|
||||||
|
value={this.state.categories[0]}
|
||||||
|
onChange={this.inputToArrayChange}
|
||||||
|
>
|
||||||
|
<option value="No Category Specified">
|
||||||
|
No Category Specified
|
||||||
|
</option>
|
||||||
|
<option value="Image Recognition">
|
||||||
|
Image Recognition
|
||||||
|
</option>
|
||||||
|
<option value="Dataset Of Datasets">
|
||||||
|
Dataset Of Datasets
|
||||||
|
</option>
|
||||||
|
<option value="Language">Language</option>
|
||||||
|
<option value="Performing Arts">
|
||||||
|
Performing Arts
|
||||||
|
</option>
|
||||||
|
<option value="Visual Arts & Design">
|
||||||
|
Visual Arts & Design
|
||||||
|
</option>
|
||||||
|
<option value="Philosophy">Philosophy</option>
|
||||||
|
<option value="History">History</option>
|
||||||
|
<option value="Theology">Theology</option>
|
||||||
|
<option value="Anthropology & Archeology">
|
||||||
|
Anthropology & Archeology
|
||||||
|
</option>
|
||||||
|
<option value="Sociology">Sociology</option>
|
||||||
|
<option value="Psychology">Psychology</option>
|
||||||
|
<option value="Politics">Politics</option>
|
||||||
|
<option value="Interdisciplinary">
|
||||||
|
Interdisciplinary
|
||||||
|
</option>
|
||||||
|
<option value="Economics & Finance">
|
||||||
|
Economics & Finance
|
||||||
|
</option>
|
||||||
|
<option value="Demography">Demography</option>
|
||||||
|
<option value="Biology">Biology</option>
|
||||||
|
<option value="Chemistry">Chemistry</option>
|
||||||
|
<option value="Physics & Energy">
|
||||||
|
Physics & Energy
|
||||||
|
</option>
|
||||||
|
<option value="Earth & Climate">
|
||||||
|
Earth & Climate
|
||||||
|
</option>
|
||||||
|
<option value="Space & Astronomy">
|
||||||
|
Space & Astronomy
|
||||||
|
</option>
|
||||||
|
<option value="Mathematics">Mathematics</option>
|
||||||
|
<option value="Computer Technology">
|
||||||
|
Computer Technology
|
||||||
|
</option>
|
||||||
|
<option value="Engineering">Engineering</option>
|
||||||
|
<option value="Agriculture & Bio Engineering">
|
||||||
|
Agriculture & Bio Engineering
|
||||||
|
</option>
|
||||||
|
<option value="Transportation">
|
||||||
|
Transportation
|
||||||
|
</option>
|
||||||
|
<option value="Urban Planning">
|
||||||
|
Urban Planning
|
||||||
|
</option>
|
||||||
|
<option value="Medicine">Medicine</option>
|
||||||
|
<option value="Language">Language</option>
|
||||||
|
<option value="Business & Management">
|
||||||
|
Business & Management
|
||||||
|
</option>
|
||||||
|
<option value="Sports & Recreation">
|
||||||
|
Sports & Recreation
|
||||||
|
</option>
|
||||||
|
<option value="Communication & Journalism">
|
||||||
|
Communication & Journalism
|
||||||
|
</option>
|
||||||
|
<option value="Other">Other</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
CopyrightHolder:
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="copyrightHolder"
|
||||||
|
value={this.state.copyrightHolder}
|
||||||
|
onChange={this.inputChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<User.Consumer>
|
||||||
|
{(states /* tslint:disable-next-line */) => (
|
||||||
|
<div>
|
||||||
|
{states.isLogged ? (
|
||||||
|
<div>
|
||||||
|
<Button>
|
||||||
|
Register asset (we are logged)
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<button onClick={states.startLogin}>
|
||||||
|
Register asset (login first)
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</User.Consumer>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inputChange = (event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>) => {
|
private inputChange = (
|
||||||
|
event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
|
||||||
|
) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
[event.target.name]: event.target.value
|
[event.target.name]: event.target.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private inputToArrayChange = (event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>) => {
|
private inputToArrayChange = (
|
||||||
|
event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
|
||||||
|
) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
[event.target.name]: [event.target.value]
|
[event.target.name]: [event.target.value]
|
||||||
})
|
})
|
||||||
@ -136,7 +261,7 @@ class Publish extends Component<{}, IState> {
|
|||||||
base: Object.assign(AssetModel.base, {
|
base: Object.assign(AssetModel.base, {
|
||||||
name: this.state.name,
|
name: this.state.name,
|
||||||
description: this.state.description,
|
description: this.state.description,
|
||||||
dateCreated: (new Date()).toString(),
|
dateCreated: new Date().toString(),
|
||||||
author: this.state.author,
|
author: this.state.author,
|
||||||
license: this.state.license,
|
license: this.state.license,
|
||||||
copyrightHolder: this.state.copyrightHolder,
|
copyrightHolder: this.state.copyrightHolder,
|
||||||
@ -152,7 +277,9 @@ class Publish extends Component<{}, IState> {
|
|||||||
tags: ''
|
tags: ''
|
||||||
}),
|
}),
|
||||||
curation: Object.assign(AssetModel.curation),
|
curation: Object.assign(AssetModel.curation),
|
||||||
additionalInformation: Object.assign(AssetModel.additionalInformation)
|
additionalInformation: Object.assign(
|
||||||
|
AssetModel.additionalInformation
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const ddo = await this.context.ocean.registerAsset(newAsset, account[0])
|
const ddo = await this.context.ocean.registerAsset(newAsset, account[0])
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,11 @@ interface IState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
location: any,
|
location: any
|
||||||
history: any
|
history: any
|
||||||
}
|
}
|
||||||
|
|
||||||
class Search extends Component<IProps, IState> {
|
class Search extends Component<IProps, IState> {
|
||||||
|
|
||||||
public state = { results: [] }
|
public state = { results: [] }
|
||||||
|
|
||||||
public async componentDidMount() {
|
public async componentDidMount() {
|
||||||
@ -30,18 +29,22 @@ class Search extends Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const assets = await ocean.searchAssets(queryRequest)
|
const assets = await ocean.searchAssets(queryRequest)
|
||||||
this.setState(state => ({results:assets}))
|
this.setState(state => ({ results: assets }))
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.state.results.length ? (this.state.results.map(asset => this.renderAssetBox(asset))): (<div>No data sets yet</div>)}
|
{this.state.results.length ? (
|
||||||
|
this.state.results.map(asset => this.renderAssetBox(asset))
|
||||||
|
) : (
|
||||||
|
<div>No data sets yet</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderAssetBox = (asset:any) => {
|
private renderAssetBox = (asset: any) => {
|
||||||
const { metadata } = asset.findServiceByType('Metadata')
|
const { metadata } = asset.findServiceByType('Metadata')
|
||||||
return (
|
return (
|
||||||
<div key={asset.id} onClick={this.openDetails.bind(this, asset.id)}>
|
<div key={asset.id} onClick={this.openDetails.bind(this, asset.id)}>
|
||||||
@ -52,7 +55,7 @@ class Search extends Component<IProps, IState> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private openDetails = (assetId:string) => {
|
private openDetails = (assetId: string) => {
|
||||||
this.props.history.push(`/asset/${assetId}`)
|
this.props.history.push(`/asset/${assetId}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user