Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TICKscript Editor #1721

Merged
merged 44 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
423f02b
Add skeleton for tickscript editor page
121watts Jul 13, 2017
b5aa82f
Introduce TICKscript editor
121watts Jul 13, 2017
202702b
Introduce CodeMirror for TICKscript editor
121watts Jul 13, 2017
ad1f78a
Polish the editor
121watts Jul 13, 2017
8722120
Display TICKscript on rules index
121watts Jul 11, 2017
1e1c955
Polish alert rules table
alexpaxton Jul 12, 2017
c4562aa
Update CHANGELOG
121watts Jul 13, 2017
b66be55
Update kapacitor links to include tasks and ping paths
121watts Jul 14, 2017
b6880c2
ES6ify
121watts Jul 14, 2017
4f1372a
Introduce skeleton to create task through proxy
121watts Jul 14, 2017
b6ca021
WIP Edit scripts returned from the server
121watts Jul 14, 2017
cea9d07
Introduce TICKscript editing
121watts Jul 15, 2017
9f371f1
Set default props for ruleID
121watts Jul 17, 2017
0e8fecf
Add lambda to syntax highlighting
121watts Jul 17, 2017
4437475
Apply selected dbrps to state
121watts Jul 17, 2017
fa2192f
Prettier
121watts Jul 18, 2017
026b1f1
Add comment
121watts Jul 18, 2017
018bd17
Add ability to apply changes per click
121watts Jul 18, 2017
1cdcc80
Make UserRow work with new MultiSelectDropdown shape
121watts Jul 18, 2017
74145b0
Cleanup checks with default props
121watts Jul 18, 2017
03e40c8
Cleanup
121watts Jul 18, 2017
f4aeefa
Add tickscript type selector
121watts Jul 18, 2017
a1ecdb6
WIP Introduce tickscript id editing
121watts Jul 18, 2017
879685d
Remove view only Tickscript
121watts Jul 19, 2017
fe6c5ac
Cleanup
121watts Jul 19, 2017
c653982
Make task ids only edit when making new task
121watts Jul 19, 2017
25d5310
Prettier
121watts Jul 25, 2017
09d554c
Organize styles and use custom theme for code mirror
alexpaxton Jul 26, 2017
077bdf2
Change layout of tickscript editor
alexpaxton Jul 26, 2017
cce44b1
Update to react-codemirror 1.0
121watts Aug 7, 2017
b817c82
Update branch with new linter rules
121watts Sep 7, 2017
b151e81
Use /rules to create tickscripts
121watts Sep 12, 2017
4915e97
Update existing tickscript
121watts Sep 12, 2017
f7d59f6
Fix auto indendation to match indentation of previous line
121watts Sep 12, 2017
701c4bf
Publish notification after route change
121watts Sep 12, 2017
dc7fc85
Remove TICKscript name creation
121watts Sep 12, 2017
6dd8e37
Use tickscript id as 'name' for raw tickscripts
121watts Sep 14, 2017
e646f42
Add a TICKscript table to alert rules page
121watts Sep 14, 2017
e314789
Refine copy
121watts Sep 14, 2017
2fdee35
Update CHANGELOG
121watts Sep 14, 2017
9059da0
Merge branch 'master' into feature/tickscript-editor
121watts Sep 14, 2017
f5209a8
Fix multiselect in Admin page
121watts Sep 22, 2017
4abe50e
Merge branch 'feature/tickscript-editor' of github.com:influxdata/chr…
121watts Sep 22, 2017
abbcd6c
Remove react-addons-update
121watts Sep 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features
1. [#1885](https://github.com/influxdata/chronograf/pull/1885): Add `fill` options to data explorer and dashboard queries
1. [#1978](https://github.com/influxdata/chronograf/pull/1978): Support editing kapacitor TICKScript
1. [#1721](https://github.com/influxdata/chronograf/pull/1721): Introduce the TICKscript editor UI
1. [#1992](https://github.com/influxdata/chronograf/pull/1992): Add .csv download button to data explorer

### UI Improvements
Expand Down Expand Up @@ -146,6 +147,8 @@
1. [#1738](https://github.com/influxdata/chronograf/pull/1738): Add shared secret JWT authorization to InfluxDB
1. [#1724](https://github.com/influxdata/chronograf/pull/1724): Add Pushover alert support
1. [#1762](https://github.com/influxdata/chronograf/pull/1762): Restore all supported Kapacitor services when creating rules, and add most optional message parameters
1. [#1681](https://github.com/influxdata/chronograf/pull/1681): Add the ability to select Custom Time Ranges in the Hostpages, Data Explorer, and Dashboards.
1. [#1717](https://github.com/influxdata/chronograf/pull/1717): View server generated TICKscripts

### UI Improvements
1. [#1707](https://github.com/influxdata/chronograf/pull/1707): Polish alerts table in status page to wrap text less
Expand Down
4 changes: 4 additions & 0 deletions server/kapacitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type kapaLinks struct {
Proxy string `json:"proxy"` // URL location of proxy endpoint for this source
Self string `json:"self"` // Self link mapping to this resource
Rules string `json:"rules"` // Rules link for defining roles alerts for kapacitor
Tasks string `json:"tasks"` // Tasks link to define a task against the proxy
Ping string `json:"ping"` // Ping path to kapacitor
}

type kapacitor struct {
Expand Down Expand Up @@ -108,6 +110,8 @@ func newKapacitor(srv chronograf.Server) kapacitor {
Self: fmt.Sprintf("%s/%d/kapacitors/%d", httpAPISrcs, srv.SrcID, srv.ID),
Proxy: fmt.Sprintf("%s/%d/kapacitors/%d/proxy", httpAPISrcs, srv.SrcID, srv.ID),
Rules: fmt.Sprintf("%s/%d/kapacitors/%d/rules", httpAPISrcs, srv.SrcID, srv.ID),
Tasks: fmt.Sprintf("%s/%d/kapacitors/%d/proxy?path=/kapacitor/v1/tasks", httpAPISrcs, srv.SrcID, srv.ID),
Ping: fmt.Sprintf("%s/%d/kapacitors/%d/proxy?path=/kapacitor/v1/ping", httpAPISrcs, srv.SrcID, srv.ID),
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"@skidding/react-codemirror": "^1.0.1",
"axios": "^0.13.1",
"bignumber.js": "^4.0.2",
"bootstrap": "^3.3.7",
Expand All @@ -112,6 +113,7 @@
"query-string": "^5.0.0",
"react": "^15.0.2",
"react-addons-shallow-compare": "^15.0.2",
"react-codemirror": "^1.0.0",
"react-custom-scrollbars": "^4.1.1",
"react-dimensions": "^1.2.0",
"react-dom": "^15.0.2",
Expand Down
22 changes: 12 additions & 10 deletions ui/src/admin/components/RoleRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import DeleteConfirmTableCell from 'shared/components/DeleteConfirmTableCell'
import {ROLES_TABLE} from 'src/admin/constants/tableSizing'

const RoleRow = ({
role: {name, permissions, users},
role: {name: roleName, permissions, users = []},
role,
allUsers,
allPermissions,
Expand All @@ -23,12 +23,14 @@ const RoleRow = ({
onUpdateRoleUsers,
onUpdateRolePermissions,
}) => {
const handleUpdateUsers = u => {
onUpdateRoleUsers(role, u.map(n => ({name: n})))
const handleUpdateUsers = usrs => {
onUpdateRoleUsers(role, usrs)
}

const handleUpdatePermissions = allowed => {
onUpdateRolePermissions(role, [{scope: 'all', allowed}])
onUpdateRolePermissions(role, [
{scope: 'all', allowed: allowed.map(({name}) => name)},
])
}

const perms = _.get(permissions, ['0', 'allowed'], [])
Expand Down Expand Up @@ -62,13 +64,13 @@ const RoleRow = ({
return (
<tr>
<td style={{width: `${ROLES_TABLE.colName}px`}}>
{name}
{roleName}
</td>
<td>
{allPermissions && allPermissions.length
? <MultiSelectDropdown
items={allPermissions}
selectedItems={perms}
items={allPermissions.map(name => ({name}))}
selectedItems={perms.map(name => ({name}))}
label={perms.length ? '' : 'Select Permissions'}
onApply={handleUpdatePermissions}
buttonSize="btn-xs"
Expand All @@ -85,9 +87,9 @@ const RoleRow = ({
<td>
{allUsers && allUsers.length
? <MultiSelectDropdown
items={allUsers.map(u => u.name)}
selectedItems={users === undefined ? [] : users.map(u => u.name)}
label={users && users.length ? '' : 'Select Users'}
items={allUsers}
selectedItems={users}
label={users.length ? '' : 'Select Users'}
onApply={handleUpdateUsers}
buttonSize="btn-xs"
buttonColor="btn-primary"
Expand Down
23 changes: 11 additions & 12 deletions ui/src/admin/components/UserRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ChangePassRow from 'src/admin/components/ChangePassRow'
import {USERS_TABLE} from 'src/admin/constants/tableSizing'

const UserRow = ({
user: {name, roles, permissions, password},
user: {name, roles = [], permissions, password},
user,
allRoles,
allPermissions,
Expand All @@ -27,21 +27,24 @@ const UserRow = ({
onUpdateRoles,
onUpdatePassword,
}) => {
const handleUpdatePermissions = allowed => {
const handleUpdatePermissions = perms => {
const allowed = perms.map(p => p.name)
onUpdatePermissions(user, [{scope: 'all', allowed}])
}

const handleUpdateRoles = roleNames => {
onUpdateRoles(
user,
allRoles.filter(r => roleNames.find(rn => rn === r.name))
allRoles.filter(r => roleNames.find(rn => rn.name === r.name))
)
}

const handleUpdatePassword = () => {
onUpdatePassword(user, password)
}

const perms = _.get(permissions, ['0', 'allowed'], [])

if (isEditing) {
return (
<tr className="admin-table--edit-row">
Expand Down Expand Up @@ -85,13 +88,9 @@ const UserRow = ({
{hasRoles
? <td>
<MultiSelectDropdown
items={allRoles.map(r => r.name)}
selectedItems={
roles
? roles.map(r => r.name)
: [] /* TODO remove check when server returns empty list */
}
label={roles && roles.length ? '' : 'Select Roles'}
items={allRoles}
selectedItems={roles.map(r => ({name: r.name}))}
label={roles.length ? '' : 'Select Roles'}
onApply={handleUpdateRoles}
buttonSize="btn-xs"
buttonColor="btn-primary"
Expand All @@ -104,8 +103,8 @@ const UserRow = ({
<td>
{allPermissions && allPermissions.length
? <MultiSelectDropdown
items={allPermissions}
selectedItems={_.get(permissions, ['0', 'allowed'], [])}
items={allPermissions.map(p => ({name: p}))}
selectedItems={perms.map(p => ({name: p}))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something wrong with the permissions dropdowns on Enterprise, they list items but don't display the text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, selecting one selects them all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed, but other issues with the backend have come up. See #2021

label={
permissions && permissions.length ? '' : 'Select Permissions'
}
Expand Down
Loading