Skip to content

Commit

Permalink
Set owner column as optional when exporting timeline (#4849)
Browse files Browse the repository at this point in the history
Co-authored-by: Janani Neelamekam <[email protected]>
  • Loading branch information
whitdog47 and Janani Neelamekam authored Jun 18, 2024
1 parent fc8d93b commit 6679816
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
57 changes: 47 additions & 10 deletions src/dispatch/event/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,22 @@ def export_timeline(
date, time = str(event_timestamp).split(" ")
if e.pinned or timeline_filters.get(e.type):
if date in dates:
table_data.append(
{time_header: time, "Description": e.description, "Owner": e.owner}
)
if timeline_filters.get("exportOwner"):
table_data.append(
{time_header: time, "Description": e.description, "Owner": e.owner}
)
else:
table_data.append({time_header: time, "Description": e.description})
else:
dates.add(date)
table_data.append({time_header: date, "Description": "\t", "Owner": "\t"})
table_data.append(
{time_header: time, "Description": e.description, "Owner": e.owner}
)
if timeline_filters.get("exportOwner"):
table_data.append({time_header: date, "Description": "\t", "Owner": "\t"})
table_data.append(
{time_header: time, "Description": e.description, "Owner": e.owner}
)
else:
table_data.append({time_header: date, "Description": "\t"})
table_data.append({time_header: time, "Description": e.description})

if table_data:
table_data = json.loads(json.dumps(table_data))
Expand Down Expand Up @@ -328,7 +335,7 @@ def export_timeline(
},
"fields": "backgroundColor",
"tableRange": {
"columnSpan": 3,
"columnSpan": num_columns,
"rowSpan": 1,
"tableCellLocation": {
"columnIndex": 0,
Expand All @@ -337,9 +344,39 @@ def export_timeline(
},
},
}
},
{
"updateTableColumnProperties": {
"tableStartLocation": {
"index": curr_table_start,
},
"columnIndices": [0],
"tableColumnProperties": {
"width": {"magnitude": 90, "unit": "PT"},
"widthType": "FIXED_WIDTH",
},
"fields": "width,widthType",
}
}
]

if timeline_filters.get("exportOwner"):
insert_data_request.append(
{
"updateTableColumnProperties": {
"tableStartLocation": {
"index": curr_table_start,
},
"columnIndices": [2],
"tableColumnProperties": {
"width": {"magnitude": 105, "unit": "PT"},
"widthType": "FIXED_WIDTH",
},
"fields": "width,widthType",
}
}
)

if plugin.instance.insert(document_id=doc_id, request=insert_data_request):
log.debug("Table Formatted successfully")

Expand Down Expand Up @@ -397,12 +434,12 @@ def export_timeline(
},
"fields": "backgroundColor",
"tableRange": {
"columnSpan": 3,
"columnSpan": num_columns,
"rowSpan": 1,
"tableCellLocation": {
"tableStartLocation": {"index": curr_table_start},
"columnIndex": 0,
"rowIndex": row_idx // 3,
"rowIndex": row_idx // len(column_headers),
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
At least one must be selected
</div>
</v-card>
<v-checkbox class="mt-3" label="Also export Owner field" v-model="exportOwner" />
<v-select
v-model="timezone"
label="Time zone"
style="margin-top: -20px"
:items="timezones"
class="mt-3 ml-2 time-zone-select"
class="ml-2 time-zone-select"
/>
</v-card-text>

Expand Down Expand Up @@ -99,6 +101,7 @@ export default {
timezones: ["UTC", "America/Los_Angeles"],
timezone: "UTC",
user_timeline_filters: {},
exportOwner: false,
}
},
computed: {
Expand Down Expand Up @@ -158,6 +161,7 @@ export default {
user_timeline_filters["incidentDocument"] = this.incidentDocument
user_timeline_filters["reviewDocument"] = this.reviewDocument
user_timeline_filters["timezone"] = this.timezone
user_timeline_filters["exportOwner"] = this.exportOwner
this.$store.dispatch("incident/exportDoc", user_timeline_filters)
this.showExportDialog = false
},
Expand Down

0 comments on commit 6679816

Please sign in to comment.