From 3d40add3a72d3b818bdc176cf9f3d4eb4dbc7c9e Mon Sep 17 00:00:00 2001 From: David Whittaker <84562015+whitdog47@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:41:16 -0700 Subject: [PATCH] Set owner column as optional when exporting timeline (#4849) Co-authored-by: Janani Neelamekam --- src/dispatch/event/service.py | 57 +++++++++++++++---- .../src/incident/TimelineExportDialog.vue | 6 +- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/dispatch/event/service.py b/src/dispatch/event/service.py index ce9ca9f84060..ada1de86bce2 100644 --- a/src/dispatch/event/service.py +++ b/src/dispatch/event/service.py @@ -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)) @@ -328,7 +335,7 @@ def export_timeline( }, "fields": "backgroundColor", "tableRange": { - "columnSpan": 3, + "columnSpan": num_columns, "rowSpan": 1, "tableCellLocation": { "columnIndex": 0, @@ -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") @@ -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), }, }, } diff --git a/src/dispatch/static/dispatch/src/incident/TimelineExportDialog.vue b/src/dispatch/static/dispatch/src/incident/TimelineExportDialog.vue index ac9c08fd9724..f33fe1ef3623 100644 --- a/src/dispatch/static/dispatch/src/incident/TimelineExportDialog.vue +++ b/src/dispatch/static/dispatch/src/incident/TimelineExportDialog.vue @@ -38,11 +38,13 @@ At least one must be selected + @@ -99,6 +101,7 @@ export default { timezones: ["UTC", "America/Los_Angeles"], timezone: "UTC", user_timeline_filters: {}, + exportOwner: false, } }, computed: { @@ -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 },