Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Website
Commits
0a9a9e8b
Commit
0a9a9e8b
authored
Jan 16, 2019
by
Maxym Borodenko
Committed by
Matija Obreza
Jan 17, 2019
Browse files
Add Download MCPD button for subsets and datasets
parent
0647be0f
Changes
7
Hide whitespace changes
Inline
Side-by-side
locales/en/translations.json
View file @
0a9a9e8b
...
...
@@ -825,6 +825,7 @@
"locations"
:
"Locations"
,
"traitsObserved"
:
"Traits observed"
,
"useAndLicensing"
:
"Dataset use and licensing"
,
"datasetMcpdPasportData"
:
"MCPD passport data"
,
"confirmDescription"
:
{
"approve"
:
"After approving the dataset no changes are permitted, a new version must be created."
,
"onPublish"
:
"The dataset will be reviewing by administrator before publishing."
...
...
@@ -1691,7 +1692,8 @@
"subTitle"
:
"Explore curated sets of subsets"
},
"display"
:
{
"title"
:
"Subset {{subsetTitle: string}}"
"title"
:
"Subset {{subsetTitle: string}}"
,
"MCPD"
:
"MCPD"
}
}
},
...
...
src/datasets/translations.json
View file @
0a9a9e8b
...
...
@@ -160,6 +160,7 @@
"locations"
:
"Locations"
,
"traitsObserved"
:
"Traits observed"
,
"useAndLicensing"
:
"Dataset use and licensing"
,
"datasetMcpdPasportData"
:
"MCPD passport data"
,
"confirmDescription"
:
{
"approve"
:
"After approving the dataset no changes are permitted, a new version must be created."
,
"onPublish"
:
"The dataset will be reviewing by administrator before publishing."
...
...
src/datasets/ui/c/DatasetDisplay.tsx
View file @
0a9a9e8b
...
...
@@ -38,6 +38,7 @@ import McpdDate from 'ui/common/time/McpdDate';
import
PagedLoader
from
'
ui/common/PagedLoader
'
;
import
AccessionRefCard
from
'
accessions/ui/c/AccessionRefCard
'
;
import
Number
from
'
ui/common/Number
'
;
import
DownloadDialog
from
'
ui/common/download-dialog
'
;
const
styles
=
(
theme
)
=>
({
root
:
{
...
...
@@ -386,6 +387,22 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
</
PropertiesItem
>
))
}
<
Authorize
role
=
"ROLE_USER"
>
<
PropertiesItem
key
=
{
dataset
.
uuid
}
title
=
{
<
DownloadDialog
downloadUrl
=
{
`/proxy/api/v1/dataset/
${
dataset
.
uuid
}
/download`
}
slug
=
"download-authenticated"
postParams
=
{
{
mcpd
:
'
mcpd
'
}
}
buttonTitle
=
{
`
${
t
(
'
common:action.download
'
)}
`
}
variant
=
"contained"
btnClasses
=
{
`
${
classes
.
buttonGreen
}
${
classes
.
button
}
`
}
/>
}
>
<
p
>
{
t
(
`datasets.public.c.datasetDisplay.datasetMcpdPasportData`
)
}
</
p
>
<
p
>
{
`MCPD -
${
dataset
.
uuid
}
.xlsx`
}
</
p
>
</
PropertiesItem
>
</
Authorize
>
</
Properties
>
</
Grid
>
</
Grid
>
...
...
src/subsets/translations.json
View file @
0a9a9e8b
...
...
@@ -30,7 +30,8 @@
"subTitle"
:
"Explore curated sets of subsets"
},
"display"
:
{
"title"
:
"Subset {{subsetTitle: string}}"
"title"
:
"Subset {{subsetTitle: string}}"
,
"MCPD"
:
"MCPD"
}
}
},
...
...
src/subsets/ui/c/SubsetCard.tsx
View file @
0a9a9e8b
...
...
@@ -12,7 +12,7 @@ import { Properties, PropertiesItem } from 'ui/common/Properties';
import
CropChips
from
'
crop/ui/c/CropChips
'
;
import
McpdDate
from
'
ui/common/time/McpdDate
'
;
const
SubsetCard
=
({
subset
,
complete
=
false
,
t
,
...
other
}:
{
subset
:
Subset
,
complete
?:
boolean
,
t
:
any
}
&
React
.
ClassAttributes
<
any
>
)
=>
{
const
SubsetCard
=
({
subset
,
complete
=
false
,
actions
,
t
,
...
other
}:
{
subset
:
Subset
,
complete
?:
boolean
,
actions
?:
any
,
t
:
any
}
&
React
.
ClassAttributes
<
any
>
)
=>
{
return
(
<
Card
>
<
CardHeader
title
=
{
<
SubsetLink
to
=
{
subset
}
/>
}
/>
...
...
@@ -27,9 +27,9 @@ const SubsetCard = ({subset, complete = false, t, ...other}: { subset: Subset, c
</
Properties
>
</
CardContent
>
{
false
&&
{
actions
&&
<
CardActions
>
A
ctions
{
a
ctions
}
</
CardActions
>
}
</
Card
>
...
...
src/subsets/ui/c/SubsetDisplay.tsx
View file @
0a9a9e8b
import
*
as
React
from
'
react
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
translate
}
from
'
react-i18next
'
;
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
// util
...
...
@@ -17,6 +18,7 @@ import Grid from '@material-ui/core/Grid';
import
Loading
from
'
ui/common/Loading
'
;
import
PagedLoader
from
'
ui/common/PagedLoader
'
;
import
AccessionRefCard
from
'
accessions/ui/c/AccessionRefCard
'
;
import
DownloadDialog
from
'
ui/common/download-dialog
'
;
const
styles
=
(
theme
)
=>
({
accessionSection
:
{
...
...
@@ -36,10 +38,21 @@ interface IDetailInfoProps extends React.ClassAttributes<any> {
deleteSubset
?:
(
subset
:
Subset
)
=>
any
;
loadAccessions
:
(
page
:
Page
<
AccessionRef
>
)
=>
any
;
accessions
:
Page
<
AccessionRef
>
;
userRoles
:
string
[];
}
class
DetailInfo
extends
React
.
Component
<
IDetailInfoProps
,
any
>
{
public
state
=
{
authenticated
:
false
,
};
public
componentWillMount
()
{
const
{
userRoles
}
=
this
.
props
;
const
authenticated
:
boolean
=
userRoles
.
findIndex
((
role
)
=>
role
===
'
ROLE_USER
'
)
!==
-
1
;
this
.
setState
({
authenticated
});
}
public
render
()
{
const
{
classes
,
subset
,
t
,
accessions
,
loadAccessions
}
=
this
.
props
;
...
...
@@ -57,7 +70,16 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
// TODO sometimes creator can be null
return
(
<
div
>
<
SubsetCard
complete
subset
=
{
subset
}
/>
<
SubsetCard
complete
subset
=
{
subset
}
actions
=
{
this
.
state
.
authenticated
&&
<
DownloadDialog
downloadUrl
=
{
`/proxy/api/v1/subset/
${
subset
.
uuid
}
/download`
}
slug
=
"download-authenticated"
postParams
=
{
{
mcpd
:
'
mcpd
'
}
}
buttonTitle
=
{
`
${
t
(
'
common:action.download
'
)}
${
t
(
'
subsets.public.p.display.MCPD
'
)}
`
}
/>
}
/>
<
Grid
container
spacing
=
{
16
}
className
=
{
classes
.
accessionSection
}
justify
=
{
'
space-between
'
}
>
{
subset
.
creators
&&
<
PropertiesCard
...
...
@@ -85,4 +107,8 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
}
export
default
translate
()((
withStyles
as
any
)(
styles
)(
DetailInfo
));
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
userRoles
:
state
.
login
.
authorities
,
});
export
default
translate
()(
connect
(
mapStateToProps
,
null
)((
withStyles
as
any
)(
styles
)(
DetailInfo
)));
src/ui/common/download-dialog/index.tsx
View file @
0a9a9e8b
...
...
@@ -71,6 +71,7 @@ interface IDownloadProps extends React.ClassAttributes<any> {
t
:
any
;
variant
?:
'
text
'
|
'
outlined
'
|
'
contained
'
|
'
contained
'
|
'
fab
'
|
'
extendedFab
'
;
btnClasses
?:
string
;
downloadUrl
:
string
;
buttonTitle
:
string
;
postParams
:
object
;
...
...
@@ -104,13 +105,17 @@ class DownloadDialog extends React.Component<IDownloadProps, any> {
private
asyncHide
=
()
=>
setTimeout
(()
=>
this
.
hide
());
public
render
()
{
const
{
variant
=
'
text
'
,
t
,
buttonTitle
,
downloadUrl
,
postParams
,
classes
,
article
}
=
this
.
props
;
const
{
variant
=
'
text
'
,
t
,
btnClasses
,
buttonTitle
,
downloadUrl
,
postParams
,
classes
,
article
}
=
this
.
props
;
let
{
disabled
}
=
this
.
props
;
disabled
=
!!
disabled
||
!
downloadUrl
;
return
(
<
div
style
=
{
{
margin
:
'
0 4px
'
}
}
>
<
Button
onClick
=
{
this
.
show
}
disabled
=
{
disabled
}
className
=
{
this
.
props
.
classes
.
permButton
}
variant
=
{
variant
}
>
{
buttonTitle
}
</
Button
>
<
div
>
<
Button
onClick
=
{
this
.
show
}
disabled
=
{
disabled
}
className
=
{
btnClasses
?
btnClasses
:
this
.
props
.
classes
.
permButton
}
variant
=
{
variant
}
>
{
buttonTitle
}
</
Button
>
{
this
.
state
.
open
&&
<
div
>
{
!!
disabled
?
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment