LogstashUI 0.5.5.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AI/__init__.py +0 -0
- AI/integration_factory.py +1392 -0
- AI/migrations/0001_initial.py +58 -0
- AI/migrations/0002_draftdefinition_normalizers.py +23 -0
- AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
- AI/migrations/__init__.py +0 -0
- AI/models.py +5 -0
- AI/static/js/integration_factory.js +1102 -0
- AI/system_prompts/dashboard_generator.md +367 -0
- AI/system_prompts/grok_patterns.txt +95 -0
- AI/system_prompts/ingest_pipeline_generator.md +331 -0
- AI/system_prompts/ingest_pipeline_processors.json +2851 -0
- AI/system_prompts/ingest_verifier.md +84 -0
- AI/system_prompts/integrations_list.json +2690 -0
- AI/system_prompts/log_classifier.md +134 -0
- AI/system_prompts/template_creator.md +123 -0
- AI/templates/integration_factory.html +200 -0
- AI/urls.py +16 -0
- AI/views.py +20 -0
- API/__init__.py +0 -0
- API/admin.py +7 -0
- API/api.http +784 -0
- API/apps.py +9 -0
- API/auth.py +101 -0
- API/connections_views.py +312 -0
- API/guides.py +88 -0
- API/mcp/__init__.py +5 -0
- API/mcp/dispatch.py +179 -0
- API/mcp/tools.py +890 -0
- API/mcp/views.py +215 -0
- API/migrations/__init__.py +0 -0
- API/models.py +7 -0
- API/pipelines_views.py +1224 -0
- API/policies_views.py +1015 -0
- API/security_views.py +488 -0
- API/simulation_detail.py +219 -0
- API/snmp_views.py +1539 -0
- API/urls.py +81 -0
- Common/__init__.py +0 -0
- Common/ai/agent_builder.py +690 -0
- Common/context_processors.py +49 -0
- Common/decorators.py +68 -0
- Common/elastic_utils.py +1154 -0
- Common/encryption.py +271 -0
- Common/error_handlers.py +65 -0
- Common/formatters.py +106 -0
- Common/logstash_config_parse.py +1469 -0
- Common/logstash_utils.py +34 -0
- Common/middleware.py +216 -0
- Common/product_ca.py +1124 -0
- Common/validators.py +66 -0
- Documentation/__init__.py +0 -0
- Documentation/admin.py +7 -0
- Documentation/apps.py +9 -0
- Documentation/content/CHANGELOG.md +890 -0
- Documentation/content/docs/getting_started.md +92 -0
- Documentation/content/docs/index.md +124 -0
- Documentation/content/docs/logstashagent/configuration/index.md +60 -0
- Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
- Documentation/content/docs/logstashagent/general/build.md +217 -0
- Documentation/content/docs/logstashagent/general/index.md +38 -0
- Documentation/content/docs/logstashagent/general/roles.md +267 -0
- Documentation/content/docs/logstashagent/index.md +264 -0
- Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
- Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
- Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
- Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
- Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
- Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
- Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
- Documentation/content/docs/logstashui/SNMP/index.md +58 -0
- Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
- Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
- Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
- Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
- Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
- Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
- Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
- Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
- Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
- Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
- Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
- Documentation/content/docs/logstashui/architecture.md +11 -0
- Documentation/content/docs/logstashui/compatibility.md +58 -0
- Documentation/content/docs/logstashui/configuration/environment.md +193 -0
- Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
- Documentation/content/docs/logstashui/configuration/index.md +72 -0
- Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
- Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
- Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
- Documentation/content/docs/logstashui/database/examples/README.md +15 -0
- Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
- Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
- Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
- Documentation/content/docs/logstashui/database/index.md +79 -0
- Documentation/content/docs/logstashui/database/migration.md +75 -0
- Documentation/content/docs/logstashui/general/build.md +154 -0
- Documentation/content/docs/logstashui/general/deploy.md +122 -0
- Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
- Documentation/content/docs/logstashui/general/index.md +62 -0
- Documentation/content/docs/logstashui/general/offline.md +68 -0
- Documentation/content/docs/logstashui/general/updating.md +50 -0
- Documentation/content/docs/logstashui/index.md +90 -0
- Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
- Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
- Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
- Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
- Documentation/content/docs/logstashui/mcp.md +224 -0
- Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
- Documentation/content/docs/logstashui/rest_api.md +2783 -0
- Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
- Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
- Documentation/content/docs/logstashui/utilities/index.md +40 -0
- Documentation/content/images/LogstashIcon.png +0 -0
- Documentation/content/images/architecture.png +0 -0
- Documentation/content/images/connection_manager.png +0 -0
- Documentation/content/images/control_plane.png +0 -0
- Documentation/content/images/graph.gif +0 -0
- Documentation/content/images/login.png +0 -0
- Documentation/content/images/monitoring.png +0 -0
- Documentation/content/images/new_connection.gif +0 -0
- Documentation/content/images/simulate.gif +0 -0
- Documentation/content/images/simulate.png +0 -0
- Documentation/content/images/snmp.gif +0 -0
- Documentation/content/images/snmp.png +0 -0
- Documentation/content/images/snmp_architecture.png +0 -0
- Documentation/migrations/__init__.py +0 -0
- Documentation/models.py +9 -0
- Documentation/static/css/markdown.css +250 -0
- Documentation/templates/documentation.html +225 -0
- Documentation/templates/nav_item.html +41 -0
- Documentation/urls.py +11 -0
- Documentation/views.py +442 -0
- LogstashUI/__init__.py +0 -0
- LogstashUI/__main__.py +10 -0
- LogstashUI/asgi.py +16 -0
- LogstashUI/cli.py +626 -0
- LogstashUI/config.py +116 -0
- LogstashUI/database.py +263 -0
- LogstashUI/insecure_http.py +117 -0
- LogstashUI/logging_config.py +99 -0
- LogstashUI/migrate_engine.py +282 -0
- LogstashUI/packaging/__init__.py +3 -0
- LogstashUI/packaging/logstashui.default +68 -0
- LogstashUI/packaging/logstashui.service.in +22 -0
- LogstashUI/paths.py +181 -0
- LogstashUI/settings.py +437 -0
- LogstashUI/telemetry.py +159 -0
- LogstashUI/urls.py +56 -0
- LogstashUI/wsgi.py +77 -0
- Management/__init__.py +0 -0
- Management/apps.py +10 -0
- Management/migrations/0001_initial.py +29 -0
- Management/migrations/0002_settings.py +25 -0
- Management/migrations/0003_settings_agent_ui_url.py +29 -0
- Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
- Management/migrations/__init__.py +0 -0
- Management/models.py +92 -0
- Management/templates/api_tokens.html +214 -0
- Management/templates/components/api_token_created.html +38 -0
- Management/templates/components/api_token_row.html +84 -0
- Management/templates/components/logstash_artifact_row.html +100 -0
- Management/templates/components/logstash_artifact_tbody.html +26 -0
- Management/templates/components/user_row.html +67 -0
- Management/templates/logs.html +98 -0
- Management/templates/logstash_artifacts.html +172 -0
- Management/templates/management.html +80 -0
- Management/templates/management_settings.html +320 -0
- Management/templates/registration/login.html +404 -0
- Management/templates/users.html +304 -0
- Management/urls.py +23 -0
- Management/views.py +804 -0
- Monitoring/__init__.py +0 -0
- Monitoring/apps.py +9 -0
- Monitoring/migrations/__init__.py +0 -0
- Monitoring/static/js/monitoring.js +463 -0
- Monitoring/templates/components/node_metrics.html +161 -0
- Monitoring/templates/components/pipeline_metrics.html +189 -0
- Monitoring/templates/monitoring.html +271 -0
- Monitoring/urls.py +16 -0
- Monitoring/views.py +724 -0
- PipelineManager/__init__.py +0 -0
- PipelineManager/agent_api.py +1173 -0
- PipelineManager/agent_client.py +59 -0
- PipelineManager/agent_modes.py +880 -0
- PipelineManager/agent_policies.py +689 -0
- PipelineManager/agent_versions.py +151 -0
- PipelineManager/apps.py +10 -0
- PipelineManager/artifact_metrics.py +171 -0
- PipelineManager/artifacts.py +820 -0
- PipelineManager/connections_crud.py +722 -0
- PipelineManager/data/default_jvm.options +76 -0
- PipelineManager/data/default_log4j2.properties +165 -0
- PipelineManager/data/default_logstash.yml +405 -0
- PipelineManager/data/plugins.json +29109 -0
- PipelineManager/editor_views.py +608 -0
- PipelineManager/forms.py +284 -0
- PipelineManager/manager_views.py +490 -0
- PipelineManager/migrations/0001_initial.py +38 -0
- PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
- PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
- PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
- PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
- PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
- PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
- PipelineManager/migrations/0008_connection_agent_id.py +18 -0
- PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
- PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
- PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
- PipelineManager/migrations/0012_policy_binary_path.py +18 -0
- PipelineManager/migrations/0013_connection_status_blob.py +18 -0
- PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
- PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
- PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
- PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
- PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
- PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
- PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
- PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
- PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
- PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
- PipelineManager/migrations/0024_seed_system_policies.py +173 -0
- PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
- PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
- PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
- PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
- PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
- PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
- PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
- PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
- PipelineManager/migrations/0033_simulation_result.py +26 -0
- PipelineManager/migrations/__init__.py +0 -0
- PipelineManager/models.py +1300 -0
- PipelineManager/pipelines_crud.py +738 -0
- PipelineManager/policies_crud.py +772 -0
- PipelineManager/sim_keystore.py +319 -0
- PipelineManager/simulation.py +1581 -0
- PipelineManager/static/css/codemirror.min.css +1 -0
- PipelineManager/static/css/graph_move.css +79 -0
- PipelineManager/static/css/monokai.min.css +1 -0
- PipelineManager/static/css/move_mode.css +144 -0
- PipelineManager/static/css/show-hint.min.css +1 -0
- PipelineManager/static/images/age.png +0 -0
- PipelineManager/static/images/aggregate.png +0 -0
- PipelineManager/static/images/alter.png +0 -0
- PipelineManager/static/images/azure_event_hubs.png +0 -0
- PipelineManager/static/images/beats.png +0 -0
- PipelineManager/static/images/boundary.png +0 -0
- PipelineManager/static/images/bytes.png +0 -0
- PipelineManager/static/images/cidr.png +0 -0
- PipelineManager/static/images/cipher.png +0 -0
- PipelineManager/static/images/circonus.png +0 -0
- PipelineManager/static/images/clone.png +0 -0
- PipelineManager/static/images/cloudwatch.png +0 -0
- PipelineManager/static/images/comment.png +0 -0
- PipelineManager/static/images/continue.png +0 -0
- PipelineManager/static/images/couchdb_changes.png +0 -0
- PipelineManager/static/images/csv.png +0 -0
- PipelineManager/static/images/datadog.png +0 -0
- PipelineManager/static/images/datadog_metrics.png +0 -0
- PipelineManager/static/images/date.png +0 -0
- PipelineManager/static/images/de_dot.png +0 -0
- PipelineManager/static/images/dead_letter_queue.png +0 -0
- PipelineManager/static/images/dissect.png +0 -0
- PipelineManager/static/images/dns.png +0 -0
- PipelineManager/static/images/drop.png +0 -0
- PipelineManager/static/images/dynatrace.png +0 -0
- PipelineManager/static/images/elapsed.png +0 -0
- PipelineManager/static/images/elastic_agent.png +0 -0
- PipelineManager/static/images/elastic_integration.png +0 -0
- PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
- PipelineManager/static/images/elastic_workplace_search.png +0 -0
- PipelineManager/static/images/elasticsearch.png +0 -0
- PipelineManager/static/images/else.png +0 -0
- PipelineManager/static/images/else_if.png +0 -0
- PipelineManager/static/images/email.png +0 -0
- PipelineManager/static/images/environment.png +0 -0
- PipelineManager/static/images/exec.png +0 -0
- PipelineManager/static/images/extractnumbers.png +0 -0
- PipelineManager/static/images/file.png +0 -0
- PipelineManager/static/images/fingerprint.png +0 -0
- PipelineManager/static/images/ganglia.png +0 -0
- PipelineManager/static/images/gelf.png +0 -0
- PipelineManager/static/images/generator.png +0 -0
- PipelineManager/static/images/geoip.png +0 -0
- PipelineManager/static/images/github.png +0 -0
- PipelineManager/static/images/google_bigquery.png +0 -0
- PipelineManager/static/images/google_cloud_storage.png +0 -0
- PipelineManager/static/images/google_pubsub.png +0 -0
- PipelineManager/static/images/graphite.png +0 -0
- PipelineManager/static/images/graphtastic.png +0 -0
- PipelineManager/static/images/grok.png +0 -0
- PipelineManager/static/images/heartbeat.png +0 -0
- PipelineManager/static/images/http.png +0 -0
- PipelineManager/static/images/http_poller.png +0 -0
- PipelineManager/static/images/i18n.png +0 -0
- PipelineManager/static/images/if.png +0 -0
- PipelineManager/static/images/imap.png +0 -0
- PipelineManager/static/images/influxdb.png +0 -0
- PipelineManager/static/images/irc.png +0 -0
- PipelineManager/static/images/java_generator.png +0 -0
- PipelineManager/static/images/java_stdin.png +0 -0
- PipelineManager/static/images/java_stdout.png +0 -0
- PipelineManager/static/images/java_uuid.png +0 -0
- PipelineManager/static/images/jdbc.png +0 -0
- PipelineManager/static/images/jdbc_static.png +0 -0
- PipelineManager/static/images/jdbc_streaming.png +0 -0
- PipelineManager/static/images/jms.png +0 -0
- PipelineManager/static/images/jmx.png +0 -0
- PipelineManager/static/images/json.png +0 -0
- PipelineManager/static/images/json_encode.png +0 -0
- PipelineManager/static/images/juggernaut.png +0 -0
- PipelineManager/static/images/kafka.png +0 -0
- PipelineManager/static/images/kinesis.png +0 -0
- PipelineManager/static/images/kv.png +0 -0
- PipelineManager/static/images/librato.png +0 -0
- PipelineManager/static/images/log4j.png +0 -0
- PipelineManager/static/images/loggly.png +0 -0
- PipelineManager/static/images/logstash.png +0 -0
- PipelineManager/static/images/lumberjack.png +0 -0
- PipelineManager/static/images/meetup.png +0 -0
- PipelineManager/static/images/memcached.png +0 -0
- PipelineManager/static/images/metriccatcher.png +0 -0
- PipelineManager/static/images/metricize.png +0 -0
- PipelineManager/static/images/metrics.png +0 -0
- PipelineManager/static/images/mongodb.png +0 -0
- PipelineManager/static/images/mutate.png +0 -0
- PipelineManager/static/images/nagios.png +0 -0
- PipelineManager/static/images/nagios_nsca.png +0 -0
- PipelineManager/static/images/opentsdb.png +0 -0
- PipelineManager/static/images/pagerduty.png +0 -0
- PipelineManager/static/images/pipe.png +0 -0
- PipelineManager/static/images/pipeline.png +0 -0
- PipelineManager/static/images/prune.png +0 -0
- PipelineManager/static/images/puppet_facter.png +0 -0
- PipelineManager/static/images/rabbitmq.png +0 -0
- PipelineManager/static/images/range.png +0 -0
- PipelineManager/static/images/redis.png +0 -0
- PipelineManager/static/images/redmine.png +0 -0
- PipelineManager/static/images/relp.png +0 -0
- PipelineManager/static/images/riak.png +0 -0
- PipelineManager/static/images/riemann.png +0 -0
- PipelineManager/static/images/rss.png +0 -0
- PipelineManager/static/images/ruby.png +0 -0
- PipelineManager/static/images/s3-sns-sqs.png +0 -0
- PipelineManager/static/images/s3.png +0 -0
- PipelineManager/static/images/salesforce.png +0 -0
- PipelineManager/static/images/sink.png +0 -0
- PipelineManager/static/images/sleep.png +0 -0
- PipelineManager/static/images/snmp.png +0 -0
- PipelineManager/static/images/snmptrap.png +0 -0
- PipelineManager/static/images/sns.png +0 -0
- PipelineManager/static/images/solr_http.png +0 -0
- PipelineManager/static/images/split.png +0 -0
- PipelineManager/static/images/sqlite.png +0 -0
- PipelineManager/static/images/sqs.png +0 -0
- PipelineManager/static/images/statsd.png +0 -0
- PipelineManager/static/images/stdin.png +0 -0
- PipelineManager/static/images/stdout.png +0 -0
- PipelineManager/static/images/stomp.png +0 -0
- PipelineManager/static/images/syslog.png +0 -0
- PipelineManager/static/images/syslog_pri.png +0 -0
- PipelineManager/static/images/tcp.png +0 -0
- PipelineManager/static/images/threats_classifier.png +0 -0
- PipelineManager/static/images/throttle.png +0 -0
- PipelineManager/static/images/timber.png +0 -0
- PipelineManager/static/images/tld.png +0 -0
- PipelineManager/static/images/translate.png +0 -0
- PipelineManager/static/images/truncate.png +0 -0
- PipelineManager/static/images/twitter.png +0 -0
- PipelineManager/static/images/udp.png +0 -0
- PipelineManager/static/images/unix.png +0 -0
- PipelineManager/static/images/urldecode.png +0 -0
- PipelineManager/static/images/useragent.png +0 -0
- PipelineManager/static/images/uuid.png +0 -0
- PipelineManager/static/images/varnishlog.png +0 -0
- PipelineManager/static/images/webhdfs.png +0 -0
- PipelineManager/static/images/websocket.png +0 -0
- PipelineManager/static/images/wmi.png +0 -0
- PipelineManager/static/images/wurfl_device_detection.png +0 -0
- PipelineManager/static/images/xml.png +0 -0
- PipelineManager/static/images/xmpp.png +0 -0
- PipelineManager/static/images/zabbix.png +0 -0
- PipelineManager/static/js/agent_inspect_modal.js +141 -0
- PipelineManager/static/js/agent_policies.js +3746 -0
- PipelineManager/static/js/agent_status_sse.js +166 -0
- PipelineManager/static/js/codemirror.min.js +1 -0
- PipelineManager/static/js/connections_table.js +551 -0
- PipelineManager/static/js/d3.v7.js +20625 -0
- PipelineManager/static/js/diff_modal.js +995 -0
- PipelineManager/static/js/expression_editor.js +291 -0
- PipelineManager/static/js/js-yaml.min.js +1 -0
- PipelineManager/static/js/logstashyml_guides.js +1063 -0
- PipelineManager/static/js/move_graph.js +577 -0
- PipelineManager/static/js/move_mode.js +559 -0
- PipelineManager/static/js/pipeline_editor.js +4102 -0
- PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
- PipelineManager/static/js/pipeline_list.js +274 -0
- PipelineManager/static/js/pipeline_settings.js +121 -0
- PipelineManager/static/js/pipeline_text_editor.js +2088 -0
- PipelineManager/static/js/plugin_config_modal.js +2827 -0
- PipelineManager/static/js/policy_deploy_modal.js +1066 -0
- PipelineManager/static/js/show-hint.min.js +1 -0
- PipelineManager/static/js/sim_targets.js +380 -0
- PipelineManager/static/js/simple-comment-mode.js +56 -0
- PipelineManager/static/js/simulation_modal.js +1135 -0
- PipelineManager/static/js/simulation_results.js +2778 -0
- PipelineManager/static/js/stats_strip.js +231 -0
- PipelineManager/static/js/yaml.js +120 -0
- PipelineManager/system_policy_defaults.py +279 -0
- PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
- PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
- PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
- PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
- PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
- PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
- PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
- PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
- PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
- PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
- PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
- PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
- PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
- PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
- PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
- PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
- PipelineManager/templates/pipeline_editor.html +1738 -0
- PipelineManager/templates/pipeline_graph_editor.html +99 -0
- PipelineManager/templates/pipeline_manager.html +584 -0
- PipelineManager/templates/pipeline_text_editor.html +350 -0
- PipelineManager/urls.py +99 -0
- SNMP/__init__.py +0 -0
- SNMP/ai_template_generation.py +232 -0
- SNMP/apps.py +9 -0
- SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
- SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
- SNMP/data/authoring_instructions.md +65 -0
- SNMP/data/grounding/.gitignore +4 -0
- SNMP/data/grounding/build_grounding.py +35 -0
- SNMP/data/grounding/grounding.json +1 -0
- SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
- SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
- SNMP/data/mib_reference/std_entity_sensors.json +28 -0
- SNMP/data/mib_reference/std_host_resources.json +32 -0
- SNMP/data/mib_reference/std_ospf_mib.json +55 -0
- SNMP/data/mib_reference/std_ucd_linux.json +27 -0
- SNMP/data/normalizers.json +103 -0
- SNMP/data/official_device_templates/arista_eos.json +24 -0
- SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
- SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
- SNMP/data/official_device_templates/cisco_ios.json +21 -0
- SNMP/data/official_device_templates/default.json +13 -0
- SNMP/data/official_device_templates/dell_idrac.json +22 -0
- SNMP/data/official_device_templates/dell_x1026.json +16 -0
- SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
- SNMP/data/official_device_templates/eastpower_ups.json +20 -0
- SNMP/data/official_device_templates/eaton_ups.json +22 -0
- SNMP/data/official_device_templates/epson_printer.json +18 -0
- SNMP/data/official_device_templates/geist_watchdog.json +20 -0
- SNMP/data/official_device_templates/generic_linux.json +18 -0
- SNMP/data/official_device_templates/generic_ont.json +18 -0
- SNMP/data/official_device_templates/generic_ups.json +16 -0
- SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
- SNMP/data/official_device_templates/hpe_nimble.json +17 -0
- SNMP/data/official_device_templates/huawei_ups.json +19 -0
- SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
- SNMP/data/official_device_templates/isilon_onefs.json +22 -0
- SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
- SNMP/data/official_device_templates/netapp_7mode.json +22 -0
- SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
- SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
- SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
- SNMP/data/official_profiles/arista_eos.json +16 -0
- SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
- SNMP/data/official_profiles/cisco_cdp.json +26 -0
- SNMP/data/official_profiles/cisco_fans.json +18 -0
- SNMP/data/official_profiles/cisco_sensors.json +21 -0
- SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
- SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
- SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
- SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
- SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
- SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
- SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
- SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
- SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
- SNMP/data/official_profiles/eaton_ups.json +40 -0
- SNMP/data/official_profiles/geist_environment.json +50 -0
- SNMP/data/official_profiles/generic_arp.json +19 -0
- SNMP/data/official_profiles/generic_bgp.json +24 -0
- SNMP/data/official_profiles/generic_entity_psu.json +26 -0
- SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
- SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
- SNMP/data/official_profiles/generic_interfaces.json +86 -0
- SNMP/data/official_profiles/generic_ip_addr.json +19 -0
- SNMP/data/official_profiles/generic_lldp.json +54 -0
- SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
- SNMP/data/official_profiles/generic_mac_table.json +19 -0
- SNMP/data/official_profiles/generic_ont.json +88 -0
- SNMP/data/official_profiles/generic_ospf.json +21 -0
- SNMP/data/official_profiles/generic_printer_mib.json +48 -0
- SNMP/data/official_profiles/generic_rmon.json +38 -0
- SNMP/data/official_profiles/generic_system.json +17 -0
- SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
- SNMP/data/official_profiles/generic_ups_mib.json +154 -0
- SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
- SNMP/data/official_profiles/huawei_ups.json +111 -0
- SNMP/data/official_profiles/isilon_performance.json +92 -0
- SNMP/data/official_profiles/isilon_protocols.json +77 -0
- SNMP/data/official_profiles/isilon_system.json +86 -0
- SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
- SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
- SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
- SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
- SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
- SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
- SNMP/data/official_profiles/paloalto_components.json +36 -0
- SNMP/data/official_profiles/paloalto_system.json +15 -0
- SNMP/data/official_profiles/traps.json +16 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
- SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
- SNMP/data/official_profiles/versa_flexvnf.json +14 -0
- SNMP/data/schema.md +650 -0
- SNMP/data/schema_reference/snmp_field_schema.md +747 -0
- SNMP/data/snmp_template.json +629 -0
- SNMP/data/template_profile_context.md +3986 -0
- SNMP/inline_grounding.py +77 -0
- SNMP/management/__init__.py +1 -0
- SNMP/management/commands/__init__.py +1 -0
- SNMP/management/commands/generate_template_profile_context.py +272 -0
- SNMP/management/commands/load_test_snmp_data.py +240 -0
- SNMP/management/commands/sync_snmp_official_data.py +263 -0
- SNMP/management/commands/unload_test_snmp_data.py +77 -0
- SNMP/migrations/0001_initial.py +101 -0
- SNMP/migrations/0002_devicetemplate.py +34 -0
- SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
- SNMP/migrations/0004_device_device_template.py +19 -0
- SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
- SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
- SNMP/migrations/0007_remove_device_profiles.py +17 -0
- SNMP/migrations/0008_devicetemplate_type.py +18 -0
- SNMP/migrations/0009_alter_device_device_template.py +19 -0
- SNMP/migrations/0010_alter_device_device_template.py +19 -0
- SNMP/migrations/0011_network_namespace.py +18 -0
- SNMP/migrations/0012_profile_normalizers.py +18 -0
- SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
- SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
- SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
- SNMP/migrations/0018_add_official_key.py +39 -0
- SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
- SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
- SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
- SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
- SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
- SNMP/migrations/0024_network_credential_mode.py +18 -0
- SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
- SNMP/migrations/__init__.py +0 -0
- SNMP/models.py +892 -0
- SNMP/network_map.py +660 -0
- SNMP/overview.py +394 -0
- SNMP/snmp_crud.py +6082 -0
- SNMP/snmp_grounding.py +146 -0
- SNMP/snmp_normalizers.py +594 -0
- SNMP/snmp_pipeline_generator.py +1658 -0
- SNMP/snmp_test.py +962 -0
- SNMP/static/css/snmp.css +33 -0
- SNMP/static/images/apc.png +0 -0
- SNMP/static/images/arista.png +0 -0
- SNMP/static/images/aruba.png +0 -0
- SNMP/static/images/brocade.png +0 -0
- SNMP/static/images/cisco.png +0 -0
- SNMP/static/images/dell.png +0 -0
- SNMP/static/images/dlink.png +0 -0
- SNMP/static/images/east.png +0 -0
- SNMP/static/images/eaton.png +0 -0
- SNMP/static/images/epson.png +0 -0
- SNMP/static/images/hauwei.png +0 -0
- SNMP/static/images/hp.png +0 -0
- SNMP/static/images/hpe.png +0 -0
- SNMP/static/images/ingrasys.png +0 -0
- SNMP/static/images/linux.png +0 -0
- SNMP/static/images/mellanox.png +0 -0
- SNMP/static/images/netapp.png +0 -0
- SNMP/static/images/paloalto.png +0 -0
- SNMP/static/images/phoenixtec.png +0 -0
- SNMP/static/images/ubiquiti.png +0 -0
- SNMP/static/images/unknown.png +0 -0
- SNMP/static/images/versa.png +0 -0
- SNMP/static/images/vertiv.png +0 -0
- SNMP/static/js/ai_device_template_modal.js +1116 -0
- SNMP/static/js/credentials_table.js +291 -0
- SNMP/static/js/devices_table.js +588 -0
- SNMP/static/js/discovered_devices.js +291 -0
- SNMP/static/js/network_map.js +1657 -0
- SNMP/static/js/networks_table.js +360 -0
- SNMP/static/js/onboarding.js +866 -0
- SNMP/static/js/overview.js +416 -0
- SNMP/static/js/snmp_changes_indicator.js +76 -0
- SNMP/static/js/snmp_commit_modal.js +39 -0
- SNMP/static/js/snmp_credentials_modal.js +217 -0
- SNMP/static/js/snmp_device_template_modal.js +669 -0
- SNMP/static/js/snmp_device_visual_preview.js +1707 -0
- SNMP/static/js/snmp_devices_modal.js +912 -0
- SNMP/static/js/snmp_diff_modal.js +1559 -0
- SNMP/static/js/snmp_network_modal.js +940 -0
- SNMP/static/js/snmp_profile_modal.js +1212 -0
- SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
- SNMP/static/js/snmp_test.js +538 -0
- SNMP/templates/Credentials.html +325 -0
- SNMP/templates/DeviceTemplates.html +1059 -0
- SNMP/templates/Devices.html +274 -0
- SNMP/templates/Networks.html +469 -0
- SNMP/templates/Onboarding.html +521 -0
- SNMP/templates/Overview.html +227 -0
- SNMP/templates/components/ai_device_template_modal.html +46 -0
- SNMP/templates/components/ai_generate_template_content.html +224 -0
- SNMP/templates/components/device_template_profile_modal.html +60 -0
- SNMP/templates/components/discovered_devices_content.html +86 -0
- SNMP/templates/components/discovered_devices_modal.html +43 -0
- SNMP/templates/components/gmaps_latlon_modal.html +93 -0
- SNMP/templates/components/network_map.html +110 -0
- SNMP/templates/components/snmp_commit_modal.html +53 -0
- SNMP/templates/components/snmp_credentials_modal.html +189 -0
- SNMP/templates/components/snmp_device_modal.html +6 -0
- SNMP/templates/components/snmp_device_template_modal.html +129 -0
- SNMP/templates/components/snmp_device_visual_preview.html +347 -0
- SNMP/templates/components/snmp_devices_modal.html +330 -0
- SNMP/templates/components/snmp_diff_modal.html +148 -0
- SNMP/templates/components/snmp_network_modal.html +380 -0
- SNMP/templates/components/snmp_profile_modal.html +147 -0
- SNMP/templates/components/snmp_test_modal.html +398 -0
- SNMP/templatetags/__init__.py +0 -0
- SNMP/templatetags/snmp_extras.py +17 -0
- SNMP/urls.py +94 -0
- SNMP/views.py +913 -0
- Site/__init__.py +0 -0
- Site/apps.py +9 -0
- Site/migrations/__init__.py +0 -0
- Site/product_ca_views.py +41 -0
- Site/static/images/ElasticIcon.png +0 -0
- Site/static/images/LoggyIcon.png +0 -0
- Site/static/images/LoggyWizardIcon.png +0 -0
- Site/static/images/LogstashAgentIcon.png +0 -0
- Site/static/images/LogstashIcon.png +0 -0
- Site/static/js/base.js +192 -0
- Site/static/js/marked.min.js +69 -0
- Site/templates/base.html +52 -0
- Site/templates/error.html +65 -0
- Site/templates/home.html +148 -0
- Site/templates/navigation.html +530 -0
- Site/templates/popup.html +251 -0
- Site/templatetags/__init__.py +0 -0
- Site/templatetags/custom_filters.py +36 -0
- Site/urls.py +21 -0
- Site/views.py +200 -0
- Utilities/__init__.py +0 -0
- Utilities/apps.py +9 -0
- Utilities/data/grok-patterns/LICENSE +202 -0
- Utilities/data/grok-patterns/ecs-v1/aws +33 -0
- Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
- Utilities/data/grok-patterns/ecs-v1/bind +13 -0
- Utilities/data/grok-patterns/ecs-v1/bro +30 -0
- Utilities/data/grok-patterns/ecs-v1/exim +26 -0
- Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
- Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
- Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
- Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
- Utilities/data/grok-patterns/ecs-v1/java +34 -0
- Utilities/data/grok-patterns/ecs-v1/junos +13 -0
- Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
- Utilities/data/grok-patterns/ecs-v1/maven +1 -0
- Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
- Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
- Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
- Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
- Utilities/data/grok-patterns/ecs-v1/rails +13 -0
- Utilities/data/grok-patterns/ecs-v1/redis +3 -0
- Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
- Utilities/data/grok-patterns/ecs-v1/squid +6 -0
- Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
- Utilities/data/grok-patterns/legacy/aws +14 -0
- Utilities/data/grok-patterns/legacy/bacula +50 -0
- Utilities/data/grok-patterns/legacy/bind +3 -0
- Utilities/data/grok-patterns/legacy/bro +13 -0
- Utilities/data/grok-patterns/legacy/exim +19 -0
- Utilities/data/grok-patterns/legacy/firewalls +91 -0
- Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
- Utilities/data/grok-patterns/legacy/haproxy +39 -0
- Utilities/data/grok-patterns/legacy/httpd +15 -0
- Utilities/data/grok-patterns/legacy/java +17 -0
- Utilities/data/grok-patterns/legacy/junos +9 -0
- Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
- Utilities/data/grok-patterns/legacy/maven +1 -0
- Utilities/data/grok-patterns/legacy/mcollective +1 -0
- Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
- Utilities/data/grok-patterns/legacy/mongodb +7 -0
- Utilities/data/grok-patterns/legacy/nagios +124 -0
- Utilities/data/grok-patterns/legacy/postgresql +3 -0
- Utilities/data/grok-patterns/legacy/rails +13 -0
- Utilities/data/grok-patterns/legacy/redis +3 -0
- Utilities/data/grok-patterns/legacy/ruby +2 -0
- Utilities/data/grok-patterns/legacy/squid +4 -0
- Utilities/dissect.py +302 -0
- Utilities/grok.py +412 -0
- Utilities/migrations/__init__.py +0 -0
- Utilities/static/css/debugger_editor.css +88 -0
- Utilities/static/js/debugger_editor.js +93 -0
- Utilities/static/js/grok_debugger.js +131 -0
- Utilities/templates/dissect_debugger.html +95 -0
- Utilities/templates/grok_debugger.html +99 -0
- Utilities/urls.py +14 -0
- Utilities/views.py +363 -0
- logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
- logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
- logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
- logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
- logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
- logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
- theme/__init__.py +0 -0
- theme/apps.py +9 -0
- theme/package-lock.json +6 -0
- theme/static/css/dist/styles.css +2 -0
- theme/static/images/favicon.ico +0 -0
- theme/static_src/.gitignore +1 -0
- theme/static_src/package-lock.json +1930 -0
- theme/static_src/package.json +26 -0
- theme/static_src/postcss.config.js +7 -0
- theme/static_src/src/styles.css +38 -0
- theme/static_src/tailwind.config.js +43 -0
- theme/templates/base.html +32 -0
|
@@ -0,0 +1,1135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License;
|
|
4
|
+
* you may not use this file except in compliance with the Elastic License.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Store simulation data globally for view switching
|
|
8
|
+
window.simulationData = null;
|
|
9
|
+
|
|
10
|
+
// Line numbers functionality
|
|
11
|
+
let logInput;
|
|
12
|
+
let logInputLineNumbers;
|
|
13
|
+
let multilineCheckbox;
|
|
14
|
+
let multilineInputBanner;
|
|
15
|
+
|
|
16
|
+
function updateLineNumbers(textarea, lineNumbersContainer) {
|
|
17
|
+
const lines = textarea.value.split('\n');
|
|
18
|
+
const lineCount = lines.length;
|
|
19
|
+
|
|
20
|
+
// Create a mirror div to measure actual line heights
|
|
21
|
+
const mirror = document.createElement('div');
|
|
22
|
+
const computedStyle = window.getComputedStyle(textarea);
|
|
23
|
+
|
|
24
|
+
// Copy relevant styles from textarea to mirror
|
|
25
|
+
mirror.style.position = 'absolute';
|
|
26
|
+
mirror.style.visibility = 'hidden';
|
|
27
|
+
mirror.style.whiteSpace = 'pre-wrap';
|
|
28
|
+
mirror.style.wordWrap = 'break-word';
|
|
29
|
+
mirror.style.overflowWrap = 'break-word';
|
|
30
|
+
// Calculate width minus padding to match actual text area
|
|
31
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
32
|
+
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
33
|
+
mirror.style.width = (textarea.clientWidth - paddingLeft - paddingRight) + 'px';
|
|
34
|
+
mirror.style.font = computedStyle.font;
|
|
35
|
+
mirror.style.fontSize = computedStyle.fontSize;
|
|
36
|
+
mirror.style.fontFamily = computedStyle.fontFamily;
|
|
37
|
+
mirror.style.lineHeight = computedStyle.lineHeight;
|
|
38
|
+
mirror.style.padding = '0';
|
|
39
|
+
mirror.style.border = 'none';
|
|
40
|
+
mirror.style.boxSizing = 'content-box';
|
|
41
|
+
|
|
42
|
+
document.body.appendChild(mirror);
|
|
43
|
+
|
|
44
|
+
// Get single line height
|
|
45
|
+
mirror.textContent = 'X';
|
|
46
|
+
const singleLineHeight = mirror.offsetHeight;
|
|
47
|
+
|
|
48
|
+
// Generate line numbers with measured heights for each logical line
|
|
49
|
+
let lineNumbersHTML = '';
|
|
50
|
+
for (let i = 0; i < lineCount; i++) {
|
|
51
|
+
// Set mirror content to this line
|
|
52
|
+
mirror.textContent = lines[i] || ' '; // Use space for empty lines
|
|
53
|
+
const totalLineHeight = mirror.offsetHeight;
|
|
54
|
+
|
|
55
|
+
// Create line number that appears at the top of this logical line
|
|
56
|
+
// but takes up the full height so the next line number appears in the right place
|
|
57
|
+
lineNumbersHTML += `<div style="height: ${totalLineHeight}px; line-height: ${singleLineHeight}px;">${i + 1}</div>`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Clean up mirror
|
|
61
|
+
document.body.removeChild(mirror);
|
|
62
|
+
|
|
63
|
+
lineNumbersContainer.innerHTML = lineNumbersHTML;
|
|
64
|
+
|
|
65
|
+
// Sync scroll position
|
|
66
|
+
lineNumbersContainer.scrollTop = textarea.scrollTop;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function updateMultilineBanner() {
|
|
70
|
+
const lines = logInput.value.split('\n').filter(line => line.trim() !== '');
|
|
71
|
+
if (lines.length > 1 && !multilineCheckbox.checked) {
|
|
72
|
+
multilineInputBanner.classList.remove('hidden');
|
|
73
|
+
} else {
|
|
74
|
+
multilineInputBanner.classList.add('hidden');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Initialize line numbers and multiline banner when DOM is ready
|
|
79
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
80
|
+
logInput = document.getElementById('logInput');
|
|
81
|
+
logInputLineNumbers = document.getElementById('logInputLineNumbers');
|
|
82
|
+
multilineCheckbox = document.getElementById('multilineCheckbox');
|
|
83
|
+
multilineInputBanner = document.getElementById('multilineInputBanner');
|
|
84
|
+
|
|
85
|
+
if (logInput && logInputLineNumbers) {
|
|
86
|
+
logInput.addEventListener('input', () => {
|
|
87
|
+
updateLineNumbers(logInput, logInputLineNumbers);
|
|
88
|
+
updateMultilineBanner();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
logInput.addEventListener('scroll', () => {
|
|
92
|
+
logInputLineNumbers.scrollTop = logInput.scrollTop;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
updateLineNumbers(logInput, logInputLineNumbers);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (multilineCheckbox) {
|
|
99
|
+
multilineCheckbox.addEventListener('change', updateMultilineBanner);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Input source switching
|
|
104
|
+
function switchInputSource(source) {
|
|
105
|
+
const textContainer = document.getElementById('textInputContainer');
|
|
106
|
+
const esContainer = document.getElementById('elasticsearchInputContainer');
|
|
107
|
+
const logInput = document.getElementById('logInput');
|
|
108
|
+
const runBtn = document.getElementById('runSimulationBtn');
|
|
109
|
+
|
|
110
|
+
if (source === 'text') {
|
|
111
|
+
textContainer.classList.remove('hidden');
|
|
112
|
+
esContainer.classList.add('hidden');
|
|
113
|
+
logInput.required = true;
|
|
114
|
+
runBtn.disabled = false;
|
|
115
|
+
} else if (source === 'elasticsearch') {
|
|
116
|
+
textContainer.classList.add('hidden');
|
|
117
|
+
esContainer.classList.remove('hidden');
|
|
118
|
+
logInput.required = false;
|
|
119
|
+
|
|
120
|
+
// Load connections
|
|
121
|
+
loadElasticsearchConnections();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Load Elasticsearch connections
|
|
126
|
+
function loadElasticsearchConnections() {
|
|
127
|
+
const select = document.getElementById('esConnection');
|
|
128
|
+
fetch('/ConnectionManager/GetElasticsearchConnections/')
|
|
129
|
+
.then(response => response.json())
|
|
130
|
+
.then(data => {
|
|
131
|
+
select.innerHTML = '<option value="">Select a connection...</option>';
|
|
132
|
+
data.connections.forEach(conn => {
|
|
133
|
+
const option = document.createElement('option');
|
|
134
|
+
option.value = conn.id;
|
|
135
|
+
option.textContent = conn.name;
|
|
136
|
+
select.appendChild(option);
|
|
137
|
+
});
|
|
138
|
+
select.disabled = false;
|
|
139
|
+
})
|
|
140
|
+
.catch(error => {
|
|
141
|
+
console.error('Error loading connections:', error);
|
|
142
|
+
select.innerHTML = '<option value="">Error loading connections</option>';
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ES Connection change handler
|
|
147
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
148
|
+
const esConnection = document.getElementById('esConnection');
|
|
149
|
+
if (esConnection) {
|
|
150
|
+
esConnection.addEventListener('change', function() {
|
|
151
|
+
const indexContainer = document.getElementById('esIndexContainer');
|
|
152
|
+
if (this.value) {
|
|
153
|
+
indexContainer.classList.remove('hidden');
|
|
154
|
+
setupIndexTypeahead();
|
|
155
|
+
} else {
|
|
156
|
+
indexContainer.classList.add('hidden');
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Index typeahead
|
|
163
|
+
function setupIndexTypeahead() {
|
|
164
|
+
const input = document.getElementById('esIndexInput');
|
|
165
|
+
const dropdown = document.getElementById('esIndexDropdown');
|
|
166
|
+
const connectionId = document.getElementById('esConnection').value;
|
|
167
|
+
|
|
168
|
+
let debounceTimer;
|
|
169
|
+
|
|
170
|
+
input.addEventListener('input', function() {
|
|
171
|
+
clearTimeout(debounceTimer);
|
|
172
|
+
const searchTerm = this.value.trim();
|
|
173
|
+
|
|
174
|
+
debounceTimer = setTimeout(() => {
|
|
175
|
+
if (searchTerm.length === 0) {
|
|
176
|
+
// Get top 50 indices
|
|
177
|
+
fetchIndices(connectionId, '*');
|
|
178
|
+
} else {
|
|
179
|
+
// Search with wildcard
|
|
180
|
+
fetchIndices(connectionId, searchTerm + '*');
|
|
181
|
+
}
|
|
182
|
+
}, 300);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Initial load
|
|
186
|
+
fetchIndices(connectionId, '*');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function fetchIndices(connectionId, pattern) {
|
|
190
|
+
const dropdown = document.getElementById('esIndexDropdown');
|
|
191
|
+
|
|
192
|
+
fetch(`/ConnectionManager/GetElasticsearchIndices/?connection_id=${connectionId}&pattern=${encodeURIComponent(pattern)}`)
|
|
193
|
+
.then(response => response.json())
|
|
194
|
+
.then(data => {
|
|
195
|
+
if (data.indices && data.indices.length > 0) {
|
|
196
|
+
// Clear dropdown and build with DOM methods to avoid XSS
|
|
197
|
+
dropdown.innerHTML = '';
|
|
198
|
+
data.indices.slice(0, 50).forEach(index => {
|
|
199
|
+
const div = document.createElement('div');
|
|
200
|
+
div.className = 'px-3 py-2 hover:bg-gray-600 cursor-pointer text-sm text-white';
|
|
201
|
+
div.textContent = index; // Safe - automatically escapes
|
|
202
|
+
div.onclick = () => selectIndex(index); // Safe - passes as parameter
|
|
203
|
+
dropdown.appendChild(div);
|
|
204
|
+
});
|
|
205
|
+
dropdown.classList.remove('hidden');
|
|
206
|
+
} else {
|
|
207
|
+
dropdown.innerHTML = '<div class="px-3 py-2 text-sm text-gray-400">No indices found</div>';
|
|
208
|
+
dropdown.classList.remove('hidden');
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
.catch(error => {
|
|
212
|
+
console.error('Error fetching indices:', error);
|
|
213
|
+
dropdown.innerHTML = '<div class="px-3 py-2 text-sm text-red-400">Error loading indices</div>';
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function selectIndex(indexName) {
|
|
218
|
+
const input = document.getElementById('esIndexInput');
|
|
219
|
+
const dropdown = document.getElementById('esIndexDropdown');
|
|
220
|
+
const queryMethodContainer = document.getElementById('esQueryMethodContainer');
|
|
221
|
+
|
|
222
|
+
input.value = indexName;
|
|
223
|
+
dropdown.classList.add('hidden');
|
|
224
|
+
queryMethodContainer.classList.remove('hidden');
|
|
225
|
+
|
|
226
|
+
// Load field mappings
|
|
227
|
+
loadFieldMappings(indexName);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function loadFieldMappings(indexName) {
|
|
231
|
+
const connectionId = document.getElementById('esConnection').value;
|
|
232
|
+
const fieldSelect = document.getElementById('esField');
|
|
233
|
+
|
|
234
|
+
fetch(`/ConnectionManager/GetElasticsearchFields/?connection_id=${connectionId}&index=${encodeURIComponent(indexName)}`)
|
|
235
|
+
.then(response => response.json())
|
|
236
|
+
.then(data => {
|
|
237
|
+
fieldSelect.innerHTML = '<option value="">Select a field...</option>';
|
|
238
|
+
data.fields.forEach(field => {
|
|
239
|
+
const option = document.createElement('option');
|
|
240
|
+
option.value = field;
|
|
241
|
+
option.textContent = field;
|
|
242
|
+
fieldSelect.appendChild(option);
|
|
243
|
+
});
|
|
244
|
+
})
|
|
245
|
+
.catch(error => {
|
|
246
|
+
console.error('Error loading fields:', error);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ES Query method switching
|
|
251
|
+
function switchEsQueryMethod(method) {
|
|
252
|
+
const fieldContainer = document.getElementById('esFieldContainer');
|
|
253
|
+
const entireContainer = document.getElementById('esEntireContainer');
|
|
254
|
+
const docIdContainer = document.getElementById('esDocIdContainer');
|
|
255
|
+
|
|
256
|
+
if (method === 'field') {
|
|
257
|
+
fieldContainer.classList.remove('hidden');
|
|
258
|
+
entireContainer.classList.add('hidden');
|
|
259
|
+
docIdContainer.classList.add('hidden');
|
|
260
|
+
} else if (method === 'entire') {
|
|
261
|
+
fieldContainer.classList.add('hidden');
|
|
262
|
+
entireContainer.classList.remove('hidden');
|
|
263
|
+
docIdContainer.classList.add('hidden');
|
|
264
|
+
} else {
|
|
265
|
+
fieldContainer.classList.add('hidden');
|
|
266
|
+
entireContainer.classList.add('hidden');
|
|
267
|
+
docIdContainer.classList.remove('hidden');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Show Elasticsearch preview
|
|
272
|
+
function showElasticsearchPreview() {
|
|
273
|
+
const connectionId = document.getElementById('esConnection').value;
|
|
274
|
+
const index = document.getElementById('esIndexInput').value;
|
|
275
|
+
const queryMethod = document.querySelector('input[name="esQueryMethod"]:checked').value;
|
|
276
|
+
|
|
277
|
+
if (!connectionId || !index) {
|
|
278
|
+
ConfirmationModal.show('Please select a connection and index first.', 'Validation', 'OK', null, true);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Show preview modal
|
|
283
|
+
const previewModal = document.getElementById('previewModal');
|
|
284
|
+
const previewContent = document.getElementById('previewContent');
|
|
285
|
+
previewModal.classList.remove('hidden');
|
|
286
|
+
|
|
287
|
+
// Show loading
|
|
288
|
+
previewContent.innerHTML = '<div class="flex items-center justify-center py-8"><div class="animate-spin rounded-full h-8 w-8 border-b-2 border-green-400"></div></div>';
|
|
289
|
+
|
|
290
|
+
// Build request data
|
|
291
|
+
let requestData = {
|
|
292
|
+
connection_id: connectionId,
|
|
293
|
+
index: index,
|
|
294
|
+
query_method: queryMethod
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
if (queryMethod === 'field') {
|
|
298
|
+
const field = document.getElementById('esField').value;
|
|
299
|
+
const size = document.getElementById('esSize').value;
|
|
300
|
+
const query = document.getElementById('esQuery').value;
|
|
301
|
+
|
|
302
|
+
if (!field) {
|
|
303
|
+
previewContent.innerHTML = '<div class="text-red-400">Please select a field first</div>';
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
requestData.field = field;
|
|
308
|
+
requestData.size = size;
|
|
309
|
+
requestData.query = query;
|
|
310
|
+
} else if (queryMethod === 'entire') {
|
|
311
|
+
const size = document.getElementById('esSizeEntire').value;
|
|
312
|
+
const query = document.getElementById('esQueryEntire').value;
|
|
313
|
+
|
|
314
|
+
requestData.size = size;
|
|
315
|
+
requestData.query = query;
|
|
316
|
+
} else if (queryMethod === 'docid') {
|
|
317
|
+
const docIds = document.getElementById('esDocIds').value;
|
|
318
|
+
|
|
319
|
+
if (!docIds.trim()) {
|
|
320
|
+
previewContent.innerHTML = '<div class="text-red-400">Please enter at least one document ID</div>';
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
requestData.doc_ids = docIds;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Fetch preview data
|
|
328
|
+
const formData = new FormData();
|
|
329
|
+
for (const key in requestData) {
|
|
330
|
+
formData.append(key, requestData[key]);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
fetch('/ConnectionManager/QueryElasticsearchDocuments/', {
|
|
334
|
+
method: 'POST',
|
|
335
|
+
body: formData,
|
|
336
|
+
headers: {
|
|
337
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
.then(response => response.json())
|
|
341
|
+
.then(data => {
|
|
342
|
+
if (data.error) {
|
|
343
|
+
previewContent.innerHTML = `<div class="text-red-400">Error: ${escapeHtml(data.error)}</div>`;
|
|
344
|
+
} else {
|
|
345
|
+
const documents = data.documents || [];
|
|
346
|
+
if (documents.length === 0) {
|
|
347
|
+
previewContent.innerHTML = '<div class="text-yellow-400">No documents found matching your criteria</div>';
|
|
348
|
+
} else {
|
|
349
|
+
let html = `<div class="text-green-400 mb-4">Found ${documents.length} document(s)</div>`;
|
|
350
|
+
documents.forEach((doc, idx) => {
|
|
351
|
+
html += `<div class="mb-4 pb-4 border-b border-gray-700">`;
|
|
352
|
+
html += `<div class="text-blue-400 font-semibold mb-2">Document ${idx + 1}:</div>`;
|
|
353
|
+
html += `<pre class="whitespace-pre-wrap overflow-x-auto">${JSON.stringify(doc, null, 2)}</pre>`;
|
|
354
|
+
html += `</div>`;
|
|
355
|
+
});
|
|
356
|
+
previewContent.innerHTML = html;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
.catch(error => {
|
|
361
|
+
previewContent.innerHTML = `<div class="text-red-400">Error fetching preview: ${escapeHtml(error.message)}</div>`;
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function closePreviewModal() {
|
|
366
|
+
const previewModal = document.getElementById('previewModal');
|
|
367
|
+
previewModal.classList.add('hidden');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Global storage for simulation documents and run IDs
|
|
371
|
+
window.simulationDocuments = [];
|
|
372
|
+
window.simulationRunIds = [];
|
|
373
|
+
window.currentDocumentIndex = 0;
|
|
374
|
+
|
|
375
|
+
// Intercept form submission to handle both ES and multiline text input
|
|
376
|
+
// Wait for DOM to ensure form element exists before attaching event listener
|
|
377
|
+
if (document.readyState === 'loading') {
|
|
378
|
+
document.addEventListener('DOMContentLoaded', attachFormListener);
|
|
379
|
+
} else {
|
|
380
|
+
attachFormListener();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function attachFormListener() {
|
|
384
|
+
const form = document.getElementById('simulationForm');
|
|
385
|
+
if (form && form.dataset.simSubmitBound === '1') {
|
|
386
|
+
return; // Prevent double-submit from re-binding
|
|
387
|
+
}
|
|
388
|
+
if (form) {
|
|
389
|
+
form.dataset.simSubmitBound = '1';
|
|
390
|
+
form.addEventListener('submit', async function(event) {
|
|
391
|
+
event.preventDefault();
|
|
392
|
+
event.stopPropagation();
|
|
393
|
+
|
|
394
|
+
// Guard against double-clicks while a run is in flight
|
|
395
|
+
if (form.dataset.simRunning === '1') {
|
|
396
|
+
console.warn('[sim] Ignoring duplicate simulate submit');
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Check if there are any filters in the pipeline (before closing modal)
|
|
401
|
+
let pipelineComponents;
|
|
402
|
+
if (typeof getSubsetComponents === 'function') {
|
|
403
|
+
pipelineComponents = getSubsetComponents();
|
|
404
|
+
} else {
|
|
405
|
+
pipelineComponents = typeof components !== 'undefined' ? components : (window.components || {});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Validate that there are filters
|
|
409
|
+
if (!pipelineComponents.filter || pipelineComponents.filter.length === 0) {
|
|
410
|
+
if (typeof showToast === 'function') {
|
|
411
|
+
showToast("There aren't any filters in your pipeline. Please add at least one filter and try again.", 'error');
|
|
412
|
+
} else {
|
|
413
|
+
await ConfirmationModal.show("There aren't any filters in your pipeline. Please add at least one filter and try again.", 'No Filters', 'OK', null, true);
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
form.dataset.simRunning = '1';
|
|
419
|
+
const submitBtns = form.querySelectorAll('button[type="submit"], #runSimulationBtn, #simulateSubmitBtn');
|
|
420
|
+
submitBtns.forEach((b) => { b.disabled = true; });
|
|
421
|
+
|
|
422
|
+
const inputSource = document.querySelector('input[name="inputSource"]:checked').value;
|
|
423
|
+
const logInput = document.getElementById('logInput');
|
|
424
|
+
let documents = [];
|
|
425
|
+
|
|
426
|
+
// Determine documents to simulate
|
|
427
|
+
if (inputSource === 'text') {
|
|
428
|
+
const multilineCheckbox = document.getElementById('multilineCheckbox');
|
|
429
|
+
const isMultiline = multilineCheckbox ? multilineCheckbox.checked : false;
|
|
430
|
+
|
|
431
|
+
// Check if input has multiple lines
|
|
432
|
+
const lines = logInput.value.split('\n').filter(line => line.trim());
|
|
433
|
+
const hasMultipleLines = lines.length > 1;
|
|
434
|
+
|
|
435
|
+
if (hasMultipleLines) {
|
|
436
|
+
// Multiple document mode - treat each line as separate document
|
|
437
|
+
documents = lines.map(line => {
|
|
438
|
+
try {
|
|
439
|
+
return JSON.parse(line);
|
|
440
|
+
} catch {
|
|
441
|
+
return { message: line };
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
} else {
|
|
445
|
+
// Single document
|
|
446
|
+
try {
|
|
447
|
+
documents = [JSON.parse(logInput.value)];
|
|
448
|
+
} catch {
|
|
449
|
+
documents = [{ message: logInput.value }];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
} else if (inputSource === 'elasticsearch') {
|
|
453
|
+
// Fetch ES documents
|
|
454
|
+
const connection_id = document.getElementById('esConnection').value;
|
|
455
|
+
const index = document.getElementById('esIndexInput').value;
|
|
456
|
+
const query_method = document.querySelector('input[name="esQueryMethod"]:checked').value;
|
|
457
|
+
|
|
458
|
+
if (!connection_id || !index) {
|
|
459
|
+
await ConfirmationModal.show('Please select a connection and index.', 'Validation', 'OK', null, true);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const formData = new FormData();
|
|
464
|
+
formData.append('connection_id', connection_id);
|
|
465
|
+
formData.append('index', index);
|
|
466
|
+
formData.append('query_method', query_method);
|
|
467
|
+
|
|
468
|
+
if (query_method === 'field') {
|
|
469
|
+
const field = document.getElementById('esField').value;
|
|
470
|
+
const size = document.getElementById('esSize').value;
|
|
471
|
+
const query = document.getElementById('esQuery').value;
|
|
472
|
+
if (!field) {
|
|
473
|
+
await ConfirmationModal.show('Please select a field.', 'Validation', 'OK', null, true);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
formData.append('field', field);
|
|
477
|
+
formData.append('size', size);
|
|
478
|
+
formData.append('query', query);
|
|
479
|
+
} else if (query_method === 'entire') {
|
|
480
|
+
const size = document.getElementById('esSizeEntire').value;
|
|
481
|
+
const query = document.getElementById('esQueryEntire').value;
|
|
482
|
+
formData.append('size', size);
|
|
483
|
+
formData.append('query', query);
|
|
484
|
+
} else if (query_method === 'docid') {
|
|
485
|
+
const doc_ids = document.getElementById('esDocIds').value;
|
|
486
|
+
if (!doc_ids.trim()) {
|
|
487
|
+
await ConfirmationModal.show('Please enter at least one document ID.', 'Validation', 'OK', null, true);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
formData.append('doc_ids', doc_ids);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
try {
|
|
494
|
+
const response = await fetch('/ConnectionManager/QueryElasticsearchDocuments/', {
|
|
495
|
+
method: 'POST',
|
|
496
|
+
body: formData,
|
|
497
|
+
headers: {
|
|
498
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
const data = await response.json();
|
|
503
|
+
if (data.error) {
|
|
504
|
+
await ConfirmationModal.show('Error fetching documents: ' + escapeHtml(data.error), 'Fetch Error', 'OK', null, true);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
documents = data.documents || [];
|
|
509
|
+
if (documents.length === 0) {
|
|
510
|
+
await ConfirmationModal.show('No documents found matching your criteria in index ' + escapeHtml(index) + '.', 'No Documents', 'OK', null, true);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
} catch (error) {
|
|
514
|
+
await ConfirmationModal.show('Error fetching documents: ' + escapeHtml(error.message), 'Fetch Error', 'OK', null, true);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Store documents globally
|
|
520
|
+
window.simulationDocuments = documents;
|
|
521
|
+
window.currentDocumentIndex = 0;
|
|
522
|
+
window.simulationRunIds = [];
|
|
523
|
+
|
|
524
|
+
// Submit all documents simultaneously
|
|
525
|
+
try {
|
|
526
|
+
await submitAllDocuments(documents);
|
|
527
|
+
} finally {
|
|
528
|
+
form.dataset.simRunning = '0';
|
|
529
|
+
submitBtns.forEach((b) => { b.disabled = false; });
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Allocate exactly one slot for this simulate session (not per document).
|
|
537
|
+
* Returns slot id string/number or null.
|
|
538
|
+
*/
|
|
539
|
+
async function allocateSessionSlot(componentsData) {
|
|
540
|
+
const formData = new FormData();
|
|
541
|
+
formData.append('components', JSON.stringify(componentsData));
|
|
542
|
+
formData.append('log_text', ''); // allocate only — no document payload
|
|
543
|
+
formData.append('csrfmiddlewaretoken', document.querySelector('[name=csrfmiddlewaretoken]').value);
|
|
544
|
+
const esId = new URLSearchParams(window.location.search).get('es_id');
|
|
545
|
+
const pipelineName = new URLSearchParams(window.location.search).get('pipeline');
|
|
546
|
+
const lsId = new URLSearchParams(window.location.search).get('ls_id');
|
|
547
|
+
if (esId) formData.append('es_id', esId);
|
|
548
|
+
if (pipelineName) formData.append('pipeline', pipelineName);
|
|
549
|
+
if (lsId) formData.append('ls_id', lsId);
|
|
550
|
+
if (typeof window.appendSimConnectionToFormData === 'function') {
|
|
551
|
+
window.appendSimConnectionToFormData(formData);
|
|
552
|
+
} else if (typeof window.getSimConnectionId === 'function' && window.getSimConnectionId()) {
|
|
553
|
+
formData.append('sim_connection_id', window.getSimConnectionId());
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
console.log('[FE->BE] Session slot allocate (once for all documents)');
|
|
557
|
+
const response = await fetch('/ConnectionManager/SimulatePipeline/', {
|
|
558
|
+
method: 'POST',
|
|
559
|
+
body: formData,
|
|
560
|
+
headers: {
|
|
561
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
562
|
+
},
|
|
563
|
+
});
|
|
564
|
+
const html = await response.text();
|
|
565
|
+
const slotMatch =
|
|
566
|
+
html.match(/data-slot-id="(\d+)"/) ||
|
|
567
|
+
html.match(/Slot\s+(\d+)/i);
|
|
568
|
+
if (!slotMatch) {
|
|
569
|
+
console.error('[FE->BE] Session allocate failed:', html.slice(0, 500));
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
return slotMatch[1];
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Function to submit all documents for simulation.
|
|
576
|
+
// Session owns the slot: allocate once (or reuse warm slot), then feed every
|
|
577
|
+
// document into that slot in series (never allocate per document).
|
|
578
|
+
async function submitAllDocuments(documents) {
|
|
579
|
+
// Create a deep copy of components with file paths updated for simulation
|
|
580
|
+
window.simulationComponents = createSimulationComponentsCopy();
|
|
581
|
+
|
|
582
|
+
// Immediate UX — don't leave the modal sitting open during allocate (can take seconds)
|
|
583
|
+
const docLabel =
|
|
584
|
+
documents.length > 1
|
|
585
|
+
? `Simulation started (${documents.length} documents)…`
|
|
586
|
+
: 'Simulation started…';
|
|
587
|
+
if (typeof showToast === 'function') {
|
|
588
|
+
showToast(docLabel, 'success');
|
|
589
|
+
}
|
|
590
|
+
if (typeof closeSimulationModal === 'function') {
|
|
591
|
+
closeSimulationModal();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Prefer warm slot from page-load prealloc when available (skip a full re-allocate).
|
|
595
|
+
// Slot must belong to the *currently selected* sim agent — embedded slot-1 ≠ simulate-N slot-1.
|
|
596
|
+
const currentSimConn =
|
|
597
|
+
(typeof window.getSimConnectionId === 'function' && window.getSimConnectionId()) ||
|
|
598
|
+
null;
|
|
599
|
+
let sessionSlotId =
|
|
600
|
+
typeof window.getWarmSessionSlotForCurrentTarget === 'function'
|
|
601
|
+
? window.getWarmSessionSlotForCurrentTarget()
|
|
602
|
+
: null;
|
|
603
|
+
|
|
604
|
+
// Belt-and-suspenders: if anything still points at another agent's slot, drop it.
|
|
605
|
+
if (
|
|
606
|
+
sessionSlotId &&
|
|
607
|
+
currentSimConn &&
|
|
608
|
+
window.simulationSessionConnectionId &&
|
|
609
|
+
String(window.simulationSessionConnectionId) !== String(currentSimConn)
|
|
610
|
+
) {
|
|
611
|
+
console.warn(
|
|
612
|
+
'[FE->BE] Dropping cross-node session slot',
|
|
613
|
+
sessionSlotId,
|
|
614
|
+
'from',
|
|
615
|
+
window.simulationSessionConnectionId,
|
|
616
|
+
'→ current',
|
|
617
|
+
currentSimConn
|
|
618
|
+
);
|
|
619
|
+
if (typeof window.clearSimulationSessionSlot === 'function') {
|
|
620
|
+
window.clearSimulationSessionSlot('cross-node reject on Run');
|
|
621
|
+
}
|
|
622
|
+
sessionSlotId = null;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// If target-switch warm is still running on *this* agent, join it.
|
|
626
|
+
if (
|
|
627
|
+
!sessionSlotId &&
|
|
628
|
+
typeof window.isSlotWarmInFlightForCurrentTarget === 'function' &&
|
|
629
|
+
window.isSlotWarmInFlightForCurrentTarget() &&
|
|
630
|
+
typeof window.warmSlotForCurrentTarget === 'function'
|
|
631
|
+
) {
|
|
632
|
+
console.log('[FE->BE] Run waiting for in-flight slot warm (same agent)');
|
|
633
|
+
if (typeof window.setPipelineSlotChip === 'function') {
|
|
634
|
+
window.setPipelineSlotChip('warming', {
|
|
635
|
+
title: 'Waiting for slot allocate already in progress…',
|
|
636
|
+
warmLabel: 'Warming…',
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
sessionSlotId = await window.warmSlotForCurrentTarget({
|
|
641
|
+
showWarming: true,
|
|
642
|
+
connectionId: currentSimConn,
|
|
643
|
+
});
|
|
644
|
+
} catch (e) {
|
|
645
|
+
console.error('[FE->BE] join in-flight warm failed', e);
|
|
646
|
+
sessionSlotId = null;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
if (sessionSlotId) {
|
|
651
|
+
console.log(
|
|
652
|
+
'[FE->BE] Using pre-warmed session slot',
|
|
653
|
+
sessionSlotId,
|
|
654
|
+
'on connection',
|
|
655
|
+
window.simulationSessionConnectionId || currentSimConn,
|
|
656
|
+
'(skip allocate on Run)'
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (!sessionSlotId) {
|
|
661
|
+
// No warm on *this* node — allocate now (never reuse another node's slot id).
|
|
662
|
+
if (typeof window.setPipelineSlotChip === 'function') {
|
|
663
|
+
window.setPipelineSlotChip('warming', {
|
|
664
|
+
title: currentSimConn
|
|
665
|
+
? `Preparing simulation slot on agent ${currentSimConn}…`
|
|
666
|
+
: 'Preparing simulation slot…',
|
|
667
|
+
warmLabel: 'Preparing…',
|
|
668
|
+
});
|
|
669
|
+
} else {
|
|
670
|
+
const statusContainer = document.getElementById('pipelineLoadStatus');
|
|
671
|
+
const statusMessage = document.getElementById('pipelineStatusMessage');
|
|
672
|
+
if (statusContainer && statusMessage) {
|
|
673
|
+
statusContainer.title = 'Preparing simulation slot…';
|
|
674
|
+
statusMessage.className = 'text-xs font-medium text-gray-300 truncate';
|
|
675
|
+
statusMessage.textContent = 'Preparing…';
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
try {
|
|
679
|
+
if (typeof window.warmSlotForCurrentTarget === 'function') {
|
|
680
|
+
sessionSlotId = await window.warmSlotForCurrentTarget({
|
|
681
|
+
showWarming: true,
|
|
682
|
+
forceNew: true,
|
|
683
|
+
preferCache: false,
|
|
684
|
+
connectionId: currentSimConn,
|
|
685
|
+
});
|
|
686
|
+
} else {
|
|
687
|
+
sessionSlotId = await allocateSessionSlot(window.simulationComponents);
|
|
688
|
+
}
|
|
689
|
+
} catch (e) {
|
|
690
|
+
console.error(e);
|
|
691
|
+
sessionSlotId = null;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (!sessionSlotId) {
|
|
696
|
+
showToast('Failed to allocate simulation slot for this session', 'error');
|
|
697
|
+
setPipelineSlotStatusFailed('Session slot allocate failed');
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (typeof window.rememberSimulationSessionSlot === 'function') {
|
|
702
|
+
window.rememberSimulationSessionSlot(sessionSlotId, currentSimConn);
|
|
703
|
+
} else {
|
|
704
|
+
window.simulationSessionSlotId = sessionSlotId;
|
|
705
|
+
window.simulationSessionConnectionId =
|
|
706
|
+
currentSimConn != null ? String(currentSimConn) : null;
|
|
707
|
+
if (typeof currentSlotId !== 'undefined') {
|
|
708
|
+
currentSlotId = sessionSlotId;
|
|
709
|
+
}
|
|
710
|
+
window.currentSlotId = sessionSlotId;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// Chip → Ready once session slot is known
|
|
714
|
+
{
|
|
715
|
+
const statusContainer = document.getElementById('pipelineLoadStatus');
|
|
716
|
+
const statusMessage = document.getElementById('pipelineStatusMessage');
|
|
717
|
+
let statusIcon = document.getElementById('pipelineStatusIcon');
|
|
718
|
+
if (statusContainer && statusMessage) {
|
|
719
|
+
statusContainer.className =
|
|
720
|
+
'inline-flex items-center gap-1.5 px-2 py-1 rounded-full border border-green-600 bg-green-900/30 max-w-[11rem]';
|
|
721
|
+
statusContainer.title = `Simulation session slot ${sessionSlotId}`;
|
|
722
|
+
if (statusIcon) {
|
|
723
|
+
statusIcon.outerHTML = `
|
|
724
|
+
<svg id="pipelineStatusIcon" class="w-3.5 h-3.5 text-green-400 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
725
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
|
726
|
+
</svg>
|
|
727
|
+
`;
|
|
728
|
+
}
|
|
729
|
+
statusMessage.className = 'text-xs font-medium text-green-300 truncate';
|
|
730
|
+
statusMessage.textContent = `Slot ${sessionSlotId}`;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Initialize run_ids array
|
|
735
|
+
window.simulationRunIds = new Array(documents.length).fill(null);
|
|
736
|
+
|
|
737
|
+
// Feed documents in series into the same session slot
|
|
738
|
+
for (let index = 0; index < documents.length; index++) {
|
|
739
|
+
await submitAndPollDocument(documents[index], index, sessionSlotId);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// Function to create a deep copy of components with file paths updated for simulation only
|
|
744
|
+
function createSimulationComponentsCopy() {
|
|
745
|
+
// Get the original components (use subset if in subset mode)
|
|
746
|
+
let originalComponents;
|
|
747
|
+
if (typeof getSubsetComponents === 'function') {
|
|
748
|
+
originalComponents = getSubsetComponents();
|
|
749
|
+
} else {
|
|
750
|
+
originalComponents = typeof components !== 'undefined' ? components : (window.components || {});
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// Create a deep copy using JSON parse/stringify
|
|
754
|
+
const componentsCopy = JSON.parse(JSON.stringify(originalComponents));
|
|
755
|
+
|
|
756
|
+
// Find all file path inputs in the modal
|
|
757
|
+
const filePathInputs = document.querySelectorAll('#filePathPluginList input[type="text"][data-generated-filename]');
|
|
758
|
+
|
|
759
|
+
// Update the copy with file paths
|
|
760
|
+
filePathInputs.forEach(input => {
|
|
761
|
+
const componentId = input.dataset.componentId;
|
|
762
|
+
const optionName = input.dataset.optionName;
|
|
763
|
+
const pluginType = input.dataset.pluginType;
|
|
764
|
+
const generatedFilename = input.dataset.generatedFilename;
|
|
765
|
+
const isIgnored = input.disabled; // If disabled, it's ignored
|
|
766
|
+
|
|
767
|
+
if (!componentId || !optionName || !generatedFilename || isIgnored) {
|
|
768
|
+
return; // Skip if missing data or ignored
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Prepend the logstashagent uploaded directory path
|
|
772
|
+
const fullPath = `/tmp/uploaded/${generatedFilename}`;
|
|
773
|
+
|
|
774
|
+
// Find the component by ID in the COPY and update its config
|
|
775
|
+
if (componentsCopy[pluginType]) {
|
|
776
|
+
const component = componentsCopy[pluginType].find(c => c.id === componentId);
|
|
777
|
+
if (component && component.config) {
|
|
778
|
+
// Update the config with the full path in the COPY only
|
|
779
|
+
component.config[optionName] = fullPath;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
return componentsCopy;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Function to submit a single document into an already-allocated session slot
|
|
788
|
+
async function submitAndPollDocument(doc, index, sessionSlotId) {
|
|
789
|
+
// Use the simulation components copy (with file paths updated)
|
|
790
|
+
// This was created in submitAllDocuments and stored in window.simulationComponents
|
|
791
|
+
const componentsData = window.simulationComponents;
|
|
792
|
+
const slotId = sessionSlotId || window.simulationSessionSlotId;
|
|
793
|
+
if (!slotId) {
|
|
794
|
+
console.error('[FE->BE] submitAndPollDocument called without session slot');
|
|
795
|
+
showToast(`Document ${index + 1}: no session slot`, 'error');
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Get es_id and pipeline from URL parameters
|
|
800
|
+
const esId = new URLSearchParams(window.location.search).get('es_id');
|
|
801
|
+
const pipelineName = new URLSearchParams(window.location.search).get('pipeline');
|
|
802
|
+
|
|
803
|
+
const formData = new FormData();
|
|
804
|
+
formData.append('log_text', JSON.stringify(doc));
|
|
805
|
+
formData.append('components', JSON.stringify(componentsData));
|
|
806
|
+
formData.append('slot_id', String(slotId)); // session slot — server skips allocate
|
|
807
|
+
formData.append('es_id', esId);
|
|
808
|
+
formData.append('pipeline', pipelineName);
|
|
809
|
+
const lsId = new URLSearchParams(window.location.search).get('ls_id');
|
|
810
|
+
if (lsId) {
|
|
811
|
+
formData.append('ls_id', lsId);
|
|
812
|
+
}
|
|
813
|
+
formData.append('csrfmiddlewaretoken', document.querySelector('[name=csrfmiddlewaretoken]').value);
|
|
814
|
+
if (typeof window.appendSimConnectionToFormData === 'function') {
|
|
815
|
+
window.appendSimConnectionToFormData(formData);
|
|
816
|
+
} else if (typeof window.getSimConnectionId === 'function' && window.getSimConnectionId()) {
|
|
817
|
+
formData.append('sim_connection_id', window.getSimConnectionId());
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
console.log('[FE->BE] Document into session slot', {
|
|
821
|
+
docIndex: index,
|
|
822
|
+
slotId: slotId,
|
|
823
|
+
filterCount: componentsData.filter?.length || 0,
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
try {
|
|
827
|
+
const response = await fetch('/ConnectionManager/SimulatePipeline/', {
|
|
828
|
+
method: 'POST',
|
|
829
|
+
body: formData,
|
|
830
|
+
headers: {
|
|
831
|
+
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
const html = await response.text();
|
|
836
|
+
|
|
837
|
+
// Extract data from response - look for initSimulationResults() call or setAttribute() calls
|
|
838
|
+
// Try to match initSimulationResults('run_id') first
|
|
839
|
+
let runIdMatch = html.match(/initSimulationResults\(['"]([^'"]+)['"]\)/);
|
|
840
|
+
// Also try setAttribute / data-run-id (incl. forward-timeout shell)
|
|
841
|
+
if (!runIdMatch) {
|
|
842
|
+
runIdMatch = html.match(/setAttribute\(['"]data-run-id['"],\s*['"]([^'"]+)['"]\)/);
|
|
843
|
+
}
|
|
844
|
+
if (!runIdMatch) {
|
|
845
|
+
runIdMatch = html.match(/data-run-id=["']([^"']+)["']/);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// Extract slot_id from setAttribute / data-slot-id
|
|
849
|
+
let slotIdMatch = html.match(/setAttribute\(['"]data-slot-id['"],\s*['"]([^'"]+)['"]\)/);
|
|
850
|
+
if (!slotIdMatch) {
|
|
851
|
+
slotIdMatch = html.match(/data-slot-id=["']([^"']+)["']/);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// Extract filter count from text content
|
|
855
|
+
const filterCountMatch = html.match(/(\d+)\s+filters/);
|
|
856
|
+
const forwardSlow =
|
|
857
|
+
/data-sim-forward-error|forward timed out|Read timed out|Error sending simulation/i.test(
|
|
858
|
+
html
|
|
859
|
+
);
|
|
860
|
+
|
|
861
|
+
if (runIdMatch) {
|
|
862
|
+
const runId = runIdMatch[1];
|
|
863
|
+
const respSlotId = slotIdMatch ? slotIdMatch[1] : slotId;
|
|
864
|
+
const filterCount = filterCountMatch ? filterCountMatch[1] : '0';
|
|
865
|
+
|
|
866
|
+
// Store run_id BEFORE doing anything else
|
|
867
|
+
window.simulationRunIds[index] = runId;
|
|
868
|
+
|
|
869
|
+
if (forwardSlow) {
|
|
870
|
+
// Slot is fine; agent/Logstash was slow to accept. Keep Ready and poll.
|
|
871
|
+
console.warn(
|
|
872
|
+
'[FE->BE] Simulation forward was slow/timed out; still polling run_id',
|
|
873
|
+
runId
|
|
874
|
+
);
|
|
875
|
+
if (typeof showToast === 'function') {
|
|
876
|
+
showToast(
|
|
877
|
+
`Document ${index + 1}: agent was slow to accept — waiting for results…`,
|
|
878
|
+
'info'
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Update status chip to show pipeline is ready (for first document only)
|
|
884
|
+
if (index === 0 && respSlotId) {
|
|
885
|
+
if (typeof window.setPipelineSlotChip === 'function') {
|
|
886
|
+
window.setPipelineSlotChip('ready', {
|
|
887
|
+
slotId: respSlotId,
|
|
888
|
+
title: `Simulation ready (slot ${respSlotId})`,
|
|
889
|
+
});
|
|
890
|
+
} else if (typeof window.rememberSimulationSessionSlot === 'function') {
|
|
891
|
+
window.rememberSimulationSessionSlot(respSlotId);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// For first document, show overlay by calling functions directly
|
|
896
|
+
if (index === 0) {
|
|
897
|
+
// Check if Text Mode is selected in the modal
|
|
898
|
+
const viewModeRadio = document.querySelector('input[name="viewMode"]:checked');
|
|
899
|
+
const isTextMode = viewModeRadio && viewModeRadio.value === 'text';
|
|
900
|
+
|
|
901
|
+
if (isTextMode) {
|
|
902
|
+
// Text Mode: Don't create overlay, keep modal open and show results in modal
|
|
903
|
+
if (typeof initSimulationResults === 'function') {
|
|
904
|
+
initSimulationResults(runId);
|
|
905
|
+
}
|
|
906
|
+
} else {
|
|
907
|
+
// Overlay Mode: Close the modal and create overlay
|
|
908
|
+
createSimulationOverlay(runId, respSlotId, filterCount);
|
|
909
|
+
|
|
910
|
+
// Initialize the simulation results polling
|
|
911
|
+
if (typeof initSimulationResults === 'function') {
|
|
912
|
+
initSimulationResults(runId);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
} else {
|
|
916
|
+
// For other documents, just start polling in background
|
|
917
|
+
if (typeof initSimulationResults === 'function') {
|
|
918
|
+
initSimulationResults(runId);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
return runId;
|
|
923
|
+
} else {
|
|
924
|
+
console.error('No run_id found in response for document', index);
|
|
925
|
+
console.error('Response content:', html.slice(0, 800));
|
|
926
|
+
const n = index + 1;
|
|
927
|
+
let hint = `Document ${n}: simulation failed (no run_id in response)`;
|
|
928
|
+
if (html.includes('Error allocating')) {
|
|
929
|
+
hint = `Document ${n}: slot allocate failed`;
|
|
930
|
+
} else if (/timed out|Timeout|Error sending simulation/i.test(html)) {
|
|
931
|
+
hint = `Document ${n}: simulation timed out talking to agent`;
|
|
932
|
+
} else {
|
|
933
|
+
const errMatch = html.match(/Error[^<:]*:\s*([^<]+)/i);
|
|
934
|
+
if (errMatch) {
|
|
935
|
+
hint = `Document ${n}: ${errMatch[1].trim().slice(0, 120)}`;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
showToast(hint, 'error');
|
|
939
|
+
// Only paint Failed when allocate itself failed. A document-send problem
|
|
940
|
+
// should not mark a valid warm slot as dead (user can Retry docs).
|
|
941
|
+
if (html.includes('Error allocating') || !slotId) {
|
|
942
|
+
setPipelineSlotStatusFailed(hint);
|
|
943
|
+
}
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
} catch (error) {
|
|
947
|
+
console.error('Error submitting document', index, ':', error);
|
|
948
|
+
const n = index + 1;
|
|
949
|
+
const hint = `Document ${n}: ${error.message || 'request failed'}`;
|
|
950
|
+
showToast(hint, 'error');
|
|
951
|
+
// Network abort/timeout after slot warm — keep slot Ready if we have one
|
|
952
|
+
if (!slotId) {
|
|
953
|
+
setPipelineSlotStatusFailed(hint);
|
|
954
|
+
}
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/** Compact status chip: failed allocation / sim (clickable retry via setPipelineSlotChip) */
|
|
960
|
+
function setPipelineSlotStatusFailed(detail) {
|
|
961
|
+
if (typeof window.setPipelineSlotChip === 'function') {
|
|
962
|
+
window.setPipelineSlotChip('failed', {
|
|
963
|
+
title: detail || 'Simulation failed',
|
|
964
|
+
});
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
const statusContainer = document.getElementById('pipelineLoadStatus');
|
|
968
|
+
let statusIcon = document.getElementById('pipelineStatusIcon');
|
|
969
|
+
const statusMessage = document.getElementById('pipelineStatusMessage');
|
|
970
|
+
if (!statusContainer || !statusMessage) return;
|
|
971
|
+
statusContainer.className =
|
|
972
|
+
'inline-flex items-center gap-1.5 px-2 py-1 rounded-full border border-red-600/50 bg-red-900/20 max-w-[11rem]';
|
|
973
|
+
statusContainer.title = detail || 'Simulation failed';
|
|
974
|
+
if (statusIcon) {
|
|
975
|
+
statusIcon.outerHTML = `
|
|
976
|
+
<svg id="pipelineStatusIcon" class="w-3.5 h-3.5 text-red-400 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
977
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
|
978
|
+
</svg>
|
|
979
|
+
`;
|
|
980
|
+
}
|
|
981
|
+
statusMessage.className = 'text-xs font-medium text-red-300 truncate';
|
|
982
|
+
statusMessage.textContent = 'Failed';
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
// Create simulation overlay (replaces eval'd script from template)
|
|
987
|
+
function createSimulationOverlay(runId, slotId, filterCount) {
|
|
988
|
+
// Close the modal
|
|
989
|
+
setTimeout(() => {
|
|
990
|
+
if (typeof closeSimulationModal === 'function') {
|
|
991
|
+
closeSimulationModal();
|
|
992
|
+
} else {
|
|
993
|
+
const modal = document.getElementById('simulationModal');
|
|
994
|
+
if (modal) {
|
|
995
|
+
modal.classList.add('hidden');
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}, 100);
|
|
999
|
+
|
|
1000
|
+
// Remove any existing overlay
|
|
1001
|
+
const existingOverlay = document.getElementById('simulation-overlay');
|
|
1002
|
+
if (existingOverlay) {
|
|
1003
|
+
existingOverlay.remove();
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// Create and show the overlay
|
|
1007
|
+
const overlay = document.createElement('div');
|
|
1008
|
+
overlay.id = 'simulation-overlay';
|
|
1009
|
+
overlay.className = 'sticky top-0 z-40 bg-gray-900 border-b-2 border-green-500 shadow-lg rounded-lg';
|
|
1010
|
+
overlay.style.height = '150px';
|
|
1011
|
+
overlay.setAttribute('data-run-id', runId);
|
|
1012
|
+
overlay.setAttribute('data-slot-id', slotId);
|
|
1013
|
+
|
|
1014
|
+
overlay.innerHTML = `
|
|
1015
|
+
<div class="h-full flex flex-col">
|
|
1016
|
+
<div class="flex items-center justify-between px-4 py-2 bg-gray-800 border-b border-gray-700">
|
|
1017
|
+
<div class="flex items-center gap-3">
|
|
1018
|
+
<span class="text-green-400 font-semibold">✓ Simulation Results</span>
|
|
1019
|
+
<span class="text-xs text-gray-400">Run ID: ${runId}</span>
|
|
1020
|
+
<span id="totalExecutionTime" class="text-xs text-yellow-400 font-semibold" style="display: none;"></span>
|
|
1021
|
+
<span class="text-xs text-gray-400">${filterCount} filters</span>
|
|
1022
|
+
<div id="documentNavigation" style="display: none;" class="flex items-center gap-2 px-3 py-1 bg-gray-700 rounded-lg">
|
|
1023
|
+
<button onclick="previousDocument()" id="prevDocBtn" class="text-gray-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed" title="Previous document">
|
|
1024
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
1025
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
|
|
1026
|
+
</svg>
|
|
1027
|
+
</button>
|
|
1028
|
+
<span id="documentCounter" class="text-xs text-gray-300 min-w-[60px] text-center">1 / 1</span>
|
|
1029
|
+
<button onclick="nextDocument()" id="nextDocBtn" class="text-gray-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed" title="Next document">
|
|
1030
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
1031
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
|
1032
|
+
</svg>
|
|
1033
|
+
</button>
|
|
1034
|
+
</div>
|
|
1035
|
+
<div id="simulation-loading-indicator" class="flex items-center gap-2">
|
|
1036
|
+
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-green-400"></div>
|
|
1037
|
+
<span class="text-xs text-gray-400">Loading results...</span>
|
|
1038
|
+
</div>
|
|
1039
|
+
<div id="viewModeSelector" style="display: none;" class="flex items-center gap-3 px-3 py-1 bg-gray-700 rounded-lg">
|
|
1040
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
1041
|
+
<input type="radio" name="overlayViewMode" value="debugger" checked onchange="switchOverlayView('debugger')" class="text-blue-600 focus:ring-blue-500">
|
|
1042
|
+
<span class="text-sm text-gray-300">Overlay</span>
|
|
1043
|
+
</label>
|
|
1044
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
1045
|
+
<input type="radio" name="overlayViewMode" value="text" onchange="switchOverlayView('text')" class="text-blue-600 focus:ring-blue-500">
|
|
1046
|
+
<span class="text-sm text-gray-300">Text</span>
|
|
1047
|
+
</label>
|
|
1048
|
+
</div>
|
|
1049
|
+
</div>
|
|
1050
|
+
<div class="flex items-center gap-2">
|
|
1051
|
+
<button onclick="toggleOverlayExpand()"
|
|
1052
|
+
id="expandOverlayBtn"
|
|
1053
|
+
class="text-gray-400 hover:text-white px-2 py-1 rounded hover:bg-gray-700"
|
|
1054
|
+
title="Expand to full screen">
|
|
1055
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
1056
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"></path>
|
|
1057
|
+
</svg>
|
|
1058
|
+
</button>
|
|
1059
|
+
<button onclick="cleanupSimulation()"
|
|
1060
|
+
class="text-gray-400 hover:text-white px-2 py-1 rounded hover:bg-gray-700">
|
|
1061
|
+
✕ Close
|
|
1062
|
+
</button>
|
|
1063
|
+
</div>
|
|
1064
|
+
</div>
|
|
1065
|
+
<div id="results-container" class="flex-1 bg-gray-900 overflow-x-auto overflow-y-hidden">
|
|
1066
|
+
<svg id="pipeline-graph" width="100%" height="100" class="bg-gray-900"></svg>
|
|
1067
|
+
</div>
|
|
1068
|
+
<div id="textViewContainer" style="display: none;" class="flex-1 bg-gray-900 overflow-y-auto p-4">
|
|
1069
|
+
<div id="textViewContent" class="space-y-4 font-mono text-sm">
|
|
1070
|
+
<!-- Text view will be populated here -->
|
|
1071
|
+
</div>
|
|
1072
|
+
</div>
|
|
1073
|
+
</div>
|
|
1074
|
+
`;
|
|
1075
|
+
|
|
1076
|
+
// Insert overlay at the beginning of the content area (after navigation)
|
|
1077
|
+
const contentArea = document.querySelector('main') || document.querySelector('.container') || document.body;
|
|
1078
|
+
if (contentArea.firstChild) {
|
|
1079
|
+
contentArea.insertBefore(overlay, contentArea.firstChild);
|
|
1080
|
+
} else {
|
|
1081
|
+
contentArea.appendChild(overlay);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// Listen for simulation data updates and display in text mode if selected
|
|
1086
|
+
window.addEventListener('simulationDataReady', function(event) {
|
|
1087
|
+
const viewMode = document.querySelector('input[name="viewMode"]:checked');
|
|
1088
|
+
if (viewMode && viewMode.value === 'text') {
|
|
1089
|
+
const textViewContainer = document.getElementById('textViewContainerModal');
|
|
1090
|
+
if (textViewContainer && event.detail) {
|
|
1091
|
+
textViewContainer.style.display = 'block';
|
|
1092
|
+
generateTextViewModal(event.detail);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
function generateTextViewModal(data) {
|
|
1098
|
+
const textViewContent = document.getElementById('textViewContentModal');
|
|
1099
|
+
if (!textViewContent || !data.nodes) return;
|
|
1100
|
+
|
|
1101
|
+
const html = window.generateTextView ? window.generateTextView(data) : '';
|
|
1102
|
+
textViewContent.innerHTML = html;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
function clearSimulationResults() {
|
|
1106
|
+
const resultsDiv = document.getElementById('simulationResults');
|
|
1107
|
+
if (resultsDiv) resultsDiv.innerHTML = '';
|
|
1108
|
+
|
|
1109
|
+
const textView = document.getElementById('textViewContentModal');
|
|
1110
|
+
if (textView) textView.innerHTML = '';
|
|
1111
|
+
|
|
1112
|
+
window.simulationData = null;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
function closeSimulationModal() {
|
|
1116
|
+
const modal = document.getElementById('simulationModal');
|
|
1117
|
+
if (modal) modal.classList.add('hidden');
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function openSimulationModal() {
|
|
1121
|
+
const modal = document.getElementById('simulationModal');
|
|
1122
|
+
if (modal) {
|
|
1123
|
+
modal.classList.remove('hidden');
|
|
1124
|
+
|
|
1125
|
+
// Prefer page-load warm; only allocate here if we still have no session slot
|
|
1126
|
+
if (typeof triggerPipelineWarmingAndChecking === 'function') {
|
|
1127
|
+
triggerPipelineWarmingAndChecking({ soft: true });
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
window.addEventListener('beforeunload', clearSimulationResults);
|
|
1133
|
+
document.addEventListener('visibilitychange', function() {
|
|
1134
|
+
if (document.hidden) clearSimulationResults();
|
|
1135
|
+
});
|