This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Improve logging and error handling; Fix edit report bug; Fix header/footer rendering #123
Merged
zhongnansu
merged 13 commits into
opendistro-for-elasticsearch:dev
from
zhongnansu:logging
Oct 15, 2020
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1227eb3
relax the es result restriction to use default max value
zhongnansu ddf6967
Merge branch 'dev' of github.com:opendistro-for-elasticsearch/kibana-…
zhongnansu f33c5a7
Merge branch 'dev' of github.com:opendistro-for-elasticsearch/kibana-…
zhongnansu 3419b53
Merge branch 'dev' of github.com:opendistro-for-elasticsearch/kibana-…
zhongnansu 9de189c
Merge branch 'dev' of github.com:opendistro-for-elasticsearch/kibana-…
zhongnansu 49cf824
Merge remote-tracking branch 'upstream/dev' into logging
zhongnansu d40b03a
improve logging, fix update API bug
zhongnansu 9184215
Merge remote-tracking branch 'upstream/dev' into logging
zhongnansu b03f71f
align with previous PRs
zhongnansu 649e80c
added logger to create visual report
zhongnansu 4ff8064
convert header to html
zhongnansu a14aa9c
address comments
zhongnansu a9c9756
remove delay use wait for navigation
zhongnansu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ import { | |
import { ReportSettings } from '../report_settings'; | ||
import { ReportDelivery } from '../delivery'; | ||
import { ReportTrigger } from '../report_trigger'; | ||
import { ReportDefinitionSchemaType } from 'server/model'; | ||
|
||
export function EditReportDefinition(props) { | ||
const [toasts, setToasts] = useState([]); | ||
|
@@ -51,6 +52,7 @@ export function EditReportDefinition(props) { | |
}; | ||
|
||
const reportDefinitionId = props['match']['params']['reportDefinitionId']; | ||
let curReportDefinition: ReportDefinitionSchemaType; | ||
let editReportDefinitionRequest = { | ||
report_params: { | ||
report_name: '', | ||
|
@@ -59,8 +61,6 @@ export function EditReportDefinition(props) { | |
core_params: { | ||
base_url: '', | ||
report_format: '', | ||
header: '', | ||
footer: '', | ||
time_duration: '', | ||
}, | ||
}, | ||
|
@@ -71,21 +71,25 @@ export function EditReportDefinition(props) { | |
trigger: { | ||
trigger_type: '', | ||
}, | ||
time_created: 0, | ||
last_updated: 0, | ||
status: '', | ||
}; | ||
|
||
let timeRange = { | ||
timeFrom: new Date(), | ||
timeTo: new Date(), | ||
}; | ||
|
||
const editReportDefinition = async (metadata) => { | ||
const callUpdateAPI = async (metadata) => { | ||
const { httpClient } = props; | ||
|
||
httpClient | ||
.put(`../api/reporting/reportDefinitions/${reportDefinitionId}`, { | ||
body: JSON.stringify(metadata), | ||
params: reportDefinitionId.toString(), | ||
}) | ||
.then(async (response) => { | ||
.then(async () => { | ||
window.location.assign(`opendistro_kibana_reports#/`); | ||
}) | ||
.catch((error) => { | ||
|
@@ -94,22 +98,61 @@ export function EditReportDefinition(props) { | |
}); | ||
}; | ||
|
||
const editReportDefinition = async (metadata) => { | ||
const { httpClient } = props; | ||
/* | ||
we check if this edit update the trigger type from Schedule to On demand. | ||
If so, need to first delete the curReportDefinition along with the scheduled job first, by calling the delete | ||
report definition API | ||
*/ | ||
const { | ||
trigger: { trigger_type: triggerType }, | ||
} = curReportDefinition; | ||
if ( | ||
triggerType !== 'On demand' && | ||
metadata.trigger.trigger_type === 'On demand' | ||
) { | ||
httpClient | ||
.delete(`../api/reporting/reportDefinitions/${reportDefinitionId}`) | ||
.then(async () => { | ||
await callUpdateAPI(metadata); | ||
}) | ||
.catch((error) => { | ||
console.log('error when deleting report definition:', error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np: add a toast for when this error is triggered There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add |
||
}); | ||
} else { | ||
await callUpdateAPI(metadata); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const { httpClient } = props; | ||
httpClient | ||
.get(`../api/reporting/reportDefinitions/${reportDefinitionId}`) | ||
.then((response) => { | ||
curReportDefinition = response.report_definition; | ||
const { | ||
time_created: timeCreated, | ||
status, | ||
last_updated: lastUpdated, | ||
report_params: { report_name: reportName }, | ||
} = curReportDefinition; | ||
// configure non-editable fields | ||
editReportDefinitionRequest.time_created = timeCreated; | ||
editReportDefinitionRequest.last_updated = lastUpdated; | ||
editReportDefinitionRequest.status = status; | ||
|
||
props.setBreadcrumbs([ | ||
{ | ||
text: 'Reporting', | ||
href: '#', | ||
}, | ||
{ | ||
text: `Report definition details: ${response.report_definition.report_params.report_name}`, | ||
text: `Report definition details: ${reportName}`, | ||
href: `#/report_definition_details/${reportDefinitionId}`, | ||
}, | ||
{ | ||
text: `Edit report definition: ${response.report_definition.report_params.report_name}`, | ||
text: `Edit report definition: ${reportName}`, | ||
}, | ||
]); | ||
}) | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: can we spell out the entire word ->
currentReportDefinition
vscurReportDefinition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change