mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-13 09:30:40 +00:00
Add new way to get results with full contest to provide moreuser feedback
This commit is contained in:
@ -126,7 +126,7 @@ class Client {
|
||||
tmp_first_cpos.push(results.data.matches[dataIndex].c[0]);
|
||||
tmp_last_cpos.push(results.data.matches[dataIndex].c[1]);
|
||||
}
|
||||
nopaque.socket.emit("corpus_analysis_inspect_match",
|
||||
nopaque.socket.emit("corpus_analysis_get_match_with_full_context",
|
||||
{type: resultsType,
|
||||
data_indexes: dataIndexes,
|
||||
first_cpos: tmp_first_cpos,
|
||||
@ -135,6 +135,7 @@ class Client {
|
||||
|
||||
//
|
||||
getResultsDataWithoutContext(resultsType, dataIndexes, results, resultsList) {
|
||||
this.notifyView('results-data-recieving', {fullContext: false});
|
||||
let objectKey = '';
|
||||
if (resultsType === 'full-results') {
|
||||
console.info('Saving full-results data without full context.');
|
||||
@ -159,12 +160,10 @@ class Client {
|
||||
}
|
||||
// Get cpos_lookups from cposes.
|
||||
let cpos_lookup = {};
|
||||
let single_lookup = {};
|
||||
let textIds = new Set;
|
||||
for (let single_cpos of cpos) {
|
||||
single_lookup[single_cpos] = results.data.cpos_lookup[single_cpos];
|
||||
textIds.add(single_lookup[single_cpos].text);
|
||||
Object.assign(cpos_lookup, single_lookup);
|
||||
textIds.add(results.data.cpos_lookup[single_cpos].text);
|
||||
Object.assign(cpos_lookup, { [single_cpos]: results.data.cpos_lookup[single_cpos]});
|
||||
}
|
||||
let text = {};
|
||||
let text_lookup = {};
|
||||
@ -189,7 +188,8 @@ class Client {
|
||||
console.info('Results data without context has been saved.', results);
|
||||
this.isBusy = false;
|
||||
this.notifyView('results-data-recieved', {type: resultsType,
|
||||
results: results});
|
||||
results: results,
|
||||
fullContext: false});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ function saveQueryData() {
|
||||
function getResultsData() {
|
||||
let [resultsType, dataIndexes, resultsList, client, results, rest] = arguments;
|
||||
client.isBusy = true;
|
||||
client.notifyView('results-data-recieving');
|
||||
if (resultsList.exportFullInspectContext.checked || resultsType === 'inspect-results') {
|
||||
console.log('Get with full context');
|
||||
console.info('Get results with full context');
|
||||
client.getResultsData(resultsType, dataIndexes, results);
|
||||
} else {
|
||||
console.info('Get results without full context');
|
||||
client.getResultsDataWithoutContext(resultsType, dataIndexes, results,
|
||||
resultsList);
|
||||
}
|
||||
@ -96,21 +96,26 @@ function saveResultsData() {
|
||||
objectKey = 'inspectResultsData'
|
||||
console.info('Saving inspect-results data');
|
||||
}
|
||||
// Save incoming data
|
||||
results[objectKey].init();
|
||||
// Save incoming data. Data is incoming one match at a time.
|
||||
results[objectKey].matches.push(...payload.matches);
|
||||
results[objectKey].addData(payload.cpos_lookup, "cpos_lookup");
|
||||
results[objectKey].addData(payload.text_lookup, "text_lookup");
|
||||
results[objectKey].addData(results.metaData);
|
||||
results[objectKey].query = results.data.query;
|
||||
results[objectKey].corpus_type = type;
|
||||
results[objectKey].match_count = [...payload.matches].length;
|
||||
results[objectKey].match_count += 1;
|
||||
results[objectKey].cpos_ranges = payload.cpos_ranges;
|
||||
results[objectKey].fullContext = true;
|
||||
console.info('Results data has been saved.', results);
|
||||
// Notify view to update progress bar
|
||||
client.notifyView('results-data-recieving', {type: type,
|
||||
progress: payload.progress})
|
||||
client.isBusy = false;
|
||||
client.notifyView('results-data-recieved', {type: type,
|
||||
results: results});
|
||||
if (payload.progress === 100) {
|
||||
client.notifyView('results-data-recieved', {type: type,
|
||||
results: results,
|
||||
fullContext: true});
|
||||
}
|
||||
}
|
||||
|
||||
// export callbacks
|
||||
|
@ -147,9 +147,9 @@ function recieveResultsData(type, client) {
|
||||
*/
|
||||
if (response.code === 200) {
|
||||
console.group('Client recieving results data')
|
||||
console.info('corpus_analysis_inspect_match: Client recieving results data',
|
||||
console.info('corpus_analysis_get_match_with_full_context: Client recieving results data',
|
||||
'via socket.on');
|
||||
console.info(`corpus_analysis_inspect_match: ${response.code} - ${response.msg}`);
|
||||
console.info(`corpus_analysis_get_match_with_full_context: ${response.code} - ${response.msg}`);
|
||||
console.info(response);
|
||||
// executing the registered callbacks
|
||||
client.eventListeners[type].executeCallbacks([response.payload,
|
||||
@ -158,9 +158,9 @@ function recieveResultsData(type, client) {
|
||||
} else {
|
||||
let errorText = `Error ${response.payload.code} - ${response.payload.msg}`;
|
||||
console.group('Failed to recieve results data.');
|
||||
console.error('corpus_analysis_inspect_match: Client failed to recieve',
|
||||
console.error('corpus_analysis_get_match_with_full_context: Client failed to recieve',
|
||||
'results data via socket.on');
|
||||
console.error(`corpus_analysis_inspect_match: ${errorText}`);
|
||||
console.error(`corpus_analysis_get_match_with_full_context: ${errorText}`);
|
||||
client.notifyView('client-failed', { msg: errorText }, 'error');
|
||||
console.groupEnd();
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class ResultsList extends List {
|
||||
// Used in addToSubResults and inspect to toggle the design of the check
|
||||
// buttons according to its checked unchecked status.
|
||||
helperActivateAddBtn(btn) {
|
||||
btn.classList.remove("grey");
|
||||
btn.classList.remove("corpus-analysis-color.lighten");
|
||||
btn.classList.add("green");
|
||||
btn.textContent = "check";
|
||||
}
|
||||
@ -228,7 +228,7 @@ class ResultsList extends List {
|
||||
// buttons according to its checked unchecked status.
|
||||
helperDeactivateAddBtn(btn) {
|
||||
btn.classList.remove("green");
|
||||
btn.classList.add("grey");
|
||||
btn.classList.add("corpus-analysis-color.lighten");
|
||||
btn.textContent = "add";
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ class ResultsList extends List {
|
||||
this.contextModal.open();
|
||||
// add a button to add this match to sub results with onclick event
|
||||
let classes = `btn-floating btn waves-effect` +
|
||||
` waves-light grey right`
|
||||
` waves-light corpus-analysis-color.lighten right`
|
||||
let addToSubResultsIdsBtn = document.createElement("a");
|
||||
addToSubResultsIdsBtn.setAttribute("class", classes + ` add`);
|
||||
addToSubResultsIdsBtn.innerHTML = '<i class="material-icons">add</i>';
|
||||
@ -722,7 +722,7 @@ class ResultsList extends List {
|
||||
// # some btn css rules and classes
|
||||
let css = `margin-right: 5px; margin-bottom: 5px;`
|
||||
let classes = `btn-floating btn waves-effect` +
|
||||
` waves-light grey`
|
||||
` waves-light corpus-analysis-color.lighten`
|
||||
// # add button to trigger more context to every match td
|
||||
inspectBtn = document.createElement("a");
|
||||
inspectBtn.setAttribute("style", css);
|
||||
|
@ -151,11 +151,26 @@ function queryDataRecievedCallback(resultsList, detail) {
|
||||
}
|
||||
|
||||
function resultsDataRecievingCallback(resultsList, detail) {
|
||||
resultsList.getHTMLElements([
|
||||
'#full-results-progress-bar',
|
||||
'#sub-results-progress-bar',
|
||||
]);
|
||||
// Disable the full context switch when results are being recieved
|
||||
resultsList.exportFullInspectContext.setAttribute('disabled', '');
|
||||
if (detail.type === 'full-results' && detail.progress) {
|
||||
resultsList.fullResultsProgressBar.firstElementChild.style.width = `${detail.progress}%`;
|
||||
resultsList.fullResultsProgressBar.classList.toggle('hide', false);
|
||||
} else if (detail.type === 'sub-results' && detail.progress) {
|
||||
resultsList.subResultsProgressBar.firstElementChild.style.width = `${detail.progress}%`;
|
||||
resultsList.subResultsProgressBar.classList.toggle('hide', false);
|
||||
}
|
||||
}
|
||||
|
||||
function resultsDataRecievedCallback(resultsList, detail) {
|
||||
// create strings for create buttons depending on type
|
||||
const handleType = (keyPrefix, text) => {
|
||||
// Enable the full context switch when results have been recieved
|
||||
resultsList.exportFullInspectContext.removeAttribute('disabled', '');
|
||||
// hides the create element after results have been recieved and reset it
|
||||
resultsList[`${keyPrefix}Create`].classList.toggle('hide');
|
||||
resultsList[`${keyPrefix}Create`].textContent = `Create ${text}`;
|
||||
@ -171,8 +186,16 @@ function resultsDataRecievedCallback(resultsList, detail) {
|
||||
}
|
||||
if (detail.type === 'full-results') {
|
||||
handleType('fullResults', 'Results');
|
||||
if (detail.fullContext) {
|
||||
resultsList.fullResultsProgressBar.firstElementChild.style.width = `0%`;
|
||||
resultsList.fullResultsProgressBar.classList.toggle('hide', true);
|
||||
}
|
||||
} else if (detail.type ==='sub-results') {
|
||||
handleType('subResults', 'Sub-Results');
|
||||
if (detail.fullContext) {
|
||||
resultsList.subResultsProgressBar.firstElementChild.style.width = `0%`;
|
||||
resultsList.subResultsProgressBar.classList.toggle('hide', true);
|
||||
}
|
||||
} else if (detail.type ==='inspect-results') {
|
||||
if (resultsList.addToSubResultsIdsToShow.size === 0) {
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ function recvMetaData(payload) {
|
||||
console.log("Metada recieved:", results.metaData);
|
||||
}
|
||||
|
||||
// This callback is called in socket.on "corpus_analysis_inspect_match" but
|
||||
// This callback is called in socket.on "corpus_analysis_get_match_with_full_context" but
|
||||
// only if the response.type is "sub-results".
|
||||
// Saves the incoming inspect match results into results.subResultsData.
|
||||
function saveSubResultsChoices(response) {
|
||||
|
Reference in New Issue
Block a user