Work on View notifications

This commit is contained in:
Stephan Porada
2020-08-24 16:33:37 +02:00
parent 0507ae4e34
commit d2453c2cc3
11 changed files with 218 additions and 117 deletions

View File

@ -41,8 +41,7 @@
<div class="col s12" id="query-display">
<div class="card">
<div class="card-content" id="result-list" style="overflow: hidden;">
<div class="error-container hide show-on-error"></div>
<div class=" row hide show-on-success">
<div id="interactions-menu" class="row hide">
{% include 'interactions/infos.html.j2' %}
{% include 'interactions/export.html.j2' %}
{% include 'interactions/create.html.j2' %}
@ -90,6 +89,13 @@ import {
saveQueryData,
saveMetaData,
} from '../../static/js/modules/corpus_analysis/client/callbacks.js';
import {
NotificationListener,
ResultsList,
} from '../../static/js/modules/corpus_analysis/view/ResultsView.js';
import {
recieveNotification,
} from '../../static/js/modules/corpus_analysis/view/listeners.js';
/**
* Second Phase:
@ -104,9 +110,11 @@ document.addEventListener("DOMContentLoaded", () => {
'dynamicMode': true});
/**
* Initializing the results object as a model holding all the data of a query.
* Also holds the metadata of one query.
* Also holds the metadata of one query. After that initialize the ResultsList
* object as the View handeling the represnetation of the data.
*/
let results = new Results();
let resultsView = new ResultsList('result-list', ResultsList.options);
/**
* Register listeners listening to socket.io events and their callbacks
* Afterwards load them.
@ -136,8 +144,17 @@ document.addEventListener("DOMContentLoaded", () => {
listenForQueryData,
listenForMetaData]);
client.loadSocketEventListeners();
/**
* Register resultsView listeners listening to nitification events.
*/
const listenForNotification = new NotificationListener('notify',
recieveNotification);
resultsView.setNotificationListeners([listenForNotification]);
resultsView.loadNotificationListeners();
// Connect client to server
client.notifyView('connecting');
client.connect();
// Send a query and recieve its answer data
let queryFormElement = document.getElementById('query-form');
queryFormElement.addEventListener('submit', (event) => {