From 9258c70f4e5680ad854c03f01fc3c43b8dfa501e Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Wed, 20 Sep 2023 09:16:22 -0700 Subject: [PATCH] Changing source for custom events and Slack-imported events --- src/dispatch/incident/views.py | 1 + .../plugins/dispatch_slack/incident/interactive.py | 4 ++-- src/dispatch/report/flows.py | 9 ++++++++- .../static/dispatch/src/incident/TimelineTab.vue | 9 ++++++++- src/dispatch/static/dispatch/src/incident/store.js | 10 +++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/dispatch/incident/views.py b/src/dispatch/incident/views.py index f29741e31bc3..37ff3434497a 100644 --- a/src/dispatch/incident/views.py +++ b/src/dispatch/incident/views.py @@ -321,6 +321,7 @@ def create_custom_event( """Creates a custom event.""" background_tasks.add_task( report_flows.log_incident_event, + user_email=current_user.email, incident_id=current_incident.id, event_in=event_in, organization_slug=organization, diff --git a/src/dispatch/plugins/dispatch_slack/incident/interactive.py b/src/dispatch/plugins/dispatch_slack/incident/interactive.py index 4fc1e3c7e861..b89b6e4ae65e 100644 --- a/src/dispatch/plugins/dispatch_slack/incident/interactive.py +++ b/src/dispatch/plugins/dispatch_slack/incident/interactive.py @@ -686,7 +686,7 @@ def handle_timeline_added_event( # we log the event event_service.log_incident_event( db_session=db_session, - source="Slack Plugin - Conversation Management", + source=f"Slack message from {individual.name}", description=f'"{message_text}," said {individual.name}', incident_id=context["subject"].id, individual_id=individual.id, @@ -1043,7 +1043,7 @@ def handle_add_timeline_submission_event( event_service.log_incident_event( db_session=db_session, - source="Slack Plugin - Conversation Management", + source=f"Slack message from {participant.individual.name}", started_at=event_dt_utc, description=f'"{event_description}," said {participant.individual.name}', incident_id=context["subject"].id, diff --git a/src/dispatch/report/flows.py b/src/dispatch/report/flows.py index bd664183178e..b724fba50eca 100644 --- a/src/dispatch/report/flows.py +++ b/src/dispatch/report/flows.py @@ -12,8 +12,8 @@ from dispatch.exceptions import InvalidConfigurationError from dispatch.incident import service as incident_service from dispatch.participant import service as participant_service +from dispatch.individual import service as individual_service from dispatch.plugin import service as plugin_service -from dispatch.event.models import EventCreate from .enums import ReportTypes from .messaging import ( @@ -82,11 +82,18 @@ def create_tactical_report( @background_task def log_incident_event( + user_email: str, incident_id: int, event_in: dict, organization_slug: str = None, db_session=None, ): + incident = incident_service.get(db_session=db_session, incident_id=incident_id) + individual = individual_service.get_by_email_and_project( + db_session=db_session, email=user_email, project_id=incident.project.id + ) + event_in["source"] = f"Custom event created by {individual.name}" + event_service.log_incident_event( db_session=db_session, source=event_in["source"], diff --git a/src/dispatch/static/dispatch/src/incident/TimelineTab.vue b/src/dispatch/static/dispatch/src/incident/TimelineTab.vue index ee82a06e35da..0de6957c2604 100644 --- a/src/dispatch/static/dispatch/src/incident/TimelineTab.vue +++ b/src/dispatch/static/dispatch/src/incident/TimelineTab.vue @@ -23,7 +23,13 @@ >
- + mdi-plus-circle-outlineAdd event
@@ -153,6 +159,7 @@ export default { "showNewEventDialog", "showEditEventDialog", "showDeleteEventDialog", + "showNewPreEventDialog", ]), exportToCSV() { this.exportLoading = true diff --git a/src/dispatch/static/dispatch/src/incident/store.js b/src/dispatch/static/dispatch/src/incident/store.js index 5b211399943b..423225559f00 100644 --- a/src/dispatch/static/dispatch/src/incident/store.js +++ b/src/dispatch/static/dispatch/src/incident/store.js @@ -5,6 +5,8 @@ import SearchUtils from "@/search/utils" import IncidentApi from "@/incident/api" import router from "@/router" +import moment from "moment-timezone" + const getDefaultSelectedState = () => { return { cases: [], @@ -249,8 +251,14 @@ const actions = { closeEditEventDialog({ commit }) { commit("SET_DIALOG_EDIT_EVENT", false) }, + showNewPreEventDialog({ commit }, started_at) { + started_at = moment(started_at).subtract(1, "seconds").toISOString() + state.selected.currentEvent = { started_at, description: "" } + commit("SET_DIALOG_EDIT_EVENT", true) + }, showNewEventDialog({ commit }, started_at) { - state.selected.currentEvent = { started_at } + started_at = moment(started_at).add(1, "seconds").toISOString() + state.selected.currentEvent = { started_at, description: "" } commit("SET_DIALOG_EDIT_EVENT", true) }, showDeleteEventDialog({ commit }, event) {