Skip to content

Commit

Permalink
Finish async
Browse files Browse the repository at this point in the history
  • Loading branch information
mapcentia committed Apr 20, 2022
1 parent ec8b0c8 commit 1afd9f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 14 additions & 16 deletions extensions/conflictSearch/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ var dataItems = new L.FeatureGroup();
*/
var config = require('../../../config/config.js');

/**
*
* @type {string}
*/
var BACKEND = config.backend;

/**
*
*/
Expand Down Expand Up @@ -385,24 +379,28 @@ module.exports = module.exports = {
* Handle for GUI toggle button
*/
control: function () {
var me = this;

let me = this;
hitsTable = $("#hits-content tbody");
hitsData = $("#hits-data");
noHitsTable = $("#nohits-content tbody");
errorTable = $("#error-content tbody");
let c = 0;
backboneEvents.get().on("end:conflictSearch", ()=>{
c = 0;
})
// Start listen to the web socket
io.connect().on(socketId.get(), function (data) {
if (typeof data.num !== "undefined") {
$("#conflict-progress").html(data.num + " " + (data.title || data.table));
$("#conflict-progress").html(c++);
if (data.error === null) {
$("#conflict-console").append(data.num + " table: " + data.table + ", hits: " + data.hits + " , time: " + data.time + "\n");
$("#conflict-console").append("table: " + data.table + ", hits: " + data.hits + " , time: " + data.time + "\n");
} else {
$("#conflict-console").append(data.table + " : " + data.error + "\n");
}
}
});


backboneEvents.get().trigger("on:conflictInfoClick");

// Emit "on" event
Expand Down Expand Up @@ -815,7 +813,7 @@ module.exports = module.exports = {
},
handleResult: function (response) {
visibleLayers = cloud.getAllTypesOfVisibleLayers().split(";"); // Must be set here also, if result is coming from state
var hitsCount = 0, noHitsCount = 0, errorCount = 0, resultOrigin, groups = [];
let hitsCount = 0, noHitsCount = 0, errorCount = 0, resultOrigin, groups = [];
_result = response;
setTimeout(function () {
$("#snackbar-conflict").snackbar("hide");
Expand Down Expand Up @@ -871,19 +869,19 @@ module.exports = module.exports = {
hitsData.append(row);
let count = 0;
$.each(response.hits, function (i, v) {
var table = i, table1, table2, tr, td, title, metaData = v.meta;
let table = v.table, table1, table2, tr, td, title, metaData = v.meta;
if (metaData.layergroup === groups[u]) {
title = (typeof metaData.f_table_title !== "undefined" && metaData.f_table_title !== "" && metaData.f_table_title !== null) ? metaData.f_table_title : table;
if (v.error === null) {
if (metaData.meta_url) {
title = "<a target='_blank' href='" + metaData.meta_url + "'>" + title + "</a>";
}
row = "<tr><td>" + title + "</td><td>" + v.hits + "</td><td><div class='checkbox'><label><input type='checkbox' data-gc2-id='" + i + "' " + ($.inArray(i, visibleLayers) > -1 ? "checked" : "") + "></label></div></td></tr>";
row = "<tr><td>" + title + "</td><td>" + v.hits + "</td><td><div class='checkbox'><label><input type='checkbox' data-gc2-id='" + table + "' " + ($.inArray(i, visibleLayers) > -1 ? "checked" : "") + "></label></div></td></tr>";
if (v.hits > 0) {
count++;
hitsCount++;
table1 = $("<table class='table table-data'/>");
hitsData.append("<h5>" + title + " (" + v.hits + ")<div class='checkbox' style='float: right; margin-top: 25px'><label><input type='checkbox' data-gc2-id='" + i + "' " + ($.inArray(i, visibleLayers) > -1 ? "checked" : "") + "></label></div></h5>");
hitsData.append("<h5>" + title + " (" + v.hits + ")<div class='checkbox' style='float: right; margin-top: 25px'><label><input type='checkbox' data-gc2-id='" + table + "' " + ($.inArray(i, visibleLayers) > -1 ? "checked" : "") + "></label></div></h5>");
let conflictForLayer = metaData.meta !== null ? JSON.parse(metaData.meta) : null;
if (conflictForLayer !== null && 'short_conflict_meta_desc' in conflictForLayer) {
hitsData.append("<p style='margin: 0'>" + conflictForLayer.short_conflict_meta_desc + "</p>");
Expand All @@ -903,8 +901,8 @@ module.exports = module.exports = {
}
if (v.data.length > 0) {
$.each(v.data, function (u, row) {
var key = null, fid = null;
tr = $("<tr style='border-top: 0px solid #eee'/>");
let key = null, fid = null;
tr = $("<tr style='border-top: 0 solid #eee'/>");
td = $("<td/>");
table2 = $("<table style='margin-bottom: 5px; margin-top: 5px;' class='table'/>");
row.sort((a, b) => (a.sort_id > b.sort_id) ? 1 : ((b.sort_id > a.sort_id) ? -1 : 0));
Expand Down
2 changes: 1 addition & 1 deletion extensions/conflictSearch/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dayjs = require('dayjs');
const XLSX = require('xlsx');
const config = require('../../../config/config.js');
const {PromisePool} = require('@supercharge/promise-pool');
const POOL_SIZE = 20;
const POOL_SIZE = 30;
const utf8 = require('utf8');
// Set locale for date/time string
dayjs.locale("da_DK");
Expand Down

0 comments on commit 1afd9f1

Please sign in to comment.