diff --git a/app/views/icons/_device_desktop.html.erb b/app/views/icons/_device_desktop.html.erb new file mode 100644 index 00000000..3a6ba14f --- /dev/null +++ b/app/views/icons/_device_desktop.html.erb @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/app/views/icons/_device_mobile.html.erb b/app/views/icons/_device_mobile.html.erb new file mode 100644 index 00000000..c820a773 --- /dev/null +++ b/app/views/icons/_device_mobile.html.erb @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/views/icons/_device_tablet.html.erb b/app/views/icons/_device_tablet.html.erb new file mode 100644 index 00000000..7dc1b8e4 --- /dev/null +++ b/app/views/icons/_device_tablet.html.erb @@ -0,0 +1,5 @@ + + + + + diff --git a/app/views/submission_events/index.html.erb b/app/views/submission_events/index.html.erb index a0a2b867..02a93b65 100644 --- a/app/views/submission_events/index.html.erb +++ b/app/views/submission_events/index.html.erb @@ -21,6 +21,7 @@

<% @submission.submission_events.order(:event_timestamp).each do |event| %> + <% device = DetectBrowserDevice.call(event.data['ua']) %> <% submitter = @submission.submitters.find { |e| e.id == event.submitter_id } %> <% bg_class = event_colors[submitters_uuids.index(submitter.uuid) % event_colors.length] %> <% submitter_name = event.event_type.include?('sms') || event.event_type.include?('phone') ? (event.data['phone'] || submitter.phone) : (submitter.name || submitter.email || submitter.phone) %> @@ -28,9 +29,14 @@ <%= svg_icon(SubmissionEventsController::SUBMISSION_EVENT_ICONS.fetch(event.event_type, 'circle_dot'), class: 'w-4 h-4') %> -

- <%= l(event.event_timestamp.in_time_zone(current_account.timezone), format: :long, locale: current_account.locale) %> -

+
+ + <%= l(event.event_timestamp.in_time_zone(current_account.timezone), format: :long, locale: current_account.locale) %> + + + <%= svg_icon("device_#{device}", class: 'w-3.5 h-3.5') %> + +

<% if event.event_type == 'complete_verification' %> <%= t('submission_event_names.complete_verification_by_html', provider: event.data['method'], submitter_name:) %> diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index c08944eb..30a30231 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -837,6 +837,9 @@ en: &en connect_google_drive: Connect Google Drive google_drive_has_been_connected: Google Drive has been connected unable_to_identify_reset_your_password_to_sign_in: Unable to identify. Reset your password to sign in. + desktop: Desktop + mobile: Mobile + tablet: Tablet submission_sources: api: API bulk: Bulk Send @@ -1758,6 +1761,9 @@ es: &es connect_google_drive: Conectar Google Drive google_drive_has_been_connected: Google Drive se ha conectado unable_to_identify_reset_your_password_to_sign_in: No se pudo identificar. Restablece tu contraseña para iniciar sesión. + desktop: Escritorio + mobile: Móvil + tablet: Tableta submission_sources: api: API bulk: Envío masivo @@ -2680,6 +2686,9 @@ it: &it connect_google_drive: Connetti Google Drive google_drive_has_been_connected: Google Drive è stato connesso unable_to_identify_reset_your_password_to_sign_in: Impossibile identificare. Reimposta la password per accedere. + desktop: Desktop + mobile: Mobile + tablet: Tablet submission_sources: api: API bulk: Invio massivo @@ -3599,6 +3608,9 @@ fr: &fr connect_google_drive: Connecter Google Drive google_drive_has_been_connected: Google Drive a été connecté unable_to_identify_reset_your_password_to_sign_in: Impossible d’identifier. Réinitialisez votre mot de passe pour vous connecter. + desktop: Bureau + mobile: Mobile + tablet: Tablette submission_sources: api: API bulk: Envoi en masse @@ -4522,6 +4534,9 @@ pt: &pt connect_google_drive: Conectar Google Drive google_drive_has_been_connected: O Google Drive foi conectado unable_to_identify_reset_your_password_to_sign_in: Não foi possível identificar. Redefina sua senha para fazer login. + desktop: Computador + mobile: Celular + tablet: Tablet submission_sources: api: API bulk: Envio em massa @@ -5445,6 +5460,9 @@ de: &de connect_google_drive: Google Drive verbinden google_drive_has_been_connected: Google Drive wurde verbunden unable_to_identify_reset_your_password_to_sign_in: Identifizierung nicht möglich. Setzen Sie Ihr Passwort zurück, um sich anzumelden. + desktop: Desktop + mobile: Mobil + tablet: Tablet submission_sources: api: API bulk: Massenversand @@ -6729,6 +6747,9 @@ nl: &nl connect_google_drive: Verbind Google Drive google_drive_has_been_connected: Google Drive is verbonden unable_to_identify_reset_your_password_to_sign_in: Kan niet worden geïdentificeerd. Stel je wachtwoord opnieuw in om in te loggen. + desktop: Desktop + mobile: Mobiel + tablet: Tablet submission_sources: api: API bulk: Bulkverzending diff --git a/lib/detect_browser_device.rb b/lib/detect_browser_device.rb new file mode 100644 index 00000000..349679f5 --- /dev/null +++ b/lib/detect_browser_device.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module DetectBrowserDevice + module_function + + # rubocop:disable Metrics/LineLength + MOBILE_USER_AGENT_REGEXP = /iPhone|iPod|Android.*Mobile|Opera Mini|Opera Mobi|webOS|IEMobile|Windows Phone|BlackBerry|BB10|Mobile/i + TABLET_USER_AGENT_REGEXP = /iPad|Android(?!.*Mobile)|Tablet|Kindle|PlayBook|Silk/i + # rubocop:enable Metrics/LineLength + + def call(user_agent) + return :mobile if mobile?(user_agent) + return :tablet if tablet?(user_agent) + + :desktop + end + + def mobile?(user_agent) + user_agent.to_s =~ MOBILE_USER_AGENT_REGEXP + end + + def tablet?(user_agent) + user_agent.to_s =~ TABLET_USER_AGENT_REGEXP + end +end