-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add priority to alert model, add sorting in display of Alerts page #77
base: master
Are you sure you want to change the base?
Conversation
* Read from the request body, which contains data in the format "alertId statusToChangeTo". | ||
* For example, the body could be "4785074604081152 RESOLVED". | ||
*/ | ||
private String[] processRequestBody(HttpServletRequest request) |
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.
Is there a reason why the data format is as what you mentioned (alertId statusToChangeTo
) separated by the space?
Also as usual prefer structured as compared to unstructured data :D
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.
Oops I forgot to change this comment. I will change the comment
So yes you can pass an object to the backend, but I found it more difficult to deal with processing the object rather than just using this unstructured method.
In hindsight, I could have done this by passing in the data as parameters, because there are only two...
const { alert } = this.state; | ||
|
||
// We have to get the P0, P1, or P2 version to match with enum representation in backend. | ||
const numToEnum = Object.keys(priorityLevels)[Object.values(priorityLevels).indexOf(newPriority)]; |
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.
i was a bit confused on what is this numToEnum
does. so you need to do the mapping with the map to convert it back?
seems the priority is just the "0", "1", "2" (the numerical value) etc for easier sorting?
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.
Yup! It's for easier sorting, but to translate it back to the backend (so that the backend understands 0, 1, 2) should convert it back. If I didn't do it in the frontend, I think I would have to do it in the backend anyway
const numToEnum = Object.keys(priorityLevels)[Object.values(priorityLevels).indexOf(newPriority)]; | ||
fetch('/api/v1/alert-visualization', { | ||
method: 'POST', | ||
body: alert.id + " " + numToEnum, |
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.
oh i think this is why the post servlet above (in the previous file I commented had the space in the body), could we not change this?
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.
refer to earlier comment - I will change this to passing through parameters in the rquest rather than the body
throws ServletException, IOException { | ||
String[] data = processRequestBody(request); | ||
Long id = Long.parseLong(data[0]); | ||
String priority = data[1]; |
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.
i thought it was "statusToChangeTo" and not priority
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.
typo :'(
const DATE_DELIMITER = '/'; | ||
|
||
/** Format JavaScript date in the form MM/DD/YYYY if mFirst is true, otherwise YYYY/MM/DD. */ | ||
export function formatDate(date, mFirst) { |
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.
monthFirst (this is from the other PR, probably ude to some out-of-sync thing
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.
yeah it's out-of-sync i changed it to monthFirst in the other one
backend/src/main/java/com/google/blackswan/mock/MultiInputAlertGenerator.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/com/google/blackswan/mock/SimpleAlertGenerator.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/com/google/blackswan/mock/DummyAlertGenerator.java
Outdated
Show resolved
Hide resolved
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.
Thanks for fixing all the small bugs :)
great job! you added a lot of great features <3
Summary:
doPost
method to the Alert Visualization servlet, and this method is called by both the AlertsContent and AlertInfo components in order to change priority of alerts.