forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build custom alert message (getredash#3137)
* build custom alert message * fit button color tone * pass existing test * fix typos * follow code style * add webhook alert description and avoid key error * refactor: create alert template module * follow code style * use es6 class, fix template display * use alerts.options, use mustache * fix email description * alert custom subject * add alert state to template context, sanitized preview * remove console.log 🙇 * chatwork custom_subject * add alert custom message. pagerduty, mattermost, hangoutschat * Pass custom subject in webhook destination * Add log message when checking alert. * Add feature flag for extra alert options.
- Loading branch information
1 parent
43c98fd
commit f12b412
Showing
15 changed files
with
186 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// import { $http } from '@/services/ng'; | ||
import Mustache from 'mustache'; | ||
|
||
export default class AlertTemplate { | ||
render(alert, queryResult) { | ||
const view = { | ||
state: alert.state, | ||
rows: queryResult.rows, | ||
cols: queryResult.columns, | ||
}; | ||
const result = Mustache.render(alert.options.template, view); | ||
const escaped = result | ||
.replace(/"/g, '"') | ||
.replace(/&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/\n|\r/g, '<br>'); | ||
|
||
return { escaped, raw: result }; | ||
} | ||
|
||
constructor() { | ||
this.helpMessage = `using template engine "mustache". | ||
you can build message with latest query result. | ||
variable name "rows" is assigned as result rows. "cols" as result columns, "state" as alert state.`; | ||
|
||
this.editorOptions = { | ||
useWrapMode: true, | ||
showPrintMargin: false, | ||
advanced: { | ||
behavioursEnabled: true, | ||
enableBasicAutocompletion: true, | ||
enableLiveAutocompletion: true, | ||
autoScrollEditorIntoView: true, | ||
}, | ||
onLoad(editor) { | ||
editor.$blockScrolling = Infinity; | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters