Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Janani Neelamekam committed Oct 2, 2023
1 parent c99505d commit 3a58fb4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 29 deletions.
17 changes: 10 additions & 7 deletions src/dispatch/plugins/dispatch_slack/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,19 @@ def datetime_picker_block(
"""Builds a datetime picker block"""
hour = None
minute = None
date = initial_option.split("|")[0] if initial_option.split("|")[0]!="" else None
date = initial_option.split("|")[0] if initial_option.split("|")[0] != "" else None

if initial_option.split("|")[1]!="":
#appends zero if time is not entered in hh format
if initial_option.split("|")[1] != "":
# appends zero if time is not entered in hh format
if len(initial_option.split("|")[1].split(":")[0]) == 1:
h= "0"+initial_option.split("|")[1].split(":")[0]
h = "0" + initial_option.split("|")[1].split(":")[0]
else:
h=initial_option.split("|")[1].split(":")[0]
hour = {"text":h,"value":h}
minute = {"text":initial_option.split("|")[1].split(":")[1],"value":initial_option.split("|")[1].split(":")[1]}
h = initial_option.split("|")[1].split(":")[0]
hour = {"text": h, "value": h}
minute = {
"text": initial_option.split("|")[1].split(":")[1],
"value": initial_option.split("|")[1].split(":")[1],
}
return [
date_picker_input(initial_date=date),
hour_picker_input(initial_option=hour),
Expand Down
34 changes: 24 additions & 10 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,15 +976,29 @@ def handle_add_timeline_event_command(
) -> None:
"""Handles the add timeline event command."""
ack()
description= None
date= ""
time= ""
if re.match('.*DESC\s*(.+?)(?: DATE|$|TIME)',body['text'], re.IGNORECASE):
description= (re.match('DESC\s*(.+?)(?: DATE|$|TIME)',body['text'], re.IGNORECASE).group(1)).strip()
if re.match('.*DATE\s*(\d{4}\-\d{2}\-\d{2})(?: TIME|$|DESC)',body['text'], re.IGNORECASE):
date= (re.match('.*DATE\s*(\d{4}\-\d{2}\-\d{2})(?: TIME|$|DESC)',body['text'], re.IGNORECASE).group(1)).strip()
if re.match('.*TIME\s*(([01]?[0-9]|2[0-3]):[0-5][0-9])(?: |DATE|$|DESC)',body['text'], re.IGNORECASE):
time= (re.match('.*TIME\s*(([01]?[0-9]|2[0-3]):[0-5][0-9])(?: |DATE|$|DESC)',body['text'], re.IGNORECASE).group(1)).strip()
description = None
date = ""
time = ""
if re.match(".*DESC\s*(.+?)(?: DATE|$|TIME)", body["text"], re.IGNORECASE):
description = (
re.match("DESC\s*(.+?)(?: DATE|$|TIME)", body["text"], re.IGNORECASE).group(1)
).strip()
if re.match(".*DATE\s*(\d{4}\-\d{2}\-\d{2})(?: TIME|$|DESC)", body["text"], re.IGNORECASE):
date = (
re.match(
".*DATE\s*(\d{4}\-\d{2}\-\d{2})(?: TIME|$|DESC)", body["text"], re.IGNORECASE
).group(1)
).strip()
if re.match(
".*TIME\s*(([01]?[0-9]|2[0-3]):[0-5][0-9])(?: |DATE|$|DESC)", body["text"], re.IGNORECASE
):
time = (
re.match(
".*TIME\s*(([01]?[0-9]|2[0-3]):[0-5][0-9])(?: |DATE|$|DESC)",
body["text"],
re.IGNORECASE,
).group(1)
).strip()

blocks = [
Context(
Expand All @@ -995,7 +1009,7 @@ def handle_add_timeline_event_command(
description_input(initial_value=description),
]

blocks.extend(datetime_picker_block(initial_option=date+"|"+time))
blocks.extend(datetime_picker_block(initial_option=date + "|" + time))

modal = Modal(
title="Add Timeline Event",
Expand Down
29 changes: 17 additions & 12 deletions src/dispatch/static/dispatch/src/incident/TimelineTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,22 @@ export default {
]),
exportToCSV() {
this.exportLoading = true
const selected_items=[]
const selected_items = []
let items = this.sortedEvents
items.forEach(item=> {
if(this.showItem(item)){
items.forEach((item) => {
if (this.showItem(item)) {
selected_items.push(item)
}
}
)
Util.exportCSV(selected_items.map(item=> ({'Time (in UTC)': item.started_at,'Description': item.description,'Owner': this.extractOwner(item)})), this.name + "-timeline-export.csv")
}
})
Util.exportCSV(
selected_items.map((item) => ({
"Time (in UTC)": item.started_at,
Description: item.description,
Owner: this.extractOwner(item),
})),
this.name + "-timeline-export.csv"
)
this.exportLoading = false
},
showItem(item) {
Expand All @@ -192,10 +198,9 @@ export default {
if (item.description == "Incident created") return "mdi-flare"
return eventTypeToIcon[item.type]
},
extractOwner(item){
if (item.owner!=null && item.owner!="") return item.owner
return 'Dispatch'
extractOwner(item) {
if (item.owner != null && item.owner != "") return item.owner
return "Dispatch"
},
countHidden() {
if (!this.events) return 0
Expand Down

0 comments on commit 3a58fb4

Please sign in to comment.