mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-06 14:30:57 -04:00
added example of fetch
This commit is contained in:
@@ -7,16 +7,14 @@
|
||||
console.log('Connected to the server');
|
||||
});
|
||||
|
||||
socket.on('message', function(msg) {
|
||||
var li = document.createElement("li");
|
||||
li.appendChild(document.createTextNode(msg));
|
||||
document.getElementById("messages").appendChild(li);
|
||||
// Listen for job updates from the server
|
||||
socket.on('job_update', function(data) {
|
||||
console.log('Received job update:', data);
|
||||
});
|
||||
|
||||
document.getElementById('sendButton').addEventListener('click', function() {
|
||||
var message = document.getElementById("message").value;
|
||||
socket.send(message);
|
||||
document.getElementById("message").value = '';
|
||||
document.getElementById('fetchJobsButton').addEventListener('click', function() {
|
||||
const serviceId = 'b1226555-1f1a-472c-9086-043b0a69f4ec'; // Example service ID
|
||||
socket.emit('fetch_jobs', serviceId);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from itertools import groupby
|
||||
|
||||
from flask import Response, abort, jsonify, render_template, request, session, url_for
|
||||
from flask_login import current_user
|
||||
from flask_socketio import send, emit
|
||||
from flask_socketio import SocketIO, emit
|
||||
from werkzeug.utils import redirect
|
||||
|
||||
from app import (
|
||||
@@ -34,14 +34,20 @@ from app.utils.user import user_has_permissions
|
||||
from notifications_utils.recipients import format_phone_number_human_readable
|
||||
|
||||
|
||||
@socketio.on('message')
|
||||
def handle_message(msg):
|
||||
print('''Message:
|
||||
# @socketio.on('connect')
|
||||
# def handle_connect():
|
||||
# print('Client connected')
|
||||
|
||||
|
||||
# @socketio.on('disconnect')
|
||||
# def handle_disconnect():
|
||||
# print('Client disconnected')
|
||||
|
||||
''' + msg)
|
||||
emit('message', msg, broadcast=True)
|
||||
|
||||
@socketio.on('fetch_jobs')
|
||||
def handle_fetch_jobs(service_id):
|
||||
job_response = job_api_client.get_jobs(service_id)["data"]
|
||||
emit('job_update', job_response)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/dashboard")
|
||||
@@ -71,7 +77,6 @@ def service_dashboard(service_id):
|
||||
job_id = notification.get("job", {}).get("id", None)
|
||||
if job_id:
|
||||
aggregate_notifications_by_job[job_id].append(notification)
|
||||
|
||||
job_and_notifications = [
|
||||
{
|
||||
"job_id": job["id"],
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
Messages sent
|
||||
</h2>
|
||||
|
||||
<input id="message" autocomplete="off"><button id="sendButton">Send</button>
|
||||
<ul id="messages"></ul>
|
||||
<h1>Job Dashboard</h1>
|
||||
<button id="fetchJobsButton">Fetch Jobs</button>
|
||||
|
||||
{{ ajax_block(partials, updates_url, 'inbox') }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user