-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time Series Annotation Layers (#3521)
* Adding annotations to backend * Auto fetching Annotations on the backend * Closing the loop * Adding missing files * annotation layers UI for #3502 * a few fixes per code review. - add annotation input sanity check before add and before update. - make SelectAsyncControl component statelesis, and generic - add annotation description in d3 tool tip - use less variable to replace hard-coded color
- Loading branch information
1 parent
3d72eb4
commit d1a7a7b
Showing
18 changed files
with
434 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
superset/assets/javascripts/explore/components/controls/SelectAsyncControl.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* global notify */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Select from '../../../components/AsyncSelect'; | ||
import { t } from '../../../locales'; | ||
|
||
const propTypes = { | ||
dataEndpoint: PropTypes.string.isRequired, | ||
multi: PropTypes.bool, | ||
mutator: PropTypes.func, | ||
onAsyncErrorMessage: PropTypes.string, | ||
onChange: PropTypes.func, | ||
placeholder: PropTypes.string, | ||
value: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.number, | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.arrayOf(PropTypes.number), | ||
]), | ||
}; | ||
|
||
const defaultProps = { | ||
multi: true, | ||
onAsyncErrorMessage: t('Error while fetching data'), | ||
onChange: () => {}, | ||
placeholder: t('Select ...'), | ||
}; | ||
|
||
const SelectAsyncControl = ({ value, onChange, dataEndpoint, | ||
multi, mutator, placeholder, onAsyncErrorMessage }) => { | ||
const onSelectionChange = (options) => { | ||
const optionValues = options.map(option => option.value); | ||
onChange(optionValues); | ||
}; | ||
|
||
return ( | ||
<Select | ||
dataEndpoint={dataEndpoint} | ||
onChange={onSelectionChange} | ||
onAsyncError={() => notify.error(onAsyncErrorMessage)} | ||
mutator={mutator} | ||
multi={multi} | ||
value={value} | ||
placeholder={placeholder} | ||
valueRenderer={v => (<div>{v.label}</div>)} | ||
/> | ||
); | ||
}; | ||
|
||
SelectAsyncControl.propTypes = propTypes; | ||
SelectAsyncControl.defaultProps = defaultProps; | ||
|
||
export default SelectAsyncControl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""empty message | ||
Revision ID: d39b1e37131d | ||
Revises: ('a9c47e2c1547', 'ddd6ebdd853b') | ||
Create Date: 2017-09-19 15:09:14.292633 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd39b1e37131d' | ||
down_revision = ('a9c47e2c1547', 'ddd6ebdd853b') | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
pass | ||
|
||
|
||
def downgrade(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""annotations | ||
Revision ID: ddd6ebdd853b | ||
Revises: ca69c70ec99b | ||
Create Date: 2017-09-13 16:36:39.144489 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ddd6ebdd853b' | ||
down_revision = 'ca69c70ec99b' | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
'annotation_layer', | ||
sa.Column('created_on', sa.DateTime(), nullable=True), | ||
sa.Column('changed_on', sa.DateTime(), nullable=True), | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(length=250), nullable=True), | ||
sa.Column('descr', sa.Text(), nullable=True), | ||
sa.Column('changed_by_fk', sa.Integer(), nullable=True), | ||
sa.Column('created_by_fk', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table( | ||
'annotation', | ||
sa.Column('created_on', sa.DateTime(), nullable=True), | ||
sa.Column('changed_on', sa.DateTime(), nullable=True), | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('start_dttm', sa.DateTime(), nullable=True), | ||
sa.Column('end_dttm', sa.DateTime(), nullable=True), | ||
sa.Column('layer_id', sa.Integer(), nullable=True), | ||
sa.Column('short_descr', sa.String(length=500), nullable=True), | ||
sa.Column('long_descr', sa.Text(), nullable=True), | ||
sa.Column('changed_by_fk', sa.Integer(), nullable=True), | ||
sa.Column('created_by_fk', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), | ||
sa.ForeignKeyConstraint(['layer_id'], [u'annotation_layer.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_index( | ||
'ti_dag_state', | ||
'annotation', ['layer_id', 'start_dttm', 'end_dttm'], unique=False) | ||
|
||
|
||
def downgrade(): | ||
op.drop_index('ti_dag_state', table_name='annotation') | ||
op.drop_table('annotation') | ||
op.drop_table('annotation_layer') |
Oops, something went wrong.