Compare commits

...

507 Commits

Author SHA1 Message Date
Arik Fraimovich
4a978bada3 Fix: triggers not created for queries.search_vector (#3634) 2019-03-24 15:58:44 +02:00
Arik Fraimovich
ff0967f0d8 Update v7 CHANGELOG and version (#3595) 2019-03-17 22:05:55 +02:00
Ran Byron
e5d082b9b3 Textbox testing - add, remove, edit (#3589) 2019-03-17 18:26:01 +02:00
Arik Fraimovich
93aa6b5b80 Fix: accept integer values in dropdowns. (#3596) 2019-03-17 15:56:23 +02:00
Gabriel Dutra
1f74c0bad5 [Bug fix] Update user list when an user is created (#3594) 2019-03-15 20:56:10 +02:00
Feng
a8cb70910e [Codebase improvement] Reuse handlers base require_fields (#3577) 2019-03-15 13:21:48 +02:00
Bernhard Mäser
852636f07c update to latest stable version (#3588) 2019-03-14 18:13:18 +02:00
Arik Fraimovich
cf5c2c5ba2 Revert "Add SAML scheme override env var (#2947)" (#3587)
This reverts commit 4768fd081e.
2019-03-14 13:54:14 +02:00
Levko Kravets
10f4b99cd3 Widget title link not updated when parameter value changes (#3586) 2019-03-14 11:20:28 +02:00
Jannis Leidel
8456bbf762 Revert "Schema Viewer Drawer (#3291)" (#3585)
This reverts commit cb4d81d6ad.
2019-03-14 10:51:30 +02:00
Ran Byron
ab39242cc4 Cypress test - dashboard create/archive (#3565) 2019-03-14 08:08:56 +02:00
Ran Byron
b799ab6f0b Added alt+enter key binding (#3479) 2019-03-14 08:06:39 +02:00
Marina Samuel
cb4d81d6ad Schema Viewer Drawer (#3291)
* Process extra column metadata for a few sql-based data sources.

* Add Table and Column metadata tables.

* Periodically update table and column schema tables in a celery task.

* Fetching schema returns data from table and column metadata tables.

* Add tests for backend changes.

* Front-end shows extra table metadata and uses new schema response.

* Delete datasource schema data when deleting a data source.

* Process and store data source schema when a data source is first created or after a migration.

* Tables should have a unique name per datasource.

* Addressing review comments.

* Update migration file for mixins.

* Appease PEP8

* Upgrade migration file for rebase.

* Cascade delete.

* Adding org_id

* Remove redundant column and table prefixes.

* Non-existing tables and columns should be filtered out on the server side not client side.

* Fetching table samples should be optional and should happen in a separate task per table.

* Allow users to force a schema refresh.

* Use updated_at to help prune old schema metadata periodically.

* Using settings.SCHEMAS_REFRESH_QUEUE
2019-03-13 18:08:00 +01:00
Ran Byron
adf935b1df Fix for parameter mapping bug #3581 (#3582)
* Fix for parameter mapping bug #3581

* Must run original snapshot with original dashboard params
2019-03-13 16:41:03 +02:00
Arik Fraimovich
f1cb0101b9 👋 goodbye, similar-code false positives. (#3578) 2019-03-13 11:04:02 +01:00
Leo Palmer Sunmo
4768fd081e Add SAML scheme override env var (#2947)
* Add SAML scheme override env var

* Make it pretty, please the linter
2019-03-13 11:39:02 +02:00
Levko Kravets
4a8d9a7fb0 Fork query does not fork tables but instead adds default table (#3580)
* getredash/redash#3572 Fork query does not fork tables but instead adds default table

* Fix code style

* CR1
2019-03-13 11:29:54 +02:00
Arik Fraimovich
ba62b46a45 Append "UTC" to timestamp on embeds (in print view) (#3574)
To communicate what timezone the timestamp is.
2019-03-13 08:26:12 +02:00
Levko Kravets
fbf4dae001 Fix webpack config to work with symlinks (#3573) 2019-03-12 21:24:21 +02:00
Omer Lachish
5943bf04d5 change the order of configuration of the Elasticsearch data source to (#3571)
make sense
2019-03-12 09:42:17 +02:00
Ran Byron
93ec19b93f Prevent blank edit-in-place value (#3557) 2019-03-11 23:24:38 +02:00
Omer Lachish
63d3f22c93 Convert all dropdown values to strings to support parameter lookup (#3563)
* convert all dropdown values to strings to support parameter lookup.
solves #3562

* unicode all the way down

* show correct default values in QueryBasedParameterInput by converting
them to strings
2019-03-11 17:54:56 +02:00
Gabriel Dutra
685c7713e4 Update Amazon Elasticsearch Service image (#3567) 2019-03-11 06:43:03 +02:00
Levko Kravets
4cfa26a55e [Bug fix] Handle errors on Group members, Group datasources and User profile pages (#3564) 2019-03-10 19:34:54 +02:00
Ran Byron
5dc74e1ef7 npm audit fixes (#3561) 2019-03-10 13:35:27 +02:00
Arik Fraimovich
b703f7a3c4 Create weekly-digest.yml 2019-03-10 11:39:13 +02:00
Arik Fraimovich
26f0ce0749 New Celery/Queries Execution Status API (#3057)
* Remove QueryTaskTracker

* Remove scheudling of cleanup_tasks

* Add Celery introspection tools

* First iteration of updating the admin API.

* Show more details

* Add option to skip building npm in Dockerfile

* Show started_at

* update the refresh schedule, as it's too fast

* Update Celery monitor to report on all active tasks.

* Update task parsing for new format

* WIP: improved celery status screen

* Fix property name.

* Update counters

* Update tab name

* Update counters names

* Move component to its own file and fix lint issues

* Add migratin to remove Redis keys

* Improve columns layout

* Remove skip_npm_build arg as it's not used anymore.

* Convert query from SQL to Python

* Simplify column definition.

* Show alert on error.
2019-03-10 11:19:31 +02:00
Levko Kravets
12d2a04946 Download Query Result links: use query name for downloaded filename (#3559)
* getredash/redash#3554 Download Query Result links: use query name for downloaded filename

* CR1
2019-03-10 10:32:08 +02:00
koooge
5501f3e61c Upgrade jest & babel (#3405) 2019-03-10 09:29:44 +02:00
Arik Fraimovich
61f143dfd3 Snowflake: add support for regions and enable by default (#3550)
* Bring back Snowflake from its exile.

* Snowflake: add support for regions.
2019-03-07 23:40:24 +02:00
Arik Fraimovich
8737e8032e Add: Docker entrypoint to do Celery healthchecks. (#3548) 2019-03-07 22:32:27 +02:00
Arik Fraimovich
dfa48caf63 Fix: order dashboard favorites (#3552)
## What type of PR is this? (check all applicable)

- [x] Refactor
- [x] Bug Fix

## Description

Move favorites list handlers to their relevant modules (`redash.handlers.queries` and `redash.handlers.dashboards`) and applied `order_results` to dashboards.
2019-03-07 15:30:11 +01:00
Arik Fraimovich
e4c933af55 Update PULL_REQUEST_TEMPLATE.md (#3549) 2019-03-07 14:35:27 +02:00
Levko Kravets
be1bd2863f [Bug fix] Wrong behavior when clicking table rows on list pages (#3540) 2019-03-07 13:59:39 +02:00
Ran Byron
507ea61151 Fix long tag labels breaking table layout (#3545) 2019-03-07 11:53:28 +02:00
Arik Fraimovich
4f79c86c0e Pin pymapd version to 0.7.1 (#3543)
Newer versions dropped support for Python 2. Closes #3542.
2019-03-07 09:02:40 +02:00
Ran Byron
160c3c1048 Param fix (#3528)
* Name help text for date range only

* Autofocus on name input

* Form acts on enter key

* Fixed range check

* Fixed startsWith
2019-03-06 10:31:33 +02:00
Jannis Leidel
8eb751f0c3 Remove docker-compose.production.yml in favor of setup/docker-compose.yml. (#3533)
Fix #3251.
2019-03-06 08:49:35 +02:00
Paul Graff
75bc469708 Remove duplicate column information for late-binding views (#3537)
Since the svv_columns system view supports them now https://docs.aws.amazon.com/redshift/latest/dg/r_SVV_COLUMNS.html
2019-03-06 08:41:48 +02:00
Jannis Leidel
21082fbe0e Make the "celery" queue the default instead of "schema" to stay backward-compatible. (#3534)
Fix #3325.
2019-03-06 08:37:54 +02:00
Jannis Leidel
4e7d16b642 Remove Flask-Admin. (#3532) 2019-03-06 08:36:46 +02:00
pieter-venter
b68051d3c5 Add Hangouts Chat as alert destination (#3525)
* Add support for Google Hangouts Chat as alert destination

* Remove redundant imports

* Remove code used for debugging

* Fix pep8 warnings

* Update redash/destinations/hangoutschat.py

Add friendly name by separating type and description

Co-Authored-By: pieter-venter <pieterventer@geotab.com>

* Fix pep8 warnings. Rename image to match desitnation type.

* Show message for unknown alert state in default color
2019-03-05 22:06:25 +02:00
Levko Kravets
bc22797009 [Refactor] Refine New user modal (#3529) 2019-03-05 14:17:59 +02:00
Ran Byron
7a4fe5055d Added UTC display to scheduler dialog (#3517) 2019-03-05 11:54:33 +02:00
Gabriel Dutra
6a75ac4a57 Migrate User Pages to React (#3506)
* Create React version for the EmailSettingsWarning

* Migrate the Create User Page

* Migrate UserProfile to React

* Add /users/me to the routes (Percy ftw)

* Fix UserShow test spec

* Remove Error Messages component

* Show invitation link if email server not setup (#3519)

* return invite link to client if e-mail server is not set up

* add a couple of tests to make sure invite links are only returned when neccessary

* show invite link when e-mail is not configured

* remove "an e-mail has been sent" when there's no e-mail configured

* return invite_url in re-invites as well. Also refactor to reuse the code.

* Use CreateUserDialog instead of Page

* Render invite link on Resend Invitation click

* Add email validation to DynamicForm

* Fix EmailWarning position + update user list with user creation success

* Fix console error on UserProfile

* Redirect from /users/new  + rename createUser -> showCreateUserDialog

* Use alert instead of toastr for user creation errors

* Remove logic from CreateUserDialog

* CR

* Use Promise.reject instead of throw to avoid console error
2019-03-04 18:26:51 -03:00
Ran Byron
34da15fd6a Migrated AddTextboxDialog to AntD (#3524) 2019-03-04 21:51:48 +02:00
Ran Byron
dd0fab7275 Moved widget and dashboard save logic out of dialog (#3522) 2019-03-04 16:31:31 +02:00
Gabriel Dutra
ade3cc72a7 Fix eslint error on AlertsList (#3518) 2019-03-03 00:28:17 +02:00
Omer Lachish
02e82a7658 Fix verification_email endpoint when in MULTI_ORG mode (#3502)
* append slug to /verification_email endpoint when in MULTI_ORG mode

* Revert "append slug to /verification_email endpoint when in MULTI_ORG mode"

This reverts commit 817fb034c4.

* fix for /email_verification in MULTI_ORG setups
2019-03-02 14:12:41 +02:00
Ran Byron
6e3b9c2977 Fixed navbar responsiveness (#3510)
* Fixed navbar responsiveness

* Adjustments so that logo should never hide
2019-02-28 16:53:42 +02:00
Ran Byron
34e03b01bb Migrated query edit/add param dialog to React/AntD/Hooks (#3488) 2019-02-28 16:31:34 +02:00
Ran Byron
dab35acd2c QuerySelector in Alert page (#3501) 2019-02-28 15:56:12 +02:00
Arik Fraimovich
a93741e64b CircleCI build improvements (#3511)
* Make sure master builds tarball/docker image only when backend and frontend tests pass.

* Build a redash/preview image alongside redash/redash image.

* Fix version variable
2019-02-28 15:23:47 +02:00
Ran Byron
549f878c98 Added <QuerySelector /> component (#3494)
* Updated npm to support react hooks

* Added <QuerySelector />

* Changed selectQuery to also clear, completed 2->3 dots in msg, avoiding setSearching on stale rejection.

* Removed unused highlight lib
2019-02-28 15:07:57 +02:00
Gabriel Dutra
194f45263b [Feature] Migrate Alerts List Page to React (#3505) 2019-02-28 12:33:03 +02:00
G. Tsirkas
83668a6840 LDAP Authentication. Create two envars REDASH_LDAP_USE_SSL and REDASH_LDAP_AUTH_BIND (#2776)
* Add two new envars. REDASH_LDAP_USE_SSL which determines if the connection will use ssl and LDAP_AUTH_BIND which determines if the binding is SIMPLE or ANONYMOUS

* Add use_ssl paremeter

* Rename LDAP_AUTH_BIND to LDAP_AUTH_METHOD and modify LDAP_SSL using parse_boolean

* Fix typo

* import ANONYMOUS constant from ldap3

* Add NTLM authentication

* Add comment to authentication method envar
2019-02-28 10:05:41 +02:00
Toshimitsu Takahashi
c9a4f07a7a Support AWS IAM profile for Amazon Elasticsearch (#3005) 2019-02-28 09:57:33 +02:00
Omer Lachish
e9c88ea176 Verify address when users change their e-mail (#3504)
* re-verify e-mail address on change

* send verification e-mail to the new address
2019-02-27 12:17:20 +02:00
ialeinikov
fbaded4548 adding gevent worker in requirements.txt, adding some gunicorn config… (#3333)
* adding gevent worker in requirements.txt, adding some gunicorn configurable parameters with defaults

* reverting the change as it's going to be set via env variable(s)
2019-02-27 11:15:31 +02:00
Omer Lachish
570e8d9f23 set invitation as not-pending in render_token_login_page only when (#3500)
handling invites (as opposed to password reset links)
2019-02-27 09:06:41 +02:00
Omer Lachish
0d76c036cb Be more permissive when parameters are safe (#3383)
* use the textless endpoint (/api/queries/:id/results) for pristine
queriest

* reverse conditional. not not is making me the headaches.

* add ParameterizedQuery#is_safe with an inital naive implementation which
treats any query with a text parameter as not safe. This will be
remedied later when DB drivers will handle these parameters.

* allow getting new query results even if user has only view permissions
to the data source (given that the query is safe)

* fix lint error - getDerivedStateFromProps should be placed after state

* Revert "use the textless endpoint (/api/queries/:id/results) for pristine"

This reverts commit cd2cee7738.

* move execution preparation to a different function, which will be soon
reused

* go to textless /api/queries/:id/results by default

* let the query view decide if text or textless endpoint is needed

* allow safe queries to be executed in the UI even if the user has no
permission to execute and create new query results

* change `run_query`'s signature to accept a ParameterizedQuery instead of
constructing it inside

* use dict#get instead of a None guard

* use ParameterizedQuery in queries handler as well

* test that /queries/:id/results allows execution of safe queries even if
user has view_only permissions

* lint

* raise HTTP 400 when receiving invalid parameter values. Fixes #3394

* remove unused methods

* avoid cyclic imports by importing only when needed

* verify that a ParameterizedQuery without any parameters is considered
safe

* introduce query.parameter_schema

* encapsulate ParameterizedQuery creation inside Query
2019-02-26 20:55:01 +02:00
Gabriel Dutra
138c55cf54 Fix DynamicForm ignoring default value for checkboxes (#3487) 2019-02-26 15:10:14 +02:00
Gabriel Dutra
60cd8812a9 Update Percy token (#3492) 2019-02-25 21:22:46 +02:00
Arik Fraimovich
5c5bfbdbbe Make sure Flask app created in Celery's worker process (#3465)
* Make sure Flask app created in worker process

* Add reference to GitHub issue
2019-02-25 19:11:03 +02:00
Sergei Beregov
75c34bf18d Add custom JSON encoder for PostgreSQL (#3442)
To handle columns with [range types][1] and display them as a
string custom JSON encoder for PostgreSQL was added.

Merging this PR will fix issue #1764

[1]:https://www.postgresql.org/docs/9.3/rangetypes.html
2019-02-25 17:52:45 +02:00
Arik Fraimovich
b56cc1cd16 Pin SQLAlchemy-Utils version (#3490)
Pin the version of SQLAlchemy-Utils following the discussion in #2970.
2019-02-25 11:22:48 +01:00
Wei
1a357df9b3 Fix prometheus query runner: get_schema and query range (#3471) 2019-02-25 11:40:35 +02:00
Yoshiken
d36e5acaea Fix update logo (#3489) 2019-02-25 10:12:02 +02:00
Arik Fraimovich
f4f34d02fb Create PULL_REQUEST_TEMPLATE.md (#3485) 2019-02-25 10:11:21 +02:00
Allen Short
3fdd3080c1 Use series name as pie chart label (#3484)
It was unconditionally using the column name; this uses the series name instead
if specified in the chart editor.
2019-02-25 10:10:27 +02:00
taminif
5d525b80b6 fix broken link in CONTRIBUTING.md (#3483) 2019-02-22 14:28:13 -03:00
Levko Kravets
5e5b0d69d8 [Feature, Tech debt] Improve list pages layout (#3482) 2019-02-22 17:26:29 +02:00
Levko Kravets
33b8bd27eb [Feature] Migrate Group List and Details pages to React (#3411) 2019-02-22 14:47:48 +02:00
Subhi Al Hasan
8679b8756e Cleaner approach for _is_collection_a_view (#3113)
* Fix collection fields retreival bug when Views are present in MongoDB

* fixing _is_collection_a_view function

* Update redash/query_runner/mongodb.py

Co-Authored-By: jodevsa <jodevsa@gmail.com>

* using options() instead of try/except on collstats  to detect if a collection  is a view
2019-02-21 23:39:36 +02:00
Omer Lachish
2a37cb31d9 Fix max-age issues on textless endpoint (#3477)
* max_age should default to -1

* pass maxAge along to `execute`
2019-02-21 16:02:06 +02:00
Ran Byron
4ad303b358 Fix some flex layout issue (#3476) 2019-02-21 14:21:54 +02:00
MURAOKA Taro
8fe1d33068 monitor "schemas" queue to run refresh_schema (#3459)
* monitor "schemas" queue to run refresh_schema

`refresh_schema` tasks won't run because "schemas" queue isn't consumed
with default settings.
and it cause leaking redis storage, a "schemas" list is growing with time.

this PR fix it, adds "schemas" queue to monitor by celery.

* use scheduled_worker for "schemas" queue

instead of "adhoc_worker"
2019-02-21 12:06:25 +02:00
Arik Fraimovich
4999ab5de7 Provide default value for .pop to avoid KeyError exception (#3474) 2019-02-21 11:17:07 +02:00
Ran Byron
8b19f16430 Help trigger dynamic component (#3472) 2019-02-20 17:55:35 +02:00
Omer Lachish
a17eb14cdf support e-mail verification for multi org setups (#3468) 2019-02-20 13:45:09 +02:00
Omer Lachish
1ad0fa6a9b avoid Flask debug error message about strict slashes (#3469) 2019-02-20 13:19:06 +02:00
Arik Fraimovich
77dcc80522 Fix: ParameterizedQuery: support for upper cases column names. (#3461)
* Fix: ParameterizedQuery: support for upper cases column names.

* Fix test name
2019-02-20 12:08:38 +02:00
Arik Fraimovich
fe10b06928 Fix: JS Map needs a set call rather than assignment (#3464) 2019-02-20 12:07:46 +02:00
Arik Fraimovich
e35f2b8f51 Fix: when max_age is None the handler fails (#3462) 2019-02-19 20:47:29 +02:00
Omer Lachish
0bca2d8920 when working with a schema, fail in the case that there are parameters (#3452)
which are not part of the schema
2019-02-19 20:46:30 +02:00
Arik Fraimovich
f421119f9d Remove options NullPool does not support (#3460) 2019-02-19 16:04:00 +02:00
Arik Fraimovich
ebef0efe06 Fix: timedelta values were not JSON serialized properly (#3463)
.
2019-02-19 14:27:37 +01:00
Ran Byron
8fc2ecf55c [Bug fix] Widget oblivious to updated parameter values (#3445) 2019-02-18 22:55:46 +02:00
Ran Byron
3147a0bd98 Version data - footer -> header menu (#3458) 2019-02-18 22:15:51 +02:00
Gabriel Dutra
2c705712fc Fixes to Percy (#3440)
* Add check for repository url

* Use CIRCLE_REPOSITORY_URL directly

* Change percy waiting to be with resources instead of time

* Add data sources types resource to Edit Data Source + eslint fixes

* Separate Page Screenshots in different spec files
2019-02-18 16:30:48 -03:00
Levko Kravets
d483785098 [Codebase improvement] Refine ItemsList base component (previously LiveItemsList) (#3415) 2019-02-18 20:48:26 +02:00
Ran Byron
298fe6a779 HelpTrigger in header (#3457)
* Moved component from services->components

* Added help trigger to header

* Reverted tooltip-anchor swap

* Moved trigger location in html (to mirror saas)

* Removed white space

* Changed tooltip text to “Help”
2019-02-18 19:52:10 +02:00
Arik Fraimovich
f07e613631 Fix: ScheduleDialog won't render for "30 days" interval with no time value (#3447) 2019-02-17 15:12:07 +02:00
Arik Fraimovich
60472e2fe0 Add support for Amazon ES service with IAM authentication (#3446)
* Add support for Amazon ES service with IAM authentication

* Add required dependency.
2019-02-17 15:11:40 +02:00
Ran Byron
81c950407d HelpTrigger to open in drawer (#3436)
* HelpTrigger to open in drawer

* Fixed “typo”

* Simplified version - removed postMessage

* Changed some wording
2019-02-17 15:11:16 +02:00
Arik Fraimovich
a34269cc7d Change: encrypt data source options. 🔓 (#2970)
* Change: encrypt data source options
* Implement migration
2019-02-17 13:54:19 +02:00
Omer Lachish
a8f74a1078 remove the word "type" from error message, as enum out-of-range errors (#3449)
have nothing to do with types.
2019-02-17 13:42:44 +02:00
Arik Fraimovich
58a53e3470 Fix: remove widgets when deleting a visualization. (#3423)
Closes #3257.
2019-02-17 10:30:23 +02:00
Ran Byron
fba2a35cef [Feature] Sharing disabled if dashboard has query params (#3439) 2019-02-16 17:06:09 +02:00
Gabriel Dutra
b9644b7456 React version of UserEdit (#3354)
* Update DynamicForm export

* Move UserShow to users folder

* Migrate User profile header and create DynamicForm for basic data

* Update UserShow to use UserProfile prop

* Add API Key input

* Add handler to regenerate API Key button

* Handle user profile save

* Add readOnly prop to DynamicForm and begin disabled user behavior

* Add Change Password Modal

* Remove action buttons for disabled users

* Add send password reset behavior

* Add minLength and password comparison to Password Modal

* Resend Invitation button

* Add Convert User Info

* Fix UserShow test

* Some code updates

* Add enable/disable user button

* Add UserPolicy as an idea

* Remove UserPolicy

* Create Edit Profile spec

* Move User profile screenshot to Edit Profile Spec

* Add tests for saving user and changing password errors

* CC is back :) - Fix trailing spaces

* Add test for succesful password update

* A few improvements from code review

* Remove Toggle User button when seeing your own profile

* Create InputWithCopy

* Fix possible errors when network is off and improve Email not sent alert

* Add default response object for $http possible errors

* Changes in UserEdit
- removed onClick from methods name
- regenerate API Key now uses InputWithCopy
- Password title added

* Update UserEdit render behavior and styling
- Password title changed to h5
- change rendering rules for actions
- Password modal is now closed when password is changed
- change DynamicForm readOnly to the fields and add hideSubmitButton

* Create ChangePasswordDialog and update UserEdit

* Fix possible console error

* Remove password match assertion from spec

* Fix typo
2019-02-14 14:08:30 -02:00
swfz
afaedb9062 [Feature] Table visualization: Raise the upper limit of MAX_JSON_SIZE (#3310)
* move constant value to clientConfig
* change name maxJsonSize to tableCellMaxJSONSize
* value from environment. default is 50000
2019-02-13 11:42:40 +02:00
Ran Byron
f2df7170d2 HelpTrigger (#3431)
* Moved to HelpTrigger

* Moved share dialog “Learn more” to HelpTrigger
2019-02-13 10:38:25 +02:00
Arik Fraimovich
d6827e3601 Version update time (#3429)
* Version update time 

* Need more 
2019-02-13 09:51:07 +02:00
Omer Lachish
c028e49bfd send ip and user id to sentry (#3430) 2019-02-13 09:41:41 +02:00
Ran Byron
9b1f277530 [Widget Params] Updated help url and tooltip (#3428) 2019-02-13 09:00:48 +02:00
Ran Byron
901f28a79f Pre-commit hook to run on modified files only (#3410)
* Pre-commit hook to run on  modified files only

* Removed git add, fixed script dup

* Removed pre-push, testing related files only in pre-commit
2019-02-13 08:21:42 +02:00
Levko Kravets
3fed697c37 [Bug fix] Query Parameters: don't save urlPrefix (#3427) 2019-02-12 21:10:53 +02:00
Levko Kravets
d567765a3c [Bug fix] Notifications randomly shown with visible page or not shown with inactive page (#3426) 2019-02-12 20:07:36 +02:00
Ran Byron
4dbc17572a Converted Share modal to Ant (#3424) 2019-02-12 16:11:08 +02:00
Omer Lachish
330c5a85f1 Enable remote debugging with ptvsd (#3419)
* open port 3000 for remote debugging

* add ptvsd

* use port 5678 to avoid changes in VSCode's default config

* attach to ptvsd

* no need to wait for attach

* actually, --debugger seems to be working

* create a new docker entry point for remote debugging

* alternative method to switch to debugging
2019-02-12 09:10:18 +02:00
Levko Kravets
2c1400d323 [Feature] Alternative implementation of dashboard param title editing (#3417) 2019-02-11 17:17:05 +02:00
Arik Fraimovich
cb22764d68 Bug fix] Saving a new query removes reference to last query result (#3421)
* Correctly test if the current query result is for the current query.
* Serialize a new query with its visualizations.
2019-02-11 14:13:01 +02:00
Arik Fraimovich
eee77a1c9b [Bug fix] Show query result footer only when there is a query result. (#3422) 2019-02-11 13:46:18 +02:00
Omer Lachish
71fb1442f1 Upgrade Sentry SDK (#3418)
* replace raven with sentry-sdk

* use sentry-sdk in celery

* use sentry-sdk with flask

* unify Flask and Celery initializations for Sentry

* extract sentry stuff to own module

* it's time for Sentry 0.7.2
2019-02-10 21:56:16 +02:00
Jannis Leidel
23908edc28 Handle InterruptException in Athena query runnner like in the Presto query runner. (#3403) 2019-02-10 13:41:16 +02:00
Ran Byron
df4ca86d35 Added short modal specific styling (#3366) 2019-02-10 13:39:55 +02:00
Omer Lachish
03f040da0e Unify query based dropdown population (#3337)
* stop testing `collect_query_parameters`, it's an implementation detail

* add tests for `missing_query_params`

* rename SQLQuery -> ParameterizedSqlQuery

* rename sql_query.py to parameterized_query.py

* split to parameterized queries and parameterized SQL queries, where
parameterized queries only do templating and parameterized SQL queries
add tree validation on top of it

* move missing parameter detection to ParameterizedQuery

* get rid of some old code

* fix tests

* set syntax to `custom`

* revert the max-age-related refactoring

* 👋 tree validations 😢

* BaseQueryRunner is no longer a factory for ParameterizedQuery, for now

* add an endpoint for running a query by its id and (optional) parameters
without having to provide the query text

* adds parameter schema to ParameterizedQuery

* adds parameter schema validation (currently for strings)

* validate number parameters

* validate date parameters

* validate parameters on POST /api/queries/<id>/results

* validate enum parameters

* validate date range parameters

* validate query-based dropdowns by preprocessing them at the handler
level and converting them to a populated enum

* change _is_date_range to be a tad more succinct

* a single assignment with a `map` is sufficiently explanatory

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/handlers/query_results.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* build error message inside the error

* support all types of numbers as number parameters

* check for permissions when populating query-based dropdowns

* check for access to query before running it

* check for empty rows when populating query-based enums

* don't bother loading query results if user doesn't have access

* 💥 on unexpected parameter types

* parameter schema default is a list, not a dictionary

* fix a totally unrelated typo

* remove redundant null guards

* introduce /dropdown.json endpoint with dummy data

* wire frontend to /dropdown.json

* always return name/value combos from /dropdown.json

* load actual data into /dropdown.json

* pluck correct values for `name` and `value`

* reuse dropdwon plucking logic in QueryResultResource

* simplify _get_dropdown_values

* when doing parameter validation, we only care about the value and not
the display name

* rename dropdown to dropdownOptions

* move dropdown_values to utils/parameterized_query.py

* stop converting queries to enums and encapsulate the work inside
ParameterizedQuery (almost - /dropdown.json would still access the
dropdown_values method)

* re-order arguments by importance

* test query parameter validation

* tests for dropdown_values logic

* remove `.json` suffix to the dropdown endpoint

* allow `BaseResource` to handle JSON stuff

* move _pluck_name_and_value outside its containing method

* case-insensitive lookup when plucking name and value

* separate concerns and simplify test isolation for `dropdown_values`

* pick the default column according to the order specified in the query
result columns attribute

* use `current_org` instead of passing `org`

* test that user has access to the query when calling the /dropdown
endpoint
2019-02-10 13:10:39 +02:00
Levko Kravets
e21bbcc6fe [UI/UX Improvement] Use Ant's Button component on users list page (#3416) 2019-02-08 17:48:48 +02:00
Levko Kravets
23f5dde488 [Codebase Improvement] Refine dialog wrapper and use it for all existing dialogs (#3407) 2019-02-08 10:00:22 +02:00
Ran Byron
29326f3610 [Widget Params] Title edit fixes (#3413) 2019-02-08 08:45:46 +02:00
Ran Byron
593ebde211 Fix: “Add TextBox” dialog not opening (#3414) 2019-02-08 01:01:50 +02:00
Levko Kravets
11507c5e5e Show active and pending users separately (for admins) (#3400) 2019-02-07 20:30:55 +02:00
Jannis Leidel
c49dccf254 Work around a resizing issue. (#3412)
* Work around a resizing issue.

Fix #3353.

* Add comment to remove this when we delete Angular.

Co-Authored-By: jezdez <jannis@leidel.info>
2019-02-07 16:05:39 +02:00
Marina Samuel
029bee18fb Coerce to moment when 'datetime' selected by user. (#3150) 2019-02-07 14:42:30 +01:00
Levko Kravets
ec475e4b7b [Bug fix] Few small bugs on Queries list page (#3402)
* Link to query page
* Sidebar menu item title: `Archive` -> `Archived`
* Whitespaces in empty state block
2019-02-06 00:19:31 +02:00
Levko Kravets
045c171bb4 Refactor TagsControl; fix TagsEditorModal animation (#3399)
* Refactor TagsControl; fix TagsEditorModal animation

* Update tooltip text

Co-Authored-By: kravets-levko <levko.ne@gmail.com>

* Update tooltip text

Co-Authored-By: kravets-levko <levko.ne@gmail.com>

* CR1
2019-02-05 23:29:09 +02:00
Arik Fraimovich
21341132f6 Fix: cohorts get stuck when passing strings instead of numbers. (#3397)
* Fix: cohorts get stuck when passing strings instead of numbers.

Parse the value to get a number.

* Use parseInt for stage

* Remove redundant parseInt
2019-02-05 21:20:17 +02:00
Levko Kravets
ac68fe1a6d Migrate Dashboards/Queries/Users list pages to React (#3381)
* Refine existing implementation of dashboards/queries/users lists and a common base controller

* Migrate common list page controller to React and refactor it's logic

* Migrate Dashboard list page to React

* Migrate Queries list page to React

* Migrate Users list page to React

* Remove react-timeago dependency

* Use composition instead of inheritance

* Refine implementation

* Merge sidebar into single component

* Refine column definitions

* Use simple controller instead of React context

* Refine implementation

* Restore changes from getredash/redash#2888

* Tweak Users list page

* Ability to render dynamically defined components

* Tweak users list page

* User list page for non-admins

* Fix: ItemsTable ignores isAvailable field

* Refine implementation

* Refine implementation

* Implement LiveItemsList as higher order component

* Some fixes

* Move some definitions to a better place

* Some fixes

* Refine components

* Refine UsersList page

* More comments for a god of comments

* Fix wrong tables size on smaller screens

* Tweak tables
2019-02-05 21:13:32 +02:00
Arik Fraimovich
13855934f9 Add YAML support in QueryEditor (#3395) 2019-02-05 20:37:54 +02:00
Ran Byron
5b62883c1c [Widget Params] Switched parameter list to table style (all parts) (#3332)
* [Widget Params] Split title and mapping editing

* [Widget Params] Restyled source editing

* [Widget Params] Switched parameter list to table style

* Displaying different labels and help phrases when changing type
Added link to knowledge base
Fixed issue with existing param default select value
2019-02-05 20:36:15 +02:00
Ran Byron
c9681d55bf Added pre-push hook (#3390) 2019-02-05 16:16:49 +02:00
Arik Fraimovich
7cfea8a6a0 Fix: only login user when it's the current user. (#3396)
Otherwise it would login the admin as the user...
2019-02-05 15:53:51 +02:00
Ran Byron
2011864fdb Fix: Selected item in dropdown unreadable (#3398) 2019-02-05 15:50:31 +02:00
Omer Lachish
8f0cffe424 Use textless endpoint for pristine queries (#3367)
* use the textless endpoint (/api/queries/:id/results) for pristine
queriest

* Revert "use the textless endpoint (/api/queries/:id/results) for pristine"

This reverts commit cd2cee7738.

* move execution preparation to a different function, which will be soon
reused

* go to textless /api/queries/:id/results by default

* let the query view decide if text or textless endpoint is needed

* lint
2019-02-05 12:08:12 +02:00
Ran Byron
3df372434f [Widget Params] Migrated edit params + new widget dialog to Ant Modal (#3387) 2019-02-04 21:00:59 +02:00
Arik Fraimovich
933dd753a8 Make the logic around schedule['until'] easier to read (#3376) 2019-02-03 21:13:27 +02:00
koooge
3992bcda9b Ignore to copy some files onto docker container (#3388)
* Ignore to copy some files onto docker container

Signed-off-by: koooge <koooooge@gmail.com>

* Dockerignore venv/

Signed-off-by: koooge <koooooge@gmail.com>
2019-02-03 20:30:08 +02:00
Jannis Leidel
69e34f048a Add archived queries section to queries list. (#2888)
* Add archived queries section to queries list.

* Refactor route building for list based controllers.

This also fixes the dashboard empty state page.
2019-02-03 14:35:25 +02:00
Omer Lachish
b0a11983fa fix lint error - getDerivedStateFromProps should be placed after state (#3391) 2019-02-03 11:13:04 +02:00
Levko Kravets
807e6aaaa6 Migrate "time ago" components to React (#3385)
* Replace <am-time-ago> (angular-moment) and <rd-timer> with React component

* PropTypes: Moment validation

* Increase polling interval

* Refine component implementation

* Add tooltip with formatted date/time

* Refine component implementation
2019-02-02 18:46:48 +02:00
Levko Kravets
324a1f55cc Merge pull request #3384 from getredash/step-component
EmptyState alternative implementation with a Step component
2019-02-02 18:29:21 +02:00
Levko Kravets
abccff03f7 Fix Add datasource step; EmptyState.icon is optional 2019-02-02 18:12:27 +02:00
Levko Kravets
aa619c453f Merge branch 'master' into step-component 2019-02-02 17:56:11 +02:00
Levko Kravets
10b5c03248 Merge pull request #3389 from getredash/cypress
Fix Cypress E2E failing in CI
2019-02-02 17:14:21 +02:00
Gabriel Dutra
fde52f5d84 Fix Cypress E2E failing in CI 2019-02-02 12:44:33 -02:00
Arik Fraimovich
78df7e7cc9 Last refinements:
* Update Step implementation to be easier to read.
* Set some props to required to remove default value.
2019-02-01 10:16:17 +02:00
Levko Kravets
e314715335 Refine implementation, fix 'shouldShow' condition, fix eslint warnings 2019-02-01 08:37:09 +02:00
Arik Fraimovich
a1cf065ec6 No need to export Step 2019-02-01 00:04:03 +02:00
Arik Fraimovich
f9570556c5 Bring back data sources step for non admins 2019-02-01 00:00:19 +02:00
Arik Fraimovich
9859610e80 Alternative implementation: Step component 2019-01-31 23:55:40 +02:00
Marina Samuel
feab2a040b BigQuery should correctly handle tmp tables that do not have a schema field. (#3382) 2019-01-31 23:20:13 +02:00
Marina Samuel
35c390a2f9 Show disabled unpublished queries for alert and dashboard modals. (#3347) 2019-01-31 19:58:47 +02:00
Ran Byron
ebb96d7ad7 Widget param url prefix p to p_w (#3380) 2019-01-31 17:03:13 +02:00
Levko Kravets
3d58860f6f Merge pull request #3374 from kravets-levko/fix-eslint-errors
Fix eslint errors
2019-01-31 14:33:28 +02:00
Levko Kravets
c223566302 Merge branch 'master' into fix-eslint-errors 2019-01-31 14:04:05 +02:00
Levko Kravets
1439714fa6 Migrate EmptyState component to React (#3373)
* Migrate EmptyState component to React

* CR1

* CR2
2019-01-31 14:02:45 +02:00
Levko Kravets
9c06e9a0bd CR1 2019-01-31 13:50:05 +02:00
Levko Kravets
f98cf7812b Merge branch 'master' into fix-eslint-errors 2019-01-31 11:25:41 +02:00
Levko Kravets
ee0e81e795 Fix eslint errors 2019-01-31 11:21:45 +02:00
Jannis Leidel
bd559b6eeb Fix some incompatible dependencies (#3348)
* Pin requests-oauthlib to work around incompatible deptree.

* Update boto3/botocore to fix incompatible deptree.
2019-01-31 09:50:47 +02:00
Arik Fraimovich
c51191aaf0 Tune CodeClimate's config to make it less annoying (#3370) 2019-01-31 07:34:31 +02:00
Levko Kravets
4a2645d4c6 Merge pull request #3368 from kravets-levko/feature/react-favorites-and-tags-list
React migration: FavoritesControl and TagsList components
2019-01-30 21:09:05 +02:00
Levko Kravets
3ad1709a0a Merge branch 'master' into feature/react-favorites-and-tags-list 2019-01-30 20:29:07 +02:00
Ran Byron
cc135398e2 Fix: static param text value is [object Object] (#3371) 2019-01-30 20:27:59 +02:00
Levko Kravets
067472643d CR3 2019-01-30 20:21:22 +02:00
Levko Kravets
225c98c52a Merge branch 'master' into feature/react-favorites-and-tags-list 2019-01-30 19:23:03 +02:00
Ran Byron
00e991ecfc Fix: Static param value not editable for Text/Number (#3369) 2019-01-30 19:18:57 +02:00
Levko Kravets
a362e97dfe CR2 2019-01-30 18:54:53 +02:00
Levko Kravets
1ea532fe26 CR1 2019-01-30 18:45:06 +02:00
Levko Kravets
9a1c8290e4 Migrate TagsList component to React 2019-01-30 17:40:42 +02:00
Levko Kravets
0d959116d8 Migrate FavoritesControl component to React 2019-01-30 17:22:54 +02:00
Aidarbek Suleimenov
0b9f575dab Fix: make ClickHouse password and username truly optional (#3362)
* clickhouse optional password

* clickhouse URL and user made optional
2019-01-30 11:17:43 +02:00
koooge
13bc910d7c Update CodeClimate configuration format to Version 2 (#3286)
* codeclimate: Update format v2
* codeclimate: Ignore generated files
2019-01-30 10:51:32 +02:00
Ran Byron
9e2f8e2461 Fix: Escape button in tag edit modal (#3363) 2019-01-30 10:43:38 +02:00
Aidarbek Suleimenov
61e7cdaa81 Filename set when /results called directly (#3359)
* filename set when /results called directly

* /results filename changed from query name to id

* Long line shortened
2019-01-29 19:47:42 +02:00
Vladislav Denisov
53aecdc607 yandex_metrica: changed auth from params to headers (#3360) 2019-01-29 18:17:13 +02:00
koooge
2da511021e Frontend lint update (#3253)
* client: Add lint command

Signed-off-by: koooge <koooooge@gmail.com>

* client: Override eslint rule object-curly-newline to keep current style

Signed-off-by: koooge <koooooge@gmail.com>

* client: Override eslint rule no-else-return to keep current style

Signed-off-by: koooge <koooooge@gmail.com>

* client: Fix eslint import/named

Signed-off-by: koooge <koooooge@gmail.com>

* client: eslint-5

Signed-off-by: koooge <koooooge@gmail.com>

* codeclimate: Delete the old setting

Signed-off-by: koooge <koooooge@gmail.com>

* client: Downgrade eslint 5 to 4 in codeclimate

Signed-off-by: koooge <koooooge@gmail.com>

* client: npx install-peerdeps --dev eslint-config-airbnb

Signed-off-by: koooge <koooooge@gmail.com>

* client: Enbale .jsx lint

Signed-off-by: koooge <koooooge@gmail.com>

* client: Set warn

Signed-off-by: koooge <koooooge@gmail.com>

* client: Fix lint indent, implicit-arrow-linebreak, lines-between-class-members

Signed-off-by: koooge <koooooge@gmail.com>

* client: Disable eslint operator-linebreak

Signed-off-by: koooge <koooooge@gmail.com>

* Revert "client: Downgrade eslint 5 to 4 in codeclimate"

This reverts commit f0fb0f0059.

* client: Fix react/button-has-type

Signed-off-by: koooge <koooooge@gmail.com>

* client: Disable an eslint rule react/jsx-one-expression-per-line

Signed-off-by: koooge <koooooge@gmail.com>

* codeclimate: Disable no-multiple-empty-lines

Signed-off-by: koooge <koooooge@gmail.com>

* client: Disable eslint react/destructuring-assignment

Signed-off-by: koooge <koooooge@gmail.com>
2019-01-29 17:25:58 +02:00
Omer Lachish
371b319e92 Server-side parameter validation (#3315)
* stop testing `collect_query_parameters`, it's an implementation detail

* add tests for `missing_query_params`

* rename SQLQuery -> ParameterizedSqlQuery

* rename sql_query.py to parameterized_query.py

* split to parameterized queries and parameterized SQL queries, where
parameterized queries only do templating and parameterized SQL queries
add tree validation on top of it

* move missing parameter detection to ParameterizedQuery

* get rid of some old code

* fix tests

* set syntax to `custom`

* revert the max-age-related refactoring

* 👋 tree validations 😢

* BaseQueryRunner is no longer a factory for ParameterizedQuery, for now

* add an endpoint for running a query by its id and (optional) parameters
without having to provide the query text

* adds parameter schema to ParameterizedQuery

* adds parameter schema validation (currently for strings)

* validate number parameters

* validate date parameters

* validate parameters on POST /api/queries/<id>/results

* validate enum parameters

* validate date range parameters

* validate query-based dropdowns by preprocessing them at the handler
level and converting them to a populated enum

* change _is_date_range to be a tad more succinct

* a single assignment with a `map` is sufficiently explanatory

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/handlers/query_results.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/utils/parameterized_query.py

Co-Authored-By: rauchy <omer@rauchy.net>

* build error message inside the error

* support all types of numbers as number parameters

* check for permissions when populating query-based dropdowns

* check for access to query before running it

* check for empty rows when populating query-based enums

* don't bother loading query results if user doesn't have access

* 💥 on unexpected parameter types

* parameter schema default is a list, not a dictionary

* remove redundant null guards
2019-01-29 09:18:07 +02:00
Arik Fraimovich
ff42ec2cc6 Cypress tests: preset the admin API key to a static value (#3358) 2019-01-28 17:54:24 +02:00
Levko Kravets
7278d4b1fc Refactor Policy and OrganizationStatus services (#3345)
* Refactor Policy and OrganizationStatus services
2019-01-28 16:46:26 +02:00
Levko Kravets
6930106380 getredash/redash#3355 Widget params: Date/Date range value empty in static param input (#3357) 2019-01-28 15:59:49 +02:00
Zsolt Kocsmárszky
c0859642fd WIP: Add dashboard details section for dashboard owner and more (#2934)
Show dashboard creator on dashboard page
2019-01-28 14:20:55 +02:00
Gabriel Dutra
37821ee008 Add Percy Page Screenshots (#3338)
* Add Percy Page Screenshots

* Add missing space
2019-01-28 10:21:42 +02:00
Arik Fraimovich
c31cb01065 Move BigQueryGCE to its own file (#3356)
* Move BigQueryGCE to its own file

* Add missing import
2019-01-28 09:37:47 +02:00
Levko Kravets
1fa58674f3 Refine SettingsMenu service and <settings-screen> component (#3339)
* Refine SettingsMenu service and <settings-screen> component

* Rename services/settingsMenu file to match default export name

* CR1
2019-01-25 17:29:35 +02:00
Jannis Leidel
d204c158a2 Allow query owners to hard-overwrite query content in case of overlap with other user (#2370)
* Hard overwrite on conflict for query owners (re #283)

* Use AlertDialog instead of custom global function.
2019-01-25 11:28:09 +01:00
Levko Kravets
b0b4d5e26a Convert Angular services to CommonJS-style and use them in React components instead of injecting (#3331)
* Refine Auth service: remove dead code and fix race condition
* Export services in CommonJS style
* Refine Users, Events and OfflineListener services
* Refactor Notifications service - rewrite to CommonJS
* Replace Angular service injection with imports in React components
* Fix Footer tests
* Events service -> recordEvent function
* CR1
2019-01-24 16:24:58 +02:00
Levko Kravets
c2c722e12e Migrate PageHeader component to React (#3324)
* Migrate PageHeader component to React

* CR1
2019-01-23 20:10:52 +02:00
Vibhor Kumar
1a61ee3ec0 Add: Uptycs query runner (#3319)
* adding uptycs query_runner in redash

* as per comment from Arik comment fixed the code

* fixed function_name

* fixed some indentation issues

* fixed the indentation issue and taken out customer_id from secret

* fixed the dependency of urllib3

* fixed the indententaton issue

* remved the urllib3 from requirements

* fixed the indentation issues

* added the new square image for Uptycs. Removed unnecessary variable and made ssl as an option

* fixed indentation issue

* Renamed SSL to verify_ssl and also added verify_ssl validate in verify in missing places
2019-01-23 20:07:40 +02:00
Ran Byron
d5afa1815e Filtering out incompatible dashboard params (#3330) 2019-01-23 16:27:49 +02:00
Arik Fraimovich
87667676e6 Remove link to roadmap (#3329)
It's no longer maintained 😢
2019-01-23 13:48:11 +02:00
Arik Fraimovich
bfeb015d71 Add configuration for the Support probot. (#3327) 2019-01-23 13:38:08 +02:00
Omer Lachish
a9c514aaf7 Textless query result endpoint (#3311)
* add an endpoint for running a query by its id and (optional) parameters
without having to provide the query text

* check for access to query before running it
2019-01-23 11:10:04 +02:00
Levko Kravets
7fa6665445 Use Ant's Paginator component; migrate SortIcon to React (#3317) 2019-01-22 17:26:11 +02:00
Miles Maddox
ff6b20b69c support for fetching all JQL results by way of pagination (#3304) 2019-01-22 15:52:13 +02:00
YOSHIDA Katsuhiko
c4bf44677a Fix an error of exporting dict value as Excel (#3323) 2019-01-22 14:43:52 +02:00
Gabriel Dutra
8bdcfb06c5 add wait time before percy data source page snapshot (#3320) 2019-01-22 08:52:23 +02:00
YOSHIDA Katsuhiko
b3643ffbb7 Add regenerate function of user's API key (#3224)
* Add regenerate function of user's API Key

* Update client/app/pages/users/show.js

Co-Authored-By: kyoshidajp <claddvd@gmail.com>

* Remove unused error message

* Refactoring: Inline temp

* Update client/app/pages/users/show.js

Co-Authored-By: kyoshidajp <claddvd@gmail.com>

* Change action event of regenerate user API key
2019-01-20 13:38:20 +02:00
Eric Chang
b91d4bdcaf override default integer/float formatting with environment variables (#3307) 2019-01-20 10:10:36 +02:00
Eric Chang
8bc8e2dadf Allow execution of highlighted subquery (#3288)
* allow execution of selected subquery
* fix query save while highlighted
* don't modify queryText and update UI when running selected
* code style and transition
* Fix query selection execution background color
* make naming consistent
2019-01-20 10:06:17 +02:00
Gabriel Dutra
84d5becf2a Update form text colors (#3296)
* Create ant variables and update form colors

* Remove less extension from imports in ant.less

* Update font-weight for labels

* Add percy snapshot for create data source page

* Remove bold in labels only for checkboxes and radio buttons
2019-01-20 09:41:52 +02:00
Arik Fraimovich
e8120c5f79 Use None as "not scheduled" default value of a query (#3277)
* Use null as the default scheduled value.

* Don't serialize None to json, so we can use SQL is not null predicate.

* Fix warning about unicode in tests

* Handling empty query.schedule in UI (#3283)

* Add migration to convert empty schedules to null and drop the not null contraint.
2019-01-18 11:30:45 +02:00
Levko Kravets
40c6a2621c Merge pull request #3299 from kravets-levko/fix/multifilter-dropdown
Multifilter's dropdown cropped when visualization container is too small
2019-01-17 15:37:26 +02:00
Levko Kravets
06887f6ff1 Multifilter's dropdown cropped when visualization container is too small 2019-01-17 15:14:46 +02:00
Omer Lachish
7847cf7d63 Fix invitation pending for older invitations (#3298)
* explicitly look for a False under details['is_invitation_pending'] and
not any falsey result, to avoid locking out invitations which were
created before the Pending Invitation feature was introduced. Solves https://github.com/getredash/redash/issues/3297

* test that old invites (that do not have any is_invitation_pending flag set in their details object) are still acceptable
2019-01-17 11:56:16 +02:00
Omer Lachish
121a44ef15 Remove tree validations and introduce ParameterizedQuery (#3230) 2019-01-17 10:26:00 +02:00
Gabriel Dutra
823e4ccdd6 Migrate DynamicForm to React (#3209)
* create DynamicForm React component

* Render fields based on target in DynamicForm

* Add missing title property to fields

* Fix style properties in DynamicForm

* Render File fields in DynamicForm

* Use React for middle component instead of Angular

* Functional save button

* Update label style

* Render functional actions

* Handle file inputs

* Update render methods to fix code climate issues

* Fix ant input number showing duplicate arrows

* Update DynamicForm style to be vertical

* Separate imports from antd in DynamicForm

* Add Feedback Icons to DynamicForm

* Change Action props on DynamicForm
- use type and pullRight instead of class prop
- update data sources and destinations pages accordingly

* Remove setDefaults method from DynamicForm fields

* Update antd version

* Remove unnecessary class selectors

* Remove another unnecessary class selector
2019-01-15 14:23:33 +02:00
Levko Kravets
0c45d69662 Dashboard Parameters (#2756)
* getredash/redash#2641 Step 1: split Add Widget/Add Textbox buttons

* Convert Add widget/textbox dialogs to React components

* getredash/redash#2641 Step 2: Implement new dashboard parameters logic

* Resolve conflicts and fix build errors

* getredash/redash#2641 Refactoring and improve code quality

* Add Edit parameter mappings dialog to the widget

* getredash/redash#2641 Changes after code review

* Use Ant's Select component instead on <select> tags

* Fix Antd imports

* Fix Antd imports

* Fix Cannot read property 'getParametersDefs' of undefined

* Fix widgets static params bugs (don't show input, don't init from URL)

* Minor UI/UX fixes
2019-01-15 13:14:54 +02:00
Gabriel Dutra
df23842c57 Separate Bootstrap/Ant styling (#3279)
* Separate Ant less dependency tree

* Change order between variables and ant imports

* Remove inc/variables from ant.less

* Update input-height-base for antd

* Set same input-color for Ant and Bootstrap
2019-01-15 11:40:38 +02:00
Arik Fraimovich
d68a4dce5f Pin version of pyparsing (#3282) 2019-01-14 17:17:23 +02:00
Levko Kravets
db86e394cf Update Antd to latest version + fix tests (#3281) 2019-01-14 16:25:57 +02:00
koooge
4c9326a9da handlers: Fix post users (#3273) 2019-01-13 15:52:56 +02:00
Ran Byron
200fea952a Pleasant alert-warning colors (#3276)
* Pleasant alert-warning colors

* Fix for json viewer primitive color
2019-01-13 15:27:26 +02:00
Ran Byron
90a0a7d39b Scheduler tests (jest/enzyme) (#3269)
* Setup enzyme and initial ScheduleDialog test

* Added tests for each schedule setting

* Added refreshOptions tests

* Added count out-of-range tests

* Added modal confirm/cancel tests

* Fixed tests failing due to server timezone difference

* Rebased to master
2019-01-13 15:26:44 +02:00
Omer Lachish
26252be75a Verify admin email address (#3267)
* add an  bit

* prompt on homepage when user's email hasn't been verified

* set e-mail as verified for new setups and invited users

* 👋 copy & paste invite links, it's time for verified e-mails!

* default `is_invitation_pending` to false and actively set it to true
when inviting users, so that existing users won't show "Invitation
Pending"

* fix tests that broke due to default is_invitation_pending value

* treat admin's e-mail address as verified

* add verification endpoint

* send verification e-mail

* Update client/app/components/empty-state/empty-state.html

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/authentication/account.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/handlers/authentication.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/templates/emails/verify.html

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/authentication/account.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/templates/verify.html

Co-Authored-By: rauchy <omer@rauchy.net>

* Update redash/templates/emails/verify.txt

Co-Authored-By: rauchy <omer@rauchy.net>

* add link in case redirects are disabled

* POSTing to /email_verification makes more sense than GETting /send_verification

* avoid sending invitations when no_invite is passed along

* Update client/app/pages/users/new.html

Co-Authored-By: rauchy <omer@rauchy.net>

* move e-mail verification prompt to home-page

* get rid of redundant $scope

* return JSON

* flip is_email_verified's default value so that existing users do not
show as not-verified

* e-mail verification propmt isn't dangerous, it just wants to warn you
2019-01-13 13:57:12 +02:00
Ran Byron
6c6366e6f0 Fix: Refresh schedule durations not pluralized sufficiently (#3268)
* Fix: Refresh schedule durations not pluralized sufficiently

* Allows omitting single value number in durationHumanize (#3274)
2019-01-13 13:31:41 +02:00
Ran Byron
de04a403d7 Fix: Refresh schedule interval count doesn't adhere to permission rules (#3265)
* Fix: Refresh schedule interval count doesn't adhere to permission rules

* Fix “4.28 weeks” to “30 days”

* Merge interval type and count into one <Select>
2019-01-13 11:39:57 +02:00
Ilya Ruzakov
0b6f1fc21b [Data Sources] Implement Apache Drill (#3188)
* Added support for Apache Drill datasource

* Improvements in `Drill` query runner and minor refactoring

1. Drill query runner now inherits from `BaseHTTPQueryRunner`, because they both have a lot of common code.
2. `BaseHTTPQueryRunner.get_response` method now accepts `http_method` argument (original implementation was only capable of sending `GET` HTTP requests).
3. Added `order` to `BaseHTTPRequestRunner` configuration schema to fix order of UI elements based on the schema.
4. Eliminated duplicate method `_guess_type` in `GoogleSpreadsheet`, `Results` and `Drill` query runners, moved `guess_type` to `redash.query_runner`.
5. Removed tests for `_guess_type` in `GoogleSpreadsheet`, `Results` and `Drill` query runners, merged them into single test case and moved to `tests.query_runner.test_utils`.
6. Various minor changes (code style, imports, etc).
2019-01-10 09:12:35 +02:00
Omer Lachish
445f8e5c36 Fix invitation pending for existing users (#3261)
* default `is_invitation_pending` to false and actively set it to true
when inviting users, so that existing users won't show "Invitation
Pending"

* fix tests that broke due to default is_invitation_pending value

* update Flask-OAuthLib
2019-01-09 13:48:47 +02:00
Omer Lachish
a29136037c update Flask-OAuthLib (#3262) 2019-01-09 13:48:21 +02:00
Arik Fraimovich
08953cc919 Redis based implementation of user active_at timestamp update (#3256)
* Switch to simpler implementation
* Fix active_at update code
* Fix sync test
2019-01-08 14:03:49 +02:00
koooge
22f835d3cb client: Remove estraverse (#3254)
Signed-off-by: koooge <koooooge@gmail.com>
2019-01-08 12:29:24 +02:00
Omer Lachish
823f172a9f Invitation Pending changes (#3229)
* determine invitation_pending according to empty password. This commit will be reverted, I'm just deferring the implementation

* show '(Invitation Pending)' to users who haven't accepted their invitation yet

* allow resending invitations

* allow deletion of pending users from user list

* set invitation as not pending when following invite link

* prevent deleting activated users

* test that users who follow invitation links are set as non-pending invitations

* prevent re-using invitations

* invitees who use SSO will now also be marked as "non-pending"

* lint
2019-01-08 08:52:48 +02:00
Jannis Leidel
44dff83046 Add "Active at" column to user list. (#3026)
* add last_active_at to users page

* Use our JSON encoder as the SQLAlchemy JSON serializer.

* Fixed some inconsistencies in the user query class methods.

* Minor cosmetic fixes.

* Add some make tasks for easier development.

* Add user detail sync system based on Redis backend.

There is a periodic Celery task that updates a new “details” JSONB column in the “user” table with the data from Redis.

Currently this is only used for tracking the date of last activity of a user but can be extended with other user information later.

Updates a few dependencies.

* Normalize a few Flask extension API names.

* Reduce implementation complexity of JSONEncoder.

* Use request_started signal to make sure we have a request context.

Otherwise loading the user based on the request won’t work.

* Fix test that checks if disabled users can login.

This correctly uses a URL path that includes the current organization and checks for the error message.

The previous test seems to have been a red herring.

* Minor cosmetic fixes.

* Remove needs_sync in favor of just deleting things.

* Misc review fixes.

* Ignore line length.

* Split redash.models import several modules.

* Move walrus UTC DateTimeField into redash.models.types.

* Restore distinctly loading dashboards.

* Simplify default values for user details.

* Define __repr__ methods generically.

* Consistently have underscore methods at the top of model methods.

* Fix tests.

* Split redash.models import several modules.

* Update to latest walrus and redis-py.

* Update kombu to 4.2.2 for redis-py 3.x compatibility.

* Remove redis-cli container after running Make task.

* Move buffer condition after datetime/time conditions.

* Update walrus to 0.7.1.

* Refactor some query APIs.

This uses the flask-sqlalchemy helpers consistently and makes more use of mixins.

* Post rebase fixes.

* Use correct kombu version

* Fix migration down revision
2019-01-07 10:30:42 +02:00
Ran Byron
569430e5cd Fix: Refresh schedule phrase overlaps title (#3250) 2019-01-06 12:46:55 +02:00
Ran Byron
07a1c23df5 Fix: Able to set out-of-range refresh interval 2019-01-06 12:27:50 +02:00
Ran Byron
b97b8477ad Feature: Refresh schedule - styling (#3247) 2019-01-06 12:14:00 +02:00
Ran Byron
9b72dfe076 Feature: Refresh schedule - save/cancel actions 2019-01-06 11:33:35 +02:00
Ran Byron
3ee83a4c4a Feature: Refresh schedule - code optimizations 2019-01-06 11:17:43 +02:00
Marina Samuel
cdd2259d08 Closes #2396: Add finer-grained scheduling. (#2426)
* Closes #187: Add finer-grained scheduling - backend.

* Closes #2396 - Add finer-grained scheduling - frontend.

* Fix linting issues

* Rename ScheduleDialgo to .jsx
2019-01-06 10:59:50 +02:00
Vincentoo
fc368ee425 Support overriding the default Celery schedule database file via SCHEDULE_DB environment variable. (#3056)
By default Celery will use a file celerybeat-schedule in the current directory.
This is an issue in a Kubernetes/Openshift environment as the file may be lost or even impossible to write.
2019-01-03 20:51:18 +02:00
YOSHIDA Katsuhiko
7a2e08c3eb Upgrade requests package (#3245) 2019-01-03 18:59:58 +02:00
Levko Kravets
ba0d069283 getredash/redash#3213 Scatter charts can have category Y axis (similar to Bubble) (#3243) 2019-01-03 17:15:51 +02:00
Omer Lachish
670d86eb5f Simple user view (#3244)
* show a simple user details page when viewing a user who isn't you (or you arent the admin)

* add a snapshot test

* lint
2019-01-03 15:23:40 +02:00
Ran Byron
63f38b7acd Fix: Query editor duplicates keystrokes [#2972] (#3239) 2019-01-01 17:40:48 +02:00
Arik Fraimovich
8b5ffc6f84 Handle the case when a QueryTracker is None and change order. (#3238) 2019-01-01 15:57:58 +02:00
Arik Fraimovich
cce2052e79 request.view_args might be None and add org_id to ApiUser (#3237) 2019-01-01 15:44:34 +02:00
Arik Fraimovich
8ea6283430 Send argsrepr value with execute_query task (#3235) 2019-01-01 15:32:02 +02:00
Arik Fraimovich
08b86c1c6d Fix: forked query wasn't opening in MULTI_ORG env (#3236) 2019-01-01 15:31:41 +02:00
koooge
0449a3ff31 Delete an unused global (#3231)
Signed-off-by: koooge <koooooge@gmail.com>
2019-01-01 08:58:31 +02:00
Arik Fraimovich
4ea46f197e It's 2019 now ! 🎉 2019-01-01 08:40:51 +02:00
Omer Lachish
d7edaa3ba2 Tests for find_missing_params (#3225)
* stop testing `collect_query_parameters`, it's an implementation detail

* add tests for `missing_query_params`
2018-12-31 12:34:57 +02:00
YOSHIDA Katsuhiko
632fc5aace Merge pull request #3232 from koooge/fix_warn_tapable
Update webpack-build-notifier to dismiss warn
2018-12-31 10:09:23 +09:00
koooge
b9abb36799 Update webpack-build-notifier to dismiss warn
Signed-off-by: koooge <koooooge@gmail.com>
2018-12-30 17:37:42 +00:00
Levko Kravets
d7e7b99a76 Merge pull request #3228 from kyoshidajp/fix_trailing_spaces_error
Fix front-end compile error
2018-12-28 20:43:10 +02:00
Katsuhiko YOSHIDA
db87c8740e Fix front-end compile error 2018-12-29 01:36:16 +09:00
Arik Fraimovich
5f2b54a320 Root folder cleanup (#3220)
* Remove old_migrations folder

* Move Dockerfile.cypress into .circleci
2018-12-26 18:09:41 +02:00
Arik Fraimovich
f62d0e1300 Use lower cased names for groups: (#3221)
Otherwise sorting depends on the Postgres collation and causes tests
to fail on different envoirnments.
2018-12-26 17:16:13 +02:00
Omer Lachish
9e156c1c30 Fix: missing param fails for object values (like date range) (#3218)
* fix: range params not recognized

* Handle parameters with unicode

* Remove debug prints

* DRY up missing_params
2018-12-26 17:06:30 +02:00
Gabriel Dutra
26965b4948 Add dot behavior to autocomplete (#3092)
* Add dot behavior to autocomplete
* Transform the Keyword Builder in an external js
* Remove methods from QueryEditor constructor
2018-12-26 17:04:11 +02:00
Omer Lachish
7a03928f48 we've noticed users with integer legacy session identifiers, so it doesn't hurt to convert to string anyway (#3219) 2018-12-26 16:24:59 +02:00
Omer Lachish
8f14efdaff Avoid exploding sql parse (#3216)
* fail silently when sql_parse explodes

* Update upstream/redash/handlers/query_results.py

Co-Authored-By: rauchy <omer@rauchy.net>

* Update upstream/redash/handlers/query_results.py

Co-Authored-By: rauchy <omer@rauchy.net>
2018-12-26 10:43:00 +02:00
deecay
03a7e24204 Show Sort Y only when type is Heatmap (#3206) 2018-12-24 17:10:16 +02:00
ialeinikov
2f7cb1bc8a [Athena] Fix: missing databases (apply pagination) (#2503)
* adding paginator on databases in glue

* reduce number of nested loops

* fixing indentation

* double for-loop instead of generator

* removing unused generator
2018-12-24 14:02:08 +02:00
koooge
64783b7f06 Switch to MULTI FROM Dockerfile and use Node 10 for builds (#3199) 2018-12-23 15:17:54 +02:00
Takuya Arita
8ed872756c Add test case for redash.utils.generate_token (#3211) 2018-12-23 15:13:00 +02:00
Arik Fraimovich
83ea472d37 Merge pull request #3093 from getredash/backend-parameter-templating
Remove Mustache templating from frontend
2018-12-20 22:24:11 +02:00
Arik Fraimovich
0505163ff9 Merge pull request #3174 from getredash/invalidate-sessions-after-email-or-password-change
Invalidate sessions after email or password change
2018-12-19 15:49:54 +02:00
Arik Fraimovich
3d38bb478f Merge pull request #3205 from kravets-levko/bug/wrong-query-link-in-widget
Widget: fix url parameters in query link
2018-12-19 15:47:30 +02:00
Levko Kravets
654e906f6b getredash/redash#3203 Widget: fix url parameters in query link 2018-12-19 15:13:58 +02:00
Omer Lachish
54da6c69ab Merge branch 'invalidate-sessions-after-email-or-password-change' of github.com:getredash/redash into invalidate-sessions-after-email-or-password-change 2018-12-19 14:36:08 +02:00
Omer Lachish
8284e829fb explain why we call on identity changes 2018-12-19 14:35:42 +02:00
Omer Lachish
bcfff469de Merge branch 'master' into invalidate-sessions-after-email-or-password-change 2018-12-19 14:23:35 +02:00
Omer Lachish
b5ceb268ef Merge branch 'master' into invalidate-sessions-after-email-or-password-change 2018-12-17 12:52:17 +02:00
Arik Fraimovich
8583eaa8ad Merge pull request #3173 from kyoshidajp/golineup
Make it possible to move up one line by Ctrl+P on macOS
2018-12-17 12:08:04 +02:00
Arik Fraimovich
ef66da7d94 V6 release (#3195)
* V6 release

* Remove "-beta"

* Update package.json

* Update package-lock.json

* Update CHANGELOG.md
2018-12-16 16:01:20 +02:00
Omer Lachish
1b4e0f5de7 rename safely_apply_parameters to apply_parameters 2018-12-16 10:58:20 +02:00
Omer Lachish
479247b60c Merge branch 'master' into backend-parameter-templating 2018-12-16 10:22:29 +02:00
Arik Fraimovich
57c8fbe14e README updates
1. Remove link to Slack channel.
2. Update number of data sources.
2018-12-16 09:55:34 +02:00
Arik Fraimovich
938a20e7c0 Use multiple issue templates instead of a single one (#3194)
* Switch to issue templates

* Apply a label to non bugs
2018-12-16 09:42:32 +02:00
Katsuhiko YOSHIDA
dc842e9201 Fix can't open new parameter dialog by Ctrl+P on Windows and Linux 2018-12-14 18:58:33 +09:00
Arik Fraimovich
f5dbdf245a Safely create_app in Celery code (try to fetch current_app first). (#3187)
Closes #3181.
2018-12-13 15:10:31 +02:00
Omer Lachish
35357afb90 transform legacy session identifiers into new session identifiers 2018-12-13 13:02:11 +02:00
Omer Lachish
419877b364 explain the motivation behind support for legacy session identifiers 2018-12-13 13:02:03 +02:00
Omer Lachish
143d515bfc use login_user instead of manually updating user_id in the session 2018-12-13 12:30:21 +02:00
Gabriel Dutra
8481dacff4 Fix eslint issues on user.js (#3186) 2018-12-12 23:32:12 +02:00
Omer Lachish
94905a287a tests for legacy session user identifiers 2018-12-12 13:03:50 +02:00
Katsuhiko YOSHIDA
34af780264 Golineup only macOS 2018-12-12 19:00:13 +09:00
Omer Lachish
3c8a3caa1d backward compatibility so users who have the old session identifier don't get logged out 2018-12-12 10:10:13 +02:00
Omer Lachish
9d566ef302 Merge branch 'master' into invalidate-sessions-after-email-or-password-change 2018-12-12 09:49:11 +02:00
Omer Lachish
e23a07af03 Remove missing coverage from pytest terminal output (#3180)
* Remove missing coverage from pytest terminal output

* move coverage reporting to CI
2018-12-12 08:30:46 +02:00
Omer Lachish
2312db46f2 test that other sessions are invalidated when changing an e-mail. I had
to resort to comments in code in order to explain this. I'm a failure
today. 😭
2018-12-11 15:14:43 +02:00
Arik Fraimovich
52434a837f Make refresh_queries less noisey in logs (#3183) 2018-12-11 15:03:29 +02:00
Arik Fraimovich
230ad33f02 [Redshift] Fix: support for schema names with dots. (#3182) 2018-12-11 14:57:42 +02:00
Omer Lachish
b3495b8c00 test that user does not get logged out when changing email or password 2018-12-11 12:25:51 +02:00
Omer Lachish
dec790a9f3 Merge branch 'master' into invalidate-sessions-after-email-or-password-change 2018-12-11 10:41:27 +02:00
Gabriel Dutra
cfe12c5a5d Add DB Seed to Cypress and setup Percy (#3155)
* Update Cypress element selectors

* Add seed data function to Cypress

* Change Cypress setup to be part of db-seed

* Add DatabaseSource selector to Create Data Source spec

* Add getElement command to Cypress

* Fix eslint issues

* Change Cypress getElement to getByTestId

* Add Percy and test it with the CI

* Change Percy dependency for CI to Cypress' Dockerfile

* Change Percy's execution to the docker container
- add --no-save to avoid errors on Dockerfile.cypress
 - pass PERCY_TOKEN from the CI to docker container

* Fix missed char on CircleCI config file

* Move Percy execution back to host on the CI

* Test adding PERCY_TOKEN to frontend-e2e-tests on CI config

* Undo add PERCY_TOKEN to config.yml

* Add Percy token and .git folder to Cypress

* Remove Percy install from config.yml

* Ignore .git folder again and use Percy env vars instead

* Update PERCY_PULL_REQUEST to be CIRCLE_PR_NUMBER

* Update cypress-server.js to handle other cypress commands
- cypress-server.js -> cypress.js
- new commands added to cypress.js
- CircleCI config updated accordingly
- added a Homepage screenshot

* Remove trailing spaces

* Add Create Query spec

* Disable Cypress videos

* Update run browser to Chrome

* Add missing --browser chrome
2018-12-10 22:29:36 +02:00
Omer Lachish
944bee6101 update identity only after succesfully updating user information 2018-12-10 14:25:04 +02:00
Omer Lachish
38ed046c9f Fix disable error message (#3175)
* display correct error message when attempting to disable yourself
* 403 (Forbidden) feels like a better status code than 400 (Bad Request)
* fix broken test
* remove redundant error title
2018-12-10 14:02:50 +02:00
Takuya Arita
1acf063755 FIX: Reject empty query name (#3171) 2018-12-10 12:35:25 +02:00
Omer Lachish
c426c826f7 fix tests that rely on sessions 2018-12-10 12:27:39 +02:00
Omer Lachish
4b1275ae56 don't sign out the current session when changing email or password 2018-12-09 11:07:42 +02:00
Katsuhiko YOSHIDA
b3c3134a86 Make it possible to move up one line by Ctrl+P 2018-12-09 15:26:01 +09:00
Omer Lachish
c311c12bcf invalidate session when email or password changes - currently not
backwards compatible
2018-12-05 23:49:55 +02:00
Omer Lachish
76321937d7 Remove API permissions for users who have been disabled (#3162) 2018-12-05 12:21:18 +02:00
Arik Fraimovich
c9ca2b99f6 Fix: Alert.evaluate failing when the column is missing. (#3167) 2018-12-05 11:28:05 +02:00
Arik Fraimovich
d42f0b2d40 Directly using record_event task requires timestamp (#3166)
Using the helper instead.
2018-12-05 10:11:08 +02:00
Vladislav Denisov
e530c23d4c clickhouse: fixed int() conversion error (#3161) 2018-12-05 09:29:47 +02:00
Omer Lachish
0973ee8abb Include correct version in production builds (#3163)
* take the first 8 characters for frontend version, not backend version

* run `npm run build` after version has been updated in CI

* `pack` should run last
2018-12-04 22:14:32 +02:00
Arik Fraimovich
3ee7537a6c WIP: Update CHANGELOG (#3159) 2018-12-03 22:07:20 +02:00
Omer Lachish
d769afab6f Merge branch 'master' into backend-parameter-templating 2018-12-03 13:22:44 +02:00
Omer Lachish
cf86509a0b remove leftovers of SQLQuery from utils 2018-12-03 13:17:40 +02:00
Omer Lachish
54894c3a26 track sql injections using an event to detect false positives 2018-12-03 13:12:34 +02:00
Arik Fraimovich
9c12b04578 json_dumps: add support for serializing buffer objects. (#3156) 2018-12-03 10:57:36 +02:00
Omer Lachish
1519849219 use SQLQuery's text property instead of method 2018-12-03 10:03:45 +02:00
Omer Lachish
202b93d8be use SQLQuery in run_query 2018-12-03 09:53:17 +02:00
Omer Lachish
0a62bee3a1 Merge branch 'master' into backend-parameter-templating 2018-12-03 09:44:52 +02:00
Omer Lachish
9579f12a83 Protect against SQL injections by using tree comparisons (#3109)
* add SQLQuery class with tests for safe queries and non-safe tautology attacks

* add test for union query injections

* split .apply calls to newline

* add tests for comment attacks

* remove double underscore

* extract complex children check to variable

* inherit from object because I'm not a lamer

Co-Authored-By: rauchy <omer@rauchy.net>

* simplify cognitive complexity

* check that additional columns are not injected

* detect appended queries

* inline .apply calls

* move SQLQuery to it's own module

* move SQLQuery tests to their own module

* serialize SQLQuery instances

* raise an exception when attempting to serialize an unsafe query

* queries without parameters are safe

* remove redundant parentheses

* use cached properties

* rename SQLInjectionException to SQLInjectionError

* support multiple word params and param negations

* refactor out methods that don't involve any state

* don't cache text()

* reduce cognitive complexity
2018-12-02 21:51:06 +02:00
Zsolt Kocsmárszky
463d4ce518 Fix label positioning on no found screen (#3148)
* Fix label positioning on no found screen

* Use TagsControl component on not found screen
2018-12-02 10:42:30 +02:00
Zsolt Kocsmárszky
2e4d196452 Add and improve recent db logos that didn't fit in size properly (#3147)
* Add and improve recent db logos that didn't fit in size properly

* Update mongodb logo

* Remove Athena Direct as requested
2018-12-02 10:27:01 +02:00
Zsolt Kocsmárszky
4078af2996 Update, replace and fix new alert destination logos so it fits better (#3146) 2018-11-29 21:04:35 +02:00
Zsolt Kocsmárszky
73825ea266 Improve tag link colors and fix group tags on Users page (#3149) 2018-11-29 21:02:54 +02:00
Zsolt Kocsmárszky
b2a0d61844 Better manage permissions modal (#3139)
* Improved design for manage permissions

* Show Owner on Permission modal, remove owner from dropdown options

* Pass owner to Permissions modal
2018-11-29 15:40:44 +02:00
Omer Lachish
1774edabc0 take the first 8 characters for frontend version, not backend version (#3145) 2018-11-29 15:20:30 +02:00
Omer Lachish
54b8e7c136 Merge pull request #3144 from getredash/display-frontend-version
Display only the first 8 characters of frontend version
2018-11-29 15:17:14 +02:00
Omer Lachish
54f09f73db take the first 8 characters for frontend version 2018-11-29 15:03:37 +02:00
Omer Lachish
35aca1d4cf Merge branch 'master' into display-frontend-version 2018-11-29 15:03:11 +02:00
Levko Kravets
757333c2d6 When editing a dashboard title results in the visualizations being replaced by the loading markers (#3142)
* getredash/redash#3015 When editing a dashboard title results in the visualizations being replaced by the loading markers

* CR1

Co-Authored-By: kravets-levko <levko.ne@gmail.com>
2018-11-29 14:48:21 +02:00
Omer Lachish
92728de04c Display frontend version (#3105)
* add git-revision-webpack-plugin

* configure git-revision-webpack-plugin

* add commit to footer

* rename version and commit to backendVersion and frontendVersion

* rename version and commit to backendVersion and frontendVersion

* disable lint error due to use of globals

* fix snapshot test

* read frontend version from VERSION file instead latest git revision

* directly require from version.json file instead of going through WebPack's DefinePlugin

* run snapshots
2018-11-29 14:24:23 +02:00
Omer Lachish
407f14ffca run snapshots 2018-11-29 13:07:04 +02:00
Arik Fraimovich
ecb8a5c244 Hive/Databricks related improvements (#3143)
* Hive: fix issues in building options.

* Hive: add missing import.

* Split Hive into two query runners: one for http and a regular one.

* Upgrade pyhive to support http.

* Specific implementation for databricks:

* Different schema loader, because column names are different (or Hive's schema loader is broken).
* Simpler configuration.

* Simplify Databricks setup even more by removing username.
2018-11-29 13:01:23 +02:00
Omer Lachish
0e8fab4872 directly require from version.json file instead of going through WebPack's DefinePlugin 2018-11-29 13:00:13 +02:00
Omer Lachish
c15fa0c592 read frontend version from VERSION file instead latest git revision 2018-11-29 11:57:53 +02:00
Levko Kravets
09ab00e360 Migrate all tags components to React (#3138) 2018-11-29 11:35:17 +02:00
Truong Hoang Phuoc, Robert
1728f924cf Fix schema refresh to work on MySQL 8 (#3141) 2018-11-29 09:19:36 +02:00
Omer Lachish
8dc10fbd9a Merge branch 'master' into display-frontend-version 2018-11-29 09:13:41 +02:00
Jannis Leidel
a16170e701 Fix tag counts for dashboards and queries. (#3120)
* Fix tag counts for dashboards to be distinct.

This also makes use of the Dashboard.all base query.

Fix #3108.

* Use Query.all_queries as the base query for Query.all_tags.

* Add test case for Dashboard.all_tags.
2018-11-28 14:06:15 +02:00
Arik Fraimovich
07c0bba568 Delete now.json (#3134) 2018-11-28 10:36:33 +02:00
Arik Fraimovich
d36d18f85b Support unicode in Postgres/Redshift schema (#3124) 2018-11-27 09:06:44 +02:00
Arik Fraimovich
bd20ce12ac Don't allow updating user's email to blacklisted domain. (#3127) 2018-11-26 21:22:14 +02:00
Arik Fraimovich
1cdfcfaa3c Vertica: update driver & add support for connection timeout (#3125)
* Update Vertica driver version

* Vertica: add support for connection timeout
2018-11-26 21:21:49 +02:00
Arik Fraimovich
2fdace518a Use lower timeout for the first 5 seconds when polling for results. (#3128) 2018-11-26 21:21:07 +02:00
Igor Canadi
3516e4ef45 Add Rockset query runner (#3068)
* Add Rockset query runner

Per REST API documented here: https://docs.rockset.com/rest/

* Update rockset.py

* Add Rockset logo

* Refactor Rockset qury runner:

* More idomatic names for configuration.
* Move API code to separate class to make it easier removing it when we
  switch to official library.
* Make Test Connection work.

* apply autopep8 to rockset.py
2018-11-26 21:20:37 +02:00
Arik Fraimovich
d842968142 MongoDB: add support for sorting columns. (#3126) 2018-11-26 16:08:04 +02:00
Arik Fraimovich
600741620a Remove (Beta) from Query Results query runner name (#3123) 2018-11-26 15:31:39 +02:00
YOSHIDA Katsuhiko
45f4277eb4 Fix forked query is opened in the same tab (#3121) 2018-11-26 14:23:55 +02:00
Jannis Leidel
bcf3041c91 Show menu divider only if query is archived. (#3122)
Fix #3117.
2018-11-26 14:02:52 +02:00
Zsolt Kocsmárszky
da423340ec Fix mobile padding issues on Query results (#3111) 2018-11-26 13:41:07 +02:00
Arik Fraimovich
4003d4f1aa Add event tracking to autocomplete toggle & trackEvent helper function (#3114)
* Add non Angular version of Events.

* Add event tracking for autocomplete toggle

* Fix lint error in QueryEditor
2018-11-26 09:58:39 +02:00
YOSHIDA Katsuhiko
a6b782e0ce Add get_current_user() into Python Data Source (#3088) 2018-11-25 14:11:27 +02:00
YOSHIDA Katsuhiko
5648de9ba8 Open new tab when forking a query (#3089)
* Open new tab when forking a query

* Delete old fork menu item and add icon
2018-11-25 14:09:52 +02:00
Jannis Leidel
13eb365f7b Update changelog for v6.0.0-beta. (#3112)
* Add v6.0.0-beta changelog entry.

* Update CHANGELOG.md
2018-11-25 14:08:25 +02:00
Udomomo
8257d9d037 Add permissions to the result of "manage.py groups list" command (#3007)
* Add permissions to the result of "groups list" command

* added permissions to test case

* removed setting for debug
2018-11-25 13:47:25 +02:00
Allen Short
babbeb79f0 keep query text in local state for now (#3107) (#3110)
* keep query text in local state for now (#3107)

This will be unnecessary once the queryText prop isn't managed by Angular.

* Fix: make formatQuery work
2018-11-23 15:28:30 +02:00
Omer Lachish
8028397f27 Merge branch 'master' into display-frontend-version 2018-11-22 12:52:43 +02:00
Subhi Al Hasan
e05c8e6060 Fix collection fields retreival bug when Views are present in MONGO DB (#3097)
* Fix collection fields retreival bug when Views are present in MongoDB

* fixing _is_collection_a_view function

* Update redash/query_runner/mongodb.py

Co-Authored-By: jodevsa <jodevsa@gmail.com>
2018-11-21 17:13:12 +02:00
Omer Lachish
ef8839aafa add tests for comment attacks 2018-11-21 13:52:08 +02:00
Omer Lachish
14860f6a8b split .apply calls to newline 2018-11-21 13:51:19 +02:00
Omer Lachish
a52c783857 add test for union query injections 2018-11-21 13:45:52 +02:00
Omer Lachish
5e7c785891 add SQLQuery class with tests for safe queries and non-safe tautology attacks 2018-11-21 13:45:29 +02:00
Omer Lachish
b242cefaa0 Merge branch 'master' into backend-parameter-templating 2018-11-21 10:51:44 +02:00
Omer Lachish
fae2b70866 Merge branch 'display-frontend-version' of github.com:getredash/redash into display-frontend-version 2018-11-21 10:49:29 +02:00
Omer Lachish
1119fce44c Merge branch 'master' into display-frontend-version 2018-11-21 10:48:03 +02:00
Omer Lachish
bfb7edc0eb fix snapshot test 2018-11-21 10:47:54 +02:00
Omer Lachish
a39a739473 disable lint error due to use of globals 2018-11-21 10:44:34 +02:00
Omer Lachish
c9dfac5b1d rename version and commit to backendVersion and frontendVersion 2018-11-21 10:44:18 +02:00
Omer Lachish
1b66fff3be rename version and commit to backendVersion and frontendVersion 2018-11-20 23:34:39 +02:00
Arik Fraimovich
0fe1b5f9d4 Fix: registerAll fails after minification (#3106) 2018-11-20 23:34:37 +02:00
Levko Kravets
143db90a50 Fix query page header (#3046)
* getredash/redash#3017 Improve query page header

* getredash/redash#3017 Resolve conflicts

* getredash/redash#3017 CR1 (fix margins/paddings)
2018-11-20 18:48:41 +02:00
Arik Fraimovich
bac90db3ee Autocomplete toggle improvements (#3091)
* Autocomplete toggle improvements:

* Refactor to its own component.
* Show state in tooltip (enabled/disabled).
* Disable the toggle if autocomplete is not possible (no schema/too many tokens).

* Remove unsued code.

* Custom icons font (currently has only two icons).

Generated with Icomoon. If we extend its use, we should probably automate this and move to its own package.

* Don't disable live autocomplete for data sources without schema.

It can still be useful to autocomplete from local keywords.

* Differentiate between autocomplete toggle states with an icon.

Also added explicit message for the disabled state.

* Remember thes state of autocomplete.

* Only auto register init functions.
2018-11-20 18:45:33 +02:00
Omer Lachish
649d46de89 add commit to footer 2018-11-20 15:25:07 +02:00
Omer Lachish
0163e85eda configure git-revision-webpack-plugin 2018-11-20 15:24:55 +02:00
Omer Lachish
f25beb3fb7 add git-revision-webpack-plugin 2018-11-20 15:24:41 +02:00
Omer Lachish
c66f63d7a5 Prevent Query's updated_at from changing when it is linked to new query results (#3082)
* avoid Query's updated_at from changing when it is linked to new query results

* move comment to previous line

* move QueryResult tests to their own module

* add test which verifies that updated_at is not changed on query data
updates

* tests were false positives - they compared HH:MM:SS, but that never
changed because the original time was 1 week behind.

* remove redundant constructor

* remove hack and use a proper event to prevent updated_at from changing

* use self.assertEqual instead of assert
2018-11-20 12:22:15 +02:00
Levko Kravets
16ae0aa3d8 getredash/redash#2901 Fix docs links (#3102) 2018-11-20 11:06:09 +02:00
Arik Fraimovich
68ada7b590 UI for the feature flag of the share edit permissions feature (#3077)
* Remove unused settings.

* Add: UI feature flag for sharing permissions

* Revise feature flag message
2018-11-20 10:04:42 +02:00
San
9e745ef648 Delete redundant regex segment (#3100) 2018-11-20 09:48:24 +02:00
Allen Short
ee0d7f5ec9 force angular to update query editor properly (re #3098) (#3099) 2018-11-20 08:06:32 +02:00
Omer Lachish
1b3bbb6c3b swap parameters so their order makes more sense 2018-11-19 22:56:51 +02:00
Omer Lachish
7bee07c9da include parameters (and query_id) in the recorded event 2018-11-19 22:54:22 +02:00
Omer Lachish
74ab7a5a42 Merge branch 'master' into backend-parameter-templating 2018-11-19 21:59:14 +02:00
Levko Kravets
e36853ca84 Tags autocomplete: some tags not shown on search (#3094)
* getredash/redash#3052 Tags autocomplete: some tags not shown on search

* getredash/redash#3052 CR1
2018-11-19 12:33:05 +02:00
Omer Lachish
bc65b62776 remove Mustache templating from frontend and send all parameters to the
API (in the POST body)
2018-11-19 10:50:00 +02:00
YOSHIDA Katsuhiko
d43b35ba6f Change Standard SQL as the default (#3085) 2018-11-18 11:21:00 +02:00
Topher Cyll
6e4f0ccee8 Bubble chart marker size override was clobbering seriesColor. (#3063)
Colors can now be set for bubble charts in UI.
2018-11-18 11:05:18 +02:00
Vladislav Denisov
0ce7772aa3 clickhouse: added WITH TOTALS option support (#3083) 2018-11-15 22:11:43 +02:00
San
f6ef38479c support tel, sms, mailto links in the query result (#3084) 2018-11-15 22:08:02 +02:00
Arik Fraimovich
bf85ddaaff Always use basic autocomplete. (#3079) 2018-11-15 08:58:30 +02:00
Arik Fraimovich
8bb96c8c91 Fix: URL data source shouldn't require URL. (#3078)
Closes #2919.
2018-11-14 15:43:34 +02:00
Filipe Veloso
42b05cee00 Update docker-compose.yml (#2905)
* Update docker-compose.yml

jut updating docker-compose dev to version 3, any special reason to keep redis on 3? and pg on 9.5? I could also add a volume to pg, any reason not to do so?

* rollback to redis 3 and pg 9.5 due to consistency in project defaults

* Configure volume directly in worker service.
2018-11-14 14:27:19 +02:00
Anton Burnashev
d0fd02123a Add white-space padding to separators in the footer (#3076) (#3076)
Closes #3075
2018-11-14 10:44:38 +02:00
Takuya Arita
e34203dac3 Remove only Redash containers (#3073) 2018-11-13 16:45:40 +02:00
koooge
c2bd8518a6 Makefile: Add make targets for test (#3032) 2018-11-12 09:06:25 +01:00
Levko Kravets
46363ccc70 Table visualization horizontal scrollbar should not be always visible (#3061) 2018-11-12 07:50:44 +01:00
Levko Kravets
5e1512e777 Mustache: don't html-escape query parameters values (#3058) 2018-11-08 21:54:08 +01:00
Arik Fraimovich
188c045fdb Add Kylin logo (#3054) 2018-11-08 11:20:05 +01:00
Omer Lachish
57d921dc2b Druid query runner (#3047)
* add Druid query runner skeleton

* enable Druid only if package is available

* add Druid

* remove redundant  override

* correct configuration schema

* implements run_query

* implement get_schema

* remove username and password

* fix small lint issues

* proper indentation

* add correct type mapping
2018-11-08 10:48:45 +01:00
Xin Bai
df0804c8fd Add Kylin plugin for SQL query (#2936) 2018-11-08 10:24:05 +01:00
Alexander Leibzon
c289dde806 Google analytics fix fixes #2965 (#3008)
* add PagerDuty as an Alert Destination

* remove comments

* add unknown state handling

* fixes

* revert setup.sh

* Remove test method.

* resolves #2965

* more elegant, as per Arik's suggestion

* Add missing whitespace.
2018-11-08 10:18:33 +01:00
Levko Kravets
b7cadca3b7 Edit-in-place component ignored isEditable flag and didn't work on Groups page (#3049) 2018-11-08 10:17:18 +01:00
Sami Jaktholm
43f8200707 feat(redshift): hide tables the configured user cannot access (#2866)
The SVV_COLUMNS table used to determine the tables of a
Redshift database includes all tables, even those the
current user cannot access, by default. These tables clutter
the schema browser and make it harder for users to determine
which tables they should have access to.

These changes modify the Redshift query runner so that
tables the configured user cannot access are filtered
out from the database schema. The checks are two-fold:

* First, the query uses HAS_SCHEMA_PRIVILEGE to check if the
  current user has USAGE rights on a schema the given table
  belongs to. This privilege is required to access any of
  the tables in a schema.

* Second, the query tries to determine if the current user
  has SELECT access to the given table. Two cases need to
  be considered here:

  * First, we need to check if the table is part of an
    external schema. Access to tables in external schema
    is controlled at schema level - you cannot grant or
    revoke access to specific external tables. Additionally,
    the HAS_TABLE_PRIVILEGE returns an error if it is asked
    to give a verdict for an external table.

    Hence, the query checks if the schema a specific table
    belongs to is an external schema and if it is, the table
    is included in the list (if we got here the user already
    had USAGE on the given schema). This check short-circuits
    the table-level access check for external tables which
    means they are never passed to HAS_TABLE_PRIVILEGE().

  * Then, if the table was not part of an external schema,
    the HAS_TABLE_PRIVILEGE() function is used to determine
    if the user has SELECT access to the given table. The
    table is included in the schema if this check passes.

Together this condition ensures that tables the user definitely
cannot access are not included in the schema browser.

These changes have been tested to work in an environment that
includes normal and external schemas, normal and late-binding
views, and normal and external tables.
2018-11-08 09:53:04 +01:00
Arik Fraimovich
a1b580bba6 Fix Docker Compose version number in Cypress config (#3051)
* Update Docker compose version

* Experiment with Docker-Composeless CI build

* Switch back to Docker compose based tests
2018-11-07 17:21:31 +01:00
Zsolt Kocsmárszky
19d0313ea2 Fixing tag issues (#3006)
* Add title="" for tags

* Fix lines

* Fix long tag and overlaying tag issues on queries
2018-11-07 16:58:15 +01:00
Arik Fraimovich
667fe43e23 Revert "address tag display on query list page" (#3050)
* Revert "remove pytest_watch (#3048)"

This reverts commit 096eba3876.

* Revert "address tag display on query list page (#2803)"

This reverts commit 99115a12e6.
2018-11-07 16:57:37 +01:00
Omer Lachish
096eba3876 remove pytest_watch (#3048) 2018-11-07 16:49:41 +01:00
Alison
99115a12e6 address tag display on query list page (#2803)
* address tag display on query list page

* character limit tags in css

* updates to tags on levko's feedback
2018-11-07 16:12:31 +01:00
Gabriel Dutra
7d601cbbc9 Cypress based E2E tests (#3019) 2018-11-07 14:37:08 +01:00
GitSumito
bf6a09c5aa CLI sort (#3041) 2018-11-06 16:45:39 +01:00
Yossi-a
99967e720f Sort columns with undefined values (#2745)
* sort should treat undefine value as the minimal value

* explicit undefined check
2018-11-05 04:47:42 +02:00
Arik Fraimovich
27f489de20 Build docker image on master branch. (#3039) 2018-11-04 12:12:13 +02:00
yoavbls
46941d3aa1 Update Flask-Admin to 1.5.2 (#3036)
I don't know if someone uses flask-admin but I upgraded it because of this bug:
https://github.com/flask-admin/flask-admin/issues/1588
In 1.4.2 you cant add and edit records/
2018-11-01 15:58:50 +02:00
Levko Kravets
60c230add7 getredash/redash#3034 Postgres query runner: handle NaN/Infinity values (#3035) 2018-11-01 15:57:39 +02:00
Takuya Arita
0784a0c6f5 Add some tests for Query Results (#3031) 2018-10-31 11:05:17 +02:00
Zsolt Kocsmárszky
9288d89248 Fix query result section (#2980) 2018-10-29 22:09:49 +02:00
Levko Kravets
391fbe130b getredash/redash#2998 Charts lose responsive features after refreshing the dashboard (#3024) 2018-10-29 22:08:35 +02:00
Levko Kravets
e25c8c4145 getredash/redash#3022 Toolbox covers part of the chart (#3023) 2018-10-29 11:38:29 +02:00
Arik Fraimovich
57353d1b40 Add -beta to version 2018-10-28 15:58:20 +02:00
Arik Fraimovich
7f4e08154f Bump version 2018-10-28 15:56:32 +02:00
Arik Fraimovich
500c82815b Add netlify config (#2999) 2018-10-28 15:31:27 +02:00
Arik Fraimovich
4a846f04e9 Add settings to import 2018-10-28 11:11:11 +02:00
Takuya Arita
b1e9d87e2a Apply query format options from settings (#2342)
* Apply query format options from settings

* Apply sqlparse format options via env-vars
2018-10-28 10:40:07 +02:00
Arik Fraimovich
ab6ed7da34 Fix: setup.sh fails when run as root. (#2996)
Closes #2979
2018-10-23 09:49:24 +03:00
GitSumito
2e6883c527 Add "Users" users are belong to into groups list (#2991) 2018-10-21 11:40:07 +03:00
YOSHIDA Katsuhiko
4c44999b2c Fix an invalid prop type warning (#2992) 2018-10-21 11:39:37 +03:00
deecay
34c118cf83 Add: Heatmap chart visualization by Plotly (#2080) 2018-10-21 11:39:06 +03:00
Arik Fraimovich
38a89b9783 Table visualization: change default size to 25 and add more size options. (#2982) 2018-10-21 11:38:47 +03:00
YOSHIDA Katsuhiko
6e836795b2 Fix url scheme (#2994) 2018-10-21 11:38:11 +03:00
YOSHIDA Katsuhiko
719fc41dd1 Add page size settings (#2993)
Add page size settings.

| name | default | description |
| :---- | :------ | :---------- |
| `REDASH_PAGE_SIZE` | 20 | How many items are displayed in one page as default. |
| `REDASH_PAGE_SIZE_OPTIONS` | 5,10,20,50,100 | How many steps as page_size. |

This feature has requested at the meetup in Japan.

https://redash-meetup.connpass.com/event/101420/
2018-10-20 14:33:31 +02:00
Arik Fraimovich
467ec201da Add Jest based tests to our stack (#2985)
* Add Jest packages
* Add first test
* Install eslint rules for jest & move deps to dev
* Configure cirlce to run jest
* package.json: Remove dev command
* package.json: clean command
* Don't autoload test files.
* Fix: webpack-dev-server was recompiling all the files on every change
* Update CircleCI step names
2018-10-19 19:04:02 +03:00
koooge
5ab143de41 Rearrange make target (#2989) 2018-10-19 11:25:24 +02:00
Arik Fraimovich
284e497483 Databricks updates: logo, name and enable by default (#2983)
* Add Databricsk logo.
* Enable it by default.
* Rename to Databricks.
2018-10-19 10:00:33 +02:00
dmonego
c5613dddf1 Chnage: switch to Webpack 4 (#2933) 2018-10-18 21:21:47 +03:00
Arik Fraimovich
34fb3ac79f Change: add timeout to destination requests. (#2960) 2018-10-18 17:33:58 +03:00
Arik Fraimovich
5f58c328f1 MongoDB: skip system collections when loading schema. (#2961) 2018-10-18 17:33:24 +03:00
Arik Fraimovich
7d1dbb87db Change: update MongoDB requirements to support srv. (#2962) 2018-10-18 17:32:43 +03:00
GitSumito
45f4d46245 Add "Groups" users are belong to into users list (#2967) 2018-10-18 17:32:21 +03:00
Arik Fraimovich
44d05c35ac Presto query runner improvements (#2968)
* Presto: support for setting protocol (http/https).

* Presto: safe loading error message.
2018-10-18 17:31:48 +03:00
Arik Fraimovich
edd2cb85f7 Update CHANGELOG.md 2018-10-18 14:59:00 +03:00
Hiroka Zaitsu
6c364369bb Fix: TreasureData data source - deduplicate column names (#2867)
* Fix: TreasureData data source - deduplicate column names

* Maping types
2018-10-18 09:43:28 +03:00
YOSHIDA Katsuhiko
869841b2ac Preventing open redirection (#2906)
* Prevent open redirection attack

* Add redirection url after logging in test

* Sanitize url just before redirecting it

* Consider when next parameter is None
2018-10-17 21:55:58 +03:00
Arik Fraimovich
c71f722552 Query Results query runner improvements: (#2969)
- Show meaningful error when failing to create table.
- Quote column names to allow more characters types.
2018-10-16 15:23:00 +03:00
Jannis Leidel
af3a1e00c6 Fix #2757 - Use full text search ranking when searching in list views. (#2798)
This applies to the queries, dashboard and users views.
2018-10-16 10:38:37 +02:00
Gabriel Dutra
5b2ec81e65 Fix no tags shown when having empty set (#2964) 2018-10-15 23:08:18 +03:00
Vladislav Denisov
0008e5803b clickhouse: move timeout to params (#2956)
* clickhouse: timeout moved to params

* clickhouse: use get() method for timeout
2018-10-15 20:06:16 +03:00
Arik Fraimovich
e1c1f67abb Add: option to auto reload widget data in shared dashboards. (#2959) 2018-10-15 20:05:40 +03:00
Marina Samuel
30283235a4 Fix tarball build failure. (#2963) 2018-10-15 20:05:07 +03:00
Levko Kravets
845e33b396 Query page layout improvements for small screens (#2922)
* getredash/redash#2796 Make entire page scrollable on small screens; improve metadata block

* getredash/redash#2796 Improve query page header layout; fix small bugs (margins, etc.)
2018-10-15 19:59:05 +03:00
Arik Fraimovich
17baa66188 Show "Add description" only after saving the query. (#2958)
Closes #2897
2018-10-15 17:45:22 +03:00
Arik Fraimovich
5df7bd12c9 Fix: apply missing CSS classes to EditInPlace component. (#2957) 2018-10-15 17:38:22 +03:00
Nicolas Ferrandini
e14c8b61a0 Add DB2 as a data source using ibm-db python package (#2848)
* Add DB2 as a data source using ibm-db python package

* fix some codeclimate issue

* fix long line and missing white space

* Manage case of bad import

* Add DB2 query_runner as default query runner

* Fixed minor PEP8 rules
2018-10-15 17:13:39 +03:00
Arik Fraimovich
a8a3ec66fd Bring back fix to Box plot hover. (#2941) 2018-10-15 16:01:38 +03:00
GitSumito
a4b9c2da12 fixed https://github.com/getredash/redash/issues/2950 (#2951)
* fixed https://github.com/getredash/redash/issues/2950

* fixed test code

* Effective -> Active. thank you @kravets-levko
2018-10-15 15:57:51 +03:00
Vladislav Denisov
e6146dae0f Clickhouse fixes (#2953)
* clickhouse: avoid last line with comment in query

* clickhouse: add request timeout
2018-10-15 15:03:02 +03:00
Levko Kravets
bd3fe880a4 Add missing default "extensions" directory (webpack fails to build without it) (#2952) 2018-10-15 13:51:13 +02:00
Marina Samuel
02e919c39b Closes #2565: Add frontend extension capability. (#2799) 2018-10-14 15:53:39 +03:00
Arik Fraimovich
99c73aef2d Update snowflake_connector_python version (#2946) 2018-10-14 14:39:52 +03:00
Ralphilius
be377b5f59 Add Counter label (#2900)
* Add Counter label

* Update index.js

* Added visualization name as placeholder

* Backward-compatible for visualization name as label
2018-10-14 11:23:20 +03:00
Zsolt Kocsmárszky
6b11ae4312 Design refinements (#2927)
* Fix search size on smaller tablet size

* Less prominent tag counter

* Fix hiding logo

* Add missing space between icon and button text

* Different embed icon

* Revert embed icon to its original

* Better edit source icon + markup cleanup
2018-10-14 11:00:27 +03:00
YOSHIDA Katsuhiko
9021977a54 Fix admin api recording (#2937) 2018-10-14 10:49:11 +03:00
Sami Jaktholm
9c8d06578a feat: add support for expanding dashboard visualizations (#2824)
* feat: add support for expanding dashboard visualizations

These changes implement support for expanding a dashboard visualization
into a larger modal dialog.

This is useful if you have a dashboard with lots of small widgets and
want to inspect one of the widgets more closely. In the past, this
would've required you to navigate to the query page to see a larger
version of the visualization. With these changes, visualizations can
be expanded right from the dashboard.

The implementation is simple as it just renders the visualization into
a modal dialog. Other parts of the widget (e.g. parameters) are not
included in this dialog.

* chore(widget-dialog): use query-link widget to render title

This reduces code duplication a bit. The link is made read-only
as navigation doesn't close the modal dialog.

* fix: make ui-select dropdown z-index > modal dialog z-index in dashboard page

Otherwise the dropdown renders behind the modal dialog if filter value
is changed from the modal view of a widget.
2018-10-14 10:42:31 +03:00
YOSHIDA Katsuhiko
114beb2480 Auto focus tag input (#2938) 2018-10-14 10:39:08 +03:00
Alexander Leibzon
e97a5cbb29 add PagerDuty as an Alert Destination (#2903) 2018-10-14 10:35:39 +03:00
Alexander Leibzon
e87efc8bc3 fixes #2924 (#2931)
Google Spreadsheets: support for open by url
2018-10-11 21:07:20 +03:00
Arik Fraimovich
be7f601d21 Speed up builds by skipping installing requirements_all_ds.txt in CI unit tests (#2928)
* Speed up builds by skipping requirements_all_ds.txt

* Update docker compose file version

* Start services before running commands

* Add boto and Athena dependencies to requirements_dev.txt
2018-10-11 14:12:28 +03:00
Levko Kravets
9b59d10677 Use Plotly's function to clean y-values (x may be category or date/time) (#2872) 2018-10-11 12:27:28 +03:00
Levko Kravets
a40669e07f getredash/redash#2875 Update plotly.js; some cleanup; fix chart legend issue in horizontal mode (#2902) 2018-10-11 11:23:40 +03:00
Levko Kravets
0bcf5d4be7 Merge pull request #2929 from combineads/fix-date-filter
Fix: date value in a filter is duplicated.
2018-10-11 09:08:31 +03:00
combineads
8bc96764a6 Fix: date value in a filter is duplicated. 2018-10-11 14:56:57 +09:00
Niko Eckerskorn
6ea03e58b4 Address edgecase when retrieving Glue schemas for Athena query runner. (#2868)
Fixes getredash/redash#2858
2018-10-10 19:13:48 +03:00
Gabriel Dutra
94801665ab Fix output file name not changing after rename query (#2917) 2018-10-10 15:07:11 +03:00
Gabriel Dutra
aa12151e19 Fix export query results output file name (#2916)
- regexp `/ /g` will seek for all space ocurrences, not only the first
2018-10-10 14:56:31 +03:00
Jannis Leidel
c2429e92d2 Consistently use simplejson to loading and dumping JSON. (#2817)
* Consistently use simplejson to loading and dumping JSON.

This introduces the new functions redash.utils.json_dumps and redash.utils.json_loads and simplifies the custom encoder setup.

UUIDs are now handled by the default encoder, too.

Fixes #2807.

Use string comparison in parse_boolean instead of the (simple)json module.
2018-10-09 15:38:06 +02:00
Jannis Leidel
5ffc85c066 Extend menu item text a bit for visual consistency. 2018-10-08 20:08:07 +02:00
Jannis Leidel
fad757c878 Don’t show “Add to dashboard” in dropdown to unsaved queries. 2018-10-08 20:08:07 +02:00
Jannis Leidel
3351a281ee Fix webpack build error about BigMessage. (#2910) 2018-10-08 12:03:54 +02:00
Arik Fraimovich
1f0053f531 MySQL: hide sys tables (#2909) 2018-10-08 10:05:16 +03:00
Arik Fraimovich
935dc38360 Update setup files: (#2908)
* Remove use of newgrp
* Updated packer configuration
2018-10-08 09:41:15 +03:00
Arik Fraimovich
bfef7fae93 Remove unused dependencies. (#2907)
Closes #2782
2018-10-08 09:39:57 +03:00
cclauss
da6d456f6f CircleCI: Flake8 tests passing on Legacy Python and Python 3 (#2881) 2018-10-05 13:48:01 +03:00
Arik Fraimovich
c19199c2fb Add margin between format and autocomplete buttons (#2899) 2018-10-04 12:34:03 +03:00
Arik Fraimovich
1e78861f85 Move Ant styles into a central location. (#2898)
This is to ensure that we include our override after loading Ant's styles.
2018-10-04 12:27:36 +03:00
Arik Fraimovich
10bc5a0bf6 Remove misplaced bracket. (#2894) 2018-10-04 12:01:38 +03:00
Marina Samuel
313af904df Add ability for extensions to add periodic tasks. (#2740) 2018-10-04 09:07:58 +03:00
Allen Short
8c478087a9 Rewrite query editor to React (#2636) 2018-10-03 22:25:19 +03:00
Arik Fraimovich
ccac41c6d4 Fix: JS build breaks because registerAll tries to run EditInPlace component (#2886) 2018-10-02 16:22:47 +03:00
Jannis Leidel
69635f2c40 Rename Yandex Metrika to Metrica. (#2884)
Fix #2874.
2018-10-02 16:11:01 +03:00
yoavbls
1867ea50bb Add option to query cached results (#2855) 2018-10-02 16:05:41 +03:00
Jannis Leidel
c64d5ef6c0 Fix #2876 - Remove accidental query-result-link component from 'Add to dashboard link.' (#2883) 2018-10-01 22:29:20 +03:00
Alison
e3a63899d3 Add ability to search table column names in schema browser (#2681) 2018-10-01 11:11:32 +02:00
Jannis Leidel
4685887fe5 Fix name of edit-in-place React component. 2018-09-29 10:14:48 +02:00
Arik Fraimovich
f103357e60 Fix: wrong reference (EditInPlaceText -> EditInPlace) 2018-09-28 21:51:36 +02:00
Jannis Leidel
11738f73ac Removed redundant exception handling since execute_query task handles that. 2018-09-28 21:31:49 +02:00
Allen Short
d07c4f969b Support authentication for the URL query runner.
Adds a new BaseHTTPQueryRunner class and tests.
2018-09-28 21:31:49 +02:00
Allen Short
505aafbce3 Convert edit-in-place component to React (#2637) 2018-09-28 22:30:10 +03:00
Marina Samuel
b765693879 Upgrade Celery to 4.2.1. (#2773) 2018-09-28 21:28:30 +02:00
Jannis Leidel
4620fed0cf Use server side sort order for tag list and show count of tagged items. (#2833)
* Use tag list ordering from backend.

This basically stops resorting the tag list on the client side and use the already existing (and correct) descending sort order bu tag usage count from the backend.

* Show count of tagged items in tag list.
2018-09-28 17:24:13 +03:00
Arik Fraimovich
48ad1d2dce Add v5.0.1 to the CHANGELOG. 2018-09-28 17:18:41 +03:00
Arik Fraimovich
f2c323a089 Disable integration tests
The integration tests are currently not failing and providing false positives when running them. I'm disabling this until the test suite is more stable.

@jrbenny35 @jezdez
2018-09-28 11:52:14 +03:00
Levko Kravets
ec17cc7eab getredash/redash#2854 Widget titles wrong rendering on public dashboards (#2870) 2018-09-28 11:26:37 +03:00
Arik Fraimovich
6c7bbe9041 Merge branch 'master' of github.com:getredash/redash 2018-09-27 21:47:56 +03:00
Arik Fraimovich
551b0222c4 Cleanup packer configuration 2018-09-27 21:47:45 +03:00
Jannis Leidel
2b0e6e9e79 Refactor list based controllers. (#2790)
This reduces the code duplication between the dashboard, user and queries list pages and normalizes many of the APIs between them.

This also:
- allows sorting query favorites
- adds a pagination size select to the dashboard list
- fixes a bunch of UI inconsistencies between the queries and dashboards list (e.g. margins)

The new ListCtrl class is subclassed in the various specific page controllers and extended as needed. New list pages can make use of the same pattern in the future.

This also adds some missing event recordings from 34e39eda4a.
2018-09-27 17:06:26 +02:00
Levko Kravets
4727c19253 getredash/redash#2796 Improve counter text scaling (#2840) 2018-09-27 13:27:10 +03:00
Arik Fraimovich
2ff4d07e83 Change placement (right/bottom) of chart legend depending on chart width (#2852)
Closes getredash/redash#2796.
2018-09-27 12:34:28 +03:00
Arik Fraimovich
1997f53f40 Fix CircleCI setup for release branches. (#2859) 2018-09-27 10:36:48 +03:00
Jannis Leidel
c03b5d51b7 Simplified data source resource. Refs #2856. 2018-09-27 09:20:07 +02:00
yoavbls
197665bb6a Fix bug in DataSourceResource load (#2857) 2018-09-27 09:15:36 +02:00
Levko Kravets
28fbc2ae62 getredash/redash#2796 Change placement (right/bottom) of chart legend depending on chart width 2018-09-27 10:14:58 +03:00
Alexey Korobkov
ea1c4ca85c Add auth via JWT providers (#2768)
* authentication via JWT providers
* add support for IAP JWT auth
* remove jwt_auth Blueprint and /headers endpoint
* fix pep8: imports
2018-09-26 21:17:48 +03:00
Alison
588e0cce43 Add autocomplete toggle (#2780) 2018-09-26 17:32:38 +02:00
Alison
8a50351520 Add ability to add viz to dashboard from query edit page (#2767) 2018-09-26 17:29:38 +02:00
Alison
34e39eda4a Port moving events serverside (#2766) 2018-09-26 17:17:46 +02:00
Alison
28a8525ce3 Add databricks query runner (#2747)
Fixes #2685.
2018-09-26 17:07:03 +02:00
Arik Fraimovich
5e70f9c04a Update README.md 2018-09-25 21:08:46 +03:00
Arik Fraimovich
a05b5ba68d Docker based setup scripts (#2850) 2018-09-25 21:08:24 +03:00
Dan VerWeire
40ba66c58e Fix invalid reference to alert.to_dict() in webhook (#2849) 2018-09-25 19:12:04 +03:00
Arik Fraimovich
3e4adaba9a Update CircleCI config to use release branches 2018-09-24 11:52:38 +03:00
578 changed files with 34331 additions and 16485 deletions

View File

@@ -0,0 +1,12 @@
FROM cypress/browsers:chrome67
ENV APP /usr/src/app
WORKDIR $APP
COPY package.json $APP/package.json
RUN npm run cypress:install > /dev/null
COPY cypress $APP/cypress
COPY cypress.json $APP/cypress.json
RUN ./node_modules/.bin/cypress verify

View File

@@ -1,6 +1,19 @@
version: 2.0
flake8-steps: &steps
- checkout
- run: sudo pip install flake8
- run: ./bin/flake8_tests.sh
jobs:
unit-tests:
python-flake8-tests:
docker:
- image: circleci/python:3.7.0
steps: *steps
legacy-python-flake8-tests:
docker:
- image: circleci/python:2.7.15
steps: *steps
backend-unit-tests:
environment:
COMPOSE_FILE: .circleci/docker-compose.circle.yml
COMPOSE_PROJECT_NAME: redash
@@ -13,6 +26,7 @@ jobs:
name: Build Docker Images
command: |
set -x
docker-compose build --build-arg skip_ds_deps=true
docker-compose up -d
sleep 10
- run:
@@ -20,7 +34,7 @@ jobs:
command: docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- run:
name: Run Tests
command: docker-compose run --name tests redash tests --junitxml=junit.xml tests/
command: docker-compose run --name tests redash tests --junitxml=junit.xml --cov-report xml --cov=redash --cov-config .coveragerc tests/
- run:
name: Copy Test Results
command: |
@@ -31,14 +45,47 @@ jobs:
path: /tmp/test-results
- store_artifacts:
path: coverage.xml
frontend-unit-tests:
docker:
- image: circleci/node:8
steps:
- checkout
- run: sudo apt install python-pip
- run: npm install
- run: npm run bundle
- run: npm test
frontend-e2e-tests:
environment:
COMPOSE_FILE: .circleci/docker-compose.cypress.yml
COMPOSE_PROJECT_NAME: cypress
PERCY_TOKEN_ENCODED: ZGRiY2ZmZDQ0OTdjMzM5ZWE0ZGQzNTZiOWNkMDRjOTk4Zjg0ZjMxMWRmMDZiM2RjOTYxNDZhOGExMjI4ZDE3MA==
docker:
- image: circleci/node:8
steps:
- setup_remote_docker
- checkout
- run:
name: Install npm dependencies
command: |
npm install
- run:
name: Setup Redash server
command: |
npm run cypress start
docker-compose run cypress node ./cypress/cypress.js db-seed
- run:
name: Execute Cypress tests
command: npm run cypress run-ci
build-tarball:
docker:
- image: circleci/node:8
steps:
- checkout
- run: sudo apt install python-pip
- run: npm install
- run: npm run build
- run: .circleci/update_version
- run: npm run bundle
- run: npm run build
- run: .circleci/pack
- store_artifacts:
path: /tmp/artifacts/
@@ -49,78 +96,34 @@ jobs:
- setup_remote_docker
- checkout
- run: .circleci/update_version
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run: docker build -t redash/redash:$(.circleci/docker_tag) .
- run: docker push redash/redash:$(.circleci/docker_tag)
integration-tests:
working_directory: ~/redash
machine: true
environment:
REDASH_SERVER_URL : "http://127.0.0.1:5000/"
DOCKER_IMAGE: mozilla/redash-ui-tests
steps:
- checkout
- run:
name: Install Docker Compose
command: |
set -x
pip install --upgrade pip
pip install docker-compose>=1.18
docker-compose --version
- run:
name: Pull redash images
command: |
set -x
docker-compose -f docker-compose.yml up --no-start
sleep 10
- run:
name: Pull redash-ui-tests
command: docker pull "${DOCKER_IMAGE}":latest
- run:
name: Setup redash instance
command: |
set -x
docker-compose run --rm --user root server create_db
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests"
docker-compose run --rm --user root server /app/manage.py users create_root root@example.com "rootuser" --password "IAMROOT" --org default
docker-compose run --rm --user root server /app/manage.py ds new "ui-tests" --type "url" --options '{"title": "uitests"}'
docker-compose run -d -p 5000:5000 --user root server
docker-compose start postgres
docker-compose run --rm --user root server npm install
docker-compose run --rm --user root server npm run build
- run:
name: Run tests
command: |
set -x
docker run --net="host" --env REDASH_SERVER_URL="${REDASH_SERVER_URL}" "${DOCKER_IMAGE}"
- store_artifacts:
path: report.html
- run: .circleci/docker_build
workflows:
version: 2
integration_tests:
jobs:
- integration-tests:
filters:
branches:
only: master
build:
jobs:
- unit-tests
- python-flake8-tests
- legacy-python-flake8-tests
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
- build-tarball:
requires:
- unit-tests
filters:
tags:
only: /v[0-9]+(\.[0-9\-a-z]+)*/
branches:
only:
- master
- release
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
only:
- master
- /release\/.*/
- build-docker-image:
requires:
- unit-tests
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9\-a-z]+)*/
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
only:
- master
- preview-image
- /release\/.*/

View File

@@ -1,4 +1,4 @@
version: '2'
version: '3'
services:
redash:
build: ../

View File

@@ -0,0 +1,47 @@
version: '3'
services:
server:
build: ../
command: dev_server
depends_on:
- postgres
- redis
ports:
- "5000:5000"
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
worker:
build: ../
command: scheduler
depends_on:
- server
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
QUEUES: "queries,scheduled_queries,celery,schemas"
WORKERS_COUNT: 2
cypress:
build:
context: ../
dockerfile: .circleci/Dockerfile.cypress
depends_on:
- server
- worker
environment:
CYPRESS_baseUrl: "http://server:5000"
PERCY_TOKEN: ${PERCY_TOKEN}
PERCY_BRANCH: ${CIRCLE_BRANCH}
PERCY_COMMIT: ${CIRCLE_SHA1}
PERCY_PULL_REQUEST: ${CIRCLE_PR_NUMBER}
redis:
image: redis:3.0-alpine
restart: unless-stopped
postgres:
image: postgres:9.5.6-alpine
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
restart: unless-stopped

17
.circleci/docker_build Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
VERSION_TAG=$VERSION.b$CIRCLE_BUILD_NUM
docker login -u $DOCKER_USER -p $DOCKER_PASS
if [ $CIRCLE_BRANCH = master ] || [ $CIRCLE_BRANCH = preview-image ]
then
docker build -t redash/redash:preview -t redash/preview:$VERSION_TAG .
docker push redash/redash:preview
docker push redash/preview:$VERSION_TAG
else
docker build -t redash/redash:$VERSION_TAG .
docker push redash/redash:$VERSION_TAG
fi
echo "Built: $VERSION_TAG"

View File

@@ -1,5 +0,0 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
FULL_VERSION=$VERSION.b$CIRCLE_BUILD_NUM
echo $FULL_VERSION

View File

@@ -2,4 +2,5 @@
VERSION=$(jq -r .version package.json)
FULL_VERSION=$VERSION+b$CIRCLE_BUILD_NUM
sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '$FULL_VERSION'/" redash/__init__.py
sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '$FULL_VERSION'/" redash/__init__.py
sed -i "s/dev/$CIRCLE_SHA1/" client/app/version.json

View File

@@ -1,22 +1,40 @@
engines:
version: "2"
checks:
complex-logic:
enabled: false
file-lines:
enabled: false
method-complexity:
enabled: false
method-count:
enabled: false
method-lines:
config:
threshold: 100
nested-control-flow:
enabled: false
identical-code:
enabled: false
similar-code:
enabled: false
plugins:
pep8:
enabled: true
eslint:
enabled: true
channel: "eslint-3"
channel: "eslint-5"
config:
config: client/.eslintrc.js
checks:
import/no-unresolved:
enabled: false
ratings:
paths:
- "redash/**/*.py"
- "client/**/*.js"
exclude_paths:
- tests/**/*.py
- migrations/**/*.py
- old_migrations/**/*.py
- setup/**/*
- bin/**/*
no-multiple-empty-lines: # TODO: Enable
enabled: false
exclude_patterns:
- "tests/**/*.py"
- "migrations/**/*.py"
- "setup/**/*"
- "bin/**/*"
- "**/node_modules/"
- "client/dist/"
- "**/*.pyc"

View File

@@ -1,4 +1,14 @@
client/.tmp/
client/dist/
node_modules/
.tmp/
.venv/
venv/
.git/
/.codeclimate.yml
/.coverage
/coverage.xml
/.circleci/
/.github/
/netlify.toml
/setup/

View File

@@ -1,34 +0,0 @@
<!--
#####################################################################
#
# Need support? USE THE FORUM! https://discuss.redash.io/c/support.
#
# Don't have steps to reproduce and actually not sure it's a bug?
# Use the forum! https://discuss.redash.io/c/support.
#
#####################################################################
**Got an idea for a new feature?** Check if it isn't on the roadmap already: http://bit.ly/redash-roadmap and start a new discussion in the features category: https://discuss.redash.io/c/feature-requests 🌟.
Found a bug? Please fill out the sections below... thank you 👍
Found a security vulnerability? Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key.
-->
### Issue Summary
A summary of the issue and the browser/OS environment in which it occurs.
### Steps to Reproduce
1. This is the first step
2. This is the second step, etc.
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?
### Technical details:
* Redash Version:
* Browser/OS:
* How did you install Redash:

34
.github/ISSUE_TEMPLATE/---bug_report.md vendored Normal file
View File

@@ -0,0 +1,34 @@
---
name: "\U0001F41B Bug report"
about: Report reproducible software issues so we can improve
---
<!--
We use GitHub only for bug reports 🐛
Anything else should be posted to https://discuss.redash.io 👫
🚨For support, help & questions use https://discuss.redash.io/c/support
💡For feature requests & ideas use https://discuss.redash.io/c/feature-requests
**Found a security vulnerability?** Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key.
-->
### Issue Summary
A summary of the issue and the browser/OS environment in which it occurs.
### Steps to Reproduce
1. This is the first step
2. This is the second step, etc.
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?
### Technical details:
* Redash Version:
* Browser/OS:
* How did you install Redash:

View File

@@ -0,0 +1,17 @@
---
name: "\U0001F4A1Anything else"
about: "For help, support, features & ideas - please use https://discuss.redash.io \U0001F46B "
labels: "Support Question"
---
We use GitHub only for bug reports 🐛
Anything else should be posted to https://discuss.redash.io 👫
🚨For support, help & questions use https://discuss.redash.io/c/support
💡For feature requests & ideas use https://discuss.redash.io/c/feature-requests
Alternatively, check out these resources below. Thanks! 😁.
- [Forum](https://disucss.redash.io)
- [Knowledge Base](https://redash.io/help)

15
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,15 @@
## What type of PR is this? (check all applicable)
<!-- Please leave only what's applicable -->
- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [ ] New Query Runner (Data Source)
- [ ] New Alert Destination
- [ ] Other
## Description
## Related Tickets & Documents
## Mobile & Desktop Screenshots/Recordings (if there are UI changes)

23
.github/support.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
# Configuration for Support Requests - https://github.com/dessant/support-requests
# Label used to mark issues as support requests
supportLabel: Support Question
# Comment to post on issues marked as support requests, `{issue-author}` is an
# optional placeholder. Set to `false` to disable
supportComment: >
:wave: @{issue-author}, we use the issue tracker exclusively for bug reports
and planned work. However, this issue appears to be a support request.
Please use [our forum](https://discuss.redash.io) to get help.
# Close issues marked as support requests
close: true
# Lock issues marked as support requests
lock: false
# Assign `off-topic` as the reason for locking. Set to `false` to disable
setLockReason: true
# Repository to extend settings from
# _extends: repo

7
.github/weekly-digest.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
# Configuration for weekly-digest - https://github.com/apps/weekly-digest
publishDay: mon
canPublishIssues: true
canPublishPullRequests: true
canPublishContributors: true
canPublishStargazers: true
canPublishCommits: true

2
.gitignore vendored
View File

@@ -24,3 +24,5 @@ node_modules
.sass-cache
npm-debug.log
cypress/screenshots
cypress/videos

View File

@@ -1,56 +1,353 @@
# Change Log
## v7.0.0 - 2019-03-17
We're trying a new format for the CHANGELOG in this release. Focusing on the bigger changes, but for whoever interested, you can see all the changes [here](https://github.com/getredash/redash/compare/v6.0.0...master).
Besides all the features, bug fixes and improvements listed below we managed to convert a large portion of Redash's frontend code from Angular.js to React. You can see status in [#3071](https://github.com/getredash/redash/issues/3071).
This release was made possible with the help of 34 contributors. 🙇‍♂️
### Data Sources
- **All data source options are now encrypted in the database.** By default the encryption uses the `REDASH_COOKIE_SECRET` value (`redash.settings.COOKIE_SECRET`), but you can specify a different value by setting the `REDASH_SECRET_KEY` environment variable value. Note that you need to set this _before_ doing the upgrade.
- New Data Sources: Uptycs and Apache Drill.
- Snowplow: is now enabled by default & supports region setting.
- Elasticsearch: add support for Amazon Elasticsearch IAM authentication (with IAM profile or key/secret pair).
- PostgreSQL: add support for serializing range values.
- Redshift: remove duplicate column information for late-binding views.
- Athena: load all databases (using pagination).
- BigQuery: correctly handle temp tables with no schema field.
- Jira (JQL): support for fetching all records with pagination.
- Prometheus: fix schema loading and add support for query range.
### In-app Help
You can now open the [Knowledge Base](https://redash.io/help) inside the application. We also added a few "help triggers" in the app, that will open the Knowledge Base in context of what you're currently doing.
### Parameters
- **Dashboard Parameters**: We improved the flow of adding queries with parameters to dashboards and now give you full control over how parameters are mapped. You no longer have to make sure all parameters have the same name or use the `Global` checkbox. We also added new options, like keeping the parameter local to the widget or setting a static value. [Read more in our Knowledge Base →](https://redash.io/help/user-guide/querying/query-parameters#Parameter-Mapping-on-Dashboards)
- We added server side validation of parameter values for all parameter types, except for parameters of `text` type. All validated parameter types are considered safe. When a query is using safe parameters (or no parameters at all), View Only users can refresh it.
- Refreshing safe queries is done using the new results API endpoint, which takes only a query ID (and optionally parameter values) and does not need the query text.
### Query Editor Improvements
- Run only the highlighted query text: hit Execute after highlighting a portion of your query and only the selected portion will be sent to the database. This is useful for testing sub-SELECT statements and CTE's.
- Improved auto complete: add a dot . after a table name in the query editor and auto complete will only suggest columns on that table.
- Autosave parameter configuration changes.
- YAML syntax support (for data sources like Yandex Metrica).
### Improved Query Scheduler
The Query Scheduler got a face lift and some new options: you can pick a day for a weekly schedule to run on and also set an end date after which the query will no longer execute on schedule.
### Data Sources
We added Apache Drill, Uptycs and a new JSON data source. Also fixed a few bugs in Athena's query runner and others.
### User Management
The users page got revamped with a new look and feel and few new features:
- An indication when a user was last active.
- Show if an invited user hasn't finished the setup process yet (Pending Invitations section).
- You can now generate a new API key for users, if there's a concern it was compromised.
### Admin
- New Celery queues status screens, replacing the old Queries Status and better reflecting the status of running queries.
- Make the queue name for schema refresh job configurable. The default used to be hard coded `schemas`, which is not available on all setups. Now it's `celery`.
- The `gevent` library is installed by default, and you can now setup gunicorn to use `gevent` based workers.
- New Docker entrypoint command to do a health check for a worker process.
- Flask-Admin is no longer setup or supported.
### Other Changes
- New Alert destination: Google Hangouts Chat.
- When downloading results from the results API it will set a user friendly filename for the downloaded file.
- Archived Queries section added to the queries list.
### Bug Fixes
- Fixed: fork query does not fork tables but instead adds default table.
- Fixed: when deleting a visualization, any widget using it was left empty on the dashboard.
- Fixed: issues with Query Editor resizing on new versions of Chrome.
- Fixed: issues with exporting dictionaries to Excel.
- Fixed: Cohort visualization gets stuck when passing string values.
- Fixed: use series name for Pie chart label.
- Make sure Flask app created in Celery's worker process (could cause some query runners to get stuck while running queries).
## v6.0.0 - 2018-12-16
v6.0.0 release version. Mainly includes fixes for regressions from the beta version.
This release had contributions from 5 people: @rauchy, @denisov-vlad, @arikfr, @ariarijp, and @gabrieldutra. Thank you, everyone 🙏
### Changed
- #3183 Make refresh_queries less noisey in logs. @arikfr
### Fixed
- #3163 Include correct version in production builds. @rauchy
- #3161 Clickhouse: fix int() conversion error. @denisov-vlad
- #3166 Directly using record_event task requires timestamp. @arikfr
- #3167 Alert.evaluate failing when the column is missing. @arikfr
- ##3162 Remove API permissions for users who have been disabled. @rauchy
- #3171 Reject empty query name. @ariarijp
- #3175, #3186 Fix disable error message. @rauchy, @gabrieldutra
- #3182 [Redshift] support for schema names with dots. @arikfr
- #3187 Safely create_app in Celery code (try to fetch current_app first). @arikfr
### Other
- #3155 Add DB Seed to Cypress and setup Percy. @gabrieldutra
- #3180 Remove coverage from pytest terminal output. @rauchy
## v6.0.0-beta - 2018-12-03
This release was 2 months in the making and it is full with good stuff!
- We have 5 new data sources: Databricks, IBM DB2, Kylin, Druid and Rockset. ⌗
- There are fixes and improvements to 11 existing data sources (MySQL, Redshift, Postgres, MongoDB, Google BigQuery, Vertica, TreasureData, Presto, ClickHouse, Google Sheets and Google Analytics).
- The Query Results data source can now load cached results, just use the `cached_query_` prefix instead of `query_`.
- On the visualizations front we added a Heatmap visualization and did updated the table and counter visualizations.
- Alerts got some fixes and a new destination: PagerDuty.
- If the live autocomplete in the code editor annoys you, you can disable it now (although we're working to make it better, see #3092).
- Fast queries will now load faster. 🏃‍♂️
- We improved the layout of visualizations and content on smaller screen sizes. 📱
- For those of you who like sharing, you can now enable the ability to share ownership of queries and dashboards and let others to edit them. Check the Settings page to enable this feature.
There were also important changes to the code and infrastructure:
- More components moved to React.
- We switched to Webpack 4 with the help of @dmonego.
- We upgraded to Celery 4 with the help of @emtwo, @jezdez, @mashrikt and @atharvai.
- We started moving towards Python 3 for our backend. The first step was to make sure our code pass basic sanity tests with Flake 8, which was implemented by @cclauss.
- We improved our testing on the frontend by adding setup for Jest tests and E2E testing using Cypress (@gabrieldutra).
- Each pull request now gets a deploy preview using Netlify to easily test frontend changes.
This is just a summary, you're welcome to review the full list below. ⬇
This release had contributions from 38 people: @arikfr, @kravets-levko, @jezdez, @kyoshidajp, @kocsmy, @alison985, @gabrieldutra, @washort, @GitSumito, @emtwo, @rauchy, @alexanderlz, @denisov-vlad, @ariarijp, @yoavbls, @zhujunsan, @sjakthol, @koooge, @SakuradaJun, @dmonego, @Udomomo, @cclauss, @combineads, @zaimy, @Trigl, @ralphilius, @jodevsa, @deecay, @igorcanadi, @pashaxp, @hoangphuoc25, @toph, @burnash, @wankdanker, @Yossi-a, @Rovel, @kadrach, and @nicof38. Thank you, everyone 🙏
### Added
- #2747, #3143 Add a new Databricks query runner. @alison985, @jezdez, @arikfr
- #2767 Add ability to add viz to dashboard from query edit page. @alison985, @jezdez
- #2780 Add a query autocomplete toggle. @alison985, @jezdez, @arikfr
- #2768 Add authentication via JWT providers. @SakuradaJun
- #2790 Add the ability to sort favorited queries, paginate the dashboard list and improve UI inconsistencies. @jezdez
- #2681 Add ability to search table column names in schema browser. @alison985
- #2855 Add option to query cached results. @yoavbls
- #2740 Add ability for extensions to add periodic tasks. @emtwo
- #2924 Google Spreadsheets: Add support for opening by URL. @alexanderlz
- #2903 Add PagerDuty as an Alert Destination. @alexanderlz
- #2824 Add support for expanding dashboard visualizations. @sjakthol
- #2900 Add ability to specify a counter label. @ralphilius
- #2565 Add frontend extension capabilities. @emtwo
- #2848 Add IBM Db2 as a data source using the ibm-db Python package. @nicof38
- #2959 Add option to auto reload widget data in shared dashboards. @arikfr
- #2993 Add page size settings. @kyoshidajp
- #2080 New Heatmap chart visualization with Plotly. @deecay
- #2991 Show users in CLI group list. @GitSumito
- #2342 New SQLPARSE_FORMAT_OPTIONS setting to configure query formatter. @ariarijp
- #3031 Add some tests for Query Results. @ariarijp
- #2936 Add Kylin data source. @Trigl
- #3047 Add Druid data source. @rauchy
- #3077 New user interface for the feature flag of the share edit permissions feature. @arikfr
- #3007 Add permissions to the result of "manage.py groups list" command. @Udomomo
- #3088 Add get_current_user() fuction for the Python query runner. @kyoshidajp
- #3114 Add event tracking to autocomplete toggle. @arikfr
- #3068 Add Rockset query runner. @igorcanadi, @arikfr
- #3105 Display frontend version. @rauchy
### Changed
- #2636 Rewrite query editor with React. @washort, @arikfr
- #2637 Convert edit-in-place component to React. @washort, @arikfr
- #2766 Suitable events are now being recorded server side instead of in the frontend. @alison985, @jezdez
- #2796 Change placement (right/bottom) of chart legend depending on chart width. @kravets-levko
- #2833 Uses server side sort order for tag list and show count of tagged items. @jezdez
- #2318 Support authentication for the URL data source. @jezdez
- #2884 Rename Yandex Metrika to Metrica. @jezdez
- #2909 MySQL: hide sys tables. @arikfr
- #2817 Consistently use simplejson for loading and dumping JSON. @jezdez
- #2872 Use Plotly's function to clean y-values (x may be category or date/time). @kravets-levko
- #2938 Auto focus tag input. @kyoshidajp
- #2927 Design refinements for queries pages. @kocsmy
- #2950 Show activity status in CLI user list. @GitSumito
- #2968 Presto data source: setting protocol (http/https), safe loading of error messages. @arikfr
- #2967 Show groups in CLI user list. @GitSumito
- #2603 MongoDB: Update requirements to support srv. @arikfr
- #2961 MongoDB: Skip system collections when loading schema. @arikfr
- #2960 Add timeout to various HTTP requests. @arikfr
- #2983 Databricks: New logo, updated name and enabled by default. @arikfr
- #2982 Table visualization: change default size to 25 and add more size options. @arikfr
- #2866 Redshift: Hide tables the configured user cannot access. @sjakthol
- #3058 Mustache: don't html-escape query parameters values. @kravets-levko
- #3079 Always use basic autocomplete, as well as the live autocomplete. @arikfr
- #3084 Support tel://, sms://, mailto:// links in query results. @zhujunsan
- #3083 Clickhouse: Add WITH TOTALS option support. @denisov-vlad
- #3063 Allow setting colors for bubble charts. @toph
- #3085 BigQuery: Switch to Standard SQL as the default. @kyoshidajp
- #3094 Tags autocomplete: Show note when creating a new label. @kravets-levko
- #2984 Autocomplete toggle improvements. @arikfr
- #3089 Open new tab when forking a query. @kyoshidajp
- #3126 MongoDB: add support for sorting columns. @arikfr
- #3128 Improve backoff algorithm of query results polling to speed it up. @arikfr
- #3125 Vertica: update driver & add support for connection timeout. @arikfr
- #3124 Support unicode in Postgres/Redshift schema. @arikfr
- #3138 Migrate all tags components to React. @kravets-levko
- #3139 Better manage permissions modal. @kocsmy
- #3149 Improve tag link colors and fix group tags on Users page. @kocsmy
- #3146 Update, replace and fix new alert destination logos so it fits better. @kocsmy
- #3147 Add and improve recent db logos that didn't fit in size properly. @kocsmy
- #3148 Fix label positioning on no found screen. @kocsmy
- #3156 json_dumps: add support for serializing buffer objects. @arikfr
### Fixed
- #2849 Fix invalid reference to alert.to_dict() in webhook. @wankdanker
- #2840 Improve counter visualization text scaling. @kravets-levko
- #2854 Widget titles are no longer rendered wrong on public dashboards. @kravets-levko
- #2318 Removed redundant exception handling in data sources since that's handled in the query backend. @jezdez
- #2886 Fix Javascript build that broke because registerAll tried to run EditInPlace component. @arikfr
- #2911 Dont show “Add to dashboard” in dropdown to unsaved queries. @jezdez
- #2916 Fix export query results output file name. @gabrieldutra
- #2917 Fix output file name not changing after rename query. @gabrieldutra
- #2868 Address edge case when retrieving Glue schemas for Athena data source. @kadrach
- #2929 Fix: date value in a filter is duplicated. @combineads
- #2875 Unbreak charts with long legend break in horizontal mode. Update plotly.js. @kravets-levko
- #2937 Fix event recording in admin API backend. @kyoshidajp
- #2953 Minor fixes for the Clickhouse data source. @denisov-vlad
- #2941 Bring back fix to Box plot hover. @arikfr
- #2957 Apply missing CSS classes to EditInPlace component. @arikfr
- #2897 Show "Add description" only after saving the query. @arikfr
- #2922 Query page layout improvements for small screens. @kravets-levko
- #2956 Clickhouse: move timeout to params. @denisov-vlad
- #2964 Fix no tags shown when having empty set. @gabrieldutra
- #2757 Use full text search ranking when searching in list views. @jezdez
- #2969 Query Results data source: improved errors, quoted column names. @arikfr
- #2906 Preventing open redirection in loging process. @kyoshidajp
- #2867 TreasureData: Deduplicate column names. @zaimy
- #2994 Fix scheme of various URLs from http to https. @kyoshidajp
- #2992 Fix an invalid prop type warning in new version notifier. @kyoshidajp
- #3022 Fix Toolbox covering part of a chart. @kravets-levko
- #2998 Fix charts losing responsive features after refreshing the dashboard. @kravets-levko
- #3034 Postgres: handle NaN/Infinity values. @kravets-levko
- #2745 Sort columns with undefined values. @Yossi-a
- #3041 Sort CLI output of lists. @GitSumito
- #2803, #3006 Address various tag display issues on query list page. @kocsmy, @alison985
- #3049 Fix edit-in-place component which ignored isEditable flag and didn't work on Groups page. @kravets-levko
- #2965 Google Analytics: Fix crash when no results are returned. @alexanderlz
- #3061 Fix table visualization so that the horizontal scrollbar is not be always visible. @kravets-levko
- #3076 Add white-space padding to separators in the footer. @burnash
- #2919 Fix URL data source to not require a URL. @arikfr
- #3098 Force AngularJS to update query editor properly. @washort
- #3100 Delete redundant regex segment in query result frontend. @zhujunsan
- #2978 Prevent the query update timestamp from changing when it is linked to new query results. @rauchy
- #3046 Fix query page header. @kravets-levko
- #3097 Mongo: Fix collection fields retreival bug when Views are present. @jodevsa
- #3107 Keep query text in local state for now. @washort
- #3111 Fix mobile padding issues on Query results. @kocsmy
- #3122 Show menu divider only if query is archived. @jezdez
- #3120 Fix tag counts for dashboards and queries. @jezdez
- #3141 Fix schema refresh to work on MySQL 8. @hoangphuoc25
- #3142 Fix: editing dashboard title results in the visualizations being replaced by the loading markers. @kravets-levko
### Other
- #2850 The setup scripts are now based on Ubuntu 18.04 LTS and Docker. @pashaxp, @arikfr
- #2985 Add Jest based tests to our stack. @arikfr
- #2999 Add netlify configuration. @arikfr
- #3000 Initial Cypress based E2E test infrastructure. @gabrieldutra
- #2898 Move Ant styles into a central location. @arikfr
- #2910 Fix webpack build error about BigMessage. @jezdez
- #2928 Speed up builds by skipping installing requirements_all_ds.txt in CI unit tests. @arikfr
- #2963 Fix tarball build failure. @emtwo
- #2996 Fix setup.sh failures when run as root. @arikfr
- #2989 Rearrange make targets. @koooge
- #3036 Update Flask-Admin to 1.5.2. @yoavbls
- #2901 Fix documentation links. @kravets-levko
- #3073 Remove only Redash containers in clean Make task. @ariarijp
- #3048 Remove pytest-watch dependency to workaround an issue with watchdog. @rauchy
- #2905 Update development docker-compose.yml file to use latest Redis and Postgres servers and specify working volume explictly. @Rovel
- #3032 Makefile: Add make targets for test. @koooge
- #2933 Switch to Webpack 4. @dmonego
- #2908 Update setup files. @arikfr
- #2946 Update snowflake_connector_python version. @arikfr
- #2773 Upgrade to Celery 4.2.1. @emtwo, @jezdez
- #2881 CircleCI: Make flake8 tests pass on Legacy Python and Python 3. @cclauss
- #2907 Remove unused dependencies (honcho, wsgiref). @arikfr
- #3039 Build docker image on master branch. @arikfr
- #3106 Fix registerAll failures after minification. @arikfr
## v5.0.2 - 2018-10-18
### Security
- Fix: prevent Open Redirect vulnerability.
## v5.0.1 - 2018-09-27
### Added
- Added support for JWT authentication (for services like Cloudflare Access or Google IAP).
### Changed
- Upgraded Celery version to 3.1.26 to make upgrade to Celery 4 easier.
## v5.0.0 - 2018-09-21
Final release for V5. Most of the changes were already in the beta release of V5, but this includes several fixes along
with UI improvements.
🙏 Thanks to @arikfr, @jezdez, @kravets-levko, @alison985, @kocsmy, @yossi-a, @tdsmith, @nasmithan, @jrbenny35, @sjakthol, @ariarijp and @combineads who contributed to this release.
### Security
* Fix: don't expose Google OAuth client secret. @arikfr
- Fix: don't expose Google OAuth client secret. @arikfr
### Changed
* Improve mobile rendering of dashboards and queries. @kocsmy
* UI improvements for favorites and empty state. @arikfr
* Remove unnecessary X at the end of the query search. @kocsmy
* Add server-side sorting to dashboard list. @jezdez
* Sort queries in descending order. @jezdez
* Throw error when non-owner tries to add a user to dashboard permissions. @alison985
* Propagate query execution errors from Celery tasks properly. @alison985
* Reload the route when using the app header search input. @jezdez
- Improve mobile rendering of dashboards and queries. @kocsmy
- UI improvements for favorites and empty state. @arikfr
- Remove unnecessary X at the end of the query search. @kocsmy
- Add server-side sorting to dashboard list. @jezdez
- Sort queries in descending order. @jezdez
- Throw error when non-owner tries to add a user to dashboard permissions. @alison985
- Propagate query execution errors from Celery tasks properly. @alison985
- Reload the route when using the app header search input. @jezdez
### Fixed
* Fix: BigQuery default location is null and not US. @arikfr
* Fix: query embeds are broken. @arikfr
* Fix: typo in Celery log foramt. @ariarijp
* Use QuerySerializer in outdated queries list. @jezdez
* Fix: sometimes widgets are getting zero height. @kravets-levko
* Athena: Switch to simple_json to serialize NaN/Infinity values as nulls. @kravets-levko, @jezdez
* Fix: queries with parameters with no value breaking the scheduler. @arikfr
* Fix: MongoDB query results parser didn't support unicode keys. @arikfr
* Fix: Google Analytics schema wasn't loading in some cases. @arikfr
* Fix: date/time parameters not working as global param @kravets-levko.
* Fix: Widgets crumble when trying to move / resize a widget. @kravets-levko
* Fix: handling rows with "length" field with forOwn method. @yossi-a
* Fix: query selection not working on alert page. @sjakthol
* Fix: query_results for Embedded Parameters (removed deprecated to_dict function). @nasmithan
* Fix: unicode not supported in dashboard search. @combineads
* Fix: unicode not supported in users search. @arikfr
- Fix: BigQuery default location is null and not US. @arikfr
- Fix: query embeds are broken. @arikfr
- Fix: typo in Celery log foramt. @ariarijp
- Use QuerySerializer in outdated queries list. @jezdez
- Fix: sometimes widgets are getting zero height. @kravets-levko
- Athena: Switch to simple_json to serialize NaN/Infinity values as nulls. @kravets-levko, @jezdez
- Fix: queries with parameters with no value breaking the scheduler. @arikfr
- Fix: MongoDB query results parser didn't support unicode keys. @arikfr
- Fix: Google Analytics schema wasn't loading in some cases. @arikfr
- Fix: date/time parameters not working as global param @kravets-levko.
- Fix: Widgets crumble when trying to move / resize a widget. @kravets-levko
- Fix: handling rows with "length" field with forOwn method. @yossi-a
- Fix: query selection not working on alert page. @sjakthol
- Fix: query_results for Embedded Parameters (removed deprecated to_dict function). @nasmithan
- Fix: unicode not supported in dashboard search. @combineads
- Fix: unicode not supported in users search. @arikfr
### Other
* Add test for using saved parameters in scheduled queries. @alison985
* Minor code smell cleanup. @jezdez
* Update QueryResultListResource docstring. @tdsmith
* Switch to CirlceCI 2.0 @jrbenny35, @arikfr
* Remove unnecessary init methods. @jezdez
- Add test for using saved parameters in scheduled queries. @alison985
- Minor code smell cleanup. @jezdez
- Update QueryResultListResource docstring. @tdsmith
- Switch to CirlceCI 2.0 @jrbenny35, @arikfr
- Remove unnecessary init methods. @jezdez
## v5.0.0-Beta - 2018-08-06
@@ -58,19 +355,19 @@ This is the first beta of the V5 release (and hopefully the last one). This vers
Some notable changes:
* Extensive work on parameters UI:
* New Date Range parameter type.
* UI for creating new parameters.
* Support for Now/Today as default value of date/time parameter.
* Tagging and favorites ⭐️ support for queries and dashboards.
* Users list page was improved (search, additional information) and you can now disable users.
* Query editor improvements: additional keyboard shortcuts and support for searching in query text.
* Visualizations improvements: option to select colors of pie chart sectors, X Axis type auto detect and option to format values, labels and tooltips.
* Data Sources:
* Support for Yandex Metrika and AppMetrika.
* BigQuery: location property support and schema will load all tables now.
* Elasticsearch: stop sending source_content_type parameter which wasn't supported in older versions.
* Started migrating the frontend codebase to React.
- Extensive work on parameters UI:
- New Date Range parameter type.
- UI for creating new parameters.
- Support for Now/Today as default value of date/time parameter.
- Tagging and favorites ⭐️ support for queries and dashboards.
- Users list page was improved (search, additional information) and you can now disable users.
- Query editor improvements: additional keyboard shortcuts and support for searching in query text.
- Visualizations improvements: option to select colors of pie chart sectors, X Axis type auto detect and option to format values, labels and tooltips.
- Data Sources:
- Support for Yandex Metrika and AppMetrika.
- BigQuery: location property support and schema will load all tables now.
- Elasticsearch: stop sending source_content_type parameter which wasn't supported in older versions.
- Started migrating the frontend codebase to React.
And much more!
@@ -78,82 +375,82 @@ And much more!
### Added
* #2712: Date/Time Range parameter type (@kravets-levko)
* #2482: Add support for ChatWork Alert Destination. (@matsumo)
* #2678: Explicit "Add Parameter" Button in Query Editor. (@kravets-levko)
* #2513: Add location property to BigQuery data source settings. (@kyoshidajp)
* #2616: Pie chart: support setting pie chart sector colors. (@kravets-levko)
* #2697: Date/Time parameters: support for "Now" as default value. (@kravets-levko)
* #2693: Enable search function in Query Editor. (@arikfr)
* #2573: Tagging and favorites for Queries and Dashboards (@arikfr)
* #2640: Keyboard shortcut to collapse query editor/schema browser (@kravets-levko)
* #2674: Add support for the Chrome Logger extension (@arikfr)
* #2653: Add redash db size to status page (@alison985)
* #2669: Store Athena query id with result metadata (@tdawber)
* #2546: Configuration for incorporating React components (@washort)
* #2533: New datasource: Yandex Metrika & AppMetrika (@denisov-vlad)
* #2536: Chart: formats for values, labels and tooltips (@kravets-levko)
* #2560: Introduce Policy object (@arikfr)
* #2380: Admin should be able to disable a user (@kravets-levko)
* #2509: Show custom date format on settings page (@kyoshidajp)
- #2712: Date/Time Range parameter type (@kravets-levko)
- #2482: Add support for ChatWork Alert Destination. (@matsumo)
- #2678: Explicit "Add Parameter" Button in Query Editor. (@kravets-levko)
- #2513: Add location property to BigQuery data source settings. (@kyoshidajp)
- #2616: Pie chart: support setting pie chart sector colors. (@kravets-levko)
- #2697: Date/Time parameters: support for "Now" as default value. (@kravets-levko)
- #2693: Enable search function in Query Editor. (@arikfr)
- #2573: Tagging and favorites for Queries and Dashboards (@arikfr)
- #2640: Keyboard shortcut to collapse query editor/schema browser (@kravets-levko)
- #2674: Add support for the Chrome Logger extension (@arikfr)
- #2653: Add redash db size to status page (@alison985)
- #2669: Store Athena query id with result metadata (@tdawber)
- #2546: Configuration for incorporating React components (@washort)
- #2533: New datasource: Yandex Metrika & AppMetrika (@denisov-vlad)
- #2536: Chart: formats for values, labels and tooltips (@kravets-levko)
- #2560: Introduce Policy object (@arikfr)
- #2380: Admin should be able to disable a user (@kravets-levko)
- #2509: Show custom date format on settings page (@kyoshidajp)
### Changed
* #2715: Improve users list page (@arikfr)
* #2710: Update Ant variables to fit Redash's style (@kocsmy)
* #2709: Move format button next Add New Param button. (@arikfr)
* #2664: Dashboard shows a spinner when query failed to load (@kravets-levko)
* #2626: Show real status when loading cached query result (@kravets-levko)
* #2663: Set column name implicitly when column name is blank (@ariarijp)
* #2695: Improve Date/DateTime type parameters (@kravets-levko)
* #2694: Block users with disposable email addresses (@arikfr)
* #2687: YAML: changed load to safe_load (@denisov-vlad)
* #2514: Update value parsing for google spreadsheets source (@atharvai)
* #2570: fixes query pagination alignment (@alison985)
* #2584: keep query result pagination out of scroll (@alison985)
* #2647: Improve Script Query Runner (@ariarijp)
* #2583: Query header improvements on widgets (@kocsmy)
* #2671: Save some space (@kocsmy)
* #2658: delaying schema filtering to improve responsiveness (@alison985)
* #2648: Update datasource documentation links (@Pablohn26)
* #2613: Improve Script Query Runner (@ariarijp)
* #2619: data source sort case insensitive (@alison985)
* #2604: Improve Google Spreadsheets Query Runner (@ariarijp)
* #2542: Closes #2541: x-axis improvements. (@emtwo)
* #2590: Remove redundant variables (@ariarijp)
* #2585: Show data only mode: allow to add and delete visualizations (@kravets-levko)
* #2549: Allow get_tables to see views and v10-style partitioned tables (@coreyhuinker)
* #2568: sort datasources alphabetically (@alison985)
* #2444: feat: show error if saml response cannot be parsed (@sjakthol)
* #2554: Display name to be delete (@kyoshidajp)
* #2510: Display confirmation dialog when deleting a item (@kyoshidajp)
* #2518: Design improvements (@kocsmy)
* #2520: Filter data sources in a data source input area (@kyoshidajp)
- #2715: Improve users list page (@arikfr)
- #2710: Update Ant variables to fit Redash's style (@kocsmy)
- #2709: Move format button next Add New Param button. (@arikfr)
- #2664: Dashboard shows a spinner when query failed to load (@kravets-levko)
- #2626: Show real status when loading cached query result (@kravets-levko)
- #2663: Set column name implicitly when column name is blank (@ariarijp)
- #2695: Improve Date/DateTime type parameters (@kravets-levko)
- #2694: Block users with disposable email addresses (@arikfr)
- #2687: YAML: changed load to safe_load (@denisov-vlad)
- #2514: Update value parsing for google spreadsheets source (@atharvai)
- #2570: fixes query pagination alignment (@alison985)
- #2584: keep query result pagination out of scroll (@alison985)
- #2647: Improve Script Query Runner (@ariarijp)
- #2583: Query header improvements on widgets (@kocsmy)
- #2671: Save some space (@kocsmy)
- #2658: delaying schema filtering to improve responsiveness (@alison985)
- #2648: Update datasource documentation links (@Pablohn26)
- #2613: Improve Script Query Runner (@ariarijp)
- #2619: data source sort case insensitive (@alison985)
- #2604: Improve Google Spreadsheets Query Runner (@ariarijp)
- #2542: Closes #2541: x-axis improvements. (@emtwo)
- #2590: Remove redundant variables (@ariarijp)
- #2585: Show data only mode: allow to add and delete visualizations (@kravets-levko)
- #2549: Allow get_tables to see views and v10-style partitioned tables (@coreyhuinker)
- #2568: sort datasources alphabetically (@alison985)
- #2444: feat: show error if saml response cannot be parsed (@sjakthol)
- #2554: Display name to be delete (@kyoshidajp)
- #2510: Display confirmation dialog when deleting a item (@kyoshidajp)
- #2518: Design improvements (@kocsmy)
- #2520: Filter data sources in a data source input area (@kyoshidajp)
### Fixed
* #2722: Elasticsearch: Don't send source_content_type parameter. (@arikfr)
* #2719: Remove closing input tags (@maxv)
* #2458: Get all tables in the BigQuery (@kyoshidajp)
* #2698: Make sure we return distinct data source values (@arikfr)
* #2315: Fix: pyHive type matches (@yuua)
* #2638: Dashboard stops rendering when adding widget with empty query (@kravets-levko)
* #2610: Fix export query results output file name (@gabrieldutra)
* #2574: commit query result to db before evaluating alerts (@mtrbean)
* #2580: add break-word wrap to add/edit text box on dashboard (@alison985)
* #2578: Fix connection error when you run "create_tables" (@ariarijp)
* #2572: remove extra menu line if query is archived (@alison985)
* #2526: Fix pivot hide control in dashboards (@deecay)
* #2511: Fixing signed_out.html template (@kocsmy)
* #2523: Frontend: fix boolean field with null value display as null. (@innovia)
- #2722: Elasticsearch: Don't send source_content_type parameter. (@arikfr)
- #2719: Remove closing input tags (@maxv)
- #2458: Get all tables in the BigQuery (@kyoshidajp)
- #2698: Make sure we return distinct data source values (@arikfr)
- #2315: Fix: pyHive type matches (@yuua)
- #2638: Dashboard stops rendering when adding widget with empty query (@kravets-levko)
- #2610: Fix export query results output file name (@gabrieldutra)
- #2574: commit query result to db before evaluating alerts (@mtrbean)
- #2580: add break-word wrap to add/edit text box on dashboard (@alison985)
- #2578: Fix connection error when you run "create_tables" (@ariarijp)
- #2572: remove extra menu line if query is archived (@alison985)
- #2526: Fix pivot hide control in dashboards (@deecay)
- #2511: Fixing signed_out.html template (@kocsmy)
- #2523: Frontend: fix boolean field with null value display as null. (@innovia)
### Other
* #2682: Add Zeit's now support to have preview builds for every PR (@arikfr)
* #2668: Upgrade bootstrap script to Redash 4.0.1 (@ariarijp)
* #2639: Add tests for SpreadSheets (@ariarijp)
* #2635: Add tests for Query Results (@ariarijp)
* #2537: Remove trailing semicolon (@sieben)
- #2682: Add Zeit's now support to have preview builds for every PR (@arikfr)
- #2668: Upgrade bootstrap script to Redash 4.0.1 (@ariarijp)
- #2639: Add tests for SpreadSheets (@ariarijp)
- #2635: Add tests for Query Results (@ariarijp)
- #2537: Remove trailing semicolon (@sieben)
## v4.0.1 - 2018-05-02
@@ -345,7 +642,6 @@ And much more!
- Handling whitespace characters in Query Results data source. @ariarijp
- [MySQL] Close cursor when cancellig the query. @jasonsmithj
## v3.0.0 - 2017-11-13
### Added
@@ -391,7 +687,7 @@ And much more!
- Salesforce: improve error messages we receive from the API. @akiray03
- Custom JS code visualization improvements. @deecay
- DQL: Update version to 0.5.24. @aterreno
- Cassandra: get_schema support for both C* 2.x and 3.x, support for SortedSet type serialization. (@mfouilleul))
- Cassandra: get_schema support for both C\* 2.x and 3.x, support for SortedSet type serialization. (@mfouilleul))
- Replace deprecated ng-annotate with babel plugin. @44px
- Update Python dependencies to recent versions. @alison985
- Bootstrap script: create /opt/redash directory only if it doesn't exist. @isomura
@@ -427,7 +723,6 @@ And much more!
This is a patch release, that adds support for Redshift ACM certificates (see #2044 for details).
## v2.0.0 - 2017-08-08
### Added
@@ -437,7 +732,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
- Add the propertyOrder field to specify order of data source settings. @rmakulov
- Add Plotly based Boxplot visualization. @deecay
- [Presto] Add: query cancellation support. @fbertsch
- [MongoDB] add $oids JSON extension.
- [MongoDB] add \$oids JSON extension.
- [PostgreSQL] support for loading materialized views in schema.
- [MySQL] Add option to hide SSL settings.
- [MySQL] support for RDS MySQL and SSL.
@@ -507,7 +802,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
- [Google Spreadsheets] handle distant future dates.
- [SQLite] better handle utf-8 error messages.
- Fix: don't remove locks for queries with task status of PENDING.
- Only split columns with __/:: that end with filter/MultiFilter.
- Only split columns with \_\_/:: that end with filter/MultiFilter.
- Alert notifications fail (sometime) with a SQLAlchemy error.
- Safeguard against empty query results when checking alert status. @danielerapati
- Delete data source doesn't work when query results referenced by queries.
@@ -526,7 +821,6 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
- PostgreSQL passwords with spaces were not supported. (#1056)
- PivotTable wasn't updating after first save.
## v1.0.3 - 2017-04-18
### Fixed
@@ -573,7 +867,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
- Fix: query embed dialog close button wasn't working @r0fls
- Fix: make errors from Presto runner JSON-serializable @washort
- Fix: race condition in query task status reporting @washort
- Fix: remove $$hashKey from Pivot table
- Fix: remove \$\$hashKey from Pivot table
- Fix: map visualization had severe performance issue.
- Fix: pemrission dialog wasn't rendering.
- Fix: word cloud visualization didn't show column names.
@@ -590,7 +884,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
### Changed
- [#1563](https://github.com/getredash/redash/pull/1563) Send events to webhook as JSON with a schema.
- [#1601] [Presto] friendlier error messages. (@aslotnick)
- [#1601][presto] friendlier error messages. (@aslotnick)
- Move the query runner unavailable log message to be DEBUG level instead of WARNING, as it was mainly confusing people.
- Remove "Send to Cloud" button from Plotly based visualizations.
- Change Plotly's default hover mode to "Compare".
@@ -599,7 +893,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
### Fixed
- [#1564] Fix: map visualization column picker wasn't populated. (@janusd)
- [#1597] [SQL Server] Fix: schema wasn't loading on case sensitive servers. (@deecay)
- [#1597][sql server] Fix: schema wasn't loading on case sensitive servers. (@deecay)
- Fix: dashbonard owner couldn't edit his dashboard.
- Fix: toggle_publish event wasn't logged properly.
- Fix: events with API keys were not logged.
@@ -614,7 +908,7 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
- Fix: extra whitespace created by the filters component.
- Fix: query results cleanup task was trying to delete query objects.
- Fix: alert subscriptions were not triggered.
- [DynamoDB] Fix: count(*) queries were broken. (@kopanitsa))
- [DynamoDB] Fix: count(\*) queries were broken. (@kopanitsa))
- Fix: Redash is using too many database connections.
- Fix: download links were not working in dashboards.
- Fix: the first selection in multi filters was broken in dashboards.
@@ -631,9 +925,9 @@ This is a patch release, that adds support for Redshift ACM certificates (see #2
This version has two big changes behind the scenes:
* Refactor the frontend to use latest (at the time) Angular version (1.5) along with better frontend pipeline based on)
- Refactor the frontend to use latest (at the time) Angular version (1.5) along with better frontend pipeline based on)
WebPack.
* Refactor the backend code to use SQLAlchemy and Alembic, for easier migrations/upgrades.)
- Refactor the backend code to use SQLAlchemy and Alembic, for easier migrations/upgrades.)
Along with that we have many fixes, additions, new data sources (Google Analytics, ClickHouse, Amazon Athena, Snowflake)
and fixes to the existing ones (mainly ElasticSearch and Cassandra).
@@ -716,7 +1010,7 @@ We're releasing a new upgrade script -- see [here](https://redash.io/help-onprem
### Added
- 61fe16e #1374: Add: allow '*' in REDASH_CORS_ACCESS_CONTROL_ALLOW_ORIGIN (Allen Short)
- 61fe16e #1374: Add: allow '\*' in REDASH_CORS_ACCESS_CONTROL_ALLOW_ORIGIN (Allen Short)
- 2f09043 #1113: Add: share modify/access permissions for queries and dashboard (whummer)
- 3db0eea #1341: Add: support for specifying SAML nameid-format (zoetrope)
- b0ecd0e #1343: Add: support for local SAML metadata file (zoetrope)
@@ -780,7 +1074,6 @@ We're releasing a new upgrade script -- see [here](https://redash.io/help-onprem
- 5d43cbe #1198: Change: add support for Standard SQL in BigQuery query runner (mystelynx)
- 84d0c22 #1193: Change: modify the argument order of moment.add function call (Kenya Yamaguchi)
### Fixed
- d6febb0 #1375: Fix: Download Dataset does not work when not logged in (Joshua Dechant)
@@ -834,7 +1127,7 @@ The main features of this release are:
Also, this release includes numerous smaller features, improvements, and bug fixes.
A big thank you goes to all who contributed code and documentation in this release: @AntoineAugusti, @James226, @adamlwgriffiths, @alexdebrie, @anthony-coble, @ariarijp, @dheerajrav, @edwardsharp, @machira, @nabilblk, @ninneko, @ordd, @tomerben, @toru-takahashi, @vishesh92, @vorakumar and @whummer.
A big thank you goes to all who contributed code and documentation in this release: @AntoineAugusti, @James226, @adamlwgriffiths, @alexdebrie, @anthony-coble, @ariarijp, @dheerajrav, @edwardsharp, @machira, @nabilblk, @ninneko, @ordd, @tomerben, @toru-takahashi, @vishesh92, @vorakumar and @whummer.
### Added
@@ -849,7 +1142,7 @@ A big thank you goes to all who contributed code and documentation in this relea
- f64622d #1089: Add support for serialising UUID type within MSSQL #961 (@James226)
- 857caab #1085: Feature: API to pause a data source (@arikfr)
- 214aa3b #1060: Feature: support configuring user's groups with SAML (@vorakumar)
- e20a005 #1007: Issue#1006: Make bottom margin editable for Chart visualization (@vorakumar)
- e20a005 #1007: Issue#1006: Make bottom margin editable for Chart visualization (@vorakumar)
- 6e0dd2b #1063: Add support for date/time Y axis (@tomerben)
- b5a4a6b #979: Feature: Add CLI to edit group permissions (@ninneko)
- 6d495d2 #1014: Add server-side parameter handling for embeds (@whummer)
@@ -895,7 +1188,7 @@ A big thank you goes to all who contributed code and documentation in this relea
- e10ecd2 #1058: Bring back filters if dashboard filters are enabled (@AntoineAugusti)
- 701035f #1059: Fix: DynamoDB having issues when setting host (@arikfr)
- 2924d4f #1040: Small fixes to visualizations view (@arikfr)
- fec0d5f #1037: Fix: multi filter wasn't working with __ syntax (@dheerajrav)
- fec0d5f #1037: Fix: multi filter wasn't working with \_\_ syntax (@dheerajrav)
- b066ce4 #1033: Fix: only ask for notification permissions if wasn't denied (@arikfr)
- 960c416 #1032: Fix: make sure we return dashboards only for current org only (@arikfr)
- b3844d3 #1029: Hive: close connection only if it exists (@arikfr)

View File

@@ -6,10 +6,9 @@ The following is a set of guidelines for contributing to Redash. These are guide
## Quick Links:
- [Feature Roadmap](https://trello.com/b/b2LUHU7A/redash-roadmap)
- [Feature Requests](https://discuss.redash.io/c/feature-requests)
- [Documentation](https://redash.io/help/)
- [Blog](http://blog.redash.io/)
- [Blog](https://blog.redash.io/)
- [Twitter](https://twitter.com/getredash)
---
@@ -61,13 +60,13 @@ If you would like to suggest an enhancement or ask for a new feature:
### Documentation
The project's documentation can be found at [https://redash.io/help/](https://redash.io/help/). The [documentation sources](https://github.com/getredash/website/tree/master/website/_kb) are hosted on GitHub. To contribute edits / new pages, you can use GitHub's interface. Click the "Edit on GitHub" link on the documentation page to quickly open the edit interface.
The project's documentation can be found at [https://redash.io/help/](https://redash.io/help/). The [documentation sources](https://github.com/getredash/website/tree/master/src/pages/kb) are hosted on GitHub. To contribute edits / new pages, you can use GitHub's interface. Click the "Edit on GitHub" link on the documentation page to quickly open the edit interface.
## Additional Notes
### Release Method
We publish a stable release every ~2 months, although the goal is to get to a stable release every month. You can see the change log on [GitHub releases page](http://github.com/getredash/redash/releases).
We publish a stable release every ~2 months, although the goal is to get to a stable release every month. You can see the change log on [GitHub releases page](https://github.com/getredash/redash/releases).
Every build of the master branch updates the latest *RC release*. These releases are usually stable, but might contain regressions and therefore recommended for "advanced users" only.
@@ -75,4 +74,4 @@ When we release a new stable release, we also update the *latest* Docker image t
## Code of Conduct
This project adheres to the Contributor Covenant [code of conduct](http://redash.io/community/code_of_conduct). By participating, you are expected to uphold this code. Please report unacceptable behavior to team@redash.io.
This project adheres to the Contributor Covenant [code of conduct](https://redash.io/community/code_of_conduct). By participating, you are expected to uphold this code. Please report unacceptable behavior to team@redash.io.

View File

@@ -1,14 +1,27 @@
FROM node:10 as frontend-builder
WORKDIR /frontend
COPY package.json package-lock.json /frontend/
RUN npm install
COPY . /frontend
RUN npm run build
FROM redash/base:latest
# Controls whether to install extra dependencies needed for all data sources.
ARG skip_ds_deps
# We first copy only the requirements file, to avoid rebuilding on every file
# change.
COPY requirements.txt requirements_dev.txt requirements_all_ds.txt ./
RUN pip install -r requirements.txt -r requirements_dev.txt -r requirements_all_ds.txt
RUN pip install -r requirements.txt -r requirements_dev.txt
RUN if [ "x$skip_ds_deps" = "x" ] ; then pip install -r requirements_all_ds.txt ; else echo "Skipping pip install -r requirements_all_ds.txt" ; fi
COPY . ./
RUN npm install && npm run build && rm -rf node_modules
COPY . /app
COPY --from=frontend-builder /frontend/client/dist /app/client/dist
RUN chown -R redash /app
USER redash
ENTRYPOINT ["/app/bin/docker-entrypoint"]
CMD ["server"]
CMD ["server"]

View File

@@ -1,4 +1,4 @@
Copyright (c) 2013-2018, Arik Fraimovich.
Copyright (c) 2013-2019, Arik Fraimovich.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,

57
Makefile Normal file
View File

@@ -0,0 +1,57 @@
.PHONY: compose_build up test_db create_database clean down bundle tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash
compose_build:
docker-compose build
up:
docker-compose up -d --build
test_db:
@for i in `seq 1 5`; do \
if (docker-compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
else echo "postgres initializing..."; sleep 5; fi \
done
docker-compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'
create_database:
docker-compose run server create_db
clean:
docker-compose down && docker-compose rm
down:
docker-compose down
bundle:
docker-compose run server bin/bundle-extensions
tests:
docker-compose run server tests
lint:
./bin/flake8_tests.sh
backend-unit-tests: up test_db
docker-compose run --rm --name tests server tests
frontend-unit-tests: bundle
npm install
npm run bundle
npm test
test: lint backend-unit-tests frontend-unit-tests
build: bundle
npm run build
watch: bundle
npm run watch
start: bundle
npm run start
redis-cli:
docker-compose run --rm redis redis-cli -h redis
bash:
docker-compose run --rm server bash

View File

@@ -16,7 +16,7 @@ Today **_Redash_** has support for querying multiple databases, including: Redsh
**_Redash_** consists of two parts:
1. **Query Editor**: think of [JS Fiddle](http://jsfiddle.net) for SQL queries. It's your way to share data in the organization in an open way, by sharing both the dataset and the query that generated it. This way everyone can peer review not only the resulting dataset but also the process that generated it. Also it's possible to fork it and generate new datasets and reach new insights.
1. **Query Editor**: think of [JS Fiddle](https://jsfiddle.net) for SQL queries. It's your way to share data in the organization in an open way, by sharing both the dataset and the query that generated it. This way everyone can peer review not only the resulting dataset but also the process that generated it. Also it's possible to fork it and generate new datasets and reach new insights.
2. **Visualizations and Dashboards**: once you have a dataset, you can create different visualizations out of it, and then combine several visualizations into a single dashboard. Currently Redash supports charts, pivot table, cohorts and [more](https://redash.io/help/user-guide/visualizations/visualization-types).
<img src="https://raw.githubusercontent.com/getredash/website/8e820cd02c73a8ddf4f946a9d293c54fd3fb08b9/website/_assets/images/redash-anim.gif" width="80%"/>
@@ -28,13 +28,12 @@ Today **_Redash_** has support for querying multiple databases, including: Redsh
## Supported Data Sources
Redash supports more than 25 [data sources](https://redash.io/help/data-sources/supported-data-sources).
Redash supports more than 35 [data sources](https://redash.io/help/data-sources/supported-data-sources).
## Getting Help
* Issues: https://github.com/getredash/redash/issues
* Discussion Forum: https://discuss.redash.io/
* Slack: http://slack.redash.io/
## Reporting Bugs and Contributing Code

39
bin/bundle-extensions Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python
import os
from subprocess import call
from distutils.dir_util import copy_tree
from pkg_resources import iter_entry_points, resource_filename, resource_isdir
# Make a directory for extensions and set it as an environment variable
# to be picked up by webpack.
EXTENSIONS_RELATIVE_PATH = os.path.join('client', 'app', 'extensions')
EXTENSIONS_DIRECTORY = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
EXTENSIONS_RELATIVE_PATH)
if not os.path.exists(EXTENSIONS_DIRECTORY):
os.makedirs(EXTENSIONS_DIRECTORY)
os.environ["EXTENSIONS_DIRECTORY"] = EXTENSIONS_RELATIVE_PATH
for entry_point in iter_entry_points('redash.extensions'):
# This is where the frontend code for an extension lives
# inside of its package.
content_folder_relative = os.path.join(
entry_point.name, 'bundle')
(root_module, _) = os.path.splitext(entry_point.module_name)
if not resource_isdir(root_module, content_folder_relative):
continue
content_folder = resource_filename(root_module, content_folder_relative)
# This is where we place our extensions folder.
destination = os.path.join(
EXTENSIONS_DIRECTORY,
entry_point.name)
copy_tree(content_folder, destination)

View File

@@ -3,7 +3,7 @@ set -e
worker() {
WORKERS_COUNT=${WORKERS_COUNT:-2}
QUEUES=${QUEUES:-queries,scheduled_queries,celery}
QUEUES=${QUEUES:-queries,scheduled_queries,celery,schemas}
echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."
exec /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
@@ -12,10 +12,11 @@ worker() {
scheduler() {
WORKERS_COUNT=${WORKERS_COUNT:-1}
QUEUES=${QUEUES:-celery}
SCHEDULE_DB=${SCHEDULE_DB:-celerybeat-schedule}
echo "Starting scheduler and $WORKERS_COUNT workers for queues: $QUEUES..."
exec /usr/local/bin/celery worker --app=redash.worker --beat -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
exec /usr/local/bin/celery worker --app=redash.worker --beat -s$SCHEDULE_DB -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
}
server() {
@@ -26,6 +27,10 @@ create_db() {
exec /app/manage.py database create_tables
}
celery_healthcheck() {
exec /usr/local/bin/celery inspect ping --app=redash.worker -d celery@$HOSTNAME
}
help() {
echo "Redash Docker."
echo ""
@@ -35,9 +40,11 @@ help() {
echo "server -- start Redash server (with gunicorn)"
echo "worker -- start Celery worker"
echo "scheduler -- start Celery worker with a beat (scheduler) process"
echo "celery_healthcheck -- runs a Celery healthcheck. Useful for Docker's HEALTHCHECK mechanism."
echo ""
echo "shell -- open shell"
echo "dev_server -- start Flask development server with debugger and auto reload"
echo "debug -- start Flask development server with remote debugger via ptvsd"
echo "create_db -- create database tables"
echo "manage -- CLI to manage redash"
echo "tests -- run tests"
@@ -71,6 +78,11 @@ case "$1" in
export FLASK_DEBUG=1
exec /app/manage.py runserver --debugger --reload -h 0.0.0.0
;;
debug)
export FLASK_DEBUG=1
export REMOTE_DEBUG=1
exec /app/manage.py runserver --debugger --no-reload -h 0.0.0.0
;;
shell)
exec /app/manage.py shell
;;

7
bin/flake8_tests.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
flake8 --version ; pip --version
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

View File

@@ -1,4 +1,5 @@
#!/bin/env python
from __future__ import print_function
import sys
import re
import subprocess
@@ -32,4 +33,4 @@ if __name__ == '__main__':
changes = get_change_log(previous_sha)
for change in changes:
print change
print(change)

View File

@@ -1,10 +1,10 @@
from __future__ import print_function
import os
import sys
import json
import re
import subprocess
import requests
import simplejson
github_token = os.environ['GITHUB_TOKEN']
auth = (github_token, 'x-oauth-basic')
@@ -17,7 +17,7 @@ def _github_request(method, path, params=None, headers={}):
url = path
if params is not None:
params = json.dumps(params)
params = simplejson.dumps(params)
response = requests.request(method, url, data=params, auth=auth)
return response

View File

@@ -1,8 +1,15 @@
{
"presets": ["env", "react", "stage-2"],
"presets": [
["@babel/preset-env", {
"targets": "> 0.5%, last 2 versions, Firefox ESR, ie 11, not dead",
"useBuiltIns": "usage"
}],
"@babel/preset-react"
],
"plugins": [
"angularjs-annotate",
"transform-object-assign",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-object-assign",
["babel-plugin-transform-builtin-extend", {
"globals": ["Error"]
}]

View File

@@ -1,11 +1,14 @@
module.exports = {
root: true,
extends: "airbnb",
extends: ["airbnb", "plugin:jest/recommended"],
plugins: ["jest", "cypress"],
settings: {
"import/resolver": "webpack"
},
parser: "babel-eslint",
env: {
"jest/globals": true,
"cypress/globals": true,
"browser": true,
"node": true
},
@@ -15,6 +18,7 @@ module.exports = {
'no-param-reassign': 0,
'no-mixed-operators': 0,
'no-underscore-dangle': 0,
"no-use-before-define": ["error", "nofunc"],
"prefer-destructuring": "off",
"prefer-template": "off",
"no-restricted-properties": "off",
@@ -23,19 +27,34 @@ module.exports = {
"no-lonely-if": "off",
"consistent-return": "off",
"no-control-regex": "off",
'no-multiple-empty-lines': 'warn',
"no-script-url": "off", // some <a> tags should have href="javascript:void(0)"
'operator-linebreak': 'off',
'react/destructuring-assignment': 'off',
"react/jsx-filename-extension": "off",
'react/jsx-one-expression-per-line': 'off',
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
'react/jsx-wrap-multilines': 'warn',
'react/no-access-state-in-setstate': 'warn',
"react/prefer-stateless-function": "warn",
"react/forbid-prop-types": "warn",
"react/prop-types": "warn",
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/label-has-associated-control": ["warn", {
"controlComponents": true
}],
"jsx-a11y/label-has-for": "off",
"jsx-a11y/no-static-element-interactions": "off",
"max-len": ['error', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}]
}],
"no-else-return": ["error", {"allowElseIf": true}],
"object-curly-newline": ["error", {"consistent": true}],
}
};

View File

@@ -0,0 +1,4 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });

View File

@@ -0,0 +1,5 @@
import MockDate from 'mockdate';
const date = new Date('2000-01-01T02:00:00.000');
MockDate.set(date);

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,249 @@
@import '~antd/lib/style/core/iconfont';
@import '~antd/lib/style/core/motion';
@import '~antd/lib/alert/style/index';
@import '~antd/lib/input/style/index';
@import '~antd/lib/input-number/style/index';
@import '~antd/lib/date-picker/style/index';
@import '~antd/lib/modal/style/index';
@import '~antd/lib/tooltip/style/index';
@import '~antd/lib/select/style/index';
@import '~antd/lib/checkbox/style/index';
@import '~antd/lib/upload/style/index';
@import '~antd/lib/form/style/index';
@import '~antd/lib/button/style/index';
@import '~antd/lib/radio/style/index';
@import '~antd/lib/time-picker/style/index';
@import '~antd/lib/pagination/style/index';
@import '~antd/lib/table/style/index';
@import '~antd/lib/popover/style/index';
@import '~antd/lib/icon/style/index';
@import '~antd/lib/tag/style/index';
@import '~antd/lib/grid/style/index';
@import '~antd/lib/switch/style/index';
@import '~antd/lib/drawer/style/index';
@import '~antd/lib/divider/style/index';
@import '~antd/lib/dropdown/style/index';
@import '~antd/lib/menu/style/index';
@import '~antd/lib/list/style/index';
@import "~antd/lib/badge/style/index";
@import "~antd/lib/card/style/index";
@import "~antd/lib/spin/style/index";
@import "~antd/lib/tabs/style/index";
@import 'inc/ant-variables';
// Remove bold in labels for Ant checkboxes and radio buttons
.ant-checkbox-wrapper,
.ant-radio-wrapper {
font-weight: normal;
}
// Fix for disabled button styles inside Tooltip component.
// Tooltip wraps disabled buttons with `<span>` and moves all styles
// and classes to that `<span>`. This resets all button styles and
// turns it into simple inline element (because now it's wrapper is a button)
.btn {
button[disabled] {
-moz-appearance: none !important;
-webkit-appearance: none !important;
appearance: none !important;
border: 0 !important;
outline: none !important;
background: transparent !important;
margin: 0 !important;
padding: 0 !important;
}
}
// Fix for Ant dropdowns when they are used in Boootstrap modals
.ant-dropdown-in-bootstrap-modal {
z-index: 1050;
}
// Button overrides
.@{btn-prefix-cls} {
transition-duration: 150ms;
}
// Fix ant input number showing duplicate arrows
.ant-input-number-input::-webkit-outer-spin-button,
.ant-input-number-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
// Pagination overrides (based on existing Bootstrap overrides)
.@{pagination-prefix-cls} {
display: inline-block;
margin-top: 18px;
margin-bottom: 18px;
vertical-align: top;
&-item {
background-color: @pagination-bg;
border-color: transparent;
color: @pagination-color;
font-size: 14px;
margin-right: 5px;
a {
color: inherit;
}
&:focus,
&:hover {
background-color: @pagination-hover-bg;
border-color: transparent;
color: @pagination-hover-color;
a {
color: inherit;
}
}
&-active {
&,
&:hover,
&:focus {
background-color: @pagination-active-bg;
color: @pagination-active-color;
border-color: transparent;
pointer-events: none;
cursor: default;
a {
color: inherit;
}
}
}
}
&-disabled {
&,
&:hover,
&:focus {
opacity: 0.5;
pointer-events: none;
}
}
&-prev,
&-next {
.@{pagination-prefix-cls}-item-link {
background-color: @pagination-bg;
border-color: transparent;
color: @pagination-color;
line-height: @pagination-item-size - 2px;
}
&:focus .@{pagination-prefix-cls}-item-link,
&:hover .@{pagination-prefix-cls}-item-link {
background-color: @pagination-hover-bg;
border-color: transparent;
color: @pagination-hover-color;
}
}
&-prev,
&-jump-prev,
&-jump-next {
margin-right: 5px;
}
&-jump-prev,
&-jump-next {
.@{pagination-prefix-cls}-item-container {
.@{pagination-prefix-cls}-item-link-icon {
color: @pagination-color;
}
}
}
}
// Table
.@{table-prefix-cls} {
color: inherit;
tr,
th,
td {
transition: none !important;
}
&-thead > tr > th {
padding: @table-padding-vertical * 2 @table-padding-horizontal;
}
.@{table-prefix-cls}-column-sorters {
&:before,
&:hover:before {
content: none;
}
}
&-thead > tr > th {
.@{table-prefix-cls}-column-sorter {
&-up,
&-down {
&.on {
color: @table-header-icon-active-color;
}
}
}
}
// Custom styles
&-headerless &-tbody > tr:first-child > td {
border-top: @border-width-base @border-style-base @border-color-split;
}
}
// List
.@{list-prefix-cls} {
&-item {
// custom rule
&.selected {
background-color: #F6F8F9;
}
&.disabled {
background-color: fade(#F6F8F9, 40%);
& > * {
opacity: 0.4;
}
}
}
}
// styling for short modals (no lines)
.@{dialog-prefix-cls}.shortModal {
.@{dialog-prefix-cls} {
&-header,
&-footer {
border: none;
padding: 16px;
}
&-body {
padding: 10px 16px;
}
&-close-x {
width: 46px;
height: 46px;
line-height: 46px;
}
}
}
// description in modal header
.modal-header-desc {
font-size: @font-size-base;
color: @text-color-secondary;
font-weight: normal;
margin-top: 4px;
}
.ant-popover {
z-index: 1000; // make sure it doesn't cover drawer
}

View File

@@ -0,0 +1,74 @@
/* --------------------------------------------------------
Colors
-----------------------------------------------------------*/
@lightblue: #03A9F4;
@primary-color: #2196F3;
@redash-gray: rgba(102, 136, 153, 1);
@redash-orange: rgba(255, 120, 100, 1);
@redash-black: rgba(0, 0, 0, 1);
@redash-yellow: rgba(252, 252, 161, 0.75);
/* --------------------------------------------------------
Font
-----------------------------------------------------------*/
@redash-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
@font-family-no-number: @redash-font;
@font-family: @redash-font;
@code-family: @redash-font;
@font-size-base: 13px;
/* --------------------------------------------------------
Typograpgy
-----------------------------------------------------------*/
@text-color: #595959;
/* --------------------------------------------------------
Form
-----------------------------------------------------------*/
@input-height-base: 35px;
@input-color: #595959;
@border-radius-base: 2px;
@border-color-base: #E8E8E8;
/* --------------------------------------------------------
Button
-----------------------------------------------------------*/
@btn-danger-bg: fade(@redash-gray, 10%);
@btn-danger-border: fade(@redash-gray, 15%);
/* --------------------------------------------------------
Pagination
-----------------------------------------------------------*/
@pagination-item-size: 33px;
@pagination-font-family: @redash-font;
@pagination-font-weight-active: normal;
@pagination-bg: fade(@redash-gray, 15%);
@pagination-color: #7E7E7E;
@pagination-active-bg: @lightblue;
@pagination-active-color: #FFF;
@pagination-disabled-bg: fade(@redash-gray, 15%);
@pagination-hover-color: #333;
@pagination-hover-bg: fade(@redash-gray, 25%);
/* --------------------------------------------------------
Table
-----------------------------------------------------------*/
@table-border-radius-base: 0;
@table-header-color: #333;
@table-header-bg: fade(@redash-gray, 3%);
@table-header-icon-color: fade(@text-color, 20%);
@table-header-icon-active-color: @text-color;
@table-header-sort-bg: @table-header-bg;
@table-header-sort-active-bg: @table-header-bg;
@table-header-filter-active-bg: @table-header-bg;
@table-body-sort-bg: transparent;
@table-row-hover-bg: fade(@redash-gray, 5%);
@table-padding-vertical: 7px;
@table-padding-horizontal: 10px;

View File

@@ -73,6 +73,10 @@ strong {
}
.clickable {
cursor: pointer;
}
.resize-vertical {
resize: vertical !important;
transition: height 0s !important;

View File

@@ -40,3 +40,10 @@
vertical-align: top;
margin-left: 0;
}
// Hide URLs next to links when printing (override `bootstrap` rules)
@media print {
a[href]:after {
content: none !important;
}
}

View File

@@ -15,15 +15,6 @@
border-radius: @redash-radius;
}
.edit-in-place input,
.edit-in-place textarea {
display: none;
}
.edit-in-place.active span {
display: none;
}
.edit-in-place.active input,
.edit-in-place.active textarea {
display: inline-block;

View File

@@ -146,6 +146,8 @@
Width
-----------------------------------------------------------*/
.w-100 { width: 100% !important; }
.w-50 { width: 50% !important; }
.w-25 { width: 25% !important; }
/* --------------------------------------------------------

View File

@@ -1,60 +1,78 @@
.list-group {
margin-bottom: 0;
&.lg-alt .list-group-item {
border: 0;
}
&:not(.lg-alt) {
&.lg-listview .list-group-item {
border-left: 0;
border-right: 0;
&:last-child {
border-bottom: 0;
}
}
}
}
.list-group-item {
&.active {
button {
color: white;
}
}
.cr-alt {
line-height: 100%;
margin-top: 2px;
}
}
.list-group-item-heading {
margin-bottom: 2px;
color: #333;
& > small {
font-size: 11px;
color: #C5C5C5;
margin-left: 10px;
}
}
.list-group-item-heading,
.list-group-item-text {
.text-overflow();
}
.list-group-item-text {
display: block;
&:not(:last-child) {
margin-bottom: 4px;
}
}
.list-group-img {
width: 38px;
height: 38px;
border-radius: 2px;
}
.list-group {
margin-bottom: 0;
&.lg-alt .list-group-item {
border: 0;
}
&:not(.lg-alt) {
&.lg-listview .list-group-item {
border-left: 0;
border-right: 0;
&:last-child {
border-bottom: 0;
}
}
}
}
tags-list {
a {
line-height: 1.1;
}
}
.tags-list__name {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
width: 88%;
line-height: 1.3;
}
.max-character {
.text-overflow();
}
.list-group-item {
&.active {
button {
color: white;
}
}
.cr-alt {
line-height: 100%;
margin-top: 2px;
}
}
.list-group-item-heading {
margin-bottom: 2px;
color: #333;
& > small {
font-size: 11px;
color: #C5C5C5;
margin-left: 10px;
}
}
.list-group-item-heading,
.list-group-item-text {
.text-overflow();
}
.list-group-item-text {
display: block;
&:not(:last-child) {
margin-bottom: 4px;
}
}
.list-group-img {
width: 38px;
height: 38px;
border-radius: 2px;
}

View File

@@ -1,6 +1,5 @@
a.navbar-brand {
padding: 5px 5px 0px 0px;
margin-left: 0px !important;
}
.navbar .fa {

View File

@@ -55,6 +55,7 @@
/* --------------------------------------------------------
Form
-----------------------------------------------------------*/
@input-color: #595959;
@input-color-placeholder: #b4b4b4;
@input-border: #e8e8e8;
@input-border-radius: 0;
@@ -98,7 +99,6 @@
@state-success-text: @green;
@state-info-text: @blue;
@state-danger-text: lighten(@red, 5%);
@state-warning-text: @orange;
/* --------------------------------------------------------
@@ -106,19 +106,16 @@
-----------------------------------------------------------*/
@alert-success-border: transparent;
@alert-info-border: transparent;
@alert-warning-border: transparent;
@alert-danger-border: transparent;
@alert-inverse-border: transparent;
@alert-success-bg: fade(@green, 70%);
@alert-info-bg: fade(@blue, 70%);
@alert-warning-bg: fade(@amber, 70%);
@alert-danger-bg: fade(@red, 70%);
@alert-inverse-bg: #333;
@alert-success-text: #fff;
@alert-info-text: #fff;
@alert-warning-text: #fff;
@alert-danger-text: #fff;
@alert-inverse-text: #fff;

View File

@@ -3,52 +3,43 @@ counter-renderer {
text-align: center;
padding: 15px 10px;
overflow: hidden;
}
counter-renderer counter {
margin: 0;
padding: 0;
display: block;
font-size: 80px;
overflow: hidden;
height: 200px;
}
counter {
margin: 0;
padding: 0;
font-size: 80px;
line-height: normal;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
counter-renderer value,
counter-renderer counter-name,
counter-renderer counter-target {
font-size: 1em;
line-height: 1em;
display: block;
}
value,
counter-target {
font-size: 1em;
display: block;
}
counter-renderer value .ruler,
counter-renderer counter-name .ruler,
counter-renderer counter-target .ruler {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font: inherit;
line-height: inherit;
margin: 0;
padding: 0;
}
counter-name {
font-size: 0.5em;
display: block;
}
counter-renderer counter-target {
color: #ccc;
}
&.positive value {
color: #5cb85c;
}
counter-renderer counter.positive value {
color: #5cb85c;
}
&.negative value {
color: #d9534f;
}
}
counter-renderer counter.negative value {
color: #d9534f;
margin-right: 15px;
}
counter-target {
color: #ccc;
}
counter-renderer counter-name {
font-size: 0.5em;
display: block;
counter-name {
font-size: 0.5em;
display: block;
}
}

View File

@@ -1,3 +1,6 @@
visualization-renderer .pagination {
margin: 0;
visualization-renderer {
.pagination,
.ant-pagination {
margin: 0;
}
}

View File

@@ -1,8 +1,3 @@
@import '~antd/lib/style/core/iconfont.less';
@import '~antd/lib/input/style/index.less';
@import '~antd/lib/date-picker/style/index.less';
@import 'redash/ant';
/** LESS Plugins **/
@import 'inc/less-plugins/for';
@@ -14,8 +9,8 @@
@import '~ui-select/dist/select.css';
@import '~angular-toastr/src/toastr';
@import '~angular-resizable/src/angular-resizable.css';
@import '~pace-progress/themes/blue/pace-theme-minimal.css';
@import '~material-design-iconic-font/dist/css/material-design-iconic-font.css';
@import '~pace-progress/themes/blue/pace-theme-minimal.css';
@import 'inc/angular';
@import 'inc/variables';
@@ -81,6 +76,7 @@
@import 'redash/redash-newstyle';
@import 'redash/redash-table';
@import 'redash/query';
@import 'redash/tags-control';

View File

@@ -1,9 +0,0 @@
// Overwritting Ant Design defaults to fit into Redash current style
@font-family-no-number : @redash-font;
@font-family : @redash-font;
@code-family : @redash-font;
@border-radius-base : @redash-input-radius;
@border-color-base : #e8e8e8;
@primary-color : @blue;

View File

@@ -95,10 +95,6 @@ edit-in-place p.editable:hover {
margin-bottom: 10px;
}
.source-control {
}
.ace_editor.ace_autocomplete .ace_completion-highlight {
text-shadow: none !important;
background: #ffff005e;
@@ -206,8 +202,11 @@ edit-in-place p.editable:hover {
}
}
.visualization-renderer .pagination {
margin-top: 10px;
.visualization-renderer {
.pagination,
.ant-pagination {
margin-top: 10px;
}
}
.embed__vis {
@@ -225,26 +224,29 @@ edit-in-place p.editable:hover {
}
.page-header--new {
.label-default {
margin-right: 3px;
.query-tags,
.query-tags__mobile {
.label-default,
.label-warning {
margin-right: 3px;
}
}
}
.page-header--query {
display: flex;
align-items: center;
h3 {
display: inline-block;
.page-title {
display: block;
margin-left: 15px;
margin-right: 15px;
}
}
a.label-tag {
background: fade(@redash-gray, 15%);
color: #333;
color: darken(@redash-gray, 15%);
&:hover {
color: #333;
color: darken(@redash-gray, 15%);
background: fade(@redash-gray, 25%);
}
}
@@ -527,9 +529,59 @@ nav .rg-bottom {
}
}
.query-tags {
display: inline-block;
vertical-align: middle;
margin-top: -3px; // padding-top of tags
}
.query-tags__mobile {
display: none;
margin: -5px 0 0 0;
padding: 0 0 0 23px;
}
.table--permission {
.profile__image {
margin-right: 0;
}
}
.mp__permission-type {
text-transform: capitalize;
}
// Smaller screens
@media (max-width: 880px) {
.page-header--query {
.page-title {
margin-left: 0;
margin-right: 0;
}
}
.query-tags:not(.query-tags__empty) {
display: none;
}
.query-tags__mobile:not(.query-tags__empty) {
display: block;
}
.btn--showhide,
.query-actions-menu .dropdown-toggle {
margin-bottom: 5px;
}
.btn-publish {
display: none;
}
.tab-nav .tab-new-vis {
display: none;
}
.query-fullscreen {
flex-direction: column;
overflow: hidden;
@@ -541,44 +593,25 @@ nav .rg-bottom {
.schema-container {
display: none;
}
}
.query-page-wrapper {
.container {
margin-left: 0;
margin-right: 0;
.query-metadata__mobile {
border-bottom: 1px solid #efefef;
min-height: 0 !important;
flex-shrink: 0;
padding: 10px 15px;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
.profile__image_thumb {
margin: 0 5px 0 0;
}
.query-metadata__property {
white-space: nowrap;
}
}
}
.query-fullscreen .query-metadata__mobile {
display: block;
border-bottom: 1px solid #efefef;
padding: 10px 0;
min-height: 0 !important;
flex-shrink: 0;
}
a.navbar-brand {
display: none;
}
.page-header--query {
padding-left: 0px !important;
h3 {
line-height: 1.25;
}
}
.query-fullscreen .content {
height: 100%;
}
.datasource-small {
visibility: visible;
}
.query-fullscreen {
main {
flex-direction: column-reverse;
@@ -600,18 +633,27 @@ nav .rg-bottom {
.content {
width: 100%;
height: 100%;
.static-position__mobile {
position: static !important;
}
}
.bottom-controller-container {
z-index: 9;
}
}
}
@media (max-width: 438px) {
.btn--showhide {
margin-bottom: 5px;
.query-page-wrapper {
.container {
margin-left: 0;
margin-right: 0;
}
}
.btn-publish {
margin-bottom: 5px;
.datasource-small {
visibility: visible;
}
}
@@ -620,15 +662,11 @@ nav .rg-bottom {
display: none;
}
a.navbar-brand {
display: block;
}
.filter-container {
padding-right: 0;
}
.btn-edit-visualisation {
display: none;
}
}

View File

@@ -1,3 +1,5 @@
@import (reference, less) '~bootstrap/less/labels.less';
// Variables
@redash-gray: rgba(102, 136, 153, 1);
@redash-orange: rgba(255, 120, 100, 1);
@@ -33,6 +35,10 @@ body {
}
}
.word-wrap-break {
word-wrap: break-word;
}
.clearboth {
clear: both;
}
@@ -52,27 +58,9 @@ body {
border-left-color: #1b809e;
}
.list-content {
@media (min-width: 992px) {
padding-right: 0;
}
}
.list-control-r-b {
@media (max-width: 992px) {
display: none;
}
}
.list-control-t {
@media (min-width: 992px) {
display: none;
}
}
// Fixed width layout for specific pages
@media (min-width: 768px) {
settings-screen, home-page, page-dashboard-list, page-queries-list, alerts-list-page, alert-page, queries-search-results-page, .fixed-container {
settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container {
.container {
width: 750px;
}
@@ -80,7 +68,7 @@ body {
}
@media (min-width: 992px) {
settings-screen, home-page, page-dashboard-list, page-queries-list, alerts-list-page, alert-page, queries-search-results-page, .fixed-container {
settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container {
.container {
width: 970px;
}
@@ -88,7 +76,7 @@ body {
}
@media (min-width: 1200px) {
settings-screen, home-page, page-dashboard-list, page-queries-list, alerts-list-page, alert-page, queries-search-results-page, .fixed-container {
settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container {
.container {
width: 1170px;
}
@@ -166,16 +154,12 @@ body {
box-shadow: inset 3px 0px 0px @brand-primary;
}
.table.table-data {
> tbody > tr > td {
.table-data {
tbody > tr > td {
padding-top: 5px !important;
}
tr:hover {
cursor: pointer;
}
.btn-favourite {
.btn-favourite, .btn-archive {
font-size: 15px;
}
}
@@ -188,7 +172,7 @@ body {
}
}
.btn-favourite {
.btn-favourite, .btn-archive {
color: #d4d4d4;
transition: all .25s ease-in-out;
@@ -201,7 +185,20 @@ body {
}
}
.page-header--new .btn-favourite {
.btn-archive {
color: #d4d4d4;
transition: all .25s ease-in-out;
&:hover, &:focus {
color: @gray-light;
}
.fa-archive {
color: @gray-light;
}
}
.page-header--new .btn-favourite, .page-header--new .btn-archive {
font-size: 19px;
}
@@ -237,7 +234,7 @@ body {
}
}
.navbar li a .btn-favourite .fa {
.navbar li a .btn-favourite .fa, .navbar li a .btn-archive .fa {
font-size: 100%;
}
@@ -364,10 +361,10 @@ body {
padding: 20px;
}
page-header, .page-header--new {
.page-header-wrapper, .page-header--new {
h3 {
margin: 0;
line-height: 1.75;
margin: 0.2em 0;
line-height: 1.3;
font-weight: 500;
}
}
@@ -449,10 +446,27 @@ page-header, .page-header--new {
background: fade(@redash-gray, 85%);
}
.label-tag-unpublished {
background: fade(@redash-gray, 85%);
}
.label-tag-archived {
.label-warning();
}
.label-tag {
background: fade(@redash-gray, 10%);
color: fade(@redash-gray, 75%);
}
.label-tag-unpublished,
.label-tag-archived,
.label-tag {
margin-right: 3px;
display: inline;
margin-top: 2px;
max-width: 24ch;
.text-overflow();
}
.tab-nav > li > a {
@@ -621,11 +635,6 @@ page-header, .page-header--new {
background: #fff;
margin-bottom: 10px;
a.navbar-brand {
padding: 4px 0px 0px 0px;
margin-left: -3px !important;
}
.btn-group.open .dropdown-toggle {
-webkit-box-shadow: none;
box-shadow: none;
@@ -636,6 +645,18 @@ page-header, .page-header--new {
}
}
.navbar-link-ANGULAR_REMOVE_ME {
line-height: 18px;
padding: 10px 15px;
display: block;
@media (min-width: 768px) {
padding-top: 16px;
padding-bottom: 16px;
}
}
.navbar-link-ANGULAR_REMOVE_ME,
.navbar-default .navbar-nav > li > a {
color: #000;
font-weight: 500;
@@ -687,6 +708,11 @@ page-header, .page-header--new {
height: 20px;
}
.user_list__user--invitation-pending {
color: fade(@alert-danger-bg, 75%);
font-weight: 500;
}
.btn__new {
margin-left: 15px;
}
@@ -698,11 +724,10 @@ page-header, .page-header--new {
.navbar-brand {
position: absolute;
left: 49%;
margin-left: -50px !important;
left: 50%;
margin-left: -25px !important; // center
display: block;
zoom: 0.9;
margin-top: 3px;
}
.va-top {
@@ -732,6 +757,14 @@ page-header, .page-header--new {
margin-top: 2px;
}
.tags-list {
.badge-light {
background: fade(@redash-gray, 10%);
color: fade(@redash-gray, 75%);
}
}
.dropdown-menu--profile {
li {
width: 200px;
@@ -779,11 +812,9 @@ page-header, .page-header--new {
// Forms
.form-control {
border-radius: @redash-input-radius;
color: #9E9E9E;
&:focus {
box-shadow: none !important;
color: #111;
border-color: @blue;
}
@@ -805,10 +836,6 @@ text.slicetext {
}
.query-page-wrapper {
.page-header--query {
padding-bottom: 5px !important;
}
h3 {
font-size: 18px;
}
@@ -820,6 +847,7 @@ text.slicetext {
.navbar-brand {
left: 2%;
margin-left: 0 !important;
}
//Fix navbar collapse
@@ -860,6 +888,31 @@ text.slicetext {
}
}
@media (min-width: 768px) {
@media (max-width: 880px) {
.navbar-link-ANGULAR_REMOVE_ME,
.navbar-default .navbar-nav > li > a,
.navbar-form {
padding-left: 10px !important;
padding-right: 10px !important;
}
a.navbar-brand {
margin-left: -15px !important;
}
}
@media (max-width: 810px) {
.menu-search {
width: 175px;
}
a.navbar-brand {
margin-left: 13px !important;
}
}
}
@media (max-width: 1084px) {
.dropdown--profile__username {
display: none;
@@ -900,3 +953,26 @@ text.slicetext {
}
}
.ui-select-choices-row.disabled > span {
background-color: inherit !important;
}
.list-group-item.inactive,
.ui-select-choices-row.disabled {
background-color: #eee !important;
border-color: transparent;
opacity: 0.5;
box-shadow: none;
color: #333;
pointer-events: none;
cursor: not-allowed;
}
.select-option-divider {
margin: 10px 0 !important;
}
.table-data .label-tag {
display: inline-block;
max-width: 135px;
}

View File

@@ -0,0 +1,22 @@
.tags-control {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
justify-content: flex-start;
line-height: 1em;
&.inline-tags-control {
display: inline-block;
}
&.disabled {
opacity: 0.4;
}
}
// This is for using .inline-tags-control in Angular which renders
// a little differently than React (e.g. in Alert.html)
.inline-tags-control .tags-control {
display: inline-block;
}

View File

@@ -0,0 +1,43 @@
import React from 'react';
import Tooltip from 'antd/lib/tooltip';
import PropTypes from 'prop-types';
import '@/redash-font/style.less';
import recordEvent from '@/services/recordEvent';
export default function AutocompleteToggle({ state, disabled, onToggle }) {
let tooltipMessage = 'Live Autocomplete Enabled';
let icon = 'icon-flash';
if (!state) {
tooltipMessage = 'Live Autocomplete Disabled';
icon = 'icon-flash-off';
}
if (disabled) {
tooltipMessage = 'Live Autocomplete Not Available (Use Ctrl+Space to Trigger)';
icon = 'icon-flash-off';
}
const toggle = (newState) => {
recordEvent('toggle_autocomplete', 'screen', 'query_editor', { state: newState });
onToggle(newState);
};
return (
<Tooltip placement="top" title={tooltipMessage}>
<button
type="button"
className={'btn btn-default m-r-5' + (disabled ? ' disabled' : '')}
onClick={() => toggle(!state)}
disabled={disabled}
>
<i className={'icon ' + icon} />
</button>
</Tooltip>
);
}
AutocompleteToggle.propTypes = {
state: PropTypes.bool.isRequired,
disabled: PropTypes.bool.isRequired,
onToggle: PropTypes.func.isRequired,
};

View File

@@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
export function BigMessage({ message, icon, children }) {
export function BigMessage({ message, icon, children, className }) {
return (
<div className="tiled bg-white p-15 text-center">
<div className={'p-15 text-center ' + className}>
<h3 className="m-t-0 m-b-0">
<i className={'fa ' + icon} />
</h3>
@@ -19,13 +19,17 @@ BigMessage.propTypes = {
message: PropTypes.string,
icon: PropTypes.string.isRequired,
children: PropTypes.node,
className: PropTypes.string,
};
BigMessage.defaultProps = {
message: '',
children: null,
className: 'tiled bg-white',
};
export default function init(ngModule) {
ngModule.component('bigMessage', react2angular(BigMessage));
}
init.init = true;

View File

@@ -1,14 +1,14 @@
import moment from 'moment';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';
function DateInput({
export function DateInput({
value,
onSelect,
// eslint-disable-next-line react/prop-types
clientConfig,
className,
}) {
const format = clientConfig.dateFormat || 'YYYY-MM-DD';
const additionalAttributes = {};
@@ -17,6 +17,7 @@ function DateInput({
}
return (
<DatePicker
className={className}
{...additionalAttributes}
format={format}
placeholder="Select Date"
@@ -26,22 +27,19 @@ function DateInput({
}
DateInput.propTypes = {
value: (props, propName, componentName) => {
const value = props[propName];
if ((value !== null) && !moment.isMoment(value)) {
return new Error('Prop `' + propName + '` supplied to `' + componentName +
'` should be a Moment.js instance.');
}
},
value: Moment,
onSelect: PropTypes.func,
className: PropTypes.string,
};
DateInput.defaultProps = {
value: null,
onSelect: () => {},
className: '',
};
export default function init(ngModule) {
ngModule.component('dateInput', react2angular(DateInput, null, ['clientConfig']));
ngModule.component('dateInput', react2angular(DateInput));
}
init.init = true;

View File

@@ -1,18 +1,17 @@
import moment from 'moment';
import { isArray } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { RangePicker } from 'antd/lib/date-picker';
import 'antd/lib/style/core/iconfont.less';
import 'antd/lib/input/style/index.less';
import 'antd/lib/date-picker/style/index.less';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';
function DateRangeInput({
const { RangePicker } = DatePicker;
export function DateRangeInput({
value,
onSelect,
// eslint-disable-next-line react/prop-types
clientConfig,
className,
}) {
const format = clientConfig.dateFormat || 'YYYY-MM-DD';
const additionalAttributes = {};
@@ -21,6 +20,7 @@ function DateRangeInput({
}
return (
<RangePicker
className={className}
{...additionalAttributes}
format={format}
onChange={onSelect}
@@ -29,27 +29,19 @@ function DateRangeInput({
}
DateRangeInput.propTypes = {
value: (props, propName, componentName) => {
const value = props[propName];
if (
(value !== null) && !(
isArray(value) && (value.length === 2) &&
moment.isMoment(value[0]) && moment.isMoment(value[1])
)
) {
return new Error('Prop `' + propName + '` supplied to `' + componentName +
'` should be an array of two Moment.js instances.');
}
},
value: PropTypes.arrayOf(Moment),
onSelect: PropTypes.func,
className: PropTypes.string,
};
DateRangeInput.defaultProps = {
value: null,
onSelect: () => {},
className: '',
};
export default function init(ngModule) {
ngModule.component('dateRangeInput', react2angular(DateRangeInput, null, ['clientConfig']));
ngModule.component('dateRangeInput', react2angular(DateRangeInput));
}
init.init = true;

View File

@@ -1,15 +1,15 @@
import moment from 'moment';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';
function DateTimeInput({
export function DateTimeInput({
value,
withSeconds,
onSelect,
// eslint-disable-next-line react/prop-types
clientConfig,
className,
}) {
const format = (clientConfig.dateFormat || 'YYYY-MM-DD') +
(withSeconds ? ' HH:mm:ss' : ' HH:mm');
@@ -19,6 +19,7 @@ function DateTimeInput({
}
return (
<DatePicker
className={className}
showTime
{...additionalAttributes}
format={format}
@@ -29,24 +30,21 @@ function DateTimeInput({
}
DateTimeInput.propTypes = {
value: (props, propName, componentName) => {
const value = props[propName];
if ((value !== null) && !moment.isMoment(value)) {
return new Error('Prop `' + propName + '` supplied to `' + componentName +
'` should be a Moment.js instance.');
}
},
value: Moment,
withSeconds: PropTypes.bool,
onSelect: PropTypes.func,
className: PropTypes.string,
};
DateTimeInput.defaultProps = {
value: null,
withSeconds: false,
onSelect: () => {},
className: '',
};
export default function init(ngModule) {
ngModule.component('dateTimeInput', react2angular(DateTimeInput, null, ['clientConfig']));
ngModule.component('dateTimeInput', react2angular(DateTimeInput));
}
init.init = true;

View File

@@ -1,19 +1,18 @@
import moment from 'moment';
import { isArray } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { RangePicker } from 'antd/lib/date-picker';
import 'antd/lib/style/core/iconfont.less';
import 'antd/lib/input/style/index.less';
import 'antd/lib/date-picker/style/index.less';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';
function DateTimeRangeInput({
const { RangePicker } = DatePicker;
export function DateTimeRangeInput({
value,
withSeconds,
onSelect,
// eslint-disable-next-line react/prop-types
clientConfig,
className,
}) {
const format = (clientConfig.dateFormat || 'YYYY-MM-DD') +
(withSeconds ? ' HH:mm:ss' : ' HH:mm');
@@ -23,6 +22,7 @@ function DateTimeRangeInput({
}
return (
<RangePicker
className={className}
showTime
{...additionalAttributes}
format={format}
@@ -32,29 +32,21 @@ function DateTimeRangeInput({
}
DateTimeRangeInput.propTypes = {
value: (props, propName, componentName) => {
const value = props[propName];
if (
(value !== null) && !(
isArray(value) && (value.length === 2) &&
moment.isMoment(value[0]) && moment.isMoment(value[1])
)
) {
return new Error('Prop `' + propName + '` supplied to `' + componentName +
'` should be an array of two Moment.js instances.');
}
},
value: PropTypes.arrayOf(Moment),
withSeconds: PropTypes.bool,
onSelect: PropTypes.func,
className: PropTypes.string,
};
DateTimeRangeInput.defaultProps = {
value: null,
withSeconds: false,
onSelect: () => {},
className: '',
};
export default function init(ngModule) {
ngModule.component('dateTimeRangeInput', react2angular(DateTimeRangeInput, null, ['clientConfig']));
ngModule.component('dateTimeRangeInput', react2angular(DateTimeRangeInput));
}
init.init = true;

View File

@@ -0,0 +1,209 @@
import { isFunction } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
/**
Wrapper for dialogs based on Ant's <Modal> component.
Using wrapped dialogs
=====================
Wrapped component is an object with two fields:
{
showModal: (dialogProps) => object({
result: Promise,
close: (result) => void,
dismiss: (reason) => void,
}),
Component: React.Component, // wrapped dialog component
}
To open dialog, use `showModal` method; optionally you can pass additional properties that
will be expanded on wrapped component:
const dialog = SomeWrappedDialog.showModal()
const dialog = SomeWrappedDialog.showModal({ greeting: 'Hello' })
To get result of modal, use `result` property:
dialog.result
.then(...) // pressed OK button or used `close` method; resolved value is a result of dialog
.catch(...) // pressed Cancel button or used `dismiss` method; optional argument is a rejection reason.
Also, dialog has `close` and `dismiss` methods that allows to close dialog by caller. Passed arguments
will be used to resolve/reject `dialog.result` promise. `update` methods allows to pass new properties
to dialog.
Creating a dialog
================
1. Add imports:
import { wrap as wrapDialog, DialogPropType } from 'path/to/DialogWrapper';
2. define a `dialog` property on your component:
propTypes = {
dialog: DialogPropType.isRequired,
};
`dialog` property is an object:
{
props: object, // properties for <Modal> component;
close: (result) => void, // method to confirm dialog; `result` will be returned to caller
dismiss: (reason) => void, // method to reject dialog; `reason` will be returned to caller
}
3. expand additional properties on <Modal> component:
render() {
const { dialog } = this.props;
return (
<Modal {...dialog.props}>
);
}
4. wrap your component and export it:
export default wrapDialog(YourComponent).
Your component is ready to use. Wrapper will manage <Modal>'s visibility and events.
If you want to override behavior of `onOk`/`onCancel` - don't forget to close dialog:
customOkHandler() {
this.saveData().then(() => {
this.props.dialog.close({ success: true }); // or dismiss();
});
}
render() {
const { dialog } = this.props;
return (
<Modal {...dialog.props} onOk={() => this.customOkHandler()}>
);
}
Settings
========
You can setup this wrapper to use custom `Promise` library (for example, Bluebird):
import DialogWrapper from 'path/to/DialogWrapper';
import Promise from 'bluebird';
DialogWrapper.Promise = Promise;
It could be useful to avoid `unhandledrejection` exception that would fire with native Promises,
or when some custom Promise library is used in application.
*/
export const DialogPropType = PropTypes.shape({
props: PropTypes.shape({
visible: PropTypes.bool,
onOk: PropTypes.func,
onCancel: PropTypes.func,
afterClose: PropTypes.func,
}).isRequired,
close: PropTypes.func.isRequired,
dismiss: PropTypes.func.isRequired,
});
// default export of module
const DialogWrapper = {
Promise,
DialogPropType,
wrap() {},
};
function openDialog(DialogComponent, props) {
const dialog = {
props: {
visible: true,
onOk: () => {},
onCancel: () => {},
afterClose: () => {},
},
close: () => {},
dismiss: () => {},
};
const dialogResult = {
resolve: () => {},
reject: () => {},
};
const container = document.createElement('div');
document.body.appendChild(container);
function render() {
ReactDOM.render(<DialogComponent {...props} dialog={dialog} />, container);
}
function destroyDialog() {
// Allow calling chain to roll up, and then destroy component
setTimeout(() => {
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
}, 10);
}
function closeDialog(result) {
dialogResult.resolve(result);
dialog.props.visible = false;
render();
}
function dismissDialog(reason) {
dialogResult.reject(reason);
dialog.props.visible = false;
render();
}
dialog.props.onOk = closeDialog;
dialog.props.onCancel = dismissDialog;
dialog.props.afterClose = destroyDialog;
dialog.close = closeDialog;
dialog.dismiss = dismissDialog;
const result = {
close: closeDialog,
dismiss: dismissDialog,
update: (newProps) => {
props = { ...props, ...newProps };
render();
},
result: new DialogWrapper.Promise((resolve, reject) => {
dialogResult.resolve = resolve;
dialogResult.reject = reject;
}),
};
render(); // show it only when all structures initialized to avoid unnecessary re-rendering
// Some known libraries support
// Bluebird: http://bluebirdjs.com/docs/api/suppressunhandledrejections.html
if (isFunction(result.result.suppressUnhandledRejections)) {
result.result.suppressUnhandledRejections();
}
return result;
}
export function wrap(DialogComponent) {
return {
Component: DialogComponent,
showModal: props => openDialog(DialogComponent, props),
};
}
DialogWrapper.wrap = wrap;
export default DialogWrapper;

View File

@@ -0,0 +1,50 @@
import { isFunction, isString } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
const componentsRegistry = new Map();
const activeInstances = new Set();
export function registerComponent(name, component) {
if (isString(name) && name !== '') {
componentsRegistry.set(name, isFunction(component) ? component : null);
// Refresh active DynamicComponent instances which use this component
activeInstances.forEach((dynamicComponent) => {
if (dynamicComponent.props.name === name) {
dynamicComponent.forceUpdate();
}
});
}
}
export function unregisterComponent(name) {
registerComponent(name, null);
}
export default class DynamicComponent extends React.Component {
static propTypes = {
name: PropTypes.string.isRequired,
children: PropTypes.node,
};
static defaultProps = {
children: null,
};
componentDidMount() {
activeInstances.add(this);
}
componentWillUnmount() {
activeInstances.delete(this);
}
render() {
const { name, children, ...props } = this.props;
const RealComponent = componentsRegistry.get(name);
if (!RealComponent) {
return null;
}
return <RealComponent {...props}>{children}</RealComponent>;
}
}

View File

@@ -0,0 +1,93 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { trim } from 'lodash';
export class EditInPlace extends React.Component {
static propTypes = {
ignoreBlanks: PropTypes.bool,
isEditable: PropTypes.bool,
editor: PropTypes.string.isRequired,
placeholder: PropTypes.string,
value: PropTypes.string,
onDone: PropTypes.func.isRequired,
};
static defaultProps = {
ignoreBlanks: false,
isEditable: true,
placeholder: '',
value: '',
};
constructor(props) {
super(props);
this.state = {
editing: false,
};
this.inputRef = React.createRef();
const self = this;
this.componentDidUpdate = (prevProps, prevState) => {
if (self.state.editing && !prevState.editing) {
self.inputRef.current.focus();
}
};
}
startEditing = () => {
if (this.props.isEditable) {
this.setState({ editing: true });
}
};
stopEditing = () => {
const newValue = trim(this.inputRef.current.value);
const ignorableBlank = this.props.ignoreBlanks && newValue === '';
if (!ignorableBlank && newValue !== this.props.value) {
this.props.onDone(newValue);
}
this.setState({ editing: false });
};
keyDown = (event) => {
if (event.keyCode === 13 && !event.shiftKey) {
event.preventDefault();
this.stopEditing();
} else if (event.keyCode === 27) {
this.setState({ editing: false });
}
};
renderNormal = () => (
<span
role="presentation"
onFocus={this.startEditing}
onClick={this.startEditing}
className={this.props.isEditable ? 'editable' : ''}
>
{this.props.value || this.props.placeholder}
</span>
);
renderEdit = () => React.createElement(this.props.editor, {
ref: this.inputRef,
className: 'rd-form-control',
defaultValue: this.props.value,
onBlur: this.stopEditing,
onKeyDown: this.keyDown,
});
render() {
return (
<span className={'edit-in-place' + (this.state.editing ? ' active' : '')}>
{this.state.editing ? this.renderEdit() : this.renderNormal()}
</span>
);
}
}
export default function init(ngModule) {
ngModule.component('editInPlace', react2angular(EditInPlace));
}
init.init = true;

View File

@@ -0,0 +1,218 @@
import { includes, startsWith, words, capitalize, clone, isNull } from 'lodash';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import Modal from 'antd/lib/modal';
import Form from 'antd/lib/form';
import Checkbox from 'antd/lib/checkbox';
import Button from 'antd/lib/button';
import Select from 'antd/lib/select';
import Input from 'antd/lib/input';
import Divider from 'antd/lib/divider';
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper';
import { QuerySelector } from '@/components/QuerySelector';
import { Query } from '@/services/query';
const { Option } = Select;
const formItemProps = { labelCol: { span: 6 }, wrapperCol: { span: 16 } };
function getDefaultTitle(text) {
return capitalize(words(text).join(' ')); // humanize
}
function isTypeDate(type) {
return startsWith(type, 'date') && !isTypeDateRange(type);
}
function isTypeDateRange(type) {
return /-range/.test(type);
}
function NameInput({ name, type, onChange, existingNames, setValidation }) {
let helpText = '';
let validateStatus = '';
if (!name) {
helpText = 'Choose a keyword for this parameter';
setValidation(false);
} else if (includes(existingNames, name)) {
helpText = 'Parameter with this name already exists';
setValidation(false);
validateStatus = 'error';
} else {
if (isTypeDateRange(type)) {
helpText = (
<React.Fragment>
Appears in query as {' '}
<code style={{ display: 'inline-block', color: 'inherit' }}>
{`{{${name}.start}} {{${name}.end}}`}
</code>
</React.Fragment>
);
}
setValidation(true);
}
return (
<Form.Item
required
label="Keyword"
help={helpText}
validateStatus={validateStatus}
{...formItemProps}
>
<Input onChange={e => onChange(e.target.value)} autoFocus />
</Form.Item>
);
}
NameInput.propTypes = {
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
existingNames: PropTypes.arrayOf(PropTypes.string).isRequired,
setValidation: PropTypes.func.isRequired,
type: PropTypes.string.isRequired,
};
function EditParameterSettingsDialog(props) {
const [param, setParam] = useState(clone(props.parameter));
const [isNameValid, setIsNameValid] = useState(true);
const [initialQuery, setInitialQuery] = useState();
const isNew = !props.parameter.name;
// fetch query by id
useEffect(() => {
const { queryId } = props.parameter;
if (queryId) {
Query.get({ id: queryId }, (query) => {
setInitialQuery(query);
});
}
}, []);
function isFulfilled() {
// name
if (!isNameValid) {
return false;
}
// title
if (param.title === '') {
return false;
}
// query
if (param.type === 'query' && !param.queryId) {
return false;
}
return true;
}
function onConfirm(e) {
// update title to default
if (!param.title) {
// forced to do this cause param won't update in time for save
param.title = getDefaultTitle(param.name);
setParam(param);
}
props.dialog.close(param);
e.preventDefault(); // stops form redirect
}
return (
<Modal
{...props.dialog.props}
title={isNew ? 'Add Parameter' : param.name}
width={600}
footer={[(
<Button key="cancel" onClick={props.dialog.dismiss}>Cancel</Button>
), (
<Button key="submit" htmlType="submit" disabled={!isFulfilled()} type="primary" form="paramForm">
{isNew ? 'Add Parameter' : 'OK'}
</Button>
)]}
>
<Form layout="horizontal" onSubmit={onConfirm} id="paramForm">
{isNew && (
<NameInput
name={param.name}
onChange={name => setParam({ ...param, name })}
setValidation={setIsNameValid}
existingNames={props.existingParams}
type={param.type}
/>
)}
<Form.Item label="Title" {...formItemProps}>
<Input
value={isNull(param.title) ? getDefaultTitle(param.name) : param.title}
onChange={e => setParam({ ...param, title: e.target.value })}
/>
</Form.Item>
<Form.Item label="Type" {...formItemProps}>
<Select value={param.type} onChange={type => setParam({ ...param, type })}>
<Option value="text">Text</Option>
<Option value="number">Number</Option>
<Option value="enum">Dropdown List</Option>
<Option value="query">Query Based Dropdown List</Option>
<Option disabled key="dv1">
<Divider className="select-option-divider" />
</Option>
<Option value="date">Date</Option>
<Option value="datetime-local">Date and Time</Option>
<Option value="datetime-with-seconds">Date and Time (with seconds)</Option>
<Option disabled key="dv2">
<Divider className="select-option-divider" />
</Option>
<Option value="date-range">Date Range</Option>
<Option value="datetime-range">Date and Time Range</Option>
<Option value="datetime-range-with-seconds">Date and Time Range (with seconds)</Option>
</Select>
</Form.Item>
{isTypeDate(param.type) && (
<Form.Item label=" " colon={false} {...formItemProps}>
<Checkbox
defaultChecked={param.useCurrentDateTime}
onChange={e => setParam({ ...param, useCurrentDateTime: e.target.checked })}
>
Default to Today/Now if no other value is set
</Checkbox>
</Form.Item>
)}
{param.type === 'enum' && (
<Form.Item label="Values" help="Dropdown list values (newline delimeted)" {...formItemProps}>
<Input.TextArea
rows={3}
value={param.enumOptions}
onChange={e => setParam({ ...param, enumOptions: e.target.value })}
/>
</Form.Item>
)}
{param.type === 'query' && (
<Form.Item label="Query" help="Select query to load dropdown values from" {...formItemProps}>
<QuerySelector
selectedQuery={initialQuery}
onChange={q => setParam({ ...param, queryId: q && q.id })}
type="select"
/>
</Form.Item>
)}
</Form>
</Modal>
);
}
EditParameterSettingsDialog.propTypes = {
parameter: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
dialog: DialogPropType.isRequired,
existingParams: PropTypes.arrayOf(PropTypes.string),
};
EditParameterSettingsDialog.defaultProps = {
existingParams: [],
};
export default wrapDialog(EditParameterSettingsDialog);

View File

@@ -0,0 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { currentUser, clientConfig } from '@/services/auth';
export function EmailSettingsWarning({ featureName }) {
return (clientConfig.mailSettingsMissing && currentUser.isAdmin) ? (
<p className="alert alert-danger">
{`It looks like your mail server isn't configured. Make sure to configure it for the ${featureName} to work.`}
</p>
) : null;
}
EmailSettingsWarning.propTypes = {
featureName: PropTypes.string.isRequired,
};
export default function init(ngModule) {
ngModule.component('emailSettingsWarning', react2angular(EmailSettingsWarning));
}
init.init = true;

View File

@@ -0,0 +1,79 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { $rootScope } from '@/services/ng';
export class FavoritesControl extends React.Component {
static propTypes = {
item: PropTypes.shape({
is_favorite: PropTypes.bool.isRequired,
}).isRequired,
onChange: PropTypes.func,
// Force component update when `item` changes.
// Remove this when `react2angular` will finally go to hell
forceUpdate: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
};
static defaultProps = {
onChange: () => {},
forceUpdate: '',
};
toggleItem(event, item, callback) {
const action = item.is_favorite ? item.$unfavorite.bind(item) : item.$favorite.bind(item);
const savedIsFavorite = item.is_favorite;
action().then(() => {
item.is_favorite = !savedIsFavorite;
this.forceUpdate();
$rootScope.$broadcast('reloadFavorites');
callback();
});
}
render() {
const { item, onChange } = this.props;
const icon = item.is_favorite ? 'fa fa-star' : 'fa fa-star-o';
const title = item.is_favorite ? 'Remove from favorites' : 'Add to favorites';
return (
<a
href="javascript:void(0)"
title={title}
className="btn-favourite"
onClick={event => this.toggleItem(event, item, onChange)}
>
<i className={icon} aria-hidden="true" />
</a>
);
}
}
export default function init(ngModule) {
ngModule.component('favoritesControlImpl', react2angular(FavoritesControl));
ngModule.component('favoritesControl', {
template: `
<favorites-control-impl
ng-if="$ctrl.item"
item="$ctrl.item"
on-change="$ctrl.onChange"
force-update="$ctrl.forceUpdateTag"
></favorites-control-impl>
`,
bindings: {
item: '=',
},
controller($scope) {
// See comment for FavoritesControl.propTypes.forceUpdate
this.forceUpdateTag = 'force' + Date.now();
$scope.$on('reloadFavorites', () => {
this.forceUpdateTag = 'force' + Date.now();
});
this.onChange = () => {
$scope.$applyAsync();
};
},
});
}
init.init = true;

View File

@@ -0,0 +1,22 @@
import React from 'react';
import { react2angular } from 'react2angular';
export function Footer() {
const separator = ' \u2022 ';
return (
<div id="footer">
<a href="https://redash.io">Redash</a>
{separator}
<a href="https://redash.io/help/">Documentation</a>
{separator}
<a href="https://github.com/getredash/redash">Contribute</a>
</div>
);
}
export default function init(ngModule) {
ngModule.component('footer', react2angular(Footer));
}
init.init = true;

View File

@@ -0,0 +1,150 @@
import { react2angular } from 'react2angular';
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Tooltip from 'antd/lib/tooltip';
import Drawer from 'antd/lib/drawer';
import { BigMessage } from '@/components/BigMessage';
import DynamicComponent from '@/components/DynamicComponent';
import './HelpTrigger.less';
const DOMAIN = 'https://redash.io';
const HELP_PATH = '/help';
const IFRAME_TIMEOUT = 20000;
const TYPES = {
HOME: [
'',
'Help',
],
VALUE_SOURCE_OPTIONS: [
'/user-guide/querying/query-parameters#Value-Source-Options',
'Guide: Value Source Options',
],
SHARE_DASHBOARD: [
'/user-guide/dashboards/sharing-dashboards',
'Guide: Sharing and Embedding Dashboards',
],
};
export class HelpTrigger extends React.Component {
static propTypes = {
type: PropTypes.oneOf(Object.keys(TYPES)).isRequired,
className: PropTypes.string,
}
static defaultProps = {
className: null,
};
iframeRef = null
iframeLoadingTimeout = null
constructor(props) {
super(props);
this.iframeRef = React.createRef();
}
state = {
visible: false,
loading: false,
error: false,
};
componentWillUnmount() {
clearTimeout(this.iframeLoadingTimeout);
}
loadIframe = (url) => {
clearTimeout(this.iframeLoadingTimeout);
this.setState({ loading: true, error: false });
this.iframeRef.current.src = url;
this.iframeLoadingTimeout = setTimeout(() => {
this.setState({ error: url, loading: false });
}, IFRAME_TIMEOUT); // safety
}
onIframeLoaded = () => {
this.setState({ loading: false });
clearTimeout(this.iframeLoadingTimeout);
}
openDrawer = () => {
this.setState({ visible: true });
const [pagePath] = TYPES[this.props.type];
const url = DOMAIN + HELP_PATH + pagePath;
// wait for drawer animation to complete so there's no animation jank
setTimeout(() => this.loadIframe(url), 300);
}
closeDrawer = () => {
this.setState({ visible: false });
}
render() {
const [, tooltip] = TYPES[this.props.type];
const className = cx('help-trigger', this.props.className);
return (
<React.Fragment>
<Tooltip title={tooltip}>
<a href="javascript: void(0)" onClick={this.openDrawer} className={className}>
<i className="fa fa-question-circle" />
</a>
</Tooltip>
<Drawer
placement="right"
onClose={this.closeDrawer}
visible={this.state.visible}
className="help-drawer"
destroyOnClose
width={400}
>
<div className="drawer-wrapper">
{/* iframe */}
{!this.state.error && (
<iframe
ref={this.iframeRef}
title="Redash Help"
src="about:blank"
className={cx({ ready: !this.state.loading })}
onLoad={this.onIframeLoaded}
/>
)}
{/* loading indicator */}
{this.state.loading && (
<BigMessage icon="fa-spinner fa-2x fa-pulse" message="Loading..." className="help-message" />
)}
{/* error message */}
{this.state.error && (
<BigMessage icon="fa-exclamation-circle" className="help-message">
Something went wrong.<br />
{/* eslint-disable-next-line react/jsx-no-target-blank */}
<a href={this.state.error} target="_blank" rel="noopener">Click here</a>{' '}
to open the page in a new window.
</BigMessage>
)}
</div>
{/* extra content */}
<DynamicComponent
name="HelpDrawerExtraContent"
onLeave={this.closeDrawer}
openPageUrl={this.loadIframe}
/>
</Drawer>
</React.Fragment>
);
}
}
export default function init(ngModule) {
ngModule.component('helpTrigger', react2angular(HelpTrigger));
}
init.init = true;

View File

@@ -0,0 +1,34 @@
.help-trigger {
font-size: 15px;
}
.help-drawer {
.ant-drawer-body {
padding: 0;
height: 100%; // to allow iframe full dimensions
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.drawer-wrapper {
flex: 1;
display: flex;
align-items: center;
width: 100%;
justify-content: center;
}
iframe {
width: 0;
visibility: hidden;
}
iframe.ready {
border: 0;
width: 100%;
height: 100%;
visibility: visible;
}
}

View File

@@ -0,0 +1,57 @@
import React from 'react';
import Input from 'antd/lib/input';
import Icon from 'antd/lib/icon';
import Tooltip from 'antd/lib/tooltip';
export default class InputWithCopy extends React.Component {
constructor(props) {
super(props);
this.state = { copied: null };
this.ref = React.createRef();
this.copyFeatureSupported = document.queryCommandSupported('copy');
this.resetCopyState = null;
}
componentWillUnmount() {
if (this.resetCopyState) {
clearTimeout(this.resetCopyState);
}
}
copy = () => {
// select text
this.ref.current.select();
// copy
try {
const success = document.execCommand('copy');
if (!success) {
throw new Error();
}
this.setState({ copied: 'Copied!' });
} catch (err) {
this.setState({
copied: 'Copy failed',
});
}
// reset tooltip
this.resetCopyState = setTimeout(() => this.setState({ copied: null }), 2000);
};
render() {
const copyButton = (
<Tooltip title={this.state.copied || 'Copy'}>
<Icon
type="copy"
style={{ cursor: 'pointer' }}
onClick={this.copy}
/>
</Tooltip>
);
return (
<Input {...this.props} ref={this.ref} addonAfter={this.copyFeatureSupported && copyButton} />
);
}
}

View File

@@ -1,26 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import { BigMessage } from './BigMessage.jsx';
import { BigMessage } from '@/components/BigMessage';
import { TagsControl } from '@/components/tags-control/TagsControl';
function NoTaggedObjectsFound({ objectType, tags }) {
export function NoTaggedObjectsFound({ objectType, tags }) {
return (
<BigMessage icon="fa-tags">
No {objectType} found tagged with
{Array.from(tags).map(tag => (
<span className="label label-tag" key={tag}>
{tag}
</span>
))}.
No {objectType} found tagged with&nbsp;<TagsControl className="inline-tags-control" tags={Array.from(tags)} />.
</BigMessage>
);
}
NoTaggedObjectsFound.propTypes = {
objectType: PropTypes.string.isRequired,
tags: PropTypes.objectOf(Set).isRequired,
tags: PropTypes.oneOfType([
PropTypes.array,
PropTypes.objectOf(Set),
]).isRequired,
};
export default function init(ngModule) {
ngModule.component('noTaggedObjectsFound', react2angular(NoTaggedObjectsFound));
}
init.init = true;

View File

@@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
export function PageHeader({ title }) {
return (
<div className="page-header-wrapper row p-l-15 p-r-15 m-b-10 m-l-0 m-r-0">
<div className="col-sm-9 p-l-0 p-r-0">
<h3>{ title }</h3>
</div>
</div>
);
}
PageHeader.propTypes = {
title: PropTypes.string.isRequired,
};
export default function init(ngModule) {
ngModule.component('pageHeader', react2angular(PageHeader));
}
init.init = true;

View File

@@ -0,0 +1,60 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import Pagination from 'antd/lib/pagination';
export function Paginator({
page,
itemsPerPage,
totalCount,
onChange,
}) {
if (totalCount <= itemsPerPage) {
return null;
}
return (
<div className="paginator-container">
<Pagination
defaultCurrent={page}
defaultPageSize={itemsPerPage}
total={totalCount}
onChange={onChange}
/>
</div>
);
}
Paginator.propTypes = {
page: PropTypes.number.isRequired,
itemsPerPage: PropTypes.number.isRequired,
totalCount: PropTypes.number.isRequired,
onChange: PropTypes.func,
};
Paginator.defaultProps = {
onChange: () => {},
};
export default function init(ngModule) {
ngModule.component('paginatorImpl', react2angular(Paginator));
ngModule.component('paginator', {
template: `
<paginator-impl
page="$ctrl.paginator.page"
items-per-page="$ctrl.paginator.itemsPerPage"
total-count="$ctrl.paginator.totalCount"
on-change="$ctrl.onPageChanged"
></paginator-impl>`,
bindings: {
paginator: '<',
},
controller($scope) {
this.onPageChanged = (page) => {
this.paginator.setPage(page);
$scope.$applyAsync();
};
},
});
}
init.init = true;

View File

@@ -0,0 +1,642 @@
/* eslint-disable react/no-multi-comp */
import { isString, extend, each, map, includes, findIndex, find, fromPairs, clone, isEmpty } from 'lodash';
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Select from 'antd/lib/select';
import Table from 'antd/lib/table';
import Popover from 'antd/lib/popover';
import Button from 'antd/lib/button';
import Icon from 'antd/lib/icon';
import Tag from 'antd/lib/tag';
import Input from 'antd/lib/input';
import Radio from 'antd/lib/radio';
import Form from 'antd/lib/form';
import Tooltip from 'antd/lib/tooltip';
import { ParameterValueInput } from '@/components/ParameterValueInput';
import { ParameterMappingType } from '@/services/widget';
import { clientConfig } from '@/services/auth';
import { Query, Parameter } from '@/services/query';
import { HelpTrigger } from '@/components/HelpTrigger';
import './ParameterMappingInput.less';
const { Option } = Select;
export const MappingType = {
DashboardAddNew: 'dashboard-add-new',
DashboardMapToExisting: 'dashboard-map-to-existing',
WidgetLevel: 'widget-level',
StaticValue: 'static-value',
};
export function parameterMappingsToEditableMappings(mappings, parameters, existingParameterNames = []) {
return map(mappings, (mapping) => {
const result = extend({}, mapping);
const alreadyExists = includes(existingParameterNames, mapping.mapTo);
result.param = find(parameters, p => p.name === mapping.name);
switch (mapping.type) {
case ParameterMappingType.DashboardLevel:
result.type = alreadyExists ? MappingType.DashboardMapToExisting : MappingType.DashboardAddNew;
result.value = null;
break;
case ParameterMappingType.StaticValue:
result.type = MappingType.StaticValue;
result.param = result.param.clone();
result.param.setValue(result.value);
break;
case ParameterMappingType.WidgetLevel:
result.type = MappingType.WidgetLevel;
result.value = null;
break;
// no default
}
return result;
});
}
export function editableMappingsToParameterMappings(mappings) {
return fromPairs(map( // convert to map
mappings,
(mapping) => {
const result = extend({}, mapping);
switch (mapping.type) {
case MappingType.DashboardAddNew:
result.type = ParameterMappingType.DashboardLevel;
result.value = null;
break;
case MappingType.DashboardMapToExisting:
result.type = ParameterMappingType.DashboardLevel;
result.value = null;
break;
case MappingType.StaticValue:
result.type = ParameterMappingType.StaticValue;
result.param = mapping.param.clone();
result.param.setValue(result.value);
result.value = result.param.value;
break;
case MappingType.WidgetLevel:
result.type = ParameterMappingType.WidgetLevel;
result.value = null;
break;
// no default
}
delete result.param;
return [result.name, result];
},
));
}
export function synchronizeWidgetTitles(sourceMappings, widgets) {
const affectedWidgets = [];
each(sourceMappings, (sourceMapping) => {
if (sourceMapping.type === ParameterMappingType.DashboardLevel) {
each(widgets, (widget) => {
const widgetMappings = widget.options.parameterMappings;
each(widgetMappings, (widgetMapping) => {
// check if mapped to the same dashboard-level parameter
if (
(widgetMapping.type === ParameterMappingType.DashboardLevel) &&
(widgetMapping.mapTo === sourceMapping.mapTo)
) {
// dirty check - update only when needed
if (widgetMapping.title !== sourceMapping.title) {
widgetMapping.title = sourceMapping.title;
affectedWidgets.push(widget);
}
}
});
});
}
});
return affectedWidgets;
}
export class ParameterMappingInput extends React.Component {
static propTypes = {
mapping: PropTypes.object, // eslint-disable-line react/forbid-prop-types
existingParamNames: PropTypes.arrayOf(PropTypes.string),
onChange: PropTypes.func,
clientConfig: PropTypes.any, // eslint-disable-line react/forbid-prop-types
Query: PropTypes.any, // eslint-disable-line react/forbid-prop-types
inputError: PropTypes.string,
};
static defaultProps = {
mapping: {},
existingParamNames: [],
onChange: () => {},
clientConfig: null,
Query: null,
inputError: null,
};
formItemProps = {
labelCol: { span: 5 },
wrapperCol: { span: 16 },
className: 'form-item',
};
updateSourceType = (type) => {
let { mapping: { mapTo } } = this.props;
const { existingParamNames } = this.props;
// if mapped name doesn't already exists
// default to first select option
if (
type === MappingType.DashboardMapToExisting &&
!includes(existingParamNames, mapTo)
) {
mapTo = existingParamNames[0];
}
this.updateParamMapping({ type, mapTo });
};
updateParamMapping = (update) => {
const { onChange, mapping } = this.props;
const newMapping = extend({}, mapping, update);
onChange(newMapping);
};
renderMappingTypeSelector() {
const noExisting = isEmpty(this.props.existingParamNames);
return (
<Radio.Group
value={this.props.mapping.type}
onChange={e => this.updateSourceType(e.target.value)}
>
<Radio className="radio" value={MappingType.DashboardAddNew}>
New dashboard parameter
</Radio>
<Radio
className="radio"
value={MappingType.DashboardMapToExisting}
disabled={noExisting}
>
Existing dashboard parameter{' '}
{noExisting ? (
<Tooltip title="There are no dashboard parameters corresponding to this data type">
<Icon type="question-circle" theme="filled" />
</Tooltip>
) : null }
</Radio>
<Radio className="radio" value={MappingType.WidgetLevel}>
Widget parameter
</Radio>
<Radio className="radio" value={MappingType.StaticValue}>
Static value
</Radio>
</Radio.Group>
);
}
renderDashboardAddNew() {
const { mapping: { mapTo } } = this.props;
return (
<Input
value={mapTo}
onChange={e => this.updateParamMapping({ mapTo: e.target.value })}
/>
);
}
renderDashboardMapToExisting() {
const { mapping, existingParamNames } = this.props;
return (
<Select
value={mapping.mapTo}
onChange={mapTo => this.updateParamMapping({ mapTo })}
dropdownMatchSelectWidth={false}
>
{map(existingParamNames, name => (
<Option value={name} key={name}>{ name }</Option>
))}
</Select>
);
}
renderStaticValue() {
const { mapping } = this.props;
return (
<ParameterValueInput
type={mapping.param.type}
value={mapping.param.normalizedValue}
enumOptions={mapping.param.enumOptions}
queryId={mapping.param.queryId}
onSelect={value => this.updateParamMapping({ value })}
clientConfig={this.props.clientConfig}
Query={this.props.Query}
/>
);
}
renderInputBlock() {
const { mapping } = this.props;
switch (mapping.type) {
case MappingType.DashboardAddNew:
return [
'Key',
'Enter a new parameter keyword',
this.renderDashboardAddNew(),
];
case MappingType.DashboardMapToExisting:
return [
'Key',
'Select from a list of existing parameters',
this.renderDashboardMapToExisting(),
];
case MappingType.StaticValue:
return [
'Value',
null,
this.renderStaticValue(),
];
default: return [];
}
}
render() {
const { inputError } = this.props;
const [label, help, input] = this.renderInputBlock();
return (
<Form layout="horizontal">
<Form.Item label="Source" {...this.formItemProps}>
{this.renderMappingTypeSelector()}
</Form.Item>
<Form.Item
style={{ height: 60, visibility: input ? 'visible' : 'hidden' }}
label={label}
{...this.formItemProps}
validateStatus={inputError ? 'error' : ''}
help={inputError || help} // empty space so line doesn't collapse
>
{input}
</Form.Item>
</Form>
);
}
}
class MappingEditor extends React.Component {
static propTypes = {
mapping: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
existingParamNames: PropTypes.arrayOf(PropTypes.string).isRequired,
onChange: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = {
visible: false,
mapping: clone(this.props.mapping),
inputError: null,
};
}
onVisibleChange = (visible) => {
if (visible) this.show(); else this.hide();
};
onChange = (mapping) => {
let inputError = null;
if (mapping.type === MappingType.DashboardAddNew) {
if (isEmpty(mapping.mapTo)) {
inputError = 'Keyword must have a value';
} else if (includes(this.props.existingParamNames, mapping.mapTo)) {
inputError = 'A parameter with this name already exists';
}
}
this.setState({ mapping, inputError });
};
save = () => {
this.props.onChange(this.props.mapping, this.state.mapping);
this.hide();
};
show = () => {
this.setState({
visible: true,
mapping: clone(this.props.mapping), // restore original state
});
};
hide = () => {
this.setState({ visible: false });
};
renderContent() {
const { mapping, inputError } = this.state;
return (
<div className="parameter-mapping-editor">
<header>
Edit Source and Value <HelpTrigger type="VALUE_SOURCE_OPTIONS" />
</header>
<ParameterMappingInput
mapping={mapping}
existingParamNames={this.props.existingParamNames}
onChange={this.onChange}
clientConfig={clientConfig}
Query={Query}
inputError={inputError}
/>
<footer>
<Button onClick={this.hide}>Cancel</Button>
<Button onClick={this.save} disabled={!!inputError} type="primary">OK</Button>
</footer>
</div>
);
}
render() {
return (
<Popover
placement="left"
trigger="click"
content={this.renderContent()}
visible={this.state.visible}
onVisibleChange={this.onVisibleChange}
>
<Button size="small" type="dashed">
<Icon type="edit" />
</Button>
</Popover>
);
}
}
class TitleEditor extends React.Component {
static propTypes = {
existingParams: PropTypes.arrayOf(PropTypes.object),
mapping: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
onChange: PropTypes.func.isRequired,
};
static defaultProps = {
existingParams: [],
};
state = {
showPopup: false,
title: '', // will be set on editing
};
onPopupVisibleChange = (showPopup) => {
this.setState({
showPopup,
title: showPopup ? this.getMappingTitle() : '',
});
};
onEditingTitleChange = (event) => {
this.setState({ title: event.target.value });
};
getMappingTitle() {
let { mapping } = this.props;
if (isString(mapping.title) && (mapping.title !== '')) {
return mapping.title;
}
// if mapped to dashboard, find source param and return it's title
if (mapping.type === MappingType.DashboardMapToExisting) {
const source = find(this.props.existingParams, { name: mapping.mapTo });
if (source) {
mapping = source;
}
}
return mapping.title || mapping.param.title;
}
save = () => {
const newMapping = extend({}, this.props.mapping, { title: this.state.title });
this.props.onChange(newMapping);
this.hide();
};
hide = () => {
this.setState({ showPopup: false });
};
renderPopover() {
const { param: { title: paramTitle } } = this.props.mapping;
return (
<div className="parameter-mapping-title-editor">
<Input
size="small"
value={this.state.title}
placeholder={paramTitle}
onChange={this.onEditingTitleChange}
onPressEnter={this.save}
maxLength={100}
autoFocus
/>
<Button size="small" type="dashed" onClick={this.hide}>
<Icon type="close" />
</Button>
<Button size="small" type="dashed" onClick={this.save}>
<Icon type="check" />
</Button>
</div>
);
}
renderEditButton() {
const { mapping } = this.props;
if (mapping.type === MappingType.StaticValue) {
return (
<Tooltip placement="right" title="Titles for static values don't appear in widgets">
<i className="fa fa-eye-slash" />
</Tooltip>
);
}
return (
<Popover
placement="right"
trigger="click"
content={this.renderPopover()}
visible={this.state.showPopup}
onVisibleChange={this.onPopupVisibleChange}
>
<Button size="small" type="dashed">
<Icon type="edit" />
</Button>
</Popover>
);
}
render() {
const { mapping } = this.props;
// static value are non-editable hence disabled
const disabled = mapping.type === MappingType.StaticValue;
return (
<div className={classNames('parameter-mapping-title', { disabled })}>
<span className="text">{this.getMappingTitle()}</span>
{this.renderEditButton()}
</div>
);
}
}
export class ParameterMappingListInput extends React.Component {
static propTypes = {
mappings: PropTypes.arrayOf(PropTypes.object),
existingParams: PropTypes.arrayOf(PropTypes.object),
onChange: PropTypes.func,
};
static defaultProps = {
mappings: [],
existingParams: [],
onChange: () => {},
};
static getStringValue(value) {
// null
if (!value) {
return '';
}
// range
if (value instanceof Object && 'start' in value && 'end' in value) {
return `${value.start} ~ ${value.end}`;
}
// just to be safe, array or object
if (typeof value === 'object') {
return map(value, v => this.getStringValue(v)).join(', ');
}
// rest
return value.toString();
}
static getDefaultValue(mapping, existingParams) {
const { type, mapTo, name } = mapping;
let { param } = mapping;
// if mapped to another param, swap 'em
if (type === MappingType.DashboardMapToExisting && mapTo !== name) {
const mappedTo = find(existingParams, { name: mapTo });
if (mappedTo) { // just being safe
param = mappedTo;
}
// static type is different since it's fed param.normalizedValue
} else if (type === MappingType.StaticValue) {
param = param.clone().setValue(mapping.value);
}
const value = Parameter.getValue(param);
return this.getStringValue(value);
}
static getSourceTypeLabel({ type, mapTo }) {
switch (type) {
case MappingType.DashboardAddNew:
case MappingType.DashboardMapToExisting:
return (
<Fragment>
Dashboard{' '}
<Tag className="tag">{mapTo}</Tag>
</Fragment>
);
case MappingType.WidgetLevel:
return 'Widget parameter';
case MappingType.StaticValue:
return 'Static value';
default:
return ''; // won't happen (typescript-ftw)
}
}
updateParamMapping(oldMapping, newMapping) {
const mappings = [...this.props.mappings];
const index = findIndex(mappings, oldMapping);
if (index >= 0) {
// This should be the only possible case, but need to handle `else` too
mappings[index] = newMapping;
} else {
mappings.push(newMapping);
}
this.props.onChange(mappings);
}
render() {
const { existingParams } = this.props; // eslint-disable-line react/prop-types
const dataSource = this.props.mappings.map(mapping => ({ mapping }));
return (
<div className="parameters-mapping-list">
<Table
dataSource={dataSource}
size="middle"
pagination={false}
rowKey={(record, idx) => `row${idx}`}
>
<Table.Column
title="Title"
dataIndex="mapping"
key="title"
render={mapping => (
<TitleEditor
existingParams={existingParams}
mapping={mapping}
onChange={newMapping => this.updateParamMapping(mapping, newMapping)}
/>
)}
/>
<Table.Column
title="Keyword"
dataIndex="mapping"
key="keyword"
className="keyword"
render={mapping => <code>{`{{ ${mapping.name} }}`}</code>}
/>
<Table.Column
title="Default Value"
dataIndex="mapping"
key="value"
render={mapping => (
this.constructor.getDefaultValue(mapping, this.props.existingParams)
)}
/>
<Table.Column
title="Value Source"
dataIndex="mapping"
key="source"
render={(mapping) => {
const existingParamsNames = existingParams
.filter(({ type }) => type === mapping.param.type) // exclude mismatching param types
.map(({ name }) => name); // keep names only
return (
<Fragment>
{this.constructor.getSourceTypeLabel(mapping)}{' '}
<MappingEditor
mapping={mapping}
existingParamNames={existingParamsNames}
onChange={(oldMapping, newMapping) => this.updateParamMapping(oldMapping, newMapping)}
/>
</Fragment>
);
}}
/>
</Table>
</div>
);
}
}

View File

@@ -0,0 +1,83 @@
@import '~antd/lib/modal/style/index'; // for ant @vars
.parameters-mapping-list {
.keyword {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
code {
white-space: nowrap; // so the curly braces don't line break
}
}
// Ant <Tag> overrides
.tag {
margin: 0;
pointer-events: none; // unclickable
&:empty {
display: none;
}
}
}
.parameter-mapping-editor {
width: 390px;
.radio {
display: block;
height: 30px;
line-height: 30px;
}
.form-item {
margin-bottom: 10px;
}
header {
padding: 0 16px 10px;
margin: 0 -16px 20px;
border-bottom: @border-width-base @border-style-base @border-color-split;
font-size: @font-size-lg;
font-weight: 500;
color: @heading-color;
display: flex;
justify-content: space-between;
}
footer {
border-top: @border-width-base @border-style-base @border-color-split;
padding: 10px 16px 0;
margin: 0 -16px;
text-align: right;
button {
margin-left: 8px;
}
}
}
.parameter-mapping-title {
.text {
margin-right: 3px;
}
&.disabled, .fa {
color: #a4a4a4;
}
.fa-eye-slash {
margin-left: 1px;
}
}
.parameter-mapping-title-editor {
input {
width: 100px;
}
button {
margin-left: 2px;
}
}

View File

@@ -0,0 +1,194 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import Select from 'antd/lib/select';
import Input from 'antd/lib/input';
import InputNumber from 'antd/lib/input-number';
import { DateInput } from './DateInput';
import { DateRangeInput } from './DateRangeInput';
import { DateTimeInput } from './DateTimeInput';
import { DateTimeRangeInput } from './DateTimeRangeInput';
import { QueryBasedParameterInput } from './QueryBasedParameterInput';
const { Option } = Select;
export class ParameterValueInput extends React.Component {
static propTypes = {
type: PropTypes.string,
value: PropTypes.any, // eslint-disable-line react/forbid-prop-types
enumOptions: PropTypes.string,
queryId: PropTypes.number,
onSelect: PropTypes.func,
className: PropTypes.string,
};
static defaultProps = {
type: 'text',
value: null,
enumOptions: '',
queryId: null,
onSelect: () => {},
className: '',
};
renderDateTimeWithSecondsInput() {
const { value, onSelect } = this.props;
return (
<DateTimeInput
className={this.props.className}
value={value}
onSelect={onSelect}
withSeconds
/>
);
}
renderDateTimeInput() {
const { value, onSelect } = this.props;
return (
<DateTimeInput
className={this.props.className}
value={value}
onSelect={onSelect}
/>
);
}
renderDateInput() {
const { value, onSelect } = this.props;
return (
<DateInput
className={this.props.className}
value={value}
onSelect={onSelect}
/>
);
}
renderDateTimeRangeWithSecondsInput() {
const { value, onSelect } = this.props;
return (
<DateTimeRangeInput
className={this.props.className}
value={value}
onSelect={onSelect}
withSeconds
/>
);
}
renderDateTimeRangeInput() {
const { value, onSelect } = this.props;
return (
<DateTimeRangeInput
className={this.props.className}
value={value}
onSelect={onSelect}
/>
);
}
renderDateRangeInput() {
const { value, onSelect } = this.props;
return (
<DateRangeInput
className={this.props.className}
value={value}
onSelect={onSelect}
/>
);
}
renderEnumInput() {
const { value, onSelect, enumOptions } = this.props;
const enumOptionsArray = enumOptions.split('\n').filter(v => v !== '');
return (
<Select
className={this.props.className}
disabled={enumOptionsArray.length === 0}
defaultValue={value}
onChange={onSelect}
dropdownMatchSelectWidth={false}
dropdownClassName="ant-dropdown-in-bootstrap-modal"
>
{enumOptionsArray.map(option => (<Option key={option} value={option}>{ option }</Option>))}
</Select>
);
}
renderQueryBasedInput() {
const { value, onSelect, queryId } = this.props;
return (
<QueryBasedParameterInput
className={this.props.className}
value={value}
queryId={queryId}
onSelect={onSelect}
/>
);
}
renderNumberInput() {
const { value, onSelect, className } = this.props;
return (
<InputNumber
className={'form-control ' + className}
defaultValue={!isNaN(value) && value || 0}
onChange={onSelect}
/>
);
}
renderTextInput() {
const { value, onSelect, className } = this.props;
return (
<Input
className={'form-control ' + className}
defaultValue={value || ''}
onChange={event => onSelect(event.target.value)}
/>
);
}
render() {
const { type } = this.props;
switch (type) {
case 'datetime-with-seconds': return this.renderDateTimeWithSecondsInput();
case 'datetime-local': return this.renderDateTimeInput();
case 'date': return this.renderDateInput();
case 'datetime-range-with-seconds': return this.renderDateTimeRangeWithSecondsInput();
case 'datetime-range': return this.renderDateTimeRangeInput();
case 'date-range': return this.renderDateRangeInput();
case 'enum': return this.renderEnumInput();
case 'query': return this.renderQueryBasedInput();
case 'number': return this.renderNumberInput();
default: return this.renderTextInput();
}
}
}
export default function init(ngModule) {
ngModule.component('parameterValueInput', {
template: `
<parameter-value-input-impl
type="$ctrl.param.type"
value="$ctrl.param.normalizedValue"
enum-options="$ctrl.param.enumOptions"
query-id="$ctrl.param.queryId"
on-select="$ctrl.setValue"
></parameter-value-input-impl>
`,
bindings: {
param: '<',
},
controller($scope) {
this.setValue = (value) => {
this.param.setValue(value);
$scope.$applyAsync();
};
},
});
ngModule.component('parameterValueInputImpl', react2angular(ParameterValueInput));
}
init.init = true;

View File

@@ -0,0 +1,79 @@
import React from 'react';
import PropTypes from 'prop-types';
// PreviewCard
export function PreviewCard({ imageUrl, title, body, children, className, ...props }) {
return (
<div {...props} className={className + ' w-100 d-flex align-items-center'}>
<img src={imageUrl} width="32" height="32" className="profile__image--settings m-r-5" alt="Logo/Avatar" />
<div className="flex-fill">
<div>{title}</div>
{body && <div className="text-muted">{body}</div>}
</div>
{children}
</div>
);
}
PreviewCard.propTypes = {
imageUrl: PropTypes.string.isRequired,
title: PropTypes.node.isRequired,
body: PropTypes.node,
className: PropTypes.string,
children: PropTypes.node,
};
PreviewCard.defaultProps = {
body: null,
className: '',
children: null,
};
// UserPreviewCard
export function UserPreviewCard({ user, withLink, children, ...props }) {
const title = withLink ? <a href={'users/' + user.id}>{user.name}</a> : user.name;
return (
<PreviewCard {...props} imageUrl={user.profile_image_url} title={title} body={user.email}>
{children}
</PreviewCard>
);
}
UserPreviewCard.propTypes = {
user: PropTypes.shape({
profile_image_url: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
}).isRequired,
withLink: PropTypes.bool,
children: PropTypes.node,
};
UserPreviewCard.defaultProps = {
withLink: false,
children: null,
};
// DataSourcePreviewCard
export function DataSourcePreviewCard({ dataSource, withLink, children, ...props }) {
const imageUrl = `/static/images/db-logos/${dataSource.type}.png`;
const title = withLink ? <a href={'data_sources/' + dataSource.id}>{dataSource.name}</a> : dataSource.name;
return <PreviewCard {...props} imageUrl={imageUrl} title={title}>{children}</PreviewCard>;
}
DataSourcePreviewCard.propTypes = {
dataSource: PropTypes.shape({
name: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
}).isRequired,
withLink: PropTypes.bool,
children: PropTypes.node,
};
DataSourcePreviewCard.defaultProps = {
withLink: false,
children: null,
};

View File

@@ -0,0 +1,85 @@
import { find, isFunction } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import Select from 'antd/lib/select';
import { Query } from '@/services/query';
const { Option } = Select;
export class QueryBasedParameterInput extends React.Component {
static propTypes = {
value: PropTypes.any, // eslint-disable-line react/forbid-prop-types
queryId: PropTypes.number,
onSelect: PropTypes.func,
className: PropTypes.string,
};
static defaultProps = {
value: null,
queryId: null,
onSelect: () => {},
className: '',
};
constructor(props) {
super(props);
this.state = {
options: [],
loading: false,
};
}
componentDidMount() {
this._loadOptions(this.props.queryId);
}
// eslint-disable-next-line no-unused-vars
componentWillReceiveProps(nextProps) {
if (nextProps.queryId !== this.props.queryId) {
this._loadOptions(nextProps.queryId, nextProps.value);
}
}
_loadOptions(queryId) {
if (queryId && (queryId !== this.state.queryId)) {
this.setState({ loading: true });
Query.dropdownOptions({ id: queryId }, (options) => {
if (this.props.queryId === queryId) {
this.setState({ options, loading: false });
const found = find(options, option => option.value === this.props.value) !== undefined;
if (!found && isFunction(this.props.onSelect)) {
this.props.onSelect(options[0].value);
}
}
});
}
}
render() {
const { className, value, onSelect } = this.props;
const { loading, options } = this.state;
return (
<span>
<Select
className={className}
disabled={loading || (options.length === 0)}
loading={loading}
defaultValue={'' + value}
onChange={onSelect}
dropdownMatchSelectWidth={false}
dropdownClassName="ant-dropdown-in-bootstrap-modal"
>
{options.map(option => (<Option value={option.value} key={option.value}>{option.name}</Option>))}
</Select>
</span>
);
}
}
export default function init(ngModule) {
ngModule.component('queryBasedParameterInput', react2angular(QueryBasedParameterInput));
}
init.init = true;

View File

@@ -0,0 +1,3 @@
.editor__container[data-executing="true"] .ace_marker-layer .ace_selection {
background-color: rgb(255, 210, 181);
}

View File

@@ -0,0 +1,330 @@
import React from 'react';
import PropTypes from 'prop-types';
import Tooltip from 'antd/lib/tooltip';
import { react2angular } from 'react2angular';
import AceEditor from 'react-ace';
import ace from 'brace';
import toastr from 'angular-toastr';
import 'brace/ext/language_tools';
import 'brace/mode/json';
import 'brace/mode/python';
import 'brace/mode/sql';
import 'brace/mode/yaml';
import 'brace/theme/textmate';
import 'brace/ext/searchbox';
import { Query } from '@/services/query';
import { QuerySnippet } from '@/services/query-snippet';
import { KeyboardShortcuts } from '@/services/keyboard-shortcuts';
import localOptions from '@/lib/localOptions';
import AutocompleteToggle from '@/components/AutocompleteToggle';
import keywordBuilder from './keywordBuilder';
import { DataSource, Schema } from './proptypes';
import './QueryEditor.css';
const langTools = ace.acequire('ace/ext/language_tools');
const snippetsModule = ace.acequire('ace/snippets');
// By default Ace will try to load snippet files for the different modes and fail.
// We don't need them, so we use these placeholders until we define our own.
function defineDummySnippets(mode) {
ace.define(`ace/snippets/${mode}`, ['require', 'exports', 'module'], (require, exports) => {
exports.snippetText = '';
exports.scope = mode;
});
}
defineDummySnippets('python');
defineDummySnippets('sql');
defineDummySnippets('json');
defineDummySnippets('yaml');
class QueryEditor extends React.Component {
static propTypes = {
queryText: PropTypes.string.isRequired,
schema: Schema, // eslint-disable-line react/no-unused-prop-types
addNewParameter: PropTypes.func.isRequired,
dataSources: PropTypes.arrayOf(DataSource),
dataSource: DataSource,
canEdit: PropTypes.bool.isRequired,
isDirty: PropTypes.bool.isRequired,
isQueryOwner: PropTypes.bool.isRequired,
updateDataSource: PropTypes.func.isRequired,
canExecuteQuery: PropTypes.func.isRequired,
executeQuery: PropTypes.func.isRequired,
queryExecuting: PropTypes.bool.isRequired,
saveQuery: PropTypes.func.isRequired,
updateQuery: PropTypes.func.isRequired,
updateSelectedQuery: PropTypes.func.isRequired,
listenForResize: PropTypes.func.isRequired,
listenForEditorCommand: PropTypes.func.isRequired,
};
static defaultProps = {
schema: null,
dataSource: {},
dataSources: [],
};
constructor(props) {
super(props);
this.refEditor = React.createRef();
this.state = {
schema: null, // eslint-disable-line react/no-unused-state
keywords: {
table: [],
column: [],
tableColumn: [],
},
autocompleteQuery: localOptions.get('liveAutocomplete', true),
liveAutocompleteDisabled: false,
// XXX temporary while interfacing with angular
queryText: props.queryText,
selectedQueryText: null,
};
const schemaCompleter = {
identifierRegexps: [/[a-zA-Z_0-9.\-\u00A2-\uFFFF]/],
getCompletions: (state, session, pos, prefix, callback) => {
const tableKeywords = this.state.keywords.table;
const columnKeywords = this.state.keywords.column;
const tableColumnKeywords = this.state.keywords.tableColumn;
if (prefix.length === 0 || tableKeywords.length === 0) {
callback(null, []);
return;
}
if (prefix[prefix.length - 1] === '.') {
const tableName = prefix.substring(0, prefix.length - 1);
callback(null, tableKeywords.concat(tableColumnKeywords[tableName]));
return;
}
callback(null, tableKeywords.concat(columnKeywords));
},
};
langTools.setCompleters([
langTools.snippetCompleter,
langTools.keyWordCompleter,
langTools.textCompleter,
schemaCompleter,
]);
}
static getDerivedStateFromProps(nextProps, prevState) {
if (!nextProps.schema) {
return {
keywords: {
table: [],
column: [],
tableColumn: [],
},
liveAutocompleteDisabled: false,
};
} else if (nextProps.schema !== prevState.schema) {
const tokensCount = nextProps.schema.reduce((totalLength, table) => totalLength + table.columns.length, 0);
return {
schema: nextProps.schema,
keywords: keywordBuilder.buildKeywordsFromSchema(nextProps.schema),
liveAutocompleteDisabled: tokensCount > 5000,
};
}
return null;
}
onLoad = (editor) => {
// Release Cmd/Ctrl+L to the browser
editor.commands.bindKey('Cmd+L', null);
editor.commands.bindKey('Ctrl+P', null);
editor.commands.bindKey('Ctrl+L', null);
// Ignore Ctrl+P to open new parameter dialog
editor.commands.bindKey({ win: 'Ctrl+P', mac: null }, null);
// Lineup only mac
editor.commands.bindKey({ win: null, mac: 'Ctrl+P' }, 'golineup');
// Reset Completer in case dot is pressed
editor.commands.on('afterExec', (e) => {
if (e.command.name === 'insertstring' && e.args === '.'
&& editor.completer) {
editor.completer.showPopup(editor);
}
});
QuerySnippet.query((snippets) => {
const snippetManager = snippetsModule.snippetManager;
const m = {
snippetText: '',
};
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
snippets.forEach((snippet) => {
m.snippets.push(snippet.getSnippet());
});
snippetManager.register(m.snippets || [], m.scope);
});
editor.focus();
this.props.listenForResize(() => editor.resize());
this.props.listenForEditorCommand((e, command, ...args) => {
switch (command) {
case 'focus': {
editor.focus();
break;
}
case 'paste': {
const [text] = args;
editor.session.doc.replace(editor.selection.getRange(), text);
const range = editor.selection.getRange();
this.props.updateQuery(editor.session.getValue());
editor.selection.setRange(range);
break;
}
default:
break;
}
});
};
updateSelectedQuery = (selection) => {
const { editor } = this.refEditor.current;
const doc = editor.getSession().doc;
const rawSelectedQueryText = doc.getTextRange(selection.getRange());
const selectedQueryText = (rawSelectedQueryText.length > 1) ? rawSelectedQueryText : null;
this.setState({ selectedQueryText });
this.props.updateSelectedQuery(selectedQueryText);
};
updateQuery = (queryText) => {
this.props.updateQuery(queryText);
this.setState({ queryText });
};
formatQuery = () => {
Query.format(this.props.dataSource.syntax || 'sql', this.props.queryText)
.then(this.updateQuery)
.catch(error => toastr.error(error));
};
toggleAutocomplete = (state) => {
this.setState({ autocompleteQuery: state });
localOptions.set('liveAutocomplete', state);
};
componentDidUpdate = () => {
// ANGULAR_REMOVE_ME Work-around for a resizing issue, see https://github.com/getredash/redash/issues/3353
const { editor } = this.refEditor.current;
editor.resize();
};
render() {
const modKey = KeyboardShortcuts.modKey;
const isExecuteDisabled = this.props.queryExecuting || !this.props.canExecuteQuery();
return (
<section style={{ height: '100%' }} data-test="QueryEditor">
<div className="container p-15 m-b-10" style={{ height: '100%' }}>
<div data-executing={this.props.queryExecuting} style={{ height: 'calc(100% - 40px)', marginBottom: '0px' }} className="editor__container">
<AceEditor
ref={this.refEditor}
theme="textmate"
mode={this.props.dataSource.syntax || 'sql'}
value={this.state.queryText}
editorProps={{ $blockScrolling: Infinity }}
width="100%"
height="100%"
setOptions={{
behavioursEnabled: true,
enableSnippets: true,
enableBasicAutocompletion: true,
enableLiveAutocompletion: !this.state.liveAutocompleteDisabled && this.state.autocompleteQuery,
autoScrollEditorIntoView: true,
}}
showPrintMargin={false}
wrapEnabled={false}
onLoad={this.onLoad}
onPaste={this.onPaste}
onChange={this.updateQuery}
onSelectionChange={this.updateSelectedQuery}
/>
</div>
<div className="editor__control">
<div className="form-inline d-flex">
<Tooltip
placement="top"
title={<span>Add New Parameter (<i>{modKey} + P</i>)</span>}
>
<button type="button" className="btn btn-default m-r-5" onClick={this.props.addNewParameter}>
&#123;&#123;&nbsp;&#125;&#125;
</button>
</Tooltip>
<Tooltip placement="top" title="Format Query">
<button type="button" className="btn btn-default m-r-5" onClick={this.formatQuery}>
<span className="zmdi zmdi-format-indent-increase" />
</button>
</Tooltip>
<AutocompleteToggle
state={this.state.autocompleteQuery}
onToggle={this.toggleAutocomplete}
disabled={this.state.liveAutocompleteDisabled}
/>
<select
className="form-control datasource-small flex-fill w-100"
onChange={this.props.updateDataSource}
disabled={!this.props.isQueryOwner}
>
{this.props.dataSources.map(ds => (
<option label={ds.name} value={ds.id} key={`ds-option-${ds.id}`}>
{ds.name}
</option>
))}
</select>
{this.props.canEdit ? (
<Tooltip placement="top" title={modKey + ' + S'}>
<button type="button" className="btn btn-default m-l-5" onClick={this.props.saveQuery} title="Save">
<span className="fa fa-floppy-o" />
<span className="hidden-xs m-l-5">Save</span>
{this.props.isDirty ? '*' : null}
</button>
</Tooltip>
) : null}
<Tooltip placement="top" title={modKey + ' + Enter'}>
{/*
Tooltip wraps disabled buttons with `<span>` and moves all styles
and classes to that `<span>`. There is a piece of CSS that fixes
button appearance, but also wwe need to add `disabled` class to
disabled buttons so it will be assigned to wrapper and make it
looking properly
*/}
<button
type="button"
className={'btn btn-primary m-l-5' + (isExecuteDisabled ? ' disabled' : '')}
disabled={isExecuteDisabled}
onClick={this.props.executeQuery}
data-test="ExecuteButton"
>
<span className="zmdi zmdi-play" />
<span className="hidden-xs m-l-5">{ (this.state.selectedQueryText == null) ? 'Execute' : 'Execute Selected' }</span>
</button>
</Tooltip>
</div>
</div>
</div>
</section>
);
}
}
export default function init(ngModule) {
ngModule.component('queryEditor', react2angular(QueryEditor));
}
init.init = true;

View File

@@ -0,0 +1,199 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { react2angular } from 'react2angular';
import { debounce, find } from 'lodash';
import Input from 'antd/lib/input';
import Select from 'antd/lib/select';
import { Query } from '@/services/query';
import { toastr } from '@/services/ng';
import { QueryTagsControl } from '@/components/tags-control/TagsControl';
const SEARCH_DEBOUNCE_DURATION = 200;
const { Option } = Select;
class StaleSearchError extends Error {
constructor() {
super('stale search');
}
}
function search(term) {
// get recent
if (!term) {
return Query.recent().$promise
.then((results) => {
const filteredResults = results.filter(item => !item.is_draft); // filter out draft
return Promise.resolve(filteredResults);
});
}
// search by query
return Query.query({ q: term }).$promise
.then(({ results }) => Promise.resolve(results));
}
export function QuerySelector(props) {
const [searchTerm, setSearchTerm] = useState();
const [searching, setSearching] = useState();
const [searchResults, setSearchResults] = useState([]);
const [selectedQuery, setSelectedQuery] = useState();
let isStaleSearch = false;
const debouncedSearch = debounce(_search, SEARCH_DEBOUNCE_DURATION);
const placeholder = 'Search a query by name';
const clearIcon = <i className="fa fa-times" onClick={() => selectQuery(null)} />;
const spinIcon = <i className={cx('fa fa-spinner fa-pulse', { hidden: !searching })} />;
// set selected from prop
useEffect(() => {
if (props.selectedQuery) {
setSelectedQuery(props.selectedQuery);
}
}, [props.selectedQuery]);
// on search term changed, debounced
useEffect(() => {
// clear results, no search
if (searchTerm === null) {
setSearchResults(null);
return () => {};
}
// search
debouncedSearch(searchTerm);
return () => {
debouncedSearch.cancel();
isStaleSearch = true;
};
}, [searchTerm]);
function _search(term) {
setSearching(true);
search(term)
.then(rejectStale)
.then((results) => {
setSearchResults(results);
setSearching(false);
})
.catch((err) => {
if (!(err instanceof StaleSearchError)) {
setSearching(false);
}
});
}
function rejectStale(results) {
return isStaleSearch
? Promise.reject(new StaleSearchError())
: Promise.resolve(results);
}
function selectQuery(queryId) {
let query = null;
if (queryId) {
query = find(searchResults, { id: queryId });
if (!query) { // shouldn't happen
toastr.error('Something went wrong... Couldn\'t select query');
}
}
setSearchTerm(query ? null : ''); // empty string triggers recent fetch
setSelectedQuery(query);
props.onChange(query);
}
function renderResults() {
if (!searchResults.length) {
return <div className="text-muted">No results matching search term.</div>;
}
return (
<div className="list-group">
{searchResults.map(q => (
<a
href="javascript:void(0)"
className={cx('list-group-item', { inactive: q.is_draft })}
key={q.id}
onClick={() => selectQuery(q.id)}
>
{q.name}
{' '}
<QueryTagsControl isDraft={q.is_draft} tags={q.tags} className="inline-tags-control" />
</a>
))}
</div>
);
}
if (props.disabled) {
return <Input value={selectedQuery && selectedQuery.name} placeholder={placeholder} disabled />;
}
if (props.type === 'select') {
const suffixIcon = selectedQuery ? clearIcon : null;
const value = selectedQuery ? selectedQuery.name : searchTerm;
return (
<Select
showSearch
dropdownMatchSelectWidth={false}
placeholder={placeholder}
value={value || undefined} // undefined for the placeholder to show
onSearch={setSearchTerm}
onChange={selectQuery}
suffixIcon={searching ? spinIcon : suffixIcon}
notFoundContent={null}
filterOption={false}
defaultActiveFirstOption={false}
>
{searchResults && searchResults.map((q) => {
const disabled = q.is_draft;
return (
<Option value={q.id} key={q.id} disabled={disabled}>
{q.name}{' '}
<QueryTagsControl isDraft={q.is_draft} tags={q.tags} className={cx('inline-tags-control', { disabled })} />
</Option>
);
})}
</Select>
);
}
return (
<React.Fragment>
{selectedQuery ? (
<Input value={selectedQuery.name} suffix={clearIcon} readOnly />
) : (
<Input
placeholder={placeholder}
value={searchTerm}
onChange={e => setSearchTerm(e.target.value)}
suffix={spinIcon}
/>
)}
<div className="scrollbox" style={{ maxHeight: '50vh', marginTop: 15 }}>
{searchResults && renderResults()}
</div>
</React.Fragment>
);
}
QuerySelector.propTypes = {
onChange: PropTypes.func.isRequired,
selectedQuery: PropTypes.object, // eslint-disable-line react/forbid-prop-types
type: PropTypes.oneOf(['select', 'default']),
disabled: PropTypes.bool,
};
QuerySelector.defaultProps = {
selectedQuery: null,
type: 'default',
disabled: false,
};
export default function init(ngModule) {
ngModule.component('querySelector', react2angular(QuerySelector));
}
init.init = true;

View File

@@ -0,0 +1,184 @@
import { filter, debounce, find } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Modal from 'antd/lib/modal';
import Input from 'antd/lib/input';
import List from 'antd/lib/list';
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper';
import { BigMessage } from '@/components/BigMessage';
import LoadingState from '@/components/items-list/components/LoadingState';
import { toastr } from '@/services/ng';
class SelectItemsDialog extends React.Component {
static propTypes = {
dialog: DialogPropType.isRequired,
dialogTitle: PropTypes.string,
inputPlaceholder: PropTypes.string,
selectedItemsTitle: PropTypes.string,
searchItems: PropTypes.func.isRequired, // (searchTerm: string): Promise<Items[]> if `searchTerm === ''` load all
itemKey: PropTypes.func, // (item) => string|number - return key of item (by default `id`)
// left list
// (item, { isSelected }) => {
// content: node, // item contents
// className: string = '', // additional class for item wrapper
// isDisabled: bool = false, // is item clickable or disabled
// }
renderItem: PropTypes.func,
// right list; args/results save as for `renderItem`. if not specified - `renderItem` will be used
renderStagedItem: PropTypes.func,
save: PropTypes.func, // (selectedItems[]) => Promise<any>
};
static defaultProps = {
dialogTitle: 'Add Items',
inputPlaceholder: 'Search...',
selectedItemsTitle: 'Selected items',
itemKey: item => item.id,
renderItem: () => '',
renderStagedItem: null, // use `renderItem` by default
save: items => items,
};
state = {
searchTerm: '',
loading: false,
items: [],
selected: [],
saveInProgress: false,
};
// eslint-disable-next-line react/sort-comp
loadItems = (searchTerm = '') => {
this.setState({ searchTerm, loading: true }, () => {
this.props.searchItems(searchTerm)
.then((items) => {
// If another search appeared while loading data - just reject this set
if (this.state.searchTerm === searchTerm) {
this.setState({ items, loading: false });
}
})
.catch(() => {
if (this.state.searchTerm === searchTerm) {
this.setState({ items: [], loading: false });
}
});
});
};
search = debounce(this.loadItems, 200);
componentDidMount() {
this.loadItems();
}
isSelected(item) {
const key = this.props.itemKey(item);
return !!find(this.state.selected, i => this.props.itemKey(i) === key);
}
toggleItem(item) {
if (this.isSelected(item)) {
const key = this.props.itemKey(item);
this.setState(({ selected }) => ({
selected: filter(selected, i => this.props.itemKey(i) !== key),
}));
} else {
this.setState(({ selected }) => ({
selected: [...selected, item],
}));
}
}
save() {
this.setState({ saveInProgress: true }, () => {
const selectedItems = this.state.selected;
Promise.resolve(this.props.save(selectedItems))
.then(() => {
this.props.dialog.close(selectedItems);
})
.catch(() => {
this.setState({ saveInProgress: false });
toastr.error('Failed to save some of selected items.');
});
});
}
renderItem(item, isStagedList) {
const { renderItem, renderStagedItem } = this.props;
const isSelected = this.isSelected(item);
const render = isStagedList ? (renderStagedItem || renderItem) : renderItem;
const { content, className, isDisabled } = render(item, { isSelected });
return (
<List.Item
className={classNames('p-l-10', 'p-r-10', { clickable: !isDisabled, disabled: isDisabled }, className)}
onClick={isDisabled ? null : () => this.toggleItem(item)}
>
{content}
</List.Item>
);
}
render() {
const { dialog, dialogTitle, inputPlaceholder, selectedItemsTitle } = this.props;
const { loading, saveInProgress, items, selected } = this.state;
const hasResults = items.length > 0;
return (
<Modal
{...dialog.props}
width="80%"
title={dialogTitle}
okText="Save"
okButtonProps={{
loading: saveInProgress,
disabled: selected.length === 0,
}}
onOk={() => this.save()}
>
<div className="d-flex align-items-center m-b-10">
<div className="w-50 m-r-10">
<Input.Search
defaultValue={this.state.searchTerm}
onChange={event => this.search(event.target.value)}
placeholder={inputPlaceholder}
autoFocus
/>
</div>
<div className="w-50 m-l-10">
<h5 className="m-0">{selectedItemsTitle}</h5>
</div>
</div>
<div className="d-flex align-items-stretch" style={{ minHeight: '30vh', maxHeight: '50vh' }}>
<div className="w-50 m-r-10 scrollbox">
{loading && <LoadingState className="" />}
{!loading && !hasResults && (
<BigMessage icon="fa-search" message="No items match your search." className="" />
)}
{!loading && hasResults && (
<List
size="small"
dataSource={items}
renderItem={item => this.renderItem(item, false)}
/>
)}
</div>
<div className="w-50 m-l-10 scrollbox">
{(selected.length > 0) && (
<List
size="small"
dataSource={selected}
renderItem={item => this.renderItem(item, true)}
/>
)}
</div>
</div>
</Modal>
);
}
}
export default wrapDialog(SelectItemsDialog);

View File

@@ -0,0 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
export function SortIcon({ column, sortColumn, reverse }) {
if (column !== sortColumn) {
return null;
}
return (
<span><i className={'fa fa-sort-' + (reverse ? 'desc' : 'asc')} /></span>
);
}
SortIcon.propTypes = {
column: PropTypes.string,
sortColumn: PropTypes.string,
reverse: PropTypes.bool,
};
SortIcon.defaultProps = {
column: null,
sortColumn: null,
reverse: false,
};
export default function init(ngModule) {
ngModule.component('sortIcon', react2angular(SortIcon));
}
init.init = true;

View File

@@ -0,0 +1,85 @@
import { map } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import classNames from 'classnames';
import getTags from '@/services/getTags';
export class TagsList extends React.Component {
static propTypes = {
tagsUrl: PropTypes.string.isRequired,
onUpdate: PropTypes.func,
};
static defaultProps = {
onUpdate: () => {},
};
constructor(props) {
super(props);
this.state = {
// An array of objects that with the name and count of the tagged items
allTags: [],
// A set of tag names
selectedTags: new Set(),
};
}
componentDidMount() {
getTags(this.props.tagsUrl).then((allTags) => {
this.setState({ allTags });
});
}
toggleTag(event, tag) {
const { selectedTags } = this.state;
if (event.shiftKey) {
// toggle tag
if (selectedTags.has(tag)) {
selectedTags.delete(tag);
} else {
selectedTags.add(tag);
}
} else {
// if the tag is the only selected, deselect it, otherwise select only it
if (selectedTags.has(tag) && (selectedTags.size === 1)) {
selectedTags.clear();
} else {
selectedTags.clear();
selectedTags.add(tag);
}
}
this.forceUpdate();
this.props.onUpdate([...this.state.selectedTags]);
}
render() {
const { allTags, selectedTags } = this.state;
if (allTags.length > 0) {
return (
<div className="list-group m-t-10 tags-list tiled">
{map(allTags, tag => (
<a
key={tag.name}
href="javascript:void(0)"
className={classNames('list-group-item', 'max-character', { active: selectedTags.has(tag.name) })}
onClick={event => this.toggleTag(event, tag.name)}
>
<span className="badge badge-light">{tag.count}</span>
<span className="tags-list__name">{tag.name}</span>
</a>
))}
</div>
);
}
return null;
}
}
export default function init(ngModule) {
ngModule.component('tagsList', react2angular(TagsList));
}
init.init = true;

View File

@@ -0,0 +1,98 @@
import moment from 'moment';
import { isNil } from 'lodash';
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { Moment } from '@/components/proptypes';
import { clientConfig } from '@/services/auth';
const autoUpdateList = new Set();
function updateComponents() {
autoUpdateList.forEach(component => component.update());
setTimeout(updateComponents, 30 * 1000);
}
updateComponents();
export class TimeAgo extends React.PureComponent {
static propTypes = {
// `date` and `placeholder` used in `getDerivedStateFromProps`
// eslint-disable-next-line react/no-unused-prop-types
date: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Date),
Moment,
]),
// eslint-disable-next-line react/no-unused-prop-types
placeholder: PropTypes.string,
autoUpdate: PropTypes.bool,
};
static defaultProps = {
date: null,
placeholder: '',
autoUpdate: true,
};
// Initial state, to get rid of React warning
state = {
title: null,
value: null,
};
static getDerivedStateFromProps({ date, placeholder }) {
// if `date` prop is not empty and a valid date/time - convert it to `moment`
date = !isNil(date) ? moment(date) : null;
date = date && date.isValid() ? date : null;
return {
value: date ? date.fromNow() : placeholder,
title: date ? date.format(clientConfig.dateTimeFormat) : '',
};
}
componentDidMount() {
autoUpdateList.add(this);
this.update(true);
}
componentWillUnmount() {
autoUpdateList.delete(this);
}
update(force = false) {
if (force || this.props.autoUpdate) {
this.setState(this.constructor.getDerivedStateFromProps(this.props));
}
}
render() {
return <span title={this.state.title} data-test="TimeAgo">{this.state.value}</span>;
}
}
export default function init(ngModule) {
ngModule.directive('amTimeAgo', () => ({
link($scope, element, attr) {
const modelName = attr.amTimeAgo;
$scope.$watch(modelName, (value) => {
ReactDOM.render(<TimeAgo date={value} />, element[0]);
});
},
}));
ngModule.component('rdTimeAgo', {
bindings: {
value: '=',
},
controller($scope, $element) {
$scope.$watch('$ctrl.value', () => {
// Initial render will occur here as well
ReactDOM.render(<TimeAgo date={this.value} placeholder="-" />, $element[0]);
});
},
});
}
init.init = true;

View File

@@ -0,0 +1,219 @@
import React from 'react';
import PropTypes from 'prop-types';
import { $http } from '@/services/ng';
import Table from 'antd/lib/table';
import Col from 'antd/lib/col';
import Row from 'antd/lib/row';
import Card from 'antd/lib/card';
import Spin from 'antd/lib/spin';
import Badge from 'antd/lib/badge';
import Tabs from 'antd/lib/tabs';
import Alert from 'antd/lib/alert';
import moment from 'moment';
import values from 'lodash/values';
import { Columns } from '@/components/items-list/components/ItemsTable';
function parseTasks(tasks) {
const queues = {};
const queries = [];
const otherTasks = [];
const counters = { active: 0, reserved: 0, waiting: 0 };
tasks.forEach((task) => {
queues[task.queue] = queues[task.queue] || { name: task.queue, active: 0, reserved: 0, waiting: 0 };
queues[task.queue][task.state] += 1;
if (task.enqueue_time) {
task.enqueue_time = moment(task.enqueue_time * 1000.0);
}
if (task.start_time) {
task.start_time = moment(task.start_time * 1000.0);
}
counters[task.state] += 1;
if (task.task_name === 'redash.tasks.execute_query') {
queries.push(task);
} else {
otherTasks.push(task);
}
});
return { queues: values(queues), queries, otherTasks, counters };
}
function QueuesTable({ loading, queues }) {
const columns = ['Name', 'Active', 'Reserved', 'Waiting'].map(c => ({ title: c, dataIndex: c.toLowerCase() }));
return <Table columns={columns} rowKey="name" dataSource={queues} loading={loading} />;
}
QueuesTable.propTypes = {
loading: PropTypes.bool.isRequired,
queues: PropTypes.arrayOf(PropTypes.any).isRequired,
};
function CounterCard({ title, value, loading }) {
return (
<Spin spinning={loading}>
<Card>
{title}
<div className="f-20">{value}</div>
</Card>
</Spin>
);
}
CounterCard.propTypes = {
title: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
loading: PropTypes.bool.isRequired,
};
CounterCard.defaultProps = {
value: '',
};
export default class AdminCeleryStatus extends React.Component {
state = {
loading: true,
error: false,
counters: {},
queries: [],
otherTasks: [],
queues: [],
};
constructor(props) {
super(props);
this.fetch();
}
fetch() {
// TODO: handle error
$http
.get('/api/admin/queries/tasks')
.then(({ data }) => {
const { queues, queries, otherTasks, counters } = parseTasks(data.tasks);
this.setState({ loading: false, queries, otherTasks, queues, counters });
})
.catch(() => {
this.setState({ loading: false, error: true });
});
}
render() {
const commonColumns = [
{
title: 'Worker Name',
dataIndex: 'worker',
},
{
title: 'PID',
dataIndex: 'worker_pid',
},
{
title: 'Queue',
dataIndex: 'queue',
},
{
title: 'State',
dataIndex: 'state',
render: (value) => {
if (value === 'active') {
return (
<span>
<Badge status="processing" /> Active
</span>
);
}
return (
<span>
<Badge status="warning" /> {value}
</span>
);
},
},
Columns.timeAgo({ title: 'Start Time', dataIndex: 'start_time' }),
];
const queryColumns = commonColumns.concat([
Columns.timeAgo({ title: 'Enqueue Time', dataIndex: 'enqueue_time' }),
{
title: 'Query ID',
dataIndex: 'query_id',
},
{
title: 'Org ID',
dataIndex: 'org_id',
},
{
title: 'Data Source ID',
dataIndex: 'data_source_id',
},
{
title: 'User ID',
dataIndex: 'user_id',
},
{
title: 'Scheduled',
dataIndex: 'scheduled',
},
]);
const otherTasksColumns = commonColumns.concat([
{
title: 'Task Name',
dataIndex: 'task_name',
},
]);
if (this.state.error) {
return (
<div className="p-5">
<Alert type="error" message="Failed loading status. Please refresh." />
</div>
);
}
return (
<div className="p-5">
<Row gutter={16}>
<Col span={4}>
<CounterCard title="Active Tasks" value={this.state.counters.active} loading={this.state.loading} />
</Col>
<Col span={4}>
<CounterCard title="Reserved Tasks" value={this.state.counters.reserved} loading={this.state.loading} />
</Col>
<Col span={4}>
<CounterCard title="Waiting Tasks" value={this.state.counters.waiting} loading={this.state.loading} />
</Col>
</Row>
<Row>
<Tabs defaultActiveKey="queues">
<Tabs.TabPane key="queues" tab="Queues">
<QueuesTable loading={this.state.loading} queues={this.state.queues} />
</Tabs.TabPane>
<Tabs.TabPane key="queries" tab="Queries">
<Table
rowKey="task_id"
dataSource={this.state.queries}
loading={this.state.loading}
columns={queryColumns}
/>
</Tabs.TabPane>
<Tabs.TabPane key="other" tab="Other Tasks">
<Table
rowKey="task_id"
dataSource={this.state.otherTasks}
loading={this.state.loading}
columns={otherTasksColumns}
/>
</Tabs.TabPane>
</Tabs>
</Row>
</div>
);
}
}

View File

@@ -111,3 +111,5 @@ export default function init(ngModule) {
controller,
}));
}
init.init = true;

View File

@@ -1,3 +1,13 @@
.menu-search input[type="text"] {
height: 30px;
}
.dropdown-menu__version {
padding: 5px 10px 8px 17px;
}
.update-available .fa {
color: #52c41a;
vertical-align: bottom;
font-size: 16px !important;
}

View File

@@ -67,7 +67,7 @@
<!-- Add New Button -->
<div class="btn-group navbar-btn navbar-left btn__new hidden-xs" uib-dropdown is-open="status.isopen">
<button id="create-button" type="button" class="btn btn-primary btn--create" uib-dropdown-toggle ng-disabled="disabled">
<button id="create-button" data-test="CreateButton" type="button" class="btn btn-primary btn--create" uib-dropdown-toggle ng-disabled="disabled">
Create <span class="caret caret--nav"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="create-button">
@@ -79,6 +79,9 @@
<!-- Profile -->
<ul class="nav navbar-nav navbar-right">
<li>
<help-trigger type="'HOME'" class-name="'navbar-link-ANGULAR_REMOVE_ME'"></help-trigger>
</li>
<li ng-show="$ctrl.currentUser.isAdmin">
<a href="data_sources" title="Settings"><i class="fa fa-sliders" aria-hidden="true"></i></a>
</li>
@@ -86,7 +89,7 @@
<!--<a href="users" title="Settings"><i class="fa fa-cog"></i></a>-->
<!--</li>-->
<li class="dropdown" uib-dropdown>
<a href="#" class="dropdown-toggle dropdown--profile" uib-dropdown-toggle>
<a href="#" class="dropdown-toggle dropdown--profile" uib-dropdown-toggle data-test="ProfileDropdown">
<img ng-src="{{ $ctrl.currentUser.profile_image_url }}" class="profile__image--navbar" width="20"/>
<span class="dropdown--profile__username" ng-bind="$ctrl.currentUser.name"></span> <span
class="caret caret--nav"></span></a>
@@ -112,7 +115,7 @@
<a href="destinations" title="Settings">Alert Destinations</a>
</li>
<li ng-if="$ctrl.currentUser.hasPermission('super_admin')" class="divider"></li>
<li ng-if="$ctrl.currentUser.hasPermission('super_admin')" class="divider"></li>
<li ng-if="$ctrl.currentUser.hasPermission('super_admin')"><a href="admin/status">System Status</a></li>
@@ -121,6 +124,19 @@
<li>
<a ng-click="$ctrl.logout()">Log out</a>
</li>
<li class="divider"></li>
<li class="dropdown-menu__version">
Version: {{$ctrl.backendVersion}}
<span ng-if="$ctrl.frontendVersion !== $ctrl.backendVersion">
({{$ctrl.frontendVersion.substring(0, 8)}})
</span>
<span class="update-available" ng-if="$ctrl.currentUser.hasPermission('super_admin') && $ctrl.newVersionAvailable">
<a href="https://version.redash.io/" target="_blank">
<i class="fa fa-arrow-circle-down"></i>
</a>
</span>
</li>
</ul>
</li>
</ul>
@@ -128,7 +144,7 @@
<!-- Search -->
<form class="navbar-form navbar-right" role="search" ng-submit="$ctrl.searchQueries()">
<div class="input-group menu-search">
<input type="text" ng-model="$ctrl.term" class="form-control navbar__search__input" placeholder="Search queries...">
<input type="text" ng-model="$ctrl.searchTerm" class="form-control navbar__search__input" placeholder="Search queries...">
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><span class="zmdi zmdi-search"></span></button>
</span>

View File

@@ -1,6 +1,7 @@
import debug from 'debug';
import logoUrl from '@/assets/images/redash_icon_small.png';
import frontendVersion from '@/version.json';
import template from './app-header.html';
import './app-header.css';
@@ -16,6 +17,10 @@ function controller($rootScope, $location, $route, $uibModal, Auth, currentUser,
this.showSettingsMenu = currentUser.hasPermission('list_users');
this.showDashboardsMenu = currentUser.hasPermission('list_dashboards');
this.frontendVersion = frontendVersion;
this.backendVersion = clientConfig.version;
this.newVersionAvailable = clientConfig.newVersionAvailable && currentUser.isAdmin;
this.reload = () => {
logger('Reloading dashboards and queries.');
Dashboard.favorites().$promise.then((data) => {
@@ -40,7 +45,7 @@ function controller($rootScope, $location, $route, $uibModal, Auth, currentUser,
};
this.searchQueries = () => {
$location.path('/queries').search({ q: this.term });
$location.path('/queries').search({ q: this.searchTerm });
$route.reload();
};
@@ -55,3 +60,5 @@ export default function init(ngModule) {
controller,
});
}
init.init = true;

View File

@@ -82,12 +82,17 @@ class AppViewComponent {
}
export default function init(ngModule) {
ngModule.factory('$exceptionHandler', () => function exceptionHandler(exception) {
handler.process(exception);
});
ngModule.factory(
'$exceptionHandler',
() => function exceptionHandler(exception) {
handler.process(exception);
},
);
ngModule.component('appView', {
template,
controller: AppViewComponent,
});
}
init.init = true;

View File

@@ -6,14 +6,14 @@ function cancelQueryButton() {
taskId: '=',
},
transclude: true,
template: '<button class="btn btn-default" ng-disabled="inProgress" ng-click="cancelExecution()"><i class="zmdi zmdi-spinner zmdi-hc-spin" ng-if="inProgress"></i> Cancel</button>',
template:
'<button class="btn btn-default" ng-disabled="inProgress" ng-click="cancelExecution()"><i class="zmdi zmdi-spinner zmdi-hc-spin" ng-if="inProgress"></i> Cancel</button>',
replace: true,
controller($scope, $http, currentUser, Events) {
$scope.inProgress = false;
$scope.cancelExecution = () => {
$http.delete(`api/jobs/${$scope.taskId}`).success(() => {
});
$http.delete(`api/jobs/${$scope.taskId}`).success(() => {});
let queryId = $scope.queryId;
if ($scope.queryId === 'adhoc') {
@@ -30,3 +30,5 @@ function cancelQueryButton() {
export default function init(ngModule) {
ngModule.directive('cancelQueryButton', cancelQueryButton);
}
init.init = true;

Some files were not shown because too many files have changed in this diff Show More