Merge pull request #2526 from GSA/2525-bugfix-js-socket-io-connection-variable

Fix connection url
This commit is contained in:
Cliff Hill
2025-04-22 09:34:17 -04:00
committed by GitHub
3 changed files with 7 additions and 3 deletions

View File

@@ -13,11 +13,12 @@ document.addEventListener('DOMContentLoaded', function () {
const jobEl = document.querySelector('[data-job-id]');
const jobId = jobEl?.dataset?.jobId;
const featureEnabled = jobEl?.dataset?.feature === 'true';
const apiHost = jobEl?.dataset?.host;
if (!jobId) return;
if (featureEnabled) {
const socket = io('http://localhost:6011');
const socket = io(apiHost);
socket.on('connect', () => {
socket.emit('join', { room: `job-${jobId}` });

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import os
from functools import partial
from flask import (
@@ -58,8 +58,11 @@ def view_job(service_id, job_id):
filter_args = parse_filter_args(request.args)
filter_args["status"] = set_status_filters(filter_args)
api_host_name = os.environ.get('API_HOST_NAME')
return render_template(
"views/jobs/job.html",
api_host_name=api_host_name,
FEATURE_SOCKET_ENABLED=current_app.config["FEATURE_SOCKET_ENABLED"],
job=job,
status=request.args.get("status", ""),

View File

@@ -11,7 +11,7 @@
{% block maincolumn_content %}
{{ page_header("Message status") }}
<div data-job-id="{{ job.id }}" data-feature="{{FEATURE_SOCKET_ENABLED | lower}}">
<div data-job-id="{{ job.id }}" data-feature="{{FEATURE_SOCKET_ENABLED | lower}}" data-host="{{ api_host_name }}">
{% if not job.finished_processing %}
<div
data-resource="{{ updates_url }}"