Skip to content

Commit

Permalink
Merge 4a6ea7e into 8213766
Browse files Browse the repository at this point in the history
  • Loading branch information
xgaia committed Oct 22, 2019
2 parents 8213766 + 4a6ea7e commit c2dced1
Show file tree
Hide file tree
Showing 30 changed files with 824 additions and 430 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
repo_token: sKBVzfBUvZi7I4DDFAn4SLzdyLCBQb3rd
repo_token: 5OBT9Dq2n5pQfhOV9gJNu8THW8O1qUxdg
9 changes: 8 additions & 1 deletion askomics/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ def login_api_key(key):
except Exception:
pass

return render_template('index.html', project="AskOmics", proxy_path=proxy_path, redirect="/")
title = "AskOmics"
try:
subtitle = current_app.iniconfig.get('askomics', 'subtitle')
title = "AskOmics | {}".format(subtitle)
except Exception:
pass

return render_template('index.html', title=title, proxy_path=proxy_path, redirect="/")

else:

Expand Down
2 changes: 1 addition & 1 deletion askomics/libaskomics/CsvFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def generate_rdf_content(self):
relation = self.askomics_prefix[self.format_uri(current_header, remove_space=True)]
attribute = rdflib.Literal(self.convert_type(cell))

if entity and relation and attribute:
if entity and relation is not None and attribute is not None:
self.graph_chunk.add((entity, relation, attribute))
if symetric_relation:
self.graph_chunk.add((attribute, relation, entity))
Expand Down
6 changes: 6 additions & 0 deletions askomics/react/src/classes/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ export default class Utils {
let event = new Date(date * 1000)
return event.toUTCString()
}

objectHaveKeys(obj, level, ...rest) {
if (obj === undefined) return false
if (rest.length == 0 && obj.hasOwnProperty(level)) return true
return this.objectHaveKeys(obj[level], ...rest)
}
}
8 changes: 7 additions & 1 deletion askomics/react/src/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import axios from 'axios'

import Ask from './routes/ask/ask'
import About from './routes/about/about'
import Jobs from './routes/jobs/jobs'
import Upload from './routes/upload/upload'
import Integration from './routes/integration/integration'
import Datasets from './routes/datasets/datasets'
Expand Down Expand Up @@ -72,6 +71,12 @@ export default class Routes extends Component {

render () {

let redirectRoot

if (document.getElementById('redirect').getAttribute('redirect') == "/") {
redirectRoot = <Redirect to="/" />
}

let admin = false
if (this.state.config.user) {
admin = this.state.config.user.admin
Expand All @@ -92,6 +97,7 @@ export default class Routes extends Component {
return (
<Router basename={this.state.config.proxyPath}>
<div>
{redirectRoot}
<AskoNavbar waitForStart={this.state.waiting} config={this.state.config} />
<Switch>
<Route path="/" exact component={() => (<Ask waitForStart={this.state.waiting} config={this.state.config} />)} />
Expand Down
1 change: 1 addition & 0 deletions askomics/react/src/routes/ask/ask.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export default class Ask extends Component {
{exempleQueries}
</Col>
</Row>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
Expand Down
2 changes: 2 additions & 0 deletions askomics/react/src/routes/datasets/datasets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from 'axios'
import DatasetsTable from './datasetstable'
import { Button } from 'reactstrap'
import PropTypes from 'prop-types'
import ErrorDiv from '../error/error'

export default class Datasets extends Component {
constructor (props) {
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class Datasets extends Component {
<br />
<Button disabled={this.isDisabled()} onClick={this.deleteSelectedDatasets} color="danger"><i className="fas fa-trash-alt"></i> Delete</Button>
</div>
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
}
Expand Down
23 changes: 19 additions & 4 deletions askomics/react/src/routes/error/error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import React, { Component } from 'react'
import { Alert } from 'reactstrap'
import { Redirect } from 'react-router'
import PropTypes from 'prop-types'
import Utils from '../../classes/utils'

export default class ErrorDiv extends Component {
constructor (props) {
super(props)
this.utils = new Utils()
}

render () {
Expand All @@ -17,19 +19,31 @@ export default class ErrorDiv extends Component {
return null
}

let messages = {
"404": this.utils.objectHaveKeys(this.props, "customMessages", "404") ? this.props.customMessages["404"] : "404 Not Found",
"503": this.utils.objectHaveKeys(this.props, "customMessages", "503") ? this.props.customMessages["503"] : "503 Service Unavailable ",
"504": this.utils.objectHaveKeys(this.props, "customMessages", "504") ? this.props.customMessages["504"] : "504 Gateway Time-out",
"500": this.utils.objectHaveKeys(this.props, "customMessages", "500") ? this.props.customMessages["500"] : this.props.errorMessage ? this.props.errorMessage : "500 Internal Server Error",
}

let errorMessage = this.props.errorMessage
if (this.utils.objectHaveKeys(this.props, "status")) {
errorMessage = messages[this.props.status.toString()]
}

let error
if (Array.isArray(this.props.errorMessage)) {
if (Array.isArray(errorMessage)) {
error = (
<Alert color="danger">
{this.props.errorMessage.map((item, index) => (
{errorMessage.map((item, index) => (
<div key={index}><i className="fas fa-exclamation-circle"></i> {item}</div>
))}
</Alert>
)
} else {
error = (
<Alert color="danger">
<div><i className="fas fa-exclamation-circle"></i> {this.props.errorMessage}</div>
<div><i className="fas fa-exclamation-circle"></i> {errorMessage}</div>
</Alert>
)
}
Expand All @@ -45,5 +59,6 @@ export default class ErrorDiv extends Component {
ErrorDiv.propTypes = {
status: PropTypes.number,
error: PropTypes.bool,
errorMessage: PropTypes.string
errorMessage: PropTypes.string,
customMessages: PropTypes.object
}
8 changes: 7 additions & 1 deletion askomics/react/src/routes/integration/bedpreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from 'axios'
import { CustomInput, Input, FormGroup, Label, ButtonGroup, Button, Col } from 'reactstrap'
import update from 'react-addons-update'
import PropTypes from 'prop-types'
import ErrorDiv from '../error/error'

export default class BedPreview extends Component {
constructor (props) {
Expand All @@ -14,7 +15,10 @@ export default class BedPreview extends Component {
id: props.file.id,
integrated: false,
publicTick: false,
privateTick: false
privateTick: false,
error: false,
errorMessage: null,
status: null
}
this.cancelRequest
this.integrate = this.integrate.bind(this)
Expand Down Expand Up @@ -87,6 +91,8 @@ export default class BedPreview extends Component {
<Button onClick={this.integrate} value="private" color="secondary" disabled={this.state.privateTick}>{privateIcon} Integrate (private dataset)</Button>
{publicButton}
</ButtonGroup>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
}
Expand Down
8 changes: 7 additions & 1 deletion askomics/react/src/routes/integration/csvtable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BootstrapTable from 'react-bootstrap-table-next'
import { CustomInput, Input, FormGroup, ButtonGroup, Button } from 'reactstrap'
import update from 'react-addons-update'
import PropTypes from 'prop-types'
import ErrorDiv from '../error/error'

export default class CsvTable extends Component {
constructor (props) {
Expand All @@ -15,7 +16,10 @@ export default class CsvTable extends Component {
columns_type: props.file.data.columns_type,
integrated: false,
publicTick: false,
privateTick: false
privateTick: false,
error: false,
errorMessage: null,
status: null
}
this.cancelRequest
this.headerFormatter = this.headerFormatter.bind(this)
Expand Down Expand Up @@ -148,6 +152,8 @@ export default class CsvTable extends Component {
{publicButton}
</ButtonGroup>
</div>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
}
Expand Down
3 changes: 3 additions & 0 deletions askomics/react/src/routes/integration/gffpreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from 'axios'
import { CustomInput, Input, FormGroup, ButtonGroup, Button } from 'reactstrap'
import update from 'react-addons-update'
import PropTypes from 'prop-types'
import ErrorDiv from '../error/error'

export default class GffPreview extends Component {
constructor (props) {
Expand Down Expand Up @@ -99,6 +100,8 @@ export default class GffPreview extends Component {
<Button onClick={this.integrate} value="private" color="secondary" disabled={this.state.privateTick}>{privateIcon} Integrate (private dataset)</Button>
{publicButton}
</ButtonGroup>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions askomics/react/src/routes/integration/integration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default class Integration extends Component {
}

<WaitingDiv waiting={this.state.waiting} center="center" />
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
Expand Down
13 changes: 9 additions & 4 deletions askomics/react/src/routes/integration/ttlpreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import axios from 'axios'
import { CustomInput, Input, FormGroup, ButtonGroup, Button } from 'reactstrap'
import update from 'react-addons-update'
import PropTypes from 'prop-types'
import brace from 'brace'
import AceEditor from 'react-ace'
import ErrorDiv from '../error/error'

import 'brace/mode/turtle'
import 'brace/theme/tomorrow'
import "ace-builds/src-noconflict/mode-turtle";
import "ace-builds/src-noconflict/theme-tomorrow";

export default class TtlPreview extends Component {
constructor (props) {
Expand All @@ -18,7 +18,10 @@ export default class TtlPreview extends Component {
id: props.file.id,
integrated: false,
publicTick: false,
privateTick: false
privateTick: false,
error: false,
errorMessage: null,
status: null
}
this.cancelRequest
this.integrate = this.integrate.bind(this)
Expand Down Expand Up @@ -101,6 +104,8 @@ export default class TtlPreview extends Component {
{publicButton}
</ButtonGroup>
</div>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>
)
}
Expand Down
37 changes: 0 additions & 37 deletions askomics/react/src/routes/jobs/jobs.jsx

This file was deleted.

10 changes: 7 additions & 3 deletions askomics/react/src/routes/query/query.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import axios from 'axios'
import { Alert, Button, Row, Col, ButtonGroup, Input } from 'reactstrap'
import { Alert, Button, Row, Col, ButtonGroup, Input, Spinner } from 'reactstrap'
import { Redirect } from 'react-router-dom'
import ErrorDiv from '../error/error'
import WaitingDiv from '../../components/waiting'
Expand Down Expand Up @@ -1196,7 +1196,11 @@ export default class Query extends Component {
)

// buttons
previewButton = <Button onClick={this.handlePreview} color="secondary" disabled={this.state.disablePreview}><i className={"fas fa-" + this.state.previewIcon}></i> Run & preview</Button>
let previewIcon = <i className={"fas fa-" + this.state.previewIcon}></i>
if (this.state.previewIcon == "spinner") {
previewIcon = <Spinner size="sm" color="light" />
}
previewButton = <Button onClick={this.handlePreview} color="secondary" disabled={this.state.disablePreview}>{previewIcon} Run & preview</Button>
if (this.state.config.logged) {
launchQueryButton = <Button onClick={this.handleQuery} color="secondary" disabled={this.state.disableSave || this.state.exceededQuota}><i className={"fas fa-" + this.state.saveIcon}></i> Run & save</Button>
}
Expand Down Expand Up @@ -1267,7 +1271,7 @@ export default class Query extends Component {
<div>
{resultsTable}
</div>
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} customMessages={{"504": "Query time is too long, use Run & Save to get your results"}} />
</div>
)
}
Expand Down
10 changes: 8 additions & 2 deletions askomics/react/src/routes/results/resultsfilestable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Utils from '../../classes/utils'
import { Badge, Button, ButtonGroup, FormGroup, CustomInput, Input, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'
import FileDownload from 'js-file-download'
import PropTypes from 'prop-types'
import ErrorDiv from '../error/error'

export default class ResultsFilesTable extends Component {
constructor (props) {
Expand All @@ -18,7 +19,10 @@ export default class ResultsFilesTable extends Component {
graphState: [],
modal: false,
idToPublish: null,
description: ''
description: '',
error: false,
errorMessage: null,
status: null
}
this.utils = new Utils()
this.handleSelection = this.handleSelection.bind(this)
Expand Down Expand Up @@ -334,7 +338,7 @@ export default class ResultsFilesTable extends Component {
<Button disabled={row.sparqlQuery != null ? true : false} id={row.id} size="sm" outline color="secondary" onClick={this.handleRedo}>Redo</Button>
<Button disabled={row.status == "success" ? false : true} id={row.id} size="sm" outline color="secondary" onClick={this.handleEditQuery}>Sparql</Button>
{this.props.config.user.galaxy ? <Button disabled={row.status == "success" ? false : true} name="result" id={row.id} size="sm" outline color="secondary" onClick={this.handleSendToGalaxy}>Send result to Galaxy</Button> : null}
{this.props.config.user.galaxy ? <Button disabled={row.sparqlQuery != "null" ? true : false} name="query" id={row.id} size="sm" outline color="secondary" onClick={this.handleSendToGalaxy}>Send query to Galaxy</Button> : null}
{this.props.config.user.galaxy ? <Button disabled={row.sparqlQuery != null ? true : false} name="query" id={row.id} size="sm" outline color="secondary" onClick={this.handleSendToGalaxy}>Send query to Galaxy</Button> : null}
</ButtonGroup>
)
},
Expand Down Expand Up @@ -384,6 +388,8 @@ export default class ResultsFilesTable extends Component {
})}
/>
</div>
<br />
<ErrorDiv status={this.state.status} error={this.state.error} errorMessage={this.state.errorMessage} />
</div>

)
Expand Down

0 comments on commit c2dced1

Please sign in to comment.