renalware-core 2.0.145 → 2.0.151
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -2
- data/app/assets/config/renalware/core/manifest.js +1 -0
- data/app/assets/images/renalware/icons/align-justify.svg +3 -0
- data/app/assets/images/renalware/icons/bar-chart.svg +1 -0
- data/app/assets/images/renalware/icons/chart-bar.svg +1 -0
- data/app/assets/images/renalware/icons/chart.svg +3 -0
- data/app/assets/images/renalware/icons/list-bullet.svg +1 -0
- data/app/assets/images/renalware/icons/list.svg +8 -0
- data/app/assets/javascripts/renalware/README.md +25 -1
- data/app/assets/javascripts/renalware/charting.js +1 -1
- data/app/assets/javascripts/renalware/components/ajax_errors.js +3 -2
- data/app/assets/javascripts/renalware/components/dialogs.js.erb +5 -3
- data/app/assets/javascripts/renalware/components/hd.js +2 -2
- data/app/assets/javascripts/renalware/components/letters.js +1 -1
- data/app/assets/javascripts/renalware/components/masonry.run.js +2 -2
- data/app/assets/javascripts/renalware/components/patient_menu.js +1 -1
- data/app/assets/javascripts/renalware/components/session_timeout_redirect.js.erb +26 -18
- data/app/assets/javascripts/renalware/components/toggler.js +1 -1
- data/app/assets/javascripts/renalware/core.js.erb +2 -0
- data/app/assets/javascripts/renalware/rollup_compiled.css +87457 -0
- data/app/assets/javascripts/renalware/rollup_compiled.js +3440 -7
- data/app/assets/stylesheets/renalware/core.scss +1 -0
- data/app/assets/stylesheets/renalware/modules/_hd.scss +8 -4
- data/app/assets/stylesheets/renalware/modules/_letters.scss +17 -0
- data/app/assets/stylesheets/renalware/modules/_pathology.scss +8 -1
- data/app/assets/stylesheets/renalware/modules/_pd.scss +35 -0
- data/app/assets/stylesheets/renalware/modules/_surveys.scss +5 -0
- data/app/assets/stylesheets/renalware/partials/_charting.scss +17 -0
- data/app/assets/stylesheets/renalware/partials/_forms.scss +10 -1
- data/app/assets/stylesheets/renalware/partials/_simple_form.scss +10 -2
- data/app/assets/stylesheets/renalware/partials/_utilities.scss +12 -0
- data/app/assets/stylesheets/tailwind/tailwind.css +3 -0
- data/app/components/renalware/application_component.rb +2 -1
- data/app/components/renalware/events/{biopsies_component.html.slim → event_list_component.html.slim} +5 -4
- data/app/components/renalware/events/event_list_component.rb +77 -0
- data/app/components/renalware/hd/administer_prescription_dropdown_component.html.slim +1 -1
- data/app/components/renalware/hd/administer_prescription_dropdown_component.rb +1 -5
- data/app/components/renalware/hd/prescription_last_administration_component.html.slim +0 -1
- data/app/components/renalware/hd/prescription_last_administration_component.rb +8 -7
- data/app/components/renalware/letters/unread_electronic_ccs_component.rb +1 -0
- data/app/components/renalware/pathology/chart_component.html.slim +5 -0
- data/app/components/renalware/pathology/chart_component.rb +40 -0
- data/app/components/renalware/pathology/sparkline_component.html.slim +15 -0
- data/app/components/renalware/pathology/sparkline_component.rb +135 -0
- data/app/components/renalware/patients/side_menu_component.rb +2 -11
- data/app/components/renalware/pd/adequacy_results_component.html.slim +9 -0
- data/app/components/renalware/pd/adequacy_results_component.rb +39 -0
- data/app/components/renalware/pd/pet_results_component.html.slim +37 -0
- data/app/components/renalware/pd/pet_results_component.rb +84 -0
- data/app/{views/renalware/surveys/_eq5d_summary_part.html.slim → components/renalware/surveys/eq5d_component.html.slim} +5 -5
- data/app/{models/renalware/surveys/eq5d_summary_part.rb → components/renalware/surveys/eq5d_component.rb} +7 -5
- data/app/{views/renalware/surveys/_pos_s_summary_part.html.slim → components/renalware/surveys/pos_s_component.html.slim} +8 -9
- data/app/{models/renalware/surveys/pos_s_summary_part.rb → components/renalware/surveys/pos_s_component.rb} +11 -7
- data/app/components/renalware/system/admin_menu_component.html.slim +2 -0
- data/app/components/renalware/system/admin_menu_component.rb +2 -2
- data/app/components/renalware/system/article_component.html.slim +3 -0
- data/app/components/renalware/system/article_component.rb +9 -0
- data/app/controllers/renalware/admin/playgrounds_controller.rb +65 -0
- data/app/controllers/renalware/admissions/consults_controller.rb +1 -1
- data/app/controllers/renalware/base_controller.rb +3 -3
- data/app/controllers/renalware/concerns/pdf_renderable.rb +1 -1
- data/app/controllers/renalware/deaths_controller.rb +6 -5
- data/app/controllers/renalware/hd/scheduling/diaries_controller.rb +1 -1
- data/app/controllers/renalware/letters/mailshots/mailshots_controller.rb +53 -0
- data/app/controllers/renalware/letters/mailshots/patient_previews_controller.rb +41 -0
- data/app/controllers/renalware/medications/home_delivery/events_controller.rb +0 -3
- data/app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb +43 -0
- data/app/controllers/renalware/medications/prescriptions_controller.rb +1 -1
- data/app/controllers/renalware/pathology/charts_controller.rb +21 -0
- data/app/controllers/renalware/pathology/current_observation_results_controller.rb +1 -1
- data/app/controllers/renalware/pathology/historical_observation_results_controller.rb +1 -1
- data/app/controllers/renalware/pathology/nearest_observation_results_controller.rb +52 -0
- data/app/controllers/renalware/pathology/observation_requests_controller.rb +1 -1
- data/app/controllers/renalware/pathology/observations_controller.rb +26 -2
- data/app/controllers/renalware/pathology/requests/requests_controller.rb +7 -5
- data/app/controllers/renalware/patients/primary_care_physician_controller.rb +6 -0
- data/app/controllers/renalware/pd/adequacy_completions_controller.rb +18 -0
- data/app/controllers/renalware/pd/adequacy_results_controller.rb +98 -0
- data/app/controllers/renalware/pd/pet_completions_controller.rb +18 -0
- data/app/controllers/renalware/pd/pet_results_controller.rb +122 -0
- data/app/controllers/renalware/pd/unified_pet_adequacies_controller.rb +102 -0
- data/app/controllers/renalware/renal/aki_alerts_controller.rb +1 -1
- data/app/controllers/renalware/renal/registry_preflight_checks_controller.rb +55 -19
- data/app/controllers/renalware/session_timeout_controller.rb +20 -17
- data/app/documents/renalware/age.rb +3 -1
- data/app/helpers/renalware/application_helper.rb +7 -7
- data/app/helpers/renalware/article_helper.rb +3 -3
- data/app/helpers/renalware/boolean_helper.rb +15 -0
- data/app/helpers/renalware/clipboard_helper.rb +2 -3
- data/app/helpers/renalware/dashboards_helper.rb +2 -2
- data/app/helpers/renalware/definition_list_helper.rb +3 -3
- data/app/helpers/renalware/devise_helper.rb +1 -1
- data/app/helpers/renalware/form_helper.rb +2 -2
- data/app/helpers/renalware/letters_helper.rb +1 -1
- data/app/helpers/renalware/link_helper.rb +1 -1
- data/app/helpers/renalware/mdm_helper.rb +1 -0
- data/app/helpers/renalware/navigation_helper.rb +1 -1
- data/app/helpers/renalware/patient_helper.rb +2 -2
- data/app/helpers/renalware/snippets_helper.rb +9 -10
- data/app/helpers/renalware/toggle_helper.rb +6 -6
- data/app/helpers/renalware/tooltip_helper.rb +14 -16
- data/app/inputs/clock_picker_input.rb +3 -3
- data/app/inputs/date_picker_input.rb +3 -3
- data/app/inputs/simple_time_input.rb +3 -3
- data/app/inputs/trix_editor_input.rb +2 -0
- data/app/javascript/renalware/controllers/blas_controller.js +37 -0
- data/app/javascript/renalware/controllers/charts_controller.js +52 -0
- data/app/javascript/renalware/controllers/medications/prescriptions_controller.js +24 -0
- data/app/javascript/renalware/controllers/modal_controller.js +137 -0
- data/app/javascript/renalware/controllers/pathology/sparklines_controller.js +206 -0
- data/app/javascript/renalware/controllers/pd/pet_charts_controller.js +169 -0
- data/app/javascript/renalware/controllers/session_controller.js +223 -0
- data/app/javascript/renalware/controllers/simple_toggle_controller.js +17 -0
- data/app/javascript/renalware/controllers/tabs_controller.js +43 -0
- data/app/javascript/renalware/controllers/toggle_controller.js +2 -2
- data/app/javascript/renalware/index.js +18 -0
- data/app/jobs/renalware/letters/mailshots/create_mailshot_letters_job.rb +27 -0
- data/app/models/concerns/renalware/patients_ransack_helper.rb +2 -0
- data/app/models/renalware/accesses/assessment.rb +5 -1
- data/app/models/renalware/accesses/procedure.rb +4 -1
- data/app/models/renalware/accesses/profile.rb +4 -1
- data/app/models/renalware/clinical/body_composition.rb +4 -1
- data/app/models/renalware/clinical/dry_weight.rb +4 -1
- data/app/models/renalware/clinics/body_surface_area.rb +40 -0
- data/app/models/renalware/clinics/clinic_visit.rb +26 -2
- data/app/models/renalware/clinics/total_body_water.rb +63 -0
- data/app/models/renalware/events/advanced_care_plan.rb +24 -0
- data/app/models/renalware/events/clinical_frailty_score.rb +24 -0
- data/app/models/renalware/feeds/hl7_message.rb +1 -0
- data/app/models/renalware/hd/preference_set.rb +4 -1
- data/app/models/renalware/hd/prescription_last_administration_query.rb +4 -0
- data/app/models/renalware/hd/profile.rb +5 -2
- data/app/models/renalware/hd/session.rb +4 -1
- data/app/models/renalware/hd/session_forms/pdf_renderer.rb +1 -1
- data/app/models/renalware/hd/sessions/auditable_session_collection.rb +4 -1
- data/app/models/renalware/letters.rb +6 -0
- data/app/models/renalware/letters/draft_letter.rb +1 -0
- data/app/models/renalware/letters/html_renderer.rb +1 -1
- data/app/models/renalware/letters/letter_factory.rb +1 -1
- data/app/models/renalware/letters/mailshots/data_source.rb +20 -0
- data/app/models/renalware/letters/mailshots/item.rb +17 -0
- data/app/models/renalware/letters/mailshots/mailshot.rb +117 -0
- data/app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb +1 -1
- data/app/models/renalware/letters/recipient_address_pdf_renderer.rb +1 -1
- data/app/models/renalware/low_clearance/profile.rb +5 -2
- data/app/models/renalware/medications.rb +2 -0
- data/app/models/renalware/medications/delivery/prescriptions_due_for_delivery_query.rb +53 -0
- data/app/models/renalware/medications/prescription.rb +4 -2
- data/app/models/renalware/pathology/code_group.rb +3 -1
- data/app/models/renalware/pathology/code_group_membership.rb +4 -1
- data/app/models/renalware/pathology/nearest_observations_query.rb +44 -0
- data/app/models/renalware/pathology/observations_jsonb_serializer.rb +1 -1
- data/app/models/renalware/patient.rb +24 -2
- data/app/models/renalware/patients/alert.rb +1 -0
- data/app/models/renalware/patients/clear_patient_ukrdc_data.rb +6 -1
- data/app/models/renalware/patients/deceased_patients_query.rb +42 -0
- data/app/models/renalware/patients/ingestion/update_master_patient_index.rb +1 -0
- data/app/models/renalware/patients/patient_hospital_identifiers.rb +1 -0
- data/app/models/renalware/patients/worry.rb +5 -1
- data/app/models/renalware/pd.rb +2 -0
- data/app/models/renalware/pd/adequacy_calculated_attributes.rb +159 -0
- data/app/models/renalware/pd/adequacy_result.rb +76 -0
- data/app/models/renalware/pd/apd/glucose_calculator.rb +1 -0
- data/app/models/renalware/pd/patient.rb +4 -0
- data/app/models/renalware/pd/pet_dextrose_concentration.rb +17 -0
- data/app/models/renalware/pd/pet_result.rb +92 -0
- data/app/models/renalware/pd/unified_pet_adequacy_form.rb +46 -0
- data/app/models/renalware/problems/problem.rb +5 -1
- data/app/models/renalware/renal/aki_alert.rb +4 -1
- data/app/models/renalware/renal/profile.rb +4 -1
- data/app/models/renalware/renal/registry/preflight_checks/missing_esrf_query.rb +50 -0
- data/app/models/renalware/snippets/duplicate_snippet_title_generator.rb +1 -0
- data/app/models/renalware/surveys/question.rb +4 -0
- data/app/models/renalware/transplants/donation.rb +4 -2
- data/app/models/renalware/transplants/donor_followup.rb +4 -2
- data/app/models/renalware/transplants/donor_operation.rb +4 -2
- data/app/models/renalware/transplants/donor_workup.rb +4 -2
- data/app/models/renalware/transplants/recipient_followup.rb +5 -2
- data/app/models/renalware/transplants/recipient_operation.rb +5 -2
- data/app/models/renalware/transplants/recipient_workup.rb +5 -2
- data/app/models/renalware/transplants/recipient_workup_builder.rb +1 -0
- data/app/models/renalware/transplants/registration.rb +5 -2
- data/app/models/renalware/transplants/registration_status.rb +1 -1
- data/app/models/renalware/transplants/rejection_episode.rb +1 -1
- data/app/models/renalware/ukrdc/{batch_number.rb → batch.rb} +1 -1
- data/app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb +49 -24
- data/app/models/renalware/ukrdc/create_patient_xml_file.rb +4 -5
- data/app/models/renalware/ukrdc/housekeeping/remove_old_export_archive_folders.rb +3 -3
- data/app/models/renalware/ukrdc/housekeeping/remove_stale_files.rb +2 -2
- data/app/models/renalware/ukrdc/incoming/import_surveys.rb +1 -2
- data/app/models/renalware/ukrdc/outgoing/rendering/patient_number.rb +1 -1
- data/app/models/renalware/ukrdc/transmission_log.rb +3 -2
- data/app/models/renalware/user.rb +10 -0
- data/app/pdfs/renalware/events/event_pdf.rb +1 -0
- data/app/policies/renalware/events/advanced_care_plan_policy.rb +10 -0
- data/app/policies/renalware/events/clinical_frailty_score_policy.rb +10 -0
- data/app/policies/renalware/letters/mailshots/mailshot_policy.rb +21 -0
- data/app/policies/renalware/pd/adequacy_result_policy.rb +15 -0
- data/app/policies/renalware/pd/pet_result_policy.rb +15 -0
- data/app/policies/renalware/renal/registry_preflight_check_policy.rb +4 -0
- data/app/presenters/renalware/clinical/profile_presenter.rb +1 -0
- data/app/presenters/renalware/hd/dashboard_presenter.rb +1 -0
- data/app/presenters/renalware/hd/profile_presenter.rb +1 -0
- data/app/presenters/renalware/hd/scheduling/diary_presenter.rb +1 -0
- data/app/presenters/renalware/hd/session_presenter.rb +1 -0
- data/app/presenters/renalware/hd/unmet_preferences_presenter.rb +1 -1
- data/app/presenters/renalware/mdm_patients_presenter.rb +1 -0
- data/app/presenters/renalware/pd/dashboard_presenter.rb +10 -2
- data/app/presenters/renalware/ukrdc/patient_presenter.rb +1 -0
- data/app/presenters/renalware/user_session_presenter.rb +44 -0
- data/app/validators/renalware/patients/nhs_number_validator.rb +88 -0
- data/app/values/renalware/address.rb +1 -0
- data/app/views/renalware/accesses/assessments/_form.html.slim +2 -2
- data/app/views/renalware/accesses/assessments/show.html.slim +1 -1
- data/app/views/renalware/accesses/plans/new.html.slim +1 -1
- data/app/views/renalware/accesses/procedures/_form.html.slim +2 -2
- data/app/views/renalware/accesses/procedures/show.html.slim +1 -1
- data/app/views/renalware/accesses/profiles/_form.html.slim +2 -2
- data/app/views/renalware/accesses/profiles/show.html.slim +1 -1
- data/app/views/renalware/admin/cache/show.html.slim +36 -0
- data/app/views/renalware/admin/playgrounds/pathology_chart_data.js.erb +1 -0
- data/app/views/renalware/admin/playgrounds/show.html.slim +62 -0
- data/app/views/renalware/admin/users/_filters.html.slim +1 -1
- data/app/views/renalware/admin/users/edit.html.slim +1 -1
- data/app/views/renalware/admissions/admissions/_filters.html.slim +1 -1
- data/app/views/renalware/admissions/admissions/_form.html.slim +1 -1
- data/app/views/renalware/admissions/admissions/index.html.slim +2 -2
- data/app/views/renalware/admissions/consults/_filters.html.slim +1 -1
- data/app/views/renalware/admissions/consults/_form.html.slim +20 -19
- data/app/views/renalware/admissions/consults/index.html.slim +2 -2
- data/app/views/renalware/admissions/requests/_form.html.slim +1 -1
- data/app/views/renalware/clinical/allergies/_new.html.slim +1 -1
- data/app/views/renalware/clinical/body_compositions/_form.html.slim +1 -1
- data/app/views/renalware/clinical/dry_weights/_form.html.slim +1 -1
- data/app/views/renalware/clinical/profiles/edit.html.slim +1 -1
- data/app/views/renalware/clinical/profiles/show.html.slim +11 -1
- data/app/views/renalware/clinics/clinic_visits/_table.html.slim +2 -0
- data/app/views/renalware/clinics/clinic_visits/_table_row.html.slim +2 -0
- data/app/views/renalware/clinics/clinic_visits/new.html.slim +1 -1
- data/app/views/renalware/clinics/visits/_filters.html.slim +1 -1
- data/app/views/renalware/dashboard/letters/_letter.html.slim +1 -1
- data/app/views/renalware/deaths/edit.html.slim +1 -1
- data/app/views/renalware/deaths/index.html.slim +18 -10
- data/app/views/renalware/directory/people/_filters.html.slim +1 -1
- data/app/views/renalware/directory/people/_form.html.slim +1 -1
- data/app/views/renalware/directory/people/show.html.slim +1 -1
- data/app/views/renalware/drugs/drugs/_filters.html.slim +1 -1
- data/app/views/renalware/drugs/drugs/_form.html.slim +1 -1
- data/app/views/renalware/events/advanced_care_plans/_cell.html.slim +2 -0
- data/app/views/renalware/events/advanced_care_plans/_inputs.html.slim +4 -0
- data/app/views/renalware/events/advanced_care_plans/_toggled_cell.html.slim +8 -0
- data/app/views/renalware/events/clinical_frailty_score/_cell.html.slim +2 -0
- data/app/views/renalware/events/clinical_frailty_score/_inputs.html.slim +4 -0
- data/app/views/renalware/events/clinical_frailty_score/_toggled_cell.html.slim +8 -0
- data/app/views/renalware/events/events/_filters.html.slim +1 -1
- data/app/views/renalware/events/events/_form.html.slim +1 -1
- data/app/views/renalware/events/events/_table.html.slim +1 -1
- data/app/views/renalware/events/events/toggled_cell/_biopsy.html.slim +1 -1
- data/app/views/renalware/events/events/toggled_cell/_simple.html.slim +1 -1
- data/app/views/renalware/events/events/toggled_cell/_swab.html.slim +1 -1
- data/app/views/renalware/events/lists/_filters.html.slim +1 -1
- data/app/views/renalware/events/types/_form.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/_form.html.slim +1 -1
- data/app/views/renalware/hd/current_profile/_form.html.slim +2 -2
- data/app/views/renalware/hd/current_profile/_show.html.slim +1 -1
- data/app/views/renalware/hd/current_profile/show.html.slim +1 -1
- data/app/views/renalware/hd/dialysates/_form.html.slim +1 -1
- data/app/views/renalware/hd/dialysers/_form.html.slim +1 -1
- data/app/views/renalware/hd/mdm_patients/_filters.html.slim +1 -1
- data/app/views/renalware/hd/ongoing_sessions/_filters.html.slim +1 -1
- data/app/views/renalware/hd/preference_sets/_form.html.slim +1 -1
- data/app/views/renalware/hd/prescription_administrations/_form.html.slim +4 -2
- data/app/views/renalware/hd/prescription_administrations/_row.html.slim +1 -1
- data/app/views/renalware/hd/prescription_administrations/new.js.erb +1 -1
- data/app/views/renalware/hd/protocols/_protocol.pdf.slim +39 -38
- data/app/views/renalware/hd/scheduling/diary_slots/_slot.html.slim +2 -1
- data/app/views/renalware/hd/sessions/_form_actions.html.slim +1 -1
- data/app/views/renalware/hd/sessions/_show.html.slim +1 -1
- data/app/views/renalware/hd/stations/_form.html.slim +1 -1
- data/app/views/renalware/hd/transmission_logs/index.html.slim +1 -2
- data/app/views/renalware/hd/unmet_preferences/_filters.html.slim +1 -1
- data/app/views/renalware/hd/witnesses/_form.html.slim +5 -3
- data/app/views/renalware/hospitals/units/_form.html.slim +1 -1
- data/app/views/renalware/letters/contacts/_contact.html.slim +1 -1
- data/app/views/renalware/letters/contacts/_edit.html.slim +1 -1
- data/app/views/renalware/letters/contacts/_new_person.html.slim +1 -1
- data/app/views/renalware/letters/contacts/_person_from_directory.html.slim +1 -1
- data/app/views/renalware/letters/electronic_receipts/_table.html.slim +1 -1
- data/app/views/renalware/letters/letters/_form.html.slim +2 -2
- data/app/views/renalware/letters/letters/index.html.slim +4 -0
- data/app/views/renalware/letters/lists/show.html.slim +1 -1
- data/app/views/renalware/letters/mailshots/mailshots/_form.html.slim +61 -0
- data/app/views/renalware/letters/mailshots/mailshots/index.html.slim +31 -0
- data/app/views/renalware/letters/mailshots/mailshots/new.html.slim +2 -0
- data/app/views/renalware/letters/mailshots/patient_previews/_index.html.slim +26 -0
- data/app/views/renalware/letters/mailshots/patient_previews/index.js.erb +1 -0
- data/app/views/renalware/low_clearance/dashboards/show.html.slim +10 -0
- data/app/views/renalware/low_clearance/profiles/edit.html.slim +1 -1
- data/app/views/renalware/mdm/_pathology.html.slim +0 -1
- data/app/views/renalware/mdm/show.html.slim +1 -1
- data/app/views/renalware/mdm_patients/_patient.html.slim +1 -2
- data/app/views/renalware/medications/drug_types/prescriptions/_filters.html.slim +1 -3
- data/app/views/renalware/medications/home_delivery/prescriptions/index.html.slim +51 -0
- data/app/views/renalware/medications/prescriptions/_filter_form.html.slim +1 -1
- data/app/views/renalware/medications/prescriptions/_form.html.slim +21 -13
- data/app/views/renalware/medications/prescriptions/index.html.slim +1 -1
- data/app/views/renalware/medications/terminations/_form.html.slim +1 -1
- data/app/views/renalware/messaging/internal/messages/_form.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/_form.html.slim +1 -1
- data/app/views/renalware/modalities/modalities/new.html.slim +1 -1
- data/app/views/renalware/navigation/_menu.html.slim +1 -0
- data/app/views/renalware/navigation/_pd.html.slim +5 -0
- data/app/views/renalware/navigation/_renal.html.slim +2 -0
- data/app/views/renalware/navigation/_sign_out.html.slim +5 -1
- data/app/views/renalware/pathology/charts/show.html.slim +11 -0
- data/app/views/renalware/pathology/current_observation_results/index.html.slim +6 -0
- data/app/views/renalware/pathology/historical_observation_results/_table.html.slim +4 -3
- data/app/views/renalware/pathology/historical_observation_results/index.html.slim +1 -1
- data/app/views/renalware/pathology/observation_requests/_filters.html.slim +1 -1
- data/app/views/renalware/pathology/observations/_diff.html.slim +1 -1
- data/app/views/renalware/pathology/patient_rules/_form.html.slim +1 -1
- data/app/views/renalware/pathology/requests/requests/index.html.slim +1 -1
- data/app/views/renalware/patients/_header.html.slim +1 -1
- data/app/views/renalware/patients/alerts/_alert.html.slim +1 -1
- data/app/views/renalware/patients/alerts/_form.html.slim +2 -2
- data/app/views/renalware/patients/bookmarks/_new.html.slim +1 -1
- data/app/views/renalware/patients/patients/_form.html.slim +1 -2
- data/app/views/renalware/patients/patients/new.html.slim +6 -5
- data/app/views/renalware/patients/patients/show.html.slim +1 -1
- data/app/views/renalware/patients/patients/show/_primary_care_physician.html.slim +10 -2
- data/app/views/renalware/patients/primary_care_physician/destroy.js.erb +1 -0
- data/app/views/renalware/patients/primary_care_physicians/_form.html.slim +1 -1
- data/app/views/renalware/patients/worries/_new.html.slim +1 -1
- data/app/views/renalware/patients/worryboard/_filters.html.slim +1 -1
- data/app/views/renalware/pd/_exit_site_infections.html.slim +4 -0
- data/app/views/renalware/pd/_peritonitis_episodes.html.slim +3 -0
- data/app/views/renalware/pd/adequacy_completions/_filters.html.slim +19 -0
- data/app/views/renalware/pd/adequacy_completions/index.html.slim +4 -0
- data/app/views/renalware/pd/adequacy_results/_form_fields.html.slim +9 -0
- data/app/views/renalware/pd/adequacy_results/_table.html.slim +72 -0
- data/app/views/renalware/pd/adequacy_results/edit.html.slim +89 -0
- data/app/views/renalware/pd/adequacy_results/index.js.erb +1 -0
- data/app/views/renalware/pd/adequacy_results/new.html.slim +8 -0
- data/app/views/renalware/pd/assessments/_form.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/_form.html.slim +1 -1
- data/app/views/renalware/pd/dashboards/show.html.slim +3 -0
- data/app/views/renalware/pd/dashboards/show/_page_actions.html.slim +16 -2
- data/app/views/renalware/pd/exit_site_infections/_form.html.slim +1 -1
- data/app/views/renalware/pd/exit_site_infections/edit.html.slim +1 -1
- data/app/views/renalware/pd/exit_site_infections/new.html.slim +1 -1
- data/app/views/renalware/pd/exit_site_infections/show.html.slim +1 -1
- data/app/views/renalware/pd/infection_organisms/_form.html.slim +1 -1
- data/app/views/renalware/pd/peritonitis_episodes/_form.html.slim +1 -1
- data/app/views/renalware/pd/peritonitis_episodes/edit.html.slim +1 -1
- data/app/views/renalware/pd/peritonitis_episodes/new.html.slim +1 -1
- data/app/views/renalware/pd/peritonitis_episodes/show.html.slim +1 -1
- data/app/views/renalware/pd/pet_adequacy_results/_form.html.slim +1 -1
- data/app/views/renalware/pd/pet_completions/_filters.html.slim +24 -0
- data/app/views/renalware/pd/pet_completions/index.html.slim +4 -0
- data/app/views/renalware/pd/pet_results/_form_fields.html.slim +12 -0
- data/app/views/renalware/pd/pet_results/_pathology_results.html.slim +36 -0
- data/app/views/renalware/pd/pet_results/_table.html.slim +62 -0
- data/app/views/renalware/pd/pet_results/edit.html.slim +35 -0
- data/app/views/renalware/pd/pet_results/index.js.erb +1 -0
- data/app/views/renalware/pd/pet_results/new.html.slim +8 -0
- data/app/views/renalware/pd/regimes/edit.html.slim +1 -1
- data/app/views/renalware/pd/regimes/new.html.slim +1 -1
- data/app/views/renalware/pd/training_sessions/_form.html.slim +1 -1
- data/app/views/renalware/pd/unified_pet_adequacies/_form.html.slim +22 -0
- data/app/views/renalware/pd/unified_pet_adequacies/new.html.slim +2 -0
- data/app/views/renalware/problems/notes/_form.html.slim +1 -1
- data/app/views/renalware/problems/problems/edit.html.slim +1 -1
- data/app/views/renalware/problems/problems/new.html.slim +1 -1
- data/app/views/renalware/renal/aki_alerts/_filters.html.slim +1 -1
- data/app/views/renalware/renal/aki_alerts/edit.html.slim +1 -1
- data/app/views/renalware/renal/profiles/edit.html.slim +2 -2
- data/app/views/renalware/renal/profiles/show.html.slim +1 -1
- data/app/views/renalware/renal/registry_preflight_checks/_filters.html.slim +6 -4
- data/app/views/renalware/renal/registry_preflight_checks/_navigation.html.slim +1 -0
- data/app/views/renalware/renal/registry_preflight_checks/deaths.html.slim +2 -1
- data/app/views/renalware/renal/registry_preflight_checks/missing_esrf.html.slim +12 -0
- data/app/views/renalware/renal/registry_preflight_checks/patients.html.slim +1 -2
- data/app/views/renalware/reporting/audits/edit.html.slim +1 -3
- data/app/views/renalware/research/_alert.html.slim +1 -1
- data/app/views/renalware/research/studies/_filters.html.slim +1 -1
- data/app/views/renalware/research/study_participants/_filters.html.slim +1 -1
- data/app/views/renalware/snippets/snippets/_row.html.slim +3 -4
- data/app/views/renalware/surveys/dashboards/show.html.slim +2 -2
- data/app/views/renalware/system/downloads/index.html.slim +3 -4
- data/app/views/renalware/transplants/donations/_form.html.slim +2 -2
- data/app/views/renalware/transplants/donor_followups/_form.html.slim +2 -2
- data/app/views/renalware/transplants/donor_operations/_form.html.slim +2 -2
- data/app/views/renalware/transplants/donor_stages/new.html.slim +1 -1
- data/app/views/renalware/transplants/donor_workups/_form.html.slim +2 -2
- data/app/views/renalware/transplants/donor_workups/show.html.slim +1 -1
- data/app/views/renalware/transplants/live_donors/_filters.html.slim +2 -2
- data/app/views/renalware/transplants/mdm/_bottom.html.slim +3 -1
- data/app/views/renalware/transplants/recipient_followups/_form.html.slim +2 -2
- data/app/views/renalware/transplants/recipient_followups/show.html.slim +1 -1
- data/app/views/renalware/transplants/recipient_operations/_form.html.slim +2 -2
- data/app/views/renalware/transplants/recipient_operations/show.html.slim +1 -1
- data/app/views/renalware/transplants/recipient_workups/_form.html.slim +2 -2
- data/app/views/renalware/transplants/recipient_workups/show.html.slim +1 -1
- data/app/views/renalware/transplants/registration_statuses/_form.html.slim +1 -1
- data/app/views/renalware/transplants/registrations/_form.html.slim +2 -2
- data/app/views/renalware/transplants/registrations/show.html.slim +1 -1
- data/app/views/renalware/transplants/wait_lists/show.html.slim +1 -1
- data/app/views/renalware/virology/profiles/edit.html.slim +1 -1
- data/config/initializers/groupdate.rb +3 -0
- data/config/initializers/inflections.rb +8 -0
- data/config/initializers/paper_trail.rb +1 -1
- data/config/initializers/simple_form_wrappers.rb +14 -9
- data/config/initializers/wicked_pdf.rb +12 -0
- data/config/locales/en-GB.yml +1 -1
- data/config/locales/renalware/events/advanced_care_plan.en.yml +12 -0
- data/config/locales/renalware/events/biopsy.en.yml +2 -0
- data/config/locales/renalware/events/clinical_frailty_score.en.yml +16 -0
- data/config/locales/renalware/events/clinical_frailty_score_component.en.yml +8 -0
- data/config/locales/renalware/medications/prescription.yml +2 -1
- data/config/locales/renalware/navigation/renal.en.yml +1 -0
- data/config/locales/renalware/nhs_number.en.yml +6 -0
- data/config/locales/renalware/pd/adequacy_result.en.yml +9 -0
- data/config/locales/renalware/pd/dashboard.en.yml +3 -0
- data/config/locales/renalware/pd/pet_result.en.yml +23 -0
- data/config/locales/renalware/renal/registry.en.yml +1 -0
- data/config/routes/admin.rb +5 -0
- data/config/routes/letters.rb +5 -0
- data/config/routes/medications.rb +5 -0
- data/config/routes/pathology.rb +6 -0
- data/config/routes/patients.rb +1 -1
- data/config/routes/pd.rb +5 -0
- data/config/routes/renal.rb +1 -0
- data/config/routes/system.rb +2 -1
- data/db/functions/generate_secure_id_v01.sql +1 -1
- data/db/functions/pathology_chart_data_v01.sql +13 -0
- data/db/migrate/20200226145010_add_unique_indexes.rb +46 -0
- data/db/migrate/20200313120655_create_pathology_chart_data_function.rb +13 -0
- data/db/migrate/20200318134807_create_letter_mailshots.rb +50 -0
- data/db/migrate/20200320103052_add_status_to_letter_mailshot_mailshots.rb +14 -0
- data/db/migrate/20200401115705_add_label_abbrv_to_survey_questions.rb +12 -0
- data/db/migrate/20200408131217_associate_batch_with_ukrdc_transmission_log.rb +15 -0
- data/db/migrate/20200421082715_add_body_surface_area_to_clinic_visits.rb +8 -0
- data/db/migrate/20200421132911_create_pd_pet_dextrose_concentrations.rb +13 -0
- data/db/migrate/20200421143546_create_pet_results.rb +66 -0
- data/db/migrate/20200427123229_create_adequacy_results.rb +54 -0
- data/db/migrate/20200616115709_add_height_weight_to_pd_adequacy_results.rb +8 -0
- data/db/migrate/20200618144228_add_feature_flags_to_users.rb +14 -0
- data/db/seeds/default/events/event_types.csv +2 -0
- data/db/seeds/seeds_helper.rb +8 -2
- data/lib/renalware/configuration.rb +6 -0
- data/lib/renalware/engine.rb +7 -3
- data/lib/renalware/version_number.rb +11 -0
- data/lib/tasks/renalware.rake +7 -1
- data/spec/factories/accesses/profiles.rb +1 -0
- data/spec/factories/events/events_types.rb +12 -0
- data/spec/factories/patients/patients.rb +22 -1
- data/spec/factories/pd/adequacy_results.rb +16 -0
- data/spec/factories/pd/pet_results.rb +9 -0
- data/spec/support/pages/letters/mailshots/form.rb +58 -0
- data/spec/support/pages/medications/prescription_fom.rb +2 -2
- data/spec/support/shared_examples/supersedable_examples.rb +2 -2
- data/vendor/assets/javascripts/renalware/highcharts.js +505 -0
- data/vendor/assets/javascripts/renalware/highcharts.js.map +1 -0
- metadata +184 -35
- data/app/components/renalware/events/biopsies_component.rb +0 -20
- data/app/views/renalware/medications/home_delivery/prescriptions/index.pdf.slim +0 -103
- data/lib/renalware/version.rb +0 -5
@@ -0,0 +1,169 @@
|
|
1
|
+
// NB Chartkick and Highcharts are defined as global in rollup
|
2
|
+
const Highcharts = window.Highcharts // Highcharts is defined as global in rollup
|
3
|
+
const $ = window.$
|
4
|
+
import { Controller } from "stimulus"
|
5
|
+
import more from "highcharts/highcharts-more"
|
6
|
+
more(Highcharts)
|
7
|
+
|
8
|
+
export default class extends Controller {
|
9
|
+
connect() {
|
10
|
+
$.getJSON(
|
11
|
+
this.data.get("url"),
|
12
|
+
(data) => {
|
13
|
+
Highcharts.chart(this.element, {
|
14
|
+
chart: {
|
15
|
+
scrollablePlotArea: {
|
16
|
+
minWidth: 600,
|
17
|
+
scrollPositionX: 1
|
18
|
+
}
|
19
|
+
},
|
20
|
+
title: {
|
21
|
+
//text: "Peritoneal Equilibration Test",
|
22
|
+
text: "",
|
23
|
+
align: "left"
|
24
|
+
},
|
25
|
+
subtitle: {
|
26
|
+
text: "",
|
27
|
+
align: "left"
|
28
|
+
},
|
29
|
+
xAxis: {
|
30
|
+
title: {
|
31
|
+
text: "D/P creatinine (4hrs)"
|
32
|
+
},
|
33
|
+
type: "linear",
|
34
|
+
labels: {
|
35
|
+
overflow: "justify"
|
36
|
+
},
|
37
|
+
plotBands: [{
|
38
|
+
from: 0.3,
|
39
|
+
to: 0.5,
|
40
|
+
color: "rgba(68, 170, 213, 0.1)",
|
41
|
+
label: {
|
42
|
+
text: "Low",
|
43
|
+
style: {
|
44
|
+
color: "#606060"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}, {
|
48
|
+
from: 0.5,
|
49
|
+
to: 0.65,
|
50
|
+
color: "rgba(0, 0, 0, 0)",
|
51
|
+
label: {
|
52
|
+
text: "Low average",
|
53
|
+
style: {
|
54
|
+
color: "#606060"
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}, {
|
58
|
+
from: 0.65,
|
59
|
+
to: 0.82,
|
60
|
+
color: "rgba(68, 170, 213, 0.1)",
|
61
|
+
label: {
|
62
|
+
text: "High average",
|
63
|
+
style: {
|
64
|
+
color: "#606060"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}, {
|
68
|
+
from: 0.82,
|
69
|
+
to: 1.0,
|
70
|
+
color: "rgba(0, 0, 0, 0)",
|
71
|
+
label: {
|
72
|
+
text: "High",
|
73
|
+
style: {
|
74
|
+
color: "#606060"
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}]
|
78
|
+
},
|
79
|
+
yAxis: {
|
80
|
+
title: {
|
81
|
+
text: "Net Ultrafiltration (mls)"
|
82
|
+
},
|
83
|
+
tickInterval: 200,
|
84
|
+
minorGridLineWidth: 0,
|
85
|
+
gridLineWidth: 0,
|
86
|
+
alternateGridColor: null,
|
87
|
+
floor: -600,
|
88
|
+
plotLines: [{
|
89
|
+
color: "#BBB",
|
90
|
+
width: 1,
|
91
|
+
value: 0
|
92
|
+
}]
|
93
|
+
},
|
94
|
+
|
95
|
+
tooltip: {
|
96
|
+
formatter: function () {
|
97
|
+
return "<br>D_Pcr <b>" + this.x + "</b><br>" +
|
98
|
+
"netUF <b>" + this.y + "</b>"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
plotOptions: {
|
102
|
+
pointStart: 0.3,
|
103
|
+
line: {
|
104
|
+
dataLabels: {
|
105
|
+
enabled: true,
|
106
|
+
format: "{point.index}",
|
107
|
+
style: {
|
108
|
+
fontSize: "15px"
|
109
|
+
}
|
110
|
+
}
|
111
|
+
},
|
112
|
+
series: {
|
113
|
+
enableMouseTracking: false
|
114
|
+
},
|
115
|
+
dataLabels: {
|
116
|
+
enabled: true,
|
117
|
+
style: {
|
118
|
+
fontWeight: "bold"
|
119
|
+
}
|
120
|
+
}
|
121
|
+
},
|
122
|
+
series: [
|
123
|
+
{
|
124
|
+
name: "Expected",
|
125
|
+
color: "#00a499", //"#D970D9",
|
126
|
+
showInLegend: true,
|
127
|
+
type: "polygon",
|
128
|
+
data: [
|
129
|
+
[0.36,400],
|
130
|
+
[0.36,1000],
|
131
|
+
[0.5,1000],
|
132
|
+
[0.9,600],
|
133
|
+
[0.9,300],
|
134
|
+
[0.6,100],
|
135
|
+
[0.36,400]
|
136
|
+
]
|
137
|
+
},
|
138
|
+
{
|
139
|
+
name: "Warning",
|
140
|
+
color: "#fff495",
|
141
|
+
showInLegend: true,
|
142
|
+
type: "polygon",
|
143
|
+
data: [
|
144
|
+
[0.6,100],
|
145
|
+
[0.9,300],
|
146
|
+
[1.0,200],
|
147
|
+
[1.0,-600],
|
148
|
+
[0.75,-600],
|
149
|
+
[0.6,100]
|
150
|
+
]
|
151
|
+
},
|
152
|
+
{
|
153
|
+
// patient data
|
154
|
+
color: "#040481",
|
155
|
+
showInLegend: false,
|
156
|
+
enableMouseTracking: true,
|
157
|
+
data: data
|
158
|
+
}],
|
159
|
+
navigation: {
|
160
|
+
menuItemStyle: {
|
161
|
+
fontSize: "10px"
|
162
|
+
}
|
163
|
+
}
|
164
|
+
})
|
165
|
+
this.element.style.overflow = "unset"
|
166
|
+
}
|
167
|
+
)
|
168
|
+
}
|
169
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
|
2
|
+
const Rails = window.Rails
|
3
|
+
const _ = window._
|
4
|
+
import { Controller } from "stimulus"
|
5
|
+
|
6
|
+
// This controller has 3 related functions
|
7
|
+
// - Keep a users session alive
|
8
|
+
// Keep the user's session alive if they are 'active' (there are keypresses,
|
9
|
+
// clicks or resize events on the same page) by sending a throttled ajax
|
10
|
+
// request to reset the session window which will prevent their session
|
11
|
+
// expiring and throwing them out when they are for example writing a long
|
12
|
+
// letter (which they would otherwise not finish before their session expires)
|
13
|
+
// - Auto logging-out a user after a period of inactivity
|
14
|
+
// Check after a period of intactivity to see if their session has expired.
|
15
|
+
// If it has then refresh the page which will redirect them to the login page.
|
16
|
+
// - Signalling to other open tabs when the user's session has expired or they
|
17
|
+
// have manually logged out - so that all tabs go to the login page at around
|
18
|
+
// the same time.
|
19
|
+
//
|
20
|
+
// Goals:
|
21
|
+
// - Performance and code clarity more important than having an accurate session
|
22
|
+
// window - if it is extended for a minute or two that is OK.
|
23
|
+
// - The server should always be the judge of whether the session has timed out
|
24
|
+
// - Query the server as little as possible - partly for performance and partly
|
25
|
+
// to avoid noise in the server logs
|
26
|
+
// - Keep event handler activity minimal to preserve CPU cycles - ie use
|
27
|
+
// throttle or debounce
|
28
|
+
//
|
29
|
+
// Possible enhancements:
|
30
|
+
// - After a period of inactivity, show a dialog asking if user wants to extend
|
31
|
+
// the session - this would involve starting a separate timer and displaying
|
32
|
+
// the countdown
|
33
|
+
//
|
34
|
+
// Scenarios to test:
|
35
|
+
// - Keypresses, clicks and window resizing - any of these should reset session
|
36
|
+
// and thus the user remains logged in as long as one of these events ocurrs
|
37
|
+
// within sessionTimeoutSeconds
|
38
|
+
// - User closes lid on laptop overnight and reopens in the morning - what is
|
39
|
+
// expected?
|
40
|
+
// - Network disconnected - what do we do?
|
41
|
+
// - user gets withing 10 seconds of session timeout and starts typing - session
|
42
|
+
// window shoud be reset
|
43
|
+
// - user has > 1 tab open and logs out of one - ideally it should log out of
|
44
|
+
// other tabs before too long. We do by setting a localStorage value to signal
|
45
|
+
// to other tabs
|
46
|
+
//
|
47
|
+
// Known issues:
|
48
|
+
// - user sitting on register page will keep polling checkAlivePath
|
49
|
+
// - if a user becomes active on a page within throttlePeriodSeconds of
|
50
|
+
// sessionTimeoutSeconds then there is no currently opportunity for
|
51
|
+
// throttledRegisterUserActivity to reset kick in a trump
|
52
|
+
// checkForSessionExpiryTimeout - so the session will log out. We might need
|
53
|
+
// an extra step before calling checkForSessionExpiry - a final chance to
|
54
|
+
// check if the user was
|
55
|
+
// active
|
56
|
+
// - Not quite sure if putting the data attribute config settings in the body
|
57
|
+
// tag is the right thing to do - perhaps should be in a config .js.erb
|
58
|
+
export default class extends Controller {
|
59
|
+
checkForSessionExpiryTimeout = null
|
60
|
+
userActivityDetected = false
|
61
|
+
checkAlivePath = null
|
62
|
+
keepAlivePath = null
|
63
|
+
loginPath = null
|
64
|
+
throttledRegisterUserActivity = null
|
65
|
+
sessionTimeoutSeconds = 0
|
66
|
+
defaultSessionTimeoutSeconds = 20 * 60 // 20 mins
|
67
|
+
throttlePeriodSeconds = 0
|
68
|
+
defaultThrottlePeriodSeconds = 20
|
69
|
+
|
70
|
+
initialize() {
|
71
|
+
this.throttlePeriodSeconds = parseInt(this.data.get("register-user-activity-after") || this.defaultThrottlePeriodSeconds)
|
72
|
+
this.sessionTimeoutSeconds = parseInt(this.data.get("timeout") || this.defaultSessionTimeoutSeconds)
|
73
|
+
this.sessionTimeoutSeconds += 10 // To allow for network roundtrips etc
|
74
|
+
this.checkAlivePath = this.data.get("check-alive-path")
|
75
|
+
this.loginPath = this.data.get("login-path")
|
76
|
+
this.keepAlivePath = this.data.get("keep-alive-path")
|
77
|
+
this.logSettings()
|
78
|
+
|
79
|
+
// Throttle the user activity callback because we only need to know about user activity
|
80
|
+
// only very occasionally, so that we can periodically tell there server the user was active.
|
81
|
+
// Here, even if there are hundreds of events (click, keypress etc) within throttlePeriodSeconds,
|
82
|
+
// our function is only called at most once in that period, when throttlePeriodSeconds has
|
83
|
+
// passed (since trailing = true). This suits is as we want to avoid making any call to the
|
84
|
+
// server unless the user has been on the page for at least throttlePeriodSeconds.
|
85
|
+
// See https://lodash.com/docs/#trottle
|
86
|
+
this.throttledRegisterUserActivity = _.throttle(
|
87
|
+
this.registerUserActivity.bind(this),
|
88
|
+
this.throttlePeriodSeconds * 1000,
|
89
|
+
{ "leading": false, "trailing": true }
|
90
|
+
)
|
91
|
+
}
|
92
|
+
|
93
|
+
connect() {
|
94
|
+
if (this.onLoginPage) {
|
95
|
+
this.log("connect: onLoginPage - skipping session time")
|
96
|
+
} else {
|
97
|
+
this.addHandlersToMonitorUserActivity()
|
98
|
+
this.resetCheckForSessionExpiryTimeout(this.sessionTimeoutSeconds)
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
disconnect() {
|
103
|
+
if (!this.onLoginPage) {
|
104
|
+
this.removeUserActivityHandlers()
|
105
|
+
clearTimeout(this.checkForSessionExpiryTimeout)
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
sendLogoutMessageToAnyOpenTabs() {
|
110
|
+
window.localStorage.setItem("logout-event", "logout" + Math.random())
|
111
|
+
}
|
112
|
+
|
113
|
+
// Debounced event handler for key/click/resize
|
114
|
+
// If we come in there then the user has interacted with the page
|
115
|
+
// within throttlePeriodSeconds
|
116
|
+
registerUserActivity() {
|
117
|
+
this.sendRequestToKeepSessionAlive()
|
118
|
+
this.resetCheckForSessionExpiryTimeout(this.sessionTimeoutSeconds)
|
119
|
+
}
|
120
|
+
|
121
|
+
// Timeout handler for checking if the sesison has expired
|
122
|
+
resetCheckForSessionExpiryTimeout(intervalSeconds) {
|
123
|
+
this.log(`resetting session expiry timeout ${intervalSeconds}`)
|
124
|
+
clearTimeout(this.checkForSessionExpiryTimeout)
|
125
|
+
this.checkForSessionExpiryTimeout = setTimeout(
|
126
|
+
this.checkForSessionExpiry.bind(this),
|
127
|
+
intervalSeconds * 1000
|
128
|
+
)
|
129
|
+
}
|
130
|
+
|
131
|
+
// Here we really expect the session to have expired. In case it hasn't
|
132
|
+
// we reset the timeout to check again. We could reset the timeout to be
|
133
|
+
// sessionTimeoutSeconds, but if when we checked for expiry we had only just
|
134
|
+
// missed it, we will end up staying on this page (assuming the user is
|
135
|
+
// inactive) for nearly twice as long as we need to. So we set the timeout
|
136
|
+
// to be throttlePeriodSeconds * 2, which gives time for the
|
137
|
+
// throttledRegisterUserActivity handler to reset the session again if it
|
138
|
+
// fires.
|
139
|
+
checkForSessionExpiry() {
|
140
|
+
this.sendRequestToTestForSessionExpiry()
|
141
|
+
this.resetCheckForSessionExpiryTimeout(this.throttlePeriodSeconds * 2)
|
142
|
+
}
|
143
|
+
|
144
|
+
sendRequestToKeepSessionAlive() {
|
145
|
+
this.ajaxGet(this.keepAlivePath)
|
146
|
+
}
|
147
|
+
|
148
|
+
sendRequestToTestForSessionExpiry() {
|
149
|
+
this.log("checking for session expiry")
|
150
|
+
this.ajaxGet(this.checkAlivePath)
|
151
|
+
}
|
152
|
+
|
153
|
+
ajaxGet(path) {
|
154
|
+
Rails.ajax({
|
155
|
+
type: "GET",
|
156
|
+
url: path,
|
157
|
+
dataType: "text",
|
158
|
+
error: this.reloadPageIfAjaxRequestWasUnauthorised.bind(this)
|
159
|
+
})
|
160
|
+
}
|
161
|
+
|
162
|
+
reloadPageIfAjaxRequestWasUnauthorised(responseText, status, xhr) {
|
163
|
+
if (xhr.status == 401) {
|
164
|
+
window.location.reload()
|
165
|
+
this.sendLogoutMessageToAnyOpenTabs()
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
addHandlersToMonitorUserActivity() {
|
170
|
+
document.addEventListener("click", this.throttledRegisterUserActivity.bind(this))
|
171
|
+
document.addEventListener("keydown", this.throttledRegisterUserActivity.bind(this))
|
172
|
+
window.addEventListener("resize", this.throttledRegisterUserActivity.bind(this))
|
173
|
+
window.addEventListener("storage", this.storageChange.bind(this))
|
174
|
+
}
|
175
|
+
|
176
|
+
removeUserActivityHandlers() {
|
177
|
+
document.removeEventListener("click", this.throttledRegisterUserActivity.bind(this))
|
178
|
+
document.removeEventListener("keydown", this.throttledRegisterUserActivity.bind(this))
|
179
|
+
window.removeEventListener("resize", this.throttledRegisterUserActivity.bind(this))
|
180
|
+
window.removeEventListener("storage", this.storageChange.bind(this))
|
181
|
+
}
|
182
|
+
|
183
|
+
logSettings() {
|
184
|
+
if (this.debug) {
|
185
|
+
this.log(`keepAlivePath ${this.keepAlivePath}`)
|
186
|
+
this.log(`checkAlivePath ${this.checkAlivePath}`)
|
187
|
+
this.log(`loginPath ${this.loginPath}`)
|
188
|
+
this.log(`sessionTimeoutSeconds ${this.sessionTimeoutSeconds}`)
|
189
|
+
this.log(`throttlePeriodSeconds ${this.throttlePeriodSeconds}`)
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
log(msg) {
|
194
|
+
if (this.debug) {
|
195
|
+
console.log(msg)
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
// An event handler to watch for changes in the value of the local storage item called
|
200
|
+
// 'logged_in'. We use localStorage as a cross-tab communication protocol: when the user has
|
201
|
+
// logged out of one tab, this mechanism is used to signal to any other logged-in tabs that they
|
202
|
+
// should log themselves out.
|
203
|
+
// This applies in 2 circumstances:
|
204
|
+
// - the user has clicked the "Log Out" link in the navbar - the sendLogoutMessageToAnyOpenTabs()
|
205
|
+
// action defined above is called
|
206
|
+
// - our tab has timed out due to inactivity; other open tabs may not timeout for another few
|
207
|
+
// minutes (depending on the polling frequency etc) so we give them a nudge.
|
208
|
+
storageChange(event) {
|
209
|
+
if(event.key == "logout-event") {
|
210
|
+
setTimeout(this.sendRequestToTestForSessionExpiry.bind(this), 2000)
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
get onLoginPage() {
|
215
|
+
return window.location.pathname == this.loginPath
|
216
|
+
}
|
217
|
+
|
218
|
+
// If you add data-session-debug=1 then logging will be enabled
|
219
|
+
// This is evaluated each time we can add debugging into a running page
|
220
|
+
get debug() {
|
221
|
+
return this.data.get("debug") === "true"
|
222
|
+
}
|
223
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Controller } from "stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ["toggleable"]
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.toggleClass = this.data.get("class") || "hidden"
|
8
|
+
}
|
9
|
+
|
10
|
+
toggle(event) {
|
11
|
+
event.preventDefault()
|
12
|
+
|
13
|
+
this.toggleableTargets.forEach(target => {
|
14
|
+
target.classList.toggle(this.toggleClass)
|
15
|
+
})
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
//
|
2
|
+
// Adapted from https://github.com/excid3/tailwindcss-stimulus-components#tabs
|
3
|
+
//
|
4
|
+
import { Controller } from "stimulus"
|
5
|
+
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["tab", "panel"]
|
8
|
+
connect() {
|
9
|
+
}
|
10
|
+
|
11
|
+
initialize() {
|
12
|
+
this.activeTabClasses = (this.data.get("activeTab") || "active").split(" ")
|
13
|
+
this.showTab()
|
14
|
+
}
|
15
|
+
|
16
|
+
change(event) {
|
17
|
+
event.preventDefault()
|
18
|
+
this.index = this.tabTargets.indexOf(event.currentTarget)
|
19
|
+
}
|
20
|
+
|
21
|
+
showTab() {
|
22
|
+
this.tabTargets.forEach((tab, index) => {
|
23
|
+
const panel = this.panelTargets[index]
|
24
|
+
|
25
|
+
if (index === this.index) {
|
26
|
+
panel.classList.remove("hidden")
|
27
|
+
tab.classList.add(...this.activeTabClasses)
|
28
|
+
} else {
|
29
|
+
panel.classList.add("hidden")
|
30
|
+
tab.classList.remove(...this.activeTabClasses)
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
get index() {
|
36
|
+
return parseInt(this.data.get("index") || 0)
|
37
|
+
}
|
38
|
+
|
39
|
+
set index(value) {
|
40
|
+
this.data.set("index", value)
|
41
|
+
this.showTab()
|
42
|
+
}
|
43
|
+
}
|