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,2088 @@
|
|
|
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
|
+
// Track current editor mode
|
|
8
|
+
let currentEditorMode = 'ui'; // 'ui' or 'text'
|
|
9
|
+
|
|
10
|
+
// CodeMirror editor instance
|
|
11
|
+
let codeMirrorEditor = null;
|
|
12
|
+
|
|
13
|
+
// Track if UI has been modified
|
|
14
|
+
let uiHasChanges = false;
|
|
15
|
+
|
|
16
|
+
// Store original pipeline text
|
|
17
|
+
let originalPipelineText = '';
|
|
18
|
+
|
|
19
|
+
// Track if Text mode has been modified
|
|
20
|
+
let textHasChanges = false;
|
|
21
|
+
|
|
22
|
+
// Store the initial text when entering Text mode
|
|
23
|
+
let textModeInitialContent = '';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Switch to UI mode
|
|
27
|
+
*/
|
|
28
|
+
async function switchToUIMode() {
|
|
29
|
+
// Check if text has been modified
|
|
30
|
+
if (textHasChanges) {
|
|
31
|
+
// Check if user has disabled conversion warnings
|
|
32
|
+
if (!shouldSkipConversionWarning()) {
|
|
33
|
+
// Show warning dialog
|
|
34
|
+
const confirmed = await ConfirmationModal.show(
|
|
35
|
+
'Switching to UI mode will reformat this configuration to match the visual editor. Some formatting or inline comments may change.\n\nContinue?',
|
|
36
|
+
'Switch to UI Mode',
|
|
37
|
+
'Continue'
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (!confirmed) {
|
|
41
|
+
// User cancelled, don't switch modes
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// If text has changes, convert it to components
|
|
48
|
+
if (textHasChanges && codeMirrorEditor) {
|
|
49
|
+
const configText = codeMirrorEditor.getValue();
|
|
50
|
+
|
|
51
|
+
if (!configText) {
|
|
52
|
+
console.error('No config text to convert');
|
|
53
|
+
alert('No pipeline configuration to convert');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Convert config text to components via API
|
|
58
|
+
const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]')?.value || '';
|
|
59
|
+
const formData = new FormData();
|
|
60
|
+
formData.append('config_text', configText);
|
|
61
|
+
|
|
62
|
+
fetch('/ConnectionManager/ConfigToComponents/', {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: {
|
|
65
|
+
'X-CSRFToken': csrfToken
|
|
66
|
+
},
|
|
67
|
+
body: formData
|
|
68
|
+
})
|
|
69
|
+
.then(response => {
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
return response.json().then(data => {
|
|
72
|
+
throw new Error(data.error || 'Failed to convert config to components');
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return response.json();
|
|
76
|
+
})
|
|
77
|
+
.then(data => {
|
|
78
|
+
|
|
79
|
+
// If data is a string, parse it
|
|
80
|
+
let parsedData = data;
|
|
81
|
+
if (typeof data === 'string') {
|
|
82
|
+
parsedData = JSON.parse(data);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The API returns the components structure directly
|
|
86
|
+
// If it's an array, it needs to be converted to the expected object format
|
|
87
|
+
let convertedComponents;
|
|
88
|
+
if (Array.isArray(parsedData)) {
|
|
89
|
+
// Data is an array [input, filter, output] - convert to object
|
|
90
|
+
convertedComponents = {
|
|
91
|
+
input: parsedData[0] || [],
|
|
92
|
+
filter: parsedData[1] || [],
|
|
93
|
+
output: parsedData[2] || []
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
// Data is already an object
|
|
97
|
+
convertedComponents = parsedData;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Update the global components variable
|
|
101
|
+
if (typeof components !== 'undefined') {
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
// Clear existing arrays and push new items (preserves Proxy/reactive behavior)
|
|
105
|
+
components.input.length = 0;
|
|
106
|
+
components.filter.length = 0;
|
|
107
|
+
components.output.length = 0;
|
|
108
|
+
|
|
109
|
+
// Use Array.isArray and check length
|
|
110
|
+
if (Array.isArray(convertedComponents.input) && convertedComponents.input.length > 0) {
|
|
111
|
+
components.input.push(...convertedComponents.input);
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(convertedComponents.filter) && convertedComponents.filter.length > 0) {
|
|
114
|
+
components.filter.push(...convertedComponents.filter);
|
|
115
|
+
}
|
|
116
|
+
if (Array.isArray(convertedComponents.output) && convertedComponents.output.length > 0) {
|
|
117
|
+
const pushResult = components.output.push(...convertedComponents.output);
|
|
118
|
+
} else {
|
|
119
|
+
console.error('Output check failed - isArray:', Array.isArray(convertedComponents.output), 'length:', convertedComponents.output?.length);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
} else {
|
|
123
|
+
console.error('Global components variable is undefined!');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Switch to UI mode first
|
|
127
|
+
performUISwitch();
|
|
128
|
+
|
|
129
|
+
// Use setTimeout to ensure UI container is visible before rendering
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
|
|
132
|
+
// Reload the visual editor with the new components
|
|
133
|
+
if (typeof loadExistingComponents === 'function') {
|
|
134
|
+
loadExistingComponents();
|
|
135
|
+
} else {
|
|
136
|
+
console.error('loadExistingComponents function not found!');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Mark UI as changed since we just loaded from text
|
|
140
|
+
// This ensures switching back to Text mode will convert components to config
|
|
141
|
+
uiHasChanges = true;
|
|
142
|
+
}, 100);
|
|
143
|
+
})
|
|
144
|
+
.catch(error => {
|
|
145
|
+
console.error('Error converting config to components:', error);
|
|
146
|
+
ConfirmationModal.show(
|
|
147
|
+
'Failed to convert pipeline configuration:',
|
|
148
|
+
'Configuration Error',
|
|
149
|
+
'OK',
|
|
150
|
+
error.message,
|
|
151
|
+
true
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
// No text changes, just switch modes
|
|
156
|
+
performUISwitch();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Perform the actual UI mode switch (internal helper)
|
|
162
|
+
*/
|
|
163
|
+
function performUISwitch() {
|
|
164
|
+
currentEditorMode = 'ui';
|
|
165
|
+
window.currentEditorMode = currentEditorMode;
|
|
166
|
+
|
|
167
|
+
// Save mode preference to localStorage
|
|
168
|
+
localStorage.setItem('lastEditorMode', 'ui');
|
|
169
|
+
|
|
170
|
+
// Clear any open autocomplete hints
|
|
171
|
+
clearAutocompleteHints();
|
|
172
|
+
|
|
173
|
+
// Reset text change tracking
|
|
174
|
+
textHasChanges = false;
|
|
175
|
+
textModeInitialContent = '';
|
|
176
|
+
|
|
177
|
+
// Update button styles
|
|
178
|
+
const uiBtn = document.getElementById('uiModeBtn');
|
|
179
|
+
const textBtn = document.getElementById('textModeBtn');
|
|
180
|
+
const graphBtn = document.getElementById('graphModeBtn');
|
|
181
|
+
|
|
182
|
+
if (uiBtn && textBtn) {
|
|
183
|
+
uiBtn.className = 'w-20 py-2 rounded-md font-medium transition-all bg-green-600 text-white mode-toggle-active';
|
|
184
|
+
textBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
185
|
+
if (graphBtn) {
|
|
186
|
+
graphBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Show UI container, hide text and graph containers
|
|
191
|
+
const uiContainer = document.getElementById('uiModeContainer');
|
|
192
|
+
const textContainer = document.getElementById('textModeContainer');
|
|
193
|
+
const graphContainer = document.getElementById('graphModeContainer');
|
|
194
|
+
|
|
195
|
+
if (uiContainer && textContainer) {
|
|
196
|
+
uiContainer.classList.remove('hidden');
|
|
197
|
+
textContainer.classList.add('hidden');
|
|
198
|
+
}
|
|
199
|
+
if (graphContainer) {
|
|
200
|
+
graphContainer.classList.add('hidden');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Enable View Code and Simulate Pipeline buttons
|
|
204
|
+
enableEditorButtons();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Switch to Text mode
|
|
209
|
+
*/
|
|
210
|
+
function switchToTextMode() {
|
|
211
|
+
currentEditorMode = 'text';
|
|
212
|
+
window.currentEditorMode = currentEditorMode;
|
|
213
|
+
|
|
214
|
+
// Save mode preference to localStorage
|
|
215
|
+
localStorage.setItem('lastEditorMode', 'text');
|
|
216
|
+
|
|
217
|
+
// Update button styles
|
|
218
|
+
const uiBtn = document.getElementById('uiModeBtn');
|
|
219
|
+
const textBtn = document.getElementById('textModeBtn');
|
|
220
|
+
const graphBtn = document.getElementById('graphModeBtn');
|
|
221
|
+
|
|
222
|
+
if (uiBtn && textBtn) {
|
|
223
|
+
uiBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
224
|
+
textBtn.className = 'w-20 py-2 rounded-md font-medium transition-all bg-green-600 text-white mode-toggle-active';
|
|
225
|
+
if (graphBtn) {
|
|
226
|
+
graphBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Hide UI and graph containers, show text container
|
|
231
|
+
const uiContainer = document.getElementById('uiModeContainer');
|
|
232
|
+
const textContainer = document.getElementById('textModeContainer');
|
|
233
|
+
const graphContainer = document.getElementById('graphModeContainer');
|
|
234
|
+
|
|
235
|
+
if (uiContainer && textContainer) {
|
|
236
|
+
uiContainer.classList.add('hidden');
|
|
237
|
+
textContainer.classList.remove('hidden');
|
|
238
|
+
}
|
|
239
|
+
if (graphContainer) {
|
|
240
|
+
graphContainer.classList.add('hidden');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Disable View Code and Simulate Pipeline buttons
|
|
244
|
+
disableEditorButtons();
|
|
245
|
+
|
|
246
|
+
const textEditor = document.getElementById('pipelineTextEditor');
|
|
247
|
+
|
|
248
|
+
// If no changes were made in UI mode, use the original pipeline text
|
|
249
|
+
if (!uiHasChanges && originalPipelineText) {
|
|
250
|
+
if (codeMirrorEditor) {
|
|
251
|
+
codeMirrorEditor.setValue(originalPipelineText);
|
|
252
|
+
} else if (textEditor) {
|
|
253
|
+
textEditor.value = originalPipelineText;
|
|
254
|
+
}
|
|
255
|
+
// Store initial content for change tracking
|
|
256
|
+
textModeInitialContent = originalPipelineText;
|
|
257
|
+
updateTextEditorStats();
|
|
258
|
+
initializeTextEditor();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// UI has changes, convert components to config
|
|
263
|
+
if (typeof components !== 'undefined') {
|
|
264
|
+
const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]')?.value || '';
|
|
265
|
+
|
|
266
|
+
// Create form data
|
|
267
|
+
const formData = new FormData();
|
|
268
|
+
formData.append('components', JSON.stringify(components));
|
|
269
|
+
|
|
270
|
+
fetch('/ConnectionManager/ComponentsToConfig/', {
|
|
271
|
+
method: 'POST',
|
|
272
|
+
headers: {
|
|
273
|
+
'X-CSRFToken': csrfToken
|
|
274
|
+
},
|
|
275
|
+
body: formData
|
|
276
|
+
})
|
|
277
|
+
.then(response => {
|
|
278
|
+
if (!response.ok) {
|
|
279
|
+
throw new Error('Network response was not ok');
|
|
280
|
+
}
|
|
281
|
+
return response.text();
|
|
282
|
+
})
|
|
283
|
+
.then(configText => {
|
|
284
|
+
// Set the config text to CodeMirror editor
|
|
285
|
+
if (codeMirrorEditor) {
|
|
286
|
+
codeMirrorEditor.setValue(configText);
|
|
287
|
+
} else if (textEditor) {
|
|
288
|
+
textEditor.value = configText;
|
|
289
|
+
}
|
|
290
|
+
// Store initial content for change tracking
|
|
291
|
+
textModeInitialContent = configText;
|
|
292
|
+
updateTextEditorStats();
|
|
293
|
+
})
|
|
294
|
+
.catch(error => {
|
|
295
|
+
console.error('Error converting components to config:', error);
|
|
296
|
+
// Fallback to client-side conversion on error
|
|
297
|
+
syncUIToTextEditor();
|
|
298
|
+
});
|
|
299
|
+
} else {
|
|
300
|
+
// Fallback to client-side conversion if components not available
|
|
301
|
+
syncUIToTextEditor();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Initialize text editor features
|
|
305
|
+
initializeTextEditor();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Convert UI components to Logstash configuration text
|
|
310
|
+
*/
|
|
311
|
+
function syncUIToTextEditor() {
|
|
312
|
+
if (typeof components === 'undefined') {
|
|
313
|
+
console.warn('Components not defined, cannot sync to text editor');
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const textEditor = document.getElementById('pipelineTextEditor');
|
|
318
|
+
if (!textEditor) return;
|
|
319
|
+
|
|
320
|
+
let configText = '';
|
|
321
|
+
|
|
322
|
+
// Generate input section
|
|
323
|
+
if (components.input && components.input.length > 0) {
|
|
324
|
+
configText += 'input {\n';
|
|
325
|
+
components.input.forEach(plugin => {
|
|
326
|
+
configText += generatePluginConfig(plugin, 1);
|
|
327
|
+
});
|
|
328
|
+
configText += '}\n\n';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Generate filter section
|
|
332
|
+
if (components.filter && components.filter.length > 0) {
|
|
333
|
+
configText += 'filter {\n';
|
|
334
|
+
components.filter.forEach(component => {
|
|
335
|
+
configText += generateComponentConfig(component, 1);
|
|
336
|
+
});
|
|
337
|
+
configText += '}\n\n';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Generate output section
|
|
341
|
+
if (components.output && components.output.length > 0) {
|
|
342
|
+
configText += 'output {\n';
|
|
343
|
+
components.output.forEach(component => {
|
|
344
|
+
configText += generateComponentConfig(component, 1);
|
|
345
|
+
});
|
|
346
|
+
configText += '}\n';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
textEditor.value = configText.trim();
|
|
350
|
+
updateTextEditorStats();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Generate configuration text for a component (plugin or conditional)
|
|
355
|
+
*/
|
|
356
|
+
function generateComponentConfig(component, indentLevel) {
|
|
357
|
+
const indent = ' '.repeat(indentLevel);
|
|
358
|
+
let config = '';
|
|
359
|
+
|
|
360
|
+
if (component.type === 'conditional') {
|
|
361
|
+
config += `${indent}if ${component.condition} {\n`;
|
|
362
|
+
if (component.plugins && component.plugins.length > 0) {
|
|
363
|
+
component.plugins.forEach(plugin => {
|
|
364
|
+
config += generatePluginConfig(plugin, indentLevel + 1);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
config += `${indent}}\n`;
|
|
368
|
+
} else {
|
|
369
|
+
config += generatePluginConfig(component, indentLevel);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return config;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Generate configuration text for a plugin
|
|
377
|
+
*/
|
|
378
|
+
function generatePluginConfig(plugin, indentLevel) {
|
|
379
|
+
const indent = ' '.repeat(indentLevel);
|
|
380
|
+
let config = '';
|
|
381
|
+
|
|
382
|
+
if (plugin.type === 'comment') {
|
|
383
|
+
config += `${indent}# ${plugin.config?.text || plugin.config?.comment || ''}\n`;
|
|
384
|
+
return config;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
config += `${indent}${plugin.plugin_name} {\n`;
|
|
388
|
+
|
|
389
|
+
if (plugin.config) {
|
|
390
|
+
Object.entries(plugin.config).forEach(([key, value]) => {
|
|
391
|
+
config += `${indent} ${key} => ${formatConfigValueForTextEditor(value)}\n`;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
config += `${indent}}\n`;
|
|
396
|
+
return config;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Format a configuration value for Logstash syntax
|
|
401
|
+
*/
|
|
402
|
+
function formatConfigValueForTextEditor(value) {
|
|
403
|
+
if (typeof value === 'string') {
|
|
404
|
+
// Check if it's already quoted or a special value
|
|
405
|
+
if (value.startsWith('"') || value.startsWith("'") ||
|
|
406
|
+
value === 'true' || value === 'false' ||
|
|
407
|
+
!isNaN(value)) {
|
|
408
|
+
return value;
|
|
409
|
+
}
|
|
410
|
+
return `"${value}"`;
|
|
411
|
+
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
412
|
+
return value;
|
|
413
|
+
} else if (Array.isArray(value)) {
|
|
414
|
+
return `[${value.map(v => formatConfigValueForTextEditor(v)).join(', ')}]`;
|
|
415
|
+
} else if (typeof value === 'object') {
|
|
416
|
+
const entries = Object.entries(value).map(([k, v]) => `"${k}" => ${formatConfigValueForTextEditor(v)}`);
|
|
417
|
+
return `{ ${entries.join(', ')} }`;
|
|
418
|
+
}
|
|
419
|
+
return String(value);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Define custom Logstash mode for CodeMirror
|
|
424
|
+
*/
|
|
425
|
+
function defineLogstashMode() {
|
|
426
|
+
CodeMirror.defineMode("logstash", function() {
|
|
427
|
+
return {
|
|
428
|
+
startState: function() {
|
|
429
|
+
return {
|
|
430
|
+
inConditional: false,
|
|
431
|
+
afterArrow: false
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
token: function(stream, state) {
|
|
435
|
+
// Check for input/filter/output keywords
|
|
436
|
+
if (stream.match(/\binput\b/)) {
|
|
437
|
+
return "logstash-input";
|
|
438
|
+
}
|
|
439
|
+
if (stream.match(/\bfilter\b/)) {
|
|
440
|
+
return "logstash-filter";
|
|
441
|
+
}
|
|
442
|
+
if (stream.match(/\boutput\b/)) {
|
|
443
|
+
return "logstash-output";
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Conditionals (if, else if, else)
|
|
447
|
+
if (stream.match(/\belse\s+if\b/)) {
|
|
448
|
+
state.inConditional = true;
|
|
449
|
+
return "logstash-conditional";
|
|
450
|
+
}
|
|
451
|
+
if (stream.match(/\bif\b/)) {
|
|
452
|
+
state.inConditional = true;
|
|
453
|
+
return "logstash-conditional";
|
|
454
|
+
}
|
|
455
|
+
if (stream.match(/\belse\b/)) {
|
|
456
|
+
state.inConditional = false;
|
|
457
|
+
return "logstash-conditional";
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Braces
|
|
461
|
+
if (stream.match(/[{}]/)) {
|
|
462
|
+
if (stream.current() === '{' && state.inConditional) {
|
|
463
|
+
state.inConditional = false;
|
|
464
|
+
}
|
|
465
|
+
return "logstash-brace";
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Strings
|
|
469
|
+
if (stream.match(/"(?:[^\\"]|\\.)*"/)) {
|
|
470
|
+
state.afterArrow = false;
|
|
471
|
+
return "string";
|
|
472
|
+
}
|
|
473
|
+
if (stream.match(/'(?:[^\\']|\\.)*'/)) {
|
|
474
|
+
state.afterArrow = false;
|
|
475
|
+
return "string";
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Comments
|
|
479
|
+
if (stream.match(/#.*/)) {
|
|
480
|
+
return "comment";
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Numbers
|
|
484
|
+
if (stream.match(/\b\d+\b/)) {
|
|
485
|
+
return "number";
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Arrow operator
|
|
489
|
+
if (stream.match(/=>/)) {
|
|
490
|
+
state.afterArrow = true;
|
|
491
|
+
return "operator";
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Other operators
|
|
495
|
+
if (stream.match(/==|!=|<=|>=|<|>/)) {
|
|
496
|
+
return "operator";
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Plugin names (words followed by {) - now with custom color
|
|
500
|
+
if (stream.match(/\b[a-z_][a-z0-9_]*(?=\s*\{)/i)) {
|
|
501
|
+
return "logstash-plugin";
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Option keys (words before =>)
|
|
505
|
+
if (stream.match(/\b[a-z_][a-z0-9_]*(?=\s*=>)/i)) {
|
|
506
|
+
return "logstash-key";
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Expressions in conditionals (words/identifiers after if/else if)
|
|
510
|
+
if (state.inConditional && stream.match(/\b[a-z_][a-z0-9_]*/i)) {
|
|
511
|
+
return "logstash-expression";
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Field names
|
|
515
|
+
if (stream.match(/\[[^\]]+\]/)) {
|
|
516
|
+
return "variable";
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
stream.next();
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Detect if cursor is inside a plugin block and return plugin info
|
|
528
|
+
*/
|
|
529
|
+
function detectCurrentPlugin(cm, cursor) {
|
|
530
|
+
let depth = 0;
|
|
531
|
+
|
|
532
|
+
// First, count braces from cursor position backwards to determine current depth
|
|
533
|
+
for (let line = cursor.line; line >= 0; line--) {
|
|
534
|
+
const fullLine = cm.getLine(line);
|
|
535
|
+
const endCh = (line === cursor.line) ? cursor.ch : fullLine.length;
|
|
536
|
+
|
|
537
|
+
// Scan this line from the end position backwards
|
|
538
|
+
for (let ch = endCh - 1; ch >= 0; ch--) {
|
|
539
|
+
if (fullLine[ch] === '}') depth++;
|
|
540
|
+
if (fullLine[ch] === '{') depth--;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// If depth is >= 0, we're not inside any block
|
|
545
|
+
if (depth >= 0) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// We're inside a block (depth < 0), now find which plugin
|
|
550
|
+
// Search backwards to find the opening brace that contains us
|
|
551
|
+
let searchDepth = 0;
|
|
552
|
+
for (let line = cursor.line; line >= 0; line--) {
|
|
553
|
+
const fullLine = cm.getLine(line);
|
|
554
|
+
const lineText = fullLine.trim();
|
|
555
|
+
const endCh = (line === cursor.line) ? cursor.ch : fullLine.length;
|
|
556
|
+
|
|
557
|
+
// Scan this line from the end position backwards
|
|
558
|
+
for (let ch = endCh - 1; ch >= 0; ch--) {
|
|
559
|
+
if (fullLine[ch] === '}') searchDepth++;
|
|
560
|
+
if (fullLine[ch] === '{') {
|
|
561
|
+
searchDepth--;
|
|
562
|
+
|
|
563
|
+
// When we find the opening brace that matches our depth
|
|
564
|
+
if (searchDepth < 0) {
|
|
565
|
+
// Check if this line starts a plugin
|
|
566
|
+
const pluginMatch = lineText.match(/^(\w+)\s*\{/);
|
|
567
|
+
if (pluginMatch) {
|
|
568
|
+
const possiblePlugin = pluginMatch[1];
|
|
569
|
+
|
|
570
|
+
// Make sure it's not a main section
|
|
571
|
+
if (!['input', 'filter', 'output', 'if', 'else'].includes(possiblePlugin)) {
|
|
572
|
+
// We found the plugin we're inside
|
|
573
|
+
const section = detectCurrentSection(cm, { line: line, ch: 0 });
|
|
574
|
+
return { name: possiblePlugin, type: section };
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// Found the brace but it's not a plugin, stop searching
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Detect which section (input/filter/output) the cursor is currently in
|
|
589
|
+
*/
|
|
590
|
+
function detectCurrentSection(cm, cursor) {
|
|
591
|
+
let currentSection = null;
|
|
592
|
+
|
|
593
|
+
// Search backwards from cursor to find the section we're in
|
|
594
|
+
for (let line = cursor.line; line >= 0; line--) {
|
|
595
|
+
const lineText = cm.getLine(line).trim();
|
|
596
|
+
|
|
597
|
+
// Check if we found a section start
|
|
598
|
+
if (/^input\s*\{/.test(lineText)) {
|
|
599
|
+
currentSection = 'input';
|
|
600
|
+
break;
|
|
601
|
+
} else if (/^filter\s*\{/.test(lineText)) {
|
|
602
|
+
currentSection = 'filter';
|
|
603
|
+
break;
|
|
604
|
+
} else if (/^output\s*\{/.test(lineText)) {
|
|
605
|
+
currentSection = 'output';
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// If we hit a closing brace at the start of a line, we might be outside sections
|
|
610
|
+
if (/^\}/.test(lineText)) {
|
|
611
|
+
// Check if this closes a section by counting braces
|
|
612
|
+
let depth = 0;
|
|
613
|
+
for (let i = line; i >= 0; i--) {
|
|
614
|
+
const text = cm.getLine(i);
|
|
615
|
+
for (let ch = 0; ch < text.length; ch++) {
|
|
616
|
+
if (text[ch] === '{') depth++;
|
|
617
|
+
if (text[ch] === '}') depth--;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const trimmed = text.trim();
|
|
621
|
+
if (depth === 0 && /^(input|filter|output)\s*\{/.test(trimmed)) {
|
|
622
|
+
// We're outside this section
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
return currentSection;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Get plugin suggestions based on current section
|
|
634
|
+
*/
|
|
635
|
+
function getPluginSuggestions(section, filterText = '') {
|
|
636
|
+
|
|
637
|
+
if (!section || !window.pluginData || !window.pluginData[section]) {
|
|
638
|
+
return [];
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const plugins = window.pluginData[section];
|
|
642
|
+
const suggestions = [];
|
|
643
|
+
const filter = filterText.toLowerCase();
|
|
644
|
+
|
|
645
|
+
// Add conditional statements for filter section
|
|
646
|
+
if (section === 'filter') {
|
|
647
|
+
const conditionals = [
|
|
648
|
+
{ name: 'if', description: 'Conditional statement - executes block if condition is true' },
|
|
649
|
+
{ name: 'else if', description: 'Alternative conditional - executes if previous conditions are false and this is true' },
|
|
650
|
+
{ name: 'else', description: 'Default block - executes if all previous conditions are false' }
|
|
651
|
+
];
|
|
652
|
+
|
|
653
|
+
for (const conditional of conditionals) {
|
|
654
|
+
if (filter && !conditional.name.toLowerCase().includes(filter)) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
suggestions.push({
|
|
659
|
+
text: conditional.name,
|
|
660
|
+
displayText: conditional.name + ' - ' + conditional.description,
|
|
661
|
+
isConditional: true,
|
|
662
|
+
render: function(element, self, data) {
|
|
663
|
+
element.innerHTML = '<span style="font-weight: bold; color: #a78bfa;">' + data.text + '</span>' +
|
|
664
|
+
'<span style="color: #9ca3af; margin-left: 8px;"> - ' + conditional.description + '</span>';
|
|
665
|
+
element.title = data.text + ' - ' + conditional.description;
|
|
666
|
+
},
|
|
667
|
+
hint: function(cm, self, data) {
|
|
668
|
+
const cursor = cm.getCursor();
|
|
669
|
+
const line = cm.getLine(cursor.line);
|
|
670
|
+
const properIndent = calculateIndentation(cm, cursor);
|
|
671
|
+
|
|
672
|
+
let conditionalBlock = '';
|
|
673
|
+
if (data.text === 'if' || data.text === 'else if') {
|
|
674
|
+
conditionalBlock = data.text + ' [condition] {\n' + properIndent + ' \n' + properIndent + '}';
|
|
675
|
+
} else {
|
|
676
|
+
// else doesn't need a condition
|
|
677
|
+
conditionalBlock = data.text + ' {\n' + properIndent + ' \n' + properIndent + '}';
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
cm.replaceRange(
|
|
681
|
+
properIndent + conditionalBlock,
|
|
682
|
+
{ line: cursor.line, ch: 0 },
|
|
683
|
+
{ line: cursor.line, ch: line.length }
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
// Position cursor inside the condition brackets for if/else if
|
|
687
|
+
if (data.text === 'if' || data.text === 'else if') {
|
|
688
|
+
const conditionStart = properIndent.length + data.text.length + ' ['.length;
|
|
689
|
+
cm.setSelection(
|
|
690
|
+
{ line: cursor.line, ch: conditionStart },
|
|
691
|
+
{ line: cursor.line, ch: conditionStart + 'condition'.length }
|
|
692
|
+
);
|
|
693
|
+
} else {
|
|
694
|
+
// For else, position cursor inside the braces
|
|
695
|
+
cm.setCursor({ line: cursor.line + 1, ch: properIndent.length + 2 });
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
for (const pluginName in plugins) {
|
|
703
|
+
const plugin = plugins[pluginName];
|
|
704
|
+
|
|
705
|
+
// Skip the 'comment' plugin
|
|
706
|
+
if (pluginName === 'comment') {
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Filter by substring match
|
|
711
|
+
if (filter && !pluginName.toLowerCase().includes(filter)) {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
suggestions.push({
|
|
716
|
+
text: pluginName,
|
|
717
|
+
displayText: pluginName + (plugin.description ? ' - ' + plugin.description : ''),
|
|
718
|
+
plugin: plugin,
|
|
719
|
+
render: function(element, self, data) {
|
|
720
|
+
const docLink = data.plugin.link || '';
|
|
721
|
+
const description = data.plugin.description || '';
|
|
722
|
+
element.innerHTML = (docLink ? '<a href="' + docLink + '" target="_blank" class="hint-doc-link" onclick="event.stopPropagation();" style="margin-right: 8px;">ⓘ</a>' : '') +
|
|
723
|
+
'<span style="font-weight: bold; color: #60a5fa;">' + data.text + '</span>' +
|
|
724
|
+
(description ? '<span style="color: #9ca3af; margin-left: 8px;"> - ' + description + '</span>' : '');
|
|
725
|
+
if (description) {
|
|
726
|
+
element.title = data.text + ' - ' + description;
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
hint: function(cm, self, data) {
|
|
730
|
+
const cursor = cm.getCursor();
|
|
731
|
+
const line = cm.getLine(cursor.line);
|
|
732
|
+
|
|
733
|
+
// Calculate proper indentation based on nesting level
|
|
734
|
+
const properIndent = calculateIndentation(cm, cursor);
|
|
735
|
+
|
|
736
|
+
// Get required options for this plugin with their types
|
|
737
|
+
const requiredOptions = [];
|
|
738
|
+
if (data.plugin.options) {
|
|
739
|
+
for (const optionName in data.plugin.options) {
|
|
740
|
+
const option = data.plugin.options[optionName];
|
|
741
|
+
if (option.required && option.required.toLowerCase().includes('yes')) {
|
|
742
|
+
requiredOptions.push({
|
|
743
|
+
name: optionName,
|
|
744
|
+
type: option.input_type,
|
|
745
|
+
option: option
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// Build the plugin block with proper indentation and placeholders
|
|
752
|
+
let pluginBlock = data.text + ' {\n';
|
|
753
|
+
|
|
754
|
+
if (requiredOptions.length > 0) {
|
|
755
|
+
for (const reqOption of requiredOptions) {
|
|
756
|
+
const placeholder = getPlaceholderForType(reqOption.type);
|
|
757
|
+
pluginBlock += properIndent + ' ' + reqOption.name + ' => ' + placeholder + '\n';
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
pluginBlock += properIndent + '}';
|
|
762
|
+
|
|
763
|
+
// Replace the current line content
|
|
764
|
+
cm.replaceRange(
|
|
765
|
+
properIndent + pluginBlock,
|
|
766
|
+
{ line: cursor.line, ch: 0 },
|
|
767
|
+
{ line: cursor.line, ch: line.length }
|
|
768
|
+
);
|
|
769
|
+
|
|
770
|
+
// Position cursor at the placeholder value of the first required option
|
|
771
|
+
if (requiredOptions.length > 0) {
|
|
772
|
+
const firstOption = requiredOptions[0];
|
|
773
|
+
const placeholder = getPlaceholderForType(firstOption.type);
|
|
774
|
+
const lineWithOption = cursor.line + 1;
|
|
775
|
+
const optionLineText = properIndent + ' ' + firstOption.name + ' => ' + placeholder;
|
|
776
|
+
const placeholderStart = (properIndent + ' ' + firstOption.name + ' => ').length;
|
|
777
|
+
|
|
778
|
+
// Select the placeholder so user can immediately type to replace it
|
|
779
|
+
cm.setSelection(
|
|
780
|
+
{ line: lineWithOption, ch: placeholderStart },
|
|
781
|
+
{ line: lineWithOption, ch: placeholderStart + placeholder.length }
|
|
782
|
+
);
|
|
783
|
+
} else {
|
|
784
|
+
// No required options - position cursor inside the empty braces on the indented line
|
|
785
|
+
cm.setCursor({ line: cursor.line + 1, ch: (properIndent + ' ').length });
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// Sort alphabetically
|
|
792
|
+
suggestions.sort((a, b) => a.text.localeCompare(b.text));
|
|
793
|
+
|
|
794
|
+
return suggestions;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Get CSS class for type badge based on input type
|
|
799
|
+
*/
|
|
800
|
+
function getTypeBadgeClass(inputType) {
|
|
801
|
+
if (!inputType) return 'hint-type-default';
|
|
802
|
+
const type = inputType.toLowerCase();
|
|
803
|
+
if (type.includes('string')) return 'hint-type-string';
|
|
804
|
+
if (type.includes('number')) return 'hint-type-number';
|
|
805
|
+
if (type.includes('boolean')) return 'hint-type-boolean';
|
|
806
|
+
if (type.includes('array')) return 'hint-type-array';
|
|
807
|
+
if (type.includes('hash')) return 'hint-type-hash';
|
|
808
|
+
if (type.includes('codec')) return 'hint-type-codec';
|
|
809
|
+
if (type.includes('path')) return 'hint-type-path';
|
|
810
|
+
if (type.includes('password')) return 'hint-type-password';
|
|
811
|
+
return 'hint-type-default';
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Check if cursor is inside an option value (after => or inside {}/[])
|
|
816
|
+
*/
|
|
817
|
+
function isInsideOptionValue(cm, cursor) {
|
|
818
|
+
// Simple check: if current line has => before cursor, we're in a value
|
|
819
|
+
const currentLine = cm.getLine(cursor.line);
|
|
820
|
+
const lineUpToCursor = currentLine.substring(0, cursor.ch);
|
|
821
|
+
if (lineUpToCursor.includes('=>')) {
|
|
822
|
+
return true;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// More complex check: scan backwards to see if we're inside an unclosed { or [ that follows =>
|
|
826
|
+
// We need to track brace/bracket depth and look for => before opening braces/brackets
|
|
827
|
+
let braceDepth = 0;
|
|
828
|
+
let bracketDepth = 0;
|
|
829
|
+
|
|
830
|
+
// Scan backwards from cursor
|
|
831
|
+
for (let lineNum = cursor.line; lineNum >= 0; lineNum--) {
|
|
832
|
+
const lineText = cm.getLine(lineNum);
|
|
833
|
+
const endCh = (lineNum === cursor.line) ? cursor.ch : lineText.length;
|
|
834
|
+
|
|
835
|
+
// Scan characters from right to left on this line
|
|
836
|
+
for (let ch = endCh - 1; ch >= 0; ch--) {
|
|
837
|
+
const char = lineText[ch];
|
|
838
|
+
|
|
839
|
+
if (char === '}') {
|
|
840
|
+
braceDepth++;
|
|
841
|
+
} else if (char === '{') {
|
|
842
|
+
if (braceDepth > 0) {
|
|
843
|
+
braceDepth--;
|
|
844
|
+
} else {
|
|
845
|
+
// Found an unclosed opening brace - check if there's => before it on this line
|
|
846
|
+
const beforeBrace = lineText.substring(0, ch);
|
|
847
|
+
if (beforeBrace.includes('=>')) {
|
|
848
|
+
return true; // We're inside a hash value
|
|
849
|
+
}
|
|
850
|
+
// This is a plugin or section opening, stop here
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
} else if (char === ']') {
|
|
854
|
+
bracketDepth++;
|
|
855
|
+
} else if (char === '[') {
|
|
856
|
+
if (bracketDepth > 0) {
|
|
857
|
+
bracketDepth--;
|
|
858
|
+
} else {
|
|
859
|
+
// Found an unclosed opening bracket - check if there's => before it on this line
|
|
860
|
+
const beforeBracket = lineText.substring(0, ch);
|
|
861
|
+
if (beforeBracket.includes('=>')) {
|
|
862
|
+
return true; // We're inside an array value
|
|
863
|
+
}
|
|
864
|
+
// Not a value array, stop here
|
|
865
|
+
return false;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// Don't scan too far back - stop at plugin declarations
|
|
871
|
+
const trimmed = lineText.trim();
|
|
872
|
+
if (lineNum < cursor.line && /^\w+\s*\{/.test(trimmed)) {
|
|
873
|
+
// Hit a plugin declaration, stop scanning
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Show autocomplete for plugin options
|
|
883
|
+
*/
|
|
884
|
+
function showOptionAutocomplete(cm, plugin) {
|
|
885
|
+
if (!plugin || !plugin.options) return;
|
|
886
|
+
|
|
887
|
+
CodeMirror.showHint(cm, function(cm) {
|
|
888
|
+
const cursor = cm.getCursor();
|
|
889
|
+
const line = cm.getLine(cursor.line);
|
|
890
|
+
const lineUpToCursor = line.substring(0, cursor.ch);
|
|
891
|
+
const currentIndent = line.match(/^\s*/)[0];
|
|
892
|
+
const trimmed = line.trim();
|
|
893
|
+
const wordStart = lineUpToCursor.search(/\S+$/);
|
|
894
|
+
const word = wordStart >= 0 ? lineUpToCursor.substring(wordStart) : '';
|
|
895
|
+
|
|
896
|
+
const suggestions = [];
|
|
897
|
+
|
|
898
|
+
for (const optionName in plugin.options) {
|
|
899
|
+
const option = plugin.options[optionName];
|
|
900
|
+
|
|
901
|
+
// Filter by what's already typed
|
|
902
|
+
if (word && !optionName.toLowerCase().includes(word.toLowerCase())) {
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
suggestions.push({
|
|
907
|
+
text: optionName,
|
|
908
|
+
displayText: optionName + ' => ' + (option.input_type || '') +
|
|
909
|
+
(option.required && option.required.toLowerCase().includes('yes') ? ' (required)' : ''),
|
|
910
|
+
option: option,
|
|
911
|
+
render: function(element, self, data) {
|
|
912
|
+
const isRequired = data.option.required && data.option.required.toLowerCase().includes('yes');
|
|
913
|
+
const typeBadgeClass = getTypeBadgeClass(data.option.input_type);
|
|
914
|
+
const typeDisplay = data.option.input_type || 'any';
|
|
915
|
+
const docLink = data.option.link || '';
|
|
916
|
+
const description = data.option.description || '';
|
|
917
|
+
|
|
918
|
+
element.innerHTML = (docLink ? '<a href="' + docLink + '" target="_blank" class="hint-doc-link" onclick="event.stopPropagation();" style="margin-right: 8px;">ⓘ</a>' : '') +
|
|
919
|
+
'<span style="font-weight: bold; color: #c4b5fd;">' + data.text + '</span>' +
|
|
920
|
+
'<span class="hint-type-badge ' + typeBadgeClass + '">' + typeDisplay + '</span>' +
|
|
921
|
+
(isRequired ? '<span class="hint-required">● REQUIRED</span>' : '');
|
|
922
|
+
|
|
923
|
+
// Add tooltip with full description
|
|
924
|
+
let tooltip = data.text + ' (' + typeDisplay + ')';
|
|
925
|
+
if (description) {
|
|
926
|
+
tooltip += ' - ' + description;
|
|
927
|
+
}
|
|
928
|
+
if (isRequired) {
|
|
929
|
+
tooltip += ' [REQUIRED]';
|
|
930
|
+
}
|
|
931
|
+
element.title = tooltip;
|
|
932
|
+
},
|
|
933
|
+
hint: function(cm, self, data) {
|
|
934
|
+
const cursor = cm.getCursor();
|
|
935
|
+
const line = cm.getLine(cursor.line);
|
|
936
|
+
const currentIndent = line.match(/^\s*/)[0];
|
|
937
|
+
const inputType = (data.option.input_type || '').toLowerCase();
|
|
938
|
+
|
|
939
|
+
// Check if this is a hash or array type - use multi-line format
|
|
940
|
+
if (inputType.includes('hash') || inputType.includes('array')) {
|
|
941
|
+
const indentUnit = ' ';
|
|
942
|
+
let optionText = '';
|
|
943
|
+
|
|
944
|
+
if (inputType.includes('hash')) {
|
|
945
|
+
// Multi-line hash format
|
|
946
|
+
optionText = data.text + ' => {\n' + currentIndent + indentUnit + '\n' + currentIndent + '}';
|
|
947
|
+
} else {
|
|
948
|
+
// Multi-line array format
|
|
949
|
+
optionText = data.text + ' => [\n' + currentIndent + indentUnit + '\n' + currentIndent + ']';
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// Replace the current line
|
|
953
|
+
cm.replaceRange(
|
|
954
|
+
currentIndent + optionText,
|
|
955
|
+
{ line: cursor.line, ch: 0 },
|
|
956
|
+
{ line: cursor.line, ch: line.length }
|
|
957
|
+
);
|
|
958
|
+
|
|
959
|
+
// Position cursor on the empty line inside the braces/brackets
|
|
960
|
+
cm.setCursor({ line: cursor.line + 1, ch: currentIndent.length + indentUnit.length });
|
|
961
|
+
} else {
|
|
962
|
+
// Single-line format for other types
|
|
963
|
+
const placeholder = getPlaceholderForType(data.option.input_type);
|
|
964
|
+
const optionLine = data.text + ' => ' + placeholder;
|
|
965
|
+
|
|
966
|
+
// Replace the current line
|
|
967
|
+
cm.replaceRange(
|
|
968
|
+
currentIndent + optionLine,
|
|
969
|
+
{ line: cursor.line, ch: 0 },
|
|
970
|
+
{ line: cursor.line, ch: line.length }
|
|
971
|
+
);
|
|
972
|
+
|
|
973
|
+
// Select the placeholder
|
|
974
|
+
const placeholderStart = currentIndent.length + data.text.length + ' => '.length;
|
|
975
|
+
cm.setSelection(
|
|
976
|
+
{ line: cursor.line, ch: placeholderStart },
|
|
977
|
+
{ line: cursor.line, ch: placeholderStart + placeholder.length }
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
suggestions.sort((a, b) => a.text.localeCompare(b.text));
|
|
985
|
+
|
|
986
|
+
if (suggestions.length === 0) return null;
|
|
987
|
+
|
|
988
|
+
return {
|
|
989
|
+
list: suggestions,
|
|
990
|
+
from: CodeMirror.Pos(cursor.line, currentIndent.length),
|
|
991
|
+
to: CodeMirror.Pos(cursor.line, line.length)
|
|
992
|
+
};
|
|
993
|
+
}, {
|
|
994
|
+
completeSingle: false,
|
|
995
|
+
closeOnUnfocus: false,
|
|
996
|
+
container: null
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
// Add header to hints container
|
|
1000
|
+
setTimeout(() => {
|
|
1001
|
+
const hintsContainer = document.querySelector('.CodeMirror-hints');
|
|
1002
|
+
if (hintsContainer) {
|
|
1003
|
+
hintsContainer.setAttribute('data-header', '⚙️ Plugin Options');
|
|
1004
|
+
}
|
|
1005
|
+
}, 0);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Calculate proper indentation based on current nesting level
|
|
1010
|
+
*/
|
|
1011
|
+
function calculateIndentation(cm, cursor) {
|
|
1012
|
+
let depth = 0;
|
|
1013
|
+
const indentUnit = ' '; // 2 spaces
|
|
1014
|
+
|
|
1015
|
+
// Count opening and closing braces from start to cursor position
|
|
1016
|
+
for (let lineNum = 0; lineNum <= cursor.line; lineNum++) {
|
|
1017
|
+
const lineText = cm.getLine(lineNum);
|
|
1018
|
+
const endCh = (lineNum === cursor.line) ? cursor.ch : lineText.length;
|
|
1019
|
+
|
|
1020
|
+
for (let ch = 0; ch < endCh; ch++) {
|
|
1021
|
+
if (lineText[ch] === '{') depth++;
|
|
1022
|
+
if (lineText[ch] === '}') depth--;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// Generate indentation string
|
|
1027
|
+
return indentUnit.repeat(Math.max(0, depth));
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Get placeholder value based on input type
|
|
1032
|
+
*/
|
|
1033
|
+
function getPlaceholderForType(inputType) {
|
|
1034
|
+
if (!inputType) return '""';
|
|
1035
|
+
|
|
1036
|
+
const type = inputType.toLowerCase();
|
|
1037
|
+
|
|
1038
|
+
// Handle array types
|
|
1039
|
+
if (type.includes('array')) {
|
|
1040
|
+
return '[]';
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// Handle hash/object types
|
|
1044
|
+
if (type.includes('hash')) {
|
|
1045
|
+
return '{}';
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// Handle number types
|
|
1049
|
+
if (type.includes('number')) {
|
|
1050
|
+
return '0';
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// Handle boolean types
|
|
1054
|
+
if (type.includes('boolean')) {
|
|
1055
|
+
return 'false';
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// Handle codec type
|
|
1059
|
+
if (type.includes('codec')) {
|
|
1060
|
+
return '"json"';
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Handle path types
|
|
1064
|
+
if (type.includes('path')) {
|
|
1065
|
+
return '"/path/to/file"';
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// Handle password types
|
|
1069
|
+
if (type.includes('password')) {
|
|
1070
|
+
return '"password"';
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// Default to empty string for string types and unknown
|
|
1074
|
+
return '""';
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Show plugin autocomplete
|
|
1079
|
+
*/
|
|
1080
|
+
function showPluginAutocomplete(cm) {
|
|
1081
|
+
if (typeof CodeMirror.showHint !== 'function') {
|
|
1082
|
+
console.error('CodeMirror.showHint is not available! The show-hint addon is not loaded.');
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const cursor = cm.getCursor();
|
|
1087
|
+
const line = cm.getLine(cursor.line);
|
|
1088
|
+
const lineUpToCursor = line.substring(0, cursor.ch);
|
|
1089
|
+
const trimmedLine = line.trim();
|
|
1090
|
+
|
|
1091
|
+
// Detect which section we're in
|
|
1092
|
+
const section = detectCurrentSection(cm, cursor);
|
|
1093
|
+
if (!section) return;
|
|
1094
|
+
|
|
1095
|
+
// Get the word being typed (if any) - this will be used for filtering
|
|
1096
|
+
const wordMatch = trimmedLine.match(/^([a-zA-Z_]+)$/);
|
|
1097
|
+
const filterText = wordMatch ? wordMatch[1] : '';
|
|
1098
|
+
|
|
1099
|
+
// Get plugin suggestions (filtered by current text)
|
|
1100
|
+
const suggestions = getPluginSuggestions(section, filterText);
|
|
1101
|
+
if (suggestions.length === 0) return;
|
|
1102
|
+
|
|
1103
|
+
CodeMirror.showHint(cm, function(cm) {
|
|
1104
|
+
const cursor = cm.getCursor();
|
|
1105
|
+
const line = cm.getLine(cursor.line);
|
|
1106
|
+
const currentIndent = line.match(/^\s*/)[0];
|
|
1107
|
+
const trimmed = line.trim();
|
|
1108
|
+
|
|
1109
|
+
// Re-filter suggestions based on current input
|
|
1110
|
+
const currentFilter = trimmed.match(/^([a-zA-Z_]+)$/) ? trimmed : '';
|
|
1111
|
+
const filteredSuggestions = getPluginSuggestions(section, currentFilter);
|
|
1112
|
+
|
|
1113
|
+
return {
|
|
1114
|
+
list: filteredSuggestions,
|
|
1115
|
+
from: CodeMirror.Pos(cursor.line, currentIndent.length),
|
|
1116
|
+
to: CodeMirror.Pos(cursor.line, line.length)
|
|
1117
|
+
};
|
|
1118
|
+
}, {
|
|
1119
|
+
completeSingle: false,
|
|
1120
|
+
closeOnUnfocus: false
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
// Add header to hints container
|
|
1124
|
+
setTimeout(() => {
|
|
1125
|
+
const hintsContainer = document.querySelector('.CodeMirror-hints');
|
|
1126
|
+
if (hintsContainer) {
|
|
1127
|
+
hintsContainer.setAttribute('data-header', '📦 Available Plugins');
|
|
1128
|
+
}
|
|
1129
|
+
}, 0);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Custom fold helper for Logstash syntax
|
|
1134
|
+
* Folds input/filter/output blocks, plugin blocks, and conditional blocks
|
|
1135
|
+
*/
|
|
1136
|
+
CodeMirror.registerHelper("fold", "logstash", function(cm, start) {
|
|
1137
|
+
const line = cm.getLine(start.line);
|
|
1138
|
+
const lineText = line.trim();
|
|
1139
|
+
|
|
1140
|
+
// Check if this line starts a foldable block
|
|
1141
|
+
// Match: input {, filter {, output {, plugin_name {, if/else if/else {
|
|
1142
|
+
const isMainSection = /^(input|filter|output)\s*\{/.test(lineText);
|
|
1143
|
+
const isConditional = /^(if\s+|else\s+if\s+|else\s*)\{/.test(lineText) ||
|
|
1144
|
+
/^(if|else\s+if|else)\s+.*\{/.test(lineText);
|
|
1145
|
+
const isPlugin = /^\w+\s*\{/.test(lineText);
|
|
1146
|
+
|
|
1147
|
+
const blockStart = isMainSection || isConditional || isPlugin;
|
|
1148
|
+
|
|
1149
|
+
if (!blockStart) return;
|
|
1150
|
+
|
|
1151
|
+
// Find the opening brace position
|
|
1152
|
+
const openBracePos = line.indexOf('{');
|
|
1153
|
+
if (openBracePos === -1) return;
|
|
1154
|
+
|
|
1155
|
+
// Find the matching closing brace
|
|
1156
|
+
let depth = 0;
|
|
1157
|
+
let foundOpen = false;
|
|
1158
|
+
|
|
1159
|
+
for (let lineNum = start.line; lineNum < cm.lineCount(); lineNum++) {
|
|
1160
|
+
const currentLine = cm.getLine(lineNum);
|
|
1161
|
+
const startCh = (lineNum === start.line) ? openBracePos : 0;
|
|
1162
|
+
|
|
1163
|
+
for (let ch = startCh; ch < currentLine.length; ch++) {
|
|
1164
|
+
if (currentLine[ch] === '{') {
|
|
1165
|
+
depth++;
|
|
1166
|
+
foundOpen = true;
|
|
1167
|
+
} else if (currentLine[ch] === '}') {
|
|
1168
|
+
depth--;
|
|
1169
|
+
if (foundOpen && depth === 0) {
|
|
1170
|
+
// Found the matching closing brace
|
|
1171
|
+
return {
|
|
1172
|
+
from: CodeMirror.Pos(start.line, line.length),
|
|
1173
|
+
to: CodeMirror.Pos(lineNum, ch)
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
return null;
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Fold/unfold code at cursor position
|
|
1185
|
+
*/
|
|
1186
|
+
CodeMirror.defineExtension("foldCode", function(pos) {
|
|
1187
|
+
const cm = this;
|
|
1188
|
+
|
|
1189
|
+
// First check if we're clicking on a folded region to unfold it
|
|
1190
|
+
const marks = cm.findMarksAt(pos);
|
|
1191
|
+
for (let j = 0; j < marks.length; j++) {
|
|
1192
|
+
if (marks[j].__isFold) {
|
|
1193
|
+
marks[j].clear();
|
|
1194
|
+
updateFoldGutter(cm);
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// Not clicking on a fold, so try to create a new fold
|
|
1200
|
+
const helpers = cm.getHelpers(pos, "fold");
|
|
1201
|
+
|
|
1202
|
+
for (let i = 0; i < helpers.length; i++) {
|
|
1203
|
+
const range = helpers[i](cm, pos);
|
|
1204
|
+
if (range) {
|
|
1205
|
+
// Create fold
|
|
1206
|
+
const widget = document.createElement("span");
|
|
1207
|
+
widget.className = "CodeMirror-foldmarker";
|
|
1208
|
+
widget.textContent = "⦚";
|
|
1209
|
+
widget.title = "Click to unfold";
|
|
1210
|
+
|
|
1211
|
+
const mark = cm.markText(range.from, range.to, {
|
|
1212
|
+
replacedWith: widget,
|
|
1213
|
+
clearOnEnter: true,
|
|
1214
|
+
__isFold: true
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
// Use mousedown instead of click for more reliable unfold
|
|
1218
|
+
widget.addEventListener("mousedown", function(e) {
|
|
1219
|
+
e.preventDefault();
|
|
1220
|
+
e.stopPropagation();
|
|
1221
|
+
mark.clear();
|
|
1222
|
+
updateFoldGutter(cm);
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
updateFoldGutter(cm);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Initialize CodeMirror text editor
|
|
1233
|
+
*/
|
|
1234
|
+
function initializeTextEditor() {
|
|
1235
|
+
const textEditor = document.getElementById('pipelineTextEditor');
|
|
1236
|
+
|
|
1237
|
+
if (!textEditor || codeMirrorEditor) return;
|
|
1238
|
+
|
|
1239
|
+
// Define custom Logstash mode
|
|
1240
|
+
defineLogstashMode();
|
|
1241
|
+
|
|
1242
|
+
// Initialize CodeMirror
|
|
1243
|
+
codeMirrorEditor = CodeMirror.fromTextArea(textEditor, {
|
|
1244
|
+
mode: 'logstash',
|
|
1245
|
+
lineNumbers: true,
|
|
1246
|
+
theme: 'default',
|
|
1247
|
+
indentUnit: 2,
|
|
1248
|
+
tabSize: 2,
|
|
1249
|
+
indentWithTabs: false,
|
|
1250
|
+
lineWrapping: true,
|
|
1251
|
+
foldGutter: true,
|
|
1252
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
|
1253
|
+
extraKeys: {
|
|
1254
|
+
"Ctrl-Q": function(cm) { cm.foldCode(cm.getCursor()); },
|
|
1255
|
+
"Cmd-Q": function(cm) { cm.foldCode(cm.getCursor()); },
|
|
1256
|
+
"'{'": function(cm) {
|
|
1257
|
+
if (cm.somethingSelected()) {
|
|
1258
|
+
const selection = cm.getSelection();
|
|
1259
|
+
cm.replaceSelection('{' + selection + '}');
|
|
1260
|
+
} else {
|
|
1261
|
+
cm.replaceSelection('{}');
|
|
1262
|
+
const cursor = cm.getCursor();
|
|
1263
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch - 1});
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
"'}'": function(cm) {
|
|
1267
|
+
const cursor = cm.getCursor();
|
|
1268
|
+
const line = cm.getLine(cursor.line);
|
|
1269
|
+
const after = line.substring(cursor.ch);
|
|
1270
|
+
|
|
1271
|
+
// If next char is already a closing brace, just move cursor
|
|
1272
|
+
if (after.startsWith('}')) {
|
|
1273
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1274
|
+
} else {
|
|
1275
|
+
cm.replaceSelection('}');
|
|
1276
|
+
}
|
|
1277
|
+
},
|
|
1278
|
+
"'['": function(cm) {
|
|
1279
|
+
if (cm.somethingSelected()) {
|
|
1280
|
+
const selection = cm.getSelection();
|
|
1281
|
+
cm.replaceSelection('[' + selection + ']');
|
|
1282
|
+
} else {
|
|
1283
|
+
cm.replaceSelection('[]');
|
|
1284
|
+
const cursor = cm.getCursor();
|
|
1285
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch - 1});
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
"']'": function(cm) {
|
|
1289
|
+
const cursor = cm.getCursor();
|
|
1290
|
+
const line = cm.getLine(cursor.line);
|
|
1291
|
+
const after = line.substring(cursor.ch);
|
|
1292
|
+
|
|
1293
|
+
// If next char is already a closing bracket, just move cursor
|
|
1294
|
+
if (after.startsWith(']')) {
|
|
1295
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1296
|
+
} else {
|
|
1297
|
+
cm.replaceSelection(']');
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1300
|
+
"'('": function(cm) {
|
|
1301
|
+
if (cm.somethingSelected()) {
|
|
1302
|
+
const selection = cm.getSelection();
|
|
1303
|
+
cm.replaceSelection('(' + selection + ')');
|
|
1304
|
+
} else {
|
|
1305
|
+
cm.replaceSelection('()');
|
|
1306
|
+
const cursor = cm.getCursor();
|
|
1307
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch - 1});
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
"')'": function(cm) {
|
|
1311
|
+
const cursor = cm.getCursor();
|
|
1312
|
+
const line = cm.getLine(cursor.line);
|
|
1313
|
+
const after = line.substring(cursor.ch);
|
|
1314
|
+
|
|
1315
|
+
// If next char is already a closing paren, just move cursor
|
|
1316
|
+
if (after.startsWith(')')) {
|
|
1317
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1318
|
+
} else {
|
|
1319
|
+
cm.replaceSelection(')');
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
"'\"'": function(cm) {
|
|
1323
|
+
if (cm.somethingSelected()) {
|
|
1324
|
+
const selection = cm.getSelection();
|
|
1325
|
+
cm.replaceSelection('"' + selection + '"');
|
|
1326
|
+
} else {
|
|
1327
|
+
const cursor = cm.getCursor();
|
|
1328
|
+
const line = cm.getLine(cursor.line);
|
|
1329
|
+
const after = line.substring(cursor.ch);
|
|
1330
|
+
|
|
1331
|
+
// If next char is already a quote, just move cursor
|
|
1332
|
+
if (after.startsWith('"')) {
|
|
1333
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1334
|
+
} else {
|
|
1335
|
+
cm.replaceSelection('""');
|
|
1336
|
+
const newCursor = cm.getCursor();
|
|
1337
|
+
cm.setCursor({line: newCursor.line, ch: newCursor.ch - 1});
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
"\"'\"": function(cm) {
|
|
1342
|
+
if (cm.somethingSelected()) {
|
|
1343
|
+
const selection = cm.getSelection();
|
|
1344
|
+
cm.replaceSelection("'" + selection + "'");
|
|
1345
|
+
} else {
|
|
1346
|
+
const cursor = cm.getCursor();
|
|
1347
|
+
const line = cm.getLine(cursor.line);
|
|
1348
|
+
const after = line.substring(cursor.ch);
|
|
1349
|
+
|
|
1350
|
+
// If next char is already a quote, just move cursor
|
|
1351
|
+
if (after.startsWith("'")) {
|
|
1352
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1353
|
+
} else {
|
|
1354
|
+
cm.replaceSelection("''");
|
|
1355
|
+
const newCursor = cm.getCursor();
|
|
1356
|
+
cm.setCursor({line: newCursor.line, ch: newCursor.ch - 1});
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
"'\''": function(cm) {
|
|
1361
|
+
if (cm.somethingSelected()) {
|
|
1362
|
+
const selection = cm.getSelection();
|
|
1363
|
+
cm.replaceSelection("'" + selection + "'");
|
|
1364
|
+
} else {
|
|
1365
|
+
const cursor = cm.getCursor();
|
|
1366
|
+
const line = cm.getLine(cursor.line);
|
|
1367
|
+
const after = line.substring(cursor.ch);
|
|
1368
|
+
|
|
1369
|
+
// If next char is already a quote, just move cursor
|
|
1370
|
+
if (after.startsWith("'")) {
|
|
1371
|
+
cm.setCursor({line: cursor.line, ch: cursor.ch + 1});
|
|
1372
|
+
} else {
|
|
1373
|
+
cm.replaceSelection("''");
|
|
1374
|
+
const newCursor = cm.getCursor();
|
|
1375
|
+
cm.setCursor({line: newCursor.line, ch: newCursor.ch - 1});
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
},
|
|
1379
|
+
"Tab": function(cm) {
|
|
1380
|
+
if (cm.somethingSelected()) {
|
|
1381
|
+
cm.indentSelection("add");
|
|
1382
|
+
} else {
|
|
1383
|
+
cm.replaceSelection(" ", "end");
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1386
|
+
"Enter": function(cm) {
|
|
1387
|
+
const cursor = cm.getCursor();
|
|
1388
|
+
const line = cm.getLine(cursor.line);
|
|
1389
|
+
const beforeCursor = line.substring(0, cursor.ch);
|
|
1390
|
+
const afterCursor = line.substring(cursor.ch);
|
|
1391
|
+
|
|
1392
|
+
// Get current indentation
|
|
1393
|
+
const indentMatch = beforeCursor.match(/^(\s*)/);
|
|
1394
|
+
const currentIndent = indentMatch ? indentMatch[1] : '';
|
|
1395
|
+
const indentUnit = ' '; // 2 spaces
|
|
1396
|
+
|
|
1397
|
+
// Check if we're between matching brackets {}
|
|
1398
|
+
const openBracket = beforeCursor.trimEnd().endsWith('{');
|
|
1399
|
+
const closeBracket = afterCursor.trimStart().startsWith('}');
|
|
1400
|
+
|
|
1401
|
+
if (openBracket && closeBracket) {
|
|
1402
|
+
// Case 1: Between {} - just add newlines and indent, don't duplicate }
|
|
1403
|
+
cm.replaceSelection('\n' + currentIndent + indentUnit + '\n' + currentIndent);
|
|
1404
|
+
// Move cursor to the indented line
|
|
1405
|
+
cm.setCursor({line: cursor.line + 1, ch: (currentIndent + indentUnit).length});
|
|
1406
|
+
} else if (openBracket) {
|
|
1407
|
+
// Case 2: After { with no immediate } - go to next line with indent
|
|
1408
|
+
cm.replaceSelection('\n' + currentIndent + indentUnit);
|
|
1409
|
+
} else if (closeBracket) {
|
|
1410
|
+
// Case 3: Before } - maintain current indent
|
|
1411
|
+
cm.replaceSelection('\n' + currentIndent);
|
|
1412
|
+
} else {
|
|
1413
|
+
// Default: maintain current indentation
|
|
1414
|
+
cm.replaceSelection('\n' + currentIndent);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
// Update stats on change and track modifications
|
|
1421
|
+
codeMirrorEditor.on('change', function(cm, changeObj) {
|
|
1422
|
+
updateTextEditorStats();
|
|
1423
|
+
|
|
1424
|
+
// Track if text has been modified (ignore setValue operations)
|
|
1425
|
+
if (changeObj.origin !== 'setValue' && textModeInitialContent) {
|
|
1426
|
+
const currentContent = cm.getValue();
|
|
1427
|
+
if (currentContent !== textModeInitialContent) {
|
|
1428
|
+
textHasChanges = true;
|
|
1429
|
+
} else {
|
|
1430
|
+
textHasChanges = false;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
// Bracket matching on cursor activity
|
|
1436
|
+
codeMirrorEditor.on('cursorActivity', function() {
|
|
1437
|
+
highlightMatchingBrackets(codeMirrorEditor);
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
// Autocomplete on cursor activity and input
|
|
1441
|
+
let autocompleteTimeout = null;
|
|
1442
|
+
|
|
1443
|
+
codeMirrorEditor.on('cursorActivity', function(cm) {
|
|
1444
|
+
// Clear any pending autocomplete
|
|
1445
|
+
clearTimeout(autocompleteTimeout);
|
|
1446
|
+
|
|
1447
|
+
// Don't show autocomplete if there's already a hint widget open
|
|
1448
|
+
if (cm.state.completionActive) return;
|
|
1449
|
+
|
|
1450
|
+
const cursor = cm.getCursor();
|
|
1451
|
+
const line = cm.getLine(cursor.line);
|
|
1452
|
+
const lineUpToCursor = line.substring(0, cursor.ch);
|
|
1453
|
+
const trimmedLine = line.trim();
|
|
1454
|
+
|
|
1455
|
+
// First check if we're inside a plugin block
|
|
1456
|
+
const currentPlugin = detectCurrentPlugin(cm, cursor);
|
|
1457
|
+
|
|
1458
|
+
if (currentPlugin) {
|
|
1459
|
+
// We're inside a plugin - check if we should show option autocomplete
|
|
1460
|
+
|
|
1461
|
+
// Don't show autocomplete if we're inside an option value
|
|
1462
|
+
if (isInsideOptionValue(cm, cursor)) {
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// Check if line contains only whitespace or partial word (option name)
|
|
1467
|
+
if (trimmedLine === '' || /^[a-zA-Z_]+$/.test(trimmedLine)) {
|
|
1468
|
+
autocompleteTimeout = setTimeout(() => {
|
|
1469
|
+
const pluginInfo = window.pluginData?.[currentPlugin.type]?.[currentPlugin.name];
|
|
1470
|
+
if (pluginInfo) {
|
|
1471
|
+
showOptionAutocomplete(cm, pluginInfo);
|
|
1472
|
+
}
|
|
1473
|
+
}, 150);
|
|
1474
|
+
}
|
|
1475
|
+
} else {
|
|
1476
|
+
// Not inside a plugin - show plugin autocomplete
|
|
1477
|
+
|
|
1478
|
+
// Don't show autocomplete if we're inside an option value (e.g., inside a hash or array)
|
|
1479
|
+
if (isInsideOptionValue(cm, cursor)) {
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
const section = detectCurrentSection(cm, cursor);
|
|
1484
|
+
|
|
1485
|
+
if (!section) return;
|
|
1486
|
+
|
|
1487
|
+
// Check if line contains only whitespace or partial word (no special chars like =>, {, etc)
|
|
1488
|
+
if (trimmedLine === '' || /^[a-zA-Z_]+$/.test(trimmedLine)) {
|
|
1489
|
+
autocompleteTimeout = setTimeout(() => {
|
|
1490
|
+
showPluginAutocomplete(cm);
|
|
1491
|
+
}, 150);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
// Update fold gutter markers
|
|
1497
|
+
codeMirrorEditor.on('change', function() {
|
|
1498
|
+
updateFoldGutter(codeMirrorEditor);
|
|
1499
|
+
});
|
|
1500
|
+
|
|
1501
|
+
// Handle gutter clicks for folding
|
|
1502
|
+
codeMirrorEditor.on('gutterClick', function(cm, line, gutter) {
|
|
1503
|
+
if (gutter === "CodeMirror-foldgutter") {
|
|
1504
|
+
// Check if this line is already folded by checking for fold marks on the entire line
|
|
1505
|
+
const lineText = cm.getLine(line);
|
|
1506
|
+
let foundFold = false;
|
|
1507
|
+
|
|
1508
|
+
// Check all positions on this line for a fold mark
|
|
1509
|
+
for (let ch = 0; ch <= lineText.length; ch++) {
|
|
1510
|
+
const marks = cm.findMarksAt(CodeMirror.Pos(line, ch));
|
|
1511
|
+
for (let i = 0; i < marks.length; i++) {
|
|
1512
|
+
if (marks[i].__isFold) {
|
|
1513
|
+
marks[i].clear();
|
|
1514
|
+
updateFoldGutter(cm);
|
|
1515
|
+
foundFold = true;
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (foundFold) break;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
// If not folded, create a fold
|
|
1523
|
+
if (!foundFold) {
|
|
1524
|
+
cm.foldCode(CodeMirror.Pos(line, 0));
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
// Initial fold gutter update
|
|
1530
|
+
updateFoldGutter(codeMirrorEditor);
|
|
1531
|
+
|
|
1532
|
+
// Initial stats update
|
|
1533
|
+
updateTextEditorStats();
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Update fold gutter markers for all foldable lines
|
|
1538
|
+
*/
|
|
1539
|
+
function updateFoldGutter(cm) {
|
|
1540
|
+
cm.clearGutter("CodeMirror-foldgutter");
|
|
1541
|
+
|
|
1542
|
+
for (let line = 0; line < cm.lineCount(); line++) {
|
|
1543
|
+
const lineText = cm.getLine(line).trim();
|
|
1544
|
+
|
|
1545
|
+
// Check if this line can be folded
|
|
1546
|
+
const isMainSection = /^(input|filter|output)\s*\{/.test(lineText);
|
|
1547
|
+
const isConditional = /^(if\s+|else\s+if\s+|else\s*)\{/.test(lineText) ||
|
|
1548
|
+
/^(if|else\s+if|else)\s+.*\{/.test(lineText);
|
|
1549
|
+
const isPlugin = /^\w+\s*\{/.test(lineText);
|
|
1550
|
+
|
|
1551
|
+
const canFold = isMainSection || isConditional || isPlugin;
|
|
1552
|
+
|
|
1553
|
+
if (canFold) {
|
|
1554
|
+
// Check if currently folded
|
|
1555
|
+
const marks = cm.findMarksAt(CodeMirror.Pos(line, 0));
|
|
1556
|
+
let isFolded = false;
|
|
1557
|
+
|
|
1558
|
+
for (let i = 0; i < marks.length; i++) {
|
|
1559
|
+
if (marks[i].__isFold) {
|
|
1560
|
+
isFolded = true;
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
const marker = document.createElement("div");
|
|
1566
|
+
marker.className = isFolded ? "CodeMirror-foldgutter-folded" : "CodeMirror-foldgutter-open";
|
|
1567
|
+
cm.setGutterMarker(line, "CodeMirror-foldgutter", marker);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Highlight matching brackets
|
|
1574
|
+
*/
|
|
1575
|
+
let bracketMarks = [];
|
|
1576
|
+
function highlightMatchingBrackets(cm) {
|
|
1577
|
+
// Clear previous marks
|
|
1578
|
+
bracketMarks.forEach(mark => mark.clear());
|
|
1579
|
+
bracketMarks = [];
|
|
1580
|
+
|
|
1581
|
+
const cursor = cm.getCursor();
|
|
1582
|
+
const line = cm.getLine(cursor.line);
|
|
1583
|
+
const ch = cursor.ch;
|
|
1584
|
+
|
|
1585
|
+
// Check character at cursor and before cursor
|
|
1586
|
+
const charAfter = line.charAt(ch);
|
|
1587
|
+
const charBefore = ch > 0 ? line.charAt(ch - 1) : '';
|
|
1588
|
+
|
|
1589
|
+
const openBrackets = ['{', '[', '('];
|
|
1590
|
+
const closeBrackets = ['}', ']', ')'];
|
|
1591
|
+
const brackets = {
|
|
1592
|
+
'{': '}', '}': '{',
|
|
1593
|
+
'[': ']', ']': '[',
|
|
1594
|
+
'(': ')', ')': '('
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
let bracketChar = '';
|
|
1598
|
+
let bracketPos = null;
|
|
1599
|
+
let searchForward = false;
|
|
1600
|
+
|
|
1601
|
+
// Prioritize: opening bracket at cursor, closing bracket before cursor, then others
|
|
1602
|
+
if (openBrackets.includes(charAfter)) {
|
|
1603
|
+
bracketChar = charAfter;
|
|
1604
|
+
bracketPos = {line: cursor.line, ch: ch};
|
|
1605
|
+
searchForward = true;
|
|
1606
|
+
} else if (closeBrackets.includes(charBefore)) {
|
|
1607
|
+
bracketChar = charBefore;
|
|
1608
|
+
bracketPos = {line: cursor.line, ch: ch - 1};
|
|
1609
|
+
searchForward = false;
|
|
1610
|
+
} else if (closeBrackets.includes(charAfter)) {
|
|
1611
|
+
bracketChar = charAfter;
|
|
1612
|
+
bracketPos = {line: cursor.line, ch: ch};
|
|
1613
|
+
searchForward = false;
|
|
1614
|
+
} else if (openBrackets.includes(charBefore)) {
|
|
1615
|
+
bracketChar = charBefore;
|
|
1616
|
+
bracketPos = {line: cursor.line, ch: ch - 1};
|
|
1617
|
+
searchForward = true;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
if (!bracketChar) return;
|
|
1621
|
+
|
|
1622
|
+
const matchChar = brackets[bracketChar];
|
|
1623
|
+
const matchPos = findMatchingBracket(cm, bracketPos, bracketChar, matchChar, searchForward);
|
|
1624
|
+
|
|
1625
|
+
if (matchPos) {
|
|
1626
|
+
// Highlight both brackets
|
|
1627
|
+
const mark1 = cm.markText(
|
|
1628
|
+
bracketPos,
|
|
1629
|
+
{line: bracketPos.line, ch: bracketPos.ch + 1},
|
|
1630
|
+
{className: 'CodeMirror-matchingbracket'}
|
|
1631
|
+
);
|
|
1632
|
+
const mark2 = cm.markText(
|
|
1633
|
+
matchPos,
|
|
1634
|
+
{line: matchPos.line, ch: matchPos.ch + 1},
|
|
1635
|
+
{className: 'CodeMirror-matchingbracket'}
|
|
1636
|
+
);
|
|
1637
|
+
bracketMarks.push(mark1, mark2);
|
|
1638
|
+
} else {
|
|
1639
|
+
// Non-matching bracket
|
|
1640
|
+
const mark = cm.markText(
|
|
1641
|
+
bracketPos,
|
|
1642
|
+
{line: bracketPos.line, ch: bracketPos.ch + 1},
|
|
1643
|
+
{className: 'CodeMirror-nonmatchingbracket'}
|
|
1644
|
+
);
|
|
1645
|
+
bracketMarks.push(mark);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Find matching bracket position
|
|
1651
|
+
*/
|
|
1652
|
+
function findMatchingBracket(cm, pos, bracketChar, matchChar, searchForward) {
|
|
1653
|
+
const maxScanLines = 1000;
|
|
1654
|
+
|
|
1655
|
+
if (searchForward) {
|
|
1656
|
+
// Search forward for closing bracket
|
|
1657
|
+
let depth = 0;
|
|
1658
|
+
for (let line = pos.line; line < Math.min(cm.lineCount(), pos.line + maxScanLines); line++) {
|
|
1659
|
+
const text = cm.getLine(line);
|
|
1660
|
+
const startCh = (line === pos.line) ? pos.ch : 0;
|
|
1661
|
+
|
|
1662
|
+
for (let ch = startCh; ch < text.length; ch++) {
|
|
1663
|
+
if (text[ch] === bracketChar) depth++;
|
|
1664
|
+
if (text[ch] === matchChar) {
|
|
1665
|
+
depth--;
|
|
1666
|
+
if (depth === 0) {
|
|
1667
|
+
return {line: line, ch: ch};
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
} else {
|
|
1673
|
+
// Search backward for opening bracket (mirror of forward search)
|
|
1674
|
+
let depth = 0;
|
|
1675
|
+
for (let line = pos.line; line >= Math.max(0, pos.line - maxScanLines); line--) {
|
|
1676
|
+
const text = cm.getLine(line);
|
|
1677
|
+
const startCh = (line === pos.line) ? pos.ch : text.length - 1;
|
|
1678
|
+
|
|
1679
|
+
for (let ch = startCh; ch >= 0; ch--) {
|
|
1680
|
+
if (text[ch] === bracketChar) depth++;
|
|
1681
|
+
if (text[ch] === matchChar) {
|
|
1682
|
+
depth--;
|
|
1683
|
+
if (depth === 0) {
|
|
1684
|
+
return {line: line, ch: ch};
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
return null;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* Update line and character count
|
|
1696
|
+
*/
|
|
1697
|
+
function updateTextEditorStats() {
|
|
1698
|
+
const lineCountEl = document.getElementById('lineCount');
|
|
1699
|
+
const charCountEl = document.getElementById('charCount');
|
|
1700
|
+
|
|
1701
|
+
if (!lineCountEl || !charCountEl) return;
|
|
1702
|
+
|
|
1703
|
+
let text = '';
|
|
1704
|
+
if (codeMirrorEditor) {
|
|
1705
|
+
text = codeMirrorEditor.getValue();
|
|
1706
|
+
} else {
|
|
1707
|
+
const textEditor = document.getElementById('pipelineTextEditor');
|
|
1708
|
+
if (textEditor) {
|
|
1709
|
+
text = textEditor.value;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
const lines = text.split('\n').length;
|
|
1714
|
+
const chars = text.length;
|
|
1715
|
+
|
|
1716
|
+
lineCountEl.textContent = `Lines: ${lines}`;
|
|
1717
|
+
charCountEl.textContent = `Characters: ${chars}`;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// Old textarea functions removed - CodeMirror handles this now
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Clear any open CodeMirror autocomplete hints
|
|
1724
|
+
*/
|
|
1725
|
+
function clearAutocompleteHints() {
|
|
1726
|
+
// Remove any visible CodeMirror hint widgets
|
|
1727
|
+
const hints = document.querySelectorAll('.CodeMirror-hints');
|
|
1728
|
+
hints.forEach(hint => hint.remove());
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Add flash animation to a button
|
|
1733
|
+
*/
|
|
1734
|
+
function addFlashAnimation(button) {
|
|
1735
|
+
const container = button.closest('.bg-gray-700');
|
|
1736
|
+
if (!container) return;
|
|
1737
|
+
|
|
1738
|
+
// Add the flash class
|
|
1739
|
+
container.classList.add('toggle-flash');
|
|
1740
|
+
|
|
1741
|
+
// Remove the class after animation completes
|
|
1742
|
+
setTimeout(() => {
|
|
1743
|
+
container.classList.remove('toggle-flash');
|
|
1744
|
+
}, 600);
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Disable View Code and Simulate Pipeline buttons
|
|
1749
|
+
*/
|
|
1750
|
+
function disableEditorButtons() {
|
|
1751
|
+
const viewCodeBtn = document.getElementById('viewCode');
|
|
1752
|
+
const simulateBtn = document.getElementById('simulatePipeline');
|
|
1753
|
+
|
|
1754
|
+
if (viewCodeBtn) {
|
|
1755
|
+
viewCodeBtn.disabled = true;
|
|
1756
|
+
viewCodeBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
1757
|
+
viewCodeBtn.classList.remove('hover:bg-gray-600');
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
if (simulateBtn) {
|
|
1761
|
+
simulateBtn.disabled = true;
|
|
1762
|
+
simulateBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
1763
|
+
simulateBtn.classList.remove('hover:bg-purple-700');
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* Enable View Code and Simulate Pipeline buttons
|
|
1769
|
+
*/
|
|
1770
|
+
function enableEditorButtons() {
|
|
1771
|
+
const viewCodeBtn = document.getElementById('viewCode');
|
|
1772
|
+
const simulateBtn = document.getElementById('simulatePipeline');
|
|
1773
|
+
|
|
1774
|
+
if (viewCodeBtn) {
|
|
1775
|
+
viewCodeBtn.disabled = false;
|
|
1776
|
+
viewCodeBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
1777
|
+
viewCodeBtn.classList.add('hover:bg-gray-600');
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
if (simulateBtn) {
|
|
1781
|
+
simulateBtn.disabled = false;
|
|
1782
|
+
simulateBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
1783
|
+
simulateBtn.classList.add('hover:bg-purple-700');
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Switch to Graph mode
|
|
1789
|
+
*/
|
|
1790
|
+
async function switchToGraphMode() {
|
|
1791
|
+
// Check if text has been modified
|
|
1792
|
+
if (textHasChanges) {
|
|
1793
|
+
// Check if user has disabled conversion warnings
|
|
1794
|
+
if (!shouldSkipConversionWarning()) {
|
|
1795
|
+
// Show warning dialog
|
|
1796
|
+
const confirmed = await ConfirmationModal.show(
|
|
1797
|
+
'Switching to Graph mode will reformat this configuration to match the visual editor. Some formatting or inline comments may change.\n\nContinue?',
|
|
1798
|
+
'Switch to Graph Mode',
|
|
1799
|
+
'Continue'
|
|
1800
|
+
);
|
|
1801
|
+
|
|
1802
|
+
if (!confirmed) {
|
|
1803
|
+
// User cancelled, don't switch modes
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
// If text has changes, convert it to components
|
|
1810
|
+
if (textHasChanges && codeMirrorEditor) {
|
|
1811
|
+
const configText = codeMirrorEditor.getValue();
|
|
1812
|
+
|
|
1813
|
+
if (!configText) {
|
|
1814
|
+
console.error('No config text to convert');
|
|
1815
|
+
alert('No pipeline configuration to convert');
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// Convert config text to components via API
|
|
1820
|
+
const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]')?.value || '';
|
|
1821
|
+
const formData = new FormData();
|
|
1822
|
+
formData.append('config_text', configText);
|
|
1823
|
+
|
|
1824
|
+
fetch('/ConnectionManager/ConfigToComponents/', {
|
|
1825
|
+
method: 'POST',
|
|
1826
|
+
headers: {
|
|
1827
|
+
'X-CSRFToken': csrfToken
|
|
1828
|
+
},
|
|
1829
|
+
body: formData
|
|
1830
|
+
})
|
|
1831
|
+
.then(response => {
|
|
1832
|
+
if (!response.ok) {
|
|
1833
|
+
return response.json().then(data => {
|
|
1834
|
+
throw new Error(data.error || 'Failed to convert config to components');
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
return response.json();
|
|
1838
|
+
})
|
|
1839
|
+
.then(data => {
|
|
1840
|
+
|
|
1841
|
+
// If data is a string, parse it
|
|
1842
|
+
let parsedData = data;
|
|
1843
|
+
if (typeof data === 'string') {
|
|
1844
|
+
parsedData = JSON.parse(data);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
// The API returns the components structure directly
|
|
1848
|
+
// If it's an array, it needs to be converted to the expected object format
|
|
1849
|
+
let convertedComponents;
|
|
1850
|
+
if (Array.isArray(parsedData)) {
|
|
1851
|
+
// Data is an array [input, filter, output] - convert to object
|
|
1852
|
+
convertedComponents = {
|
|
1853
|
+
input: parsedData[0] || [],
|
|
1854
|
+
filter: parsedData[1] || [],
|
|
1855
|
+
output: parsedData[2] || []
|
|
1856
|
+
};
|
|
1857
|
+
} else {
|
|
1858
|
+
// Data is already an object
|
|
1859
|
+
convertedComponents = parsedData;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
// Update the global components variable
|
|
1863
|
+
if (typeof components !== 'undefined') {
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
// Clear existing arrays and push new items (preserves Proxy/reactive behavior)
|
|
1867
|
+
components.input.length = 0;
|
|
1868
|
+
components.filter.length = 0;
|
|
1869
|
+
components.output.length = 0;
|
|
1870
|
+
|
|
1871
|
+
// Use Array.isArray and check length
|
|
1872
|
+
if (Array.isArray(convertedComponents.input) && convertedComponents.input.length > 0) {
|
|
1873
|
+
components.input.push(...convertedComponents.input);
|
|
1874
|
+
}
|
|
1875
|
+
if (Array.isArray(convertedComponents.filter) && convertedComponents.filter.length > 0) {
|
|
1876
|
+
components.filter.push(...convertedComponents.filter);
|
|
1877
|
+
}
|
|
1878
|
+
if (Array.isArray(convertedComponents.output) && convertedComponents.output.length > 0) {
|
|
1879
|
+
const pushResult = components.output.push(...convertedComponents.output);
|
|
1880
|
+
} else {
|
|
1881
|
+
console.error('Output check failed - isArray:', Array.isArray(convertedComponents.output), 'length:', convertedComponents.output?.length);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
} else {
|
|
1885
|
+
console.error('Global components variable is undefined!');
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// Switch to Graph mode first
|
|
1889
|
+
performGraphSwitch();
|
|
1890
|
+
|
|
1891
|
+
// Use setTimeout to ensure Graph container is visible before rendering
|
|
1892
|
+
setTimeout(() => {
|
|
1893
|
+
|
|
1894
|
+
// Render the graph with the new components
|
|
1895
|
+
if (typeof renderGraphEditor === 'function') {
|
|
1896
|
+
renderGraphEditor();
|
|
1897
|
+
} else {
|
|
1898
|
+
console.error('renderGraphEditor function not found!');
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// Mark UI as changed since we just loaded from text
|
|
1902
|
+
// This ensures switching back to Text mode will convert components to config
|
|
1903
|
+
uiHasChanges = true;
|
|
1904
|
+
}, 100);
|
|
1905
|
+
})
|
|
1906
|
+
.catch(error => {
|
|
1907
|
+
console.error('Error converting config to components:', error);
|
|
1908
|
+
ConfirmationModal.show(
|
|
1909
|
+
'Failed to convert pipeline configuration:',
|
|
1910
|
+
'Configuration Error',
|
|
1911
|
+
'OK',
|
|
1912
|
+
error.message,
|
|
1913
|
+
true
|
|
1914
|
+
);
|
|
1915
|
+
});
|
|
1916
|
+
} else {
|
|
1917
|
+
// No text changes, just switch modes
|
|
1918
|
+
performGraphSwitch();
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
/**
|
|
1923
|
+
* Perform the actual Graph mode switch (internal helper)
|
|
1924
|
+
*/
|
|
1925
|
+
function performGraphSwitch() {
|
|
1926
|
+
currentEditorMode = 'graph';
|
|
1927
|
+
window.currentEditorMode = currentEditorMode;
|
|
1928
|
+
|
|
1929
|
+
// Save mode preference to localStorage
|
|
1930
|
+
localStorage.setItem('lastEditorMode', 'graph');
|
|
1931
|
+
|
|
1932
|
+
// Clear any open autocomplete hints
|
|
1933
|
+
clearAutocompleteHints();
|
|
1934
|
+
|
|
1935
|
+
// Reset text change tracking
|
|
1936
|
+
textHasChanges = false;
|
|
1937
|
+
textModeInitialContent = '';
|
|
1938
|
+
|
|
1939
|
+
// Update button styles
|
|
1940
|
+
const uiBtn = document.getElementById('uiModeBtn');
|
|
1941
|
+
const textBtn = document.getElementById('textModeBtn');
|
|
1942
|
+
const graphBtn = document.getElementById('graphModeBtn');
|
|
1943
|
+
|
|
1944
|
+
if (uiBtn && textBtn && graphBtn) {
|
|
1945
|
+
uiBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
1946
|
+
textBtn.className = 'w-20 py-2 rounded-md font-medium transition-all text-gray-300 hover:bg-gray-600';
|
|
1947
|
+
graphBtn.className = 'w-20 py-2 rounded-md font-medium transition-all bg-green-600 text-white mode-toggle-active';
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
// Hide UI and Text containers, show Graph container
|
|
1951
|
+
const uiContainer = document.getElementById('uiModeContainer');
|
|
1952
|
+
const textContainer = document.getElementById('textModeContainer');
|
|
1953
|
+
const graphContainer = document.getElementById('graphModeContainer');
|
|
1954
|
+
|
|
1955
|
+
if (uiContainer && textContainer && graphContainer) {
|
|
1956
|
+
uiContainer.classList.add('hidden');
|
|
1957
|
+
textContainer.classList.add('hidden');
|
|
1958
|
+
graphContainer.classList.remove('hidden');
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
// Render the graph with current components
|
|
1962
|
+
if (typeof renderGraphEditor === 'function') {
|
|
1963
|
+
renderGraphEditor();
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
// Enable View Code button but disable Simulate button in Graph mode
|
|
1967
|
+
const viewCodeBtn = document.getElementById('viewCode');
|
|
1968
|
+
const simulateBtn = document.getElementById('simulatePipeline');
|
|
1969
|
+
|
|
1970
|
+
if (viewCodeBtn) {
|
|
1971
|
+
viewCodeBtn.disabled = false;
|
|
1972
|
+
viewCodeBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
1973
|
+
viewCodeBtn.classList.add('hover:bg-gray-600');
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
if (simulateBtn) {
|
|
1977
|
+
simulateBtn.disabled = true;
|
|
1978
|
+
simulateBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
1979
|
+
simulateBtn.classList.remove('hover:bg-purple-700');
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* Toggle fullscreen mode for text editor
|
|
1985
|
+
*/
|
|
1986
|
+
let isTextFullscreen = false;
|
|
1987
|
+
|
|
1988
|
+
function toggleTextFullscreen() {
|
|
1989
|
+
const container = document.getElementById('textEditorContainer');
|
|
1990
|
+
const btn = document.getElementById('textFullscreenBtn');
|
|
1991
|
+
|
|
1992
|
+
if (!container || !btn) return;
|
|
1993
|
+
|
|
1994
|
+
isTextFullscreen = !isTextFullscreen;
|
|
1995
|
+
|
|
1996
|
+
if (isTextFullscreen) {
|
|
1997
|
+
// Enter fullscreen
|
|
1998
|
+
container.style.position = 'fixed';
|
|
1999
|
+
container.style.top = '0';
|
|
2000
|
+
container.style.left = '0';
|
|
2001
|
+
container.style.right = '0';
|
|
2002
|
+
container.style.bottom = '0';
|
|
2003
|
+
container.style.zIndex = '9999';
|
|
2004
|
+
container.style.backgroundColor = '#1a1d23';
|
|
2005
|
+
|
|
2006
|
+
// Change icon to minimize
|
|
2007
|
+
btn.innerHTML = `
|
|
2008
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
2009
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
|
2010
|
+
</svg>
|
|
2011
|
+
`;
|
|
2012
|
+
btn.title = 'Exit fullscreen';
|
|
2013
|
+
} else {
|
|
2014
|
+
// Exit fullscreen
|
|
2015
|
+
container.style.position = '';
|
|
2016
|
+
container.style.top = '';
|
|
2017
|
+
container.style.left = '';
|
|
2018
|
+
container.style.right = '';
|
|
2019
|
+
container.style.bottom = '';
|
|
2020
|
+
container.style.zIndex = '';
|
|
2021
|
+
container.style.backgroundColor = '';
|
|
2022
|
+
|
|
2023
|
+
// Change icon back to expand
|
|
2024
|
+
btn.innerHTML = `
|
|
2025
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
2026
|
+
<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>
|
|
2027
|
+
</svg>
|
|
2028
|
+
`;
|
|
2029
|
+
btn.title = 'Toggle fullscreen';
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
// Refresh CodeMirror to adjust to new size
|
|
2033
|
+
if (codeMirrorEditor) {
|
|
2034
|
+
setTimeout(() => codeMirrorEditor.refresh(), 100);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
// Make function globally available
|
|
2039
|
+
window.toggleTextFullscreen = toggleTextFullscreen;
|
|
2040
|
+
|
|
2041
|
+
/**
|
|
2042
|
+
* Initialize conversion warning checkbox from localStorage
|
|
2043
|
+
*/
|
|
2044
|
+
function initializeConversionWarningCheckbox() {
|
|
2045
|
+
const checkbox = document.getElementById('disableConversionWarning');
|
|
2046
|
+
if (!checkbox) return;
|
|
2047
|
+
|
|
2048
|
+
// Load saved preference from localStorage
|
|
2049
|
+
const savedPreference = localStorage.getItem('disableConversionWarning');
|
|
2050
|
+
if (savedPreference === 'true') {
|
|
2051
|
+
checkbox.checked = true;
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
// Save preference when checkbox changes
|
|
2055
|
+
checkbox.addEventListener('change', function() {
|
|
2056
|
+
localStorage.setItem('disableConversionWarning', this.checked);
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* Check if conversion warnings are disabled
|
|
2062
|
+
*/
|
|
2063
|
+
function shouldSkipConversionWarning() {
|
|
2064
|
+
return localStorage.getItem('disableConversionWarning') === 'true';
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
// Initialize when DOM is ready
|
|
2068
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
2069
|
+
// Initialize conversion warning checkbox
|
|
2070
|
+
initializeConversionWarningCheckbox();
|
|
2071
|
+
|
|
2072
|
+
// Load last editor mode from localStorage, default to UI if not set
|
|
2073
|
+
const lastMode = localStorage.getItem('lastEditorMode') || 'ui';
|
|
2074
|
+
|
|
2075
|
+
// Switch to the saved mode
|
|
2076
|
+
switch(lastMode) {
|
|
2077
|
+
case 'text':
|
|
2078
|
+
switchToTextMode();
|
|
2079
|
+
break;
|
|
2080
|
+
case 'graph':
|
|
2081
|
+
switchToGraphMode();
|
|
2082
|
+
break;
|
|
2083
|
+
case 'ui':
|
|
2084
|
+
default:
|
|
2085
|
+
switchToUIMode();
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
2088
|
+
});
|