From 2a1d609d6145f6fb70db939f6fea5223ae45f5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20S=C3=B8by?= Date: Wed, 29 Jun 2022 09:49:18 +0200 Subject: [PATCH 1/3] First commit. --- bitrepository-webclient/src/main/webapp/integrity-service.html | 1 + 1 file changed, 1 insertion(+) diff --git a/bitrepository-webclient/src/main/webapp/integrity-service.html b/bitrepository-webclient/src/main/webapp/integrity-service.html index 6d97edd61..3fcbd2943 100644 --- a/bitrepository-webclient/src/main/webapp/integrity-service.html +++ b/bitrepository-webclient/src/main/webapp/integrity-service.html @@ -172,6 +172,7 @@

Modal header

element = "#" + id + "-lastRun"; title = "Last run details"; } + if(element != null) { $(element).popover({placement : "right", title : title, From 0207f22e1f9bbbb7af27399d42749dc4524caab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20S=C3=B8by?= Date: Wed, 29 Jun 2022 10:42:48 +0200 Subject: [PATCH 2/3] Popovers now close when clicking on another or outside the popover itself. --- .../src/main/webapp/integrity-service.html | 103 ++++++++++-------- .../src/main/webapp/status-service.html | 1 + .../src/main/webapp/utils.js | 12 +- 3 files changed, 71 insertions(+), 45 deletions(-) diff --git a/bitrepository-webclient/src/main/webapp/integrity-service.html b/bitrepository-webclient/src/main/webapp/integrity-service.html index 3fcbd2943..c0e1dc62f 100644 --- a/bitrepository-webclient/src/main/webapp/integrity-service.html +++ b/bitrepository-webclient/src/main/webapp/integrity-service.html @@ -128,7 +128,7 @@

Modal header

function loadWorkflows() { var url = integrityServiceUrl + '/integrity/IntegrityService/getWorkflowList/?collectionID=' + getCollectionID(); - $.getJSON(url, {}, function(j) { + $.getJSON(url, {}, function (j) { for (var i = 0; i < j.length; i++) { $("#workflowSelector").append(''); } @@ -157,7 +157,7 @@

Modal header

function getStoredWorkflowInfo(id, type) { var myID = id; var myType = type; - return function() { + return function () { return nl2br(workflows[myID][myType]); } } @@ -165,33 +165,37 @@

Modal header

function attachWorkflowInfoButton(id, type) { var element; var title; - if(type == "workflowDescription") { + if (type == "workflowDescription") { element = "#" + id + "-details"; title = "Workflow description"; - } else if(type == "lastRunDetails") { + } else if (type == "lastRunDetails") { element = "#" + id + "-lastRun"; title = "Last run details"; } - if(element != null) { - $(element).popover({placement : "right", - title : title, - html : true, - content : getStoredWorkflowInfo(id, type)}); + if (element != null) { + $(element).popover({ + placement: "right", + title: title, + html: true, + content: getStoredWorkflowInfo(id, type) + }); } } function getWorkflowStatuses() { var url = integrityServiceUrl + '/integrity/IntegrityService/getWorkflowSetup/?collectionID=' + getCollectionID(); - $.getJSON(url, {}, function(j) { + $.getJSON(url, {}, function (j) { var htmlTableBody; for (var i = 0; i < j.length; i++) { - if(workflows[j[i].workflowID] == null) { + if (workflows[j[i].workflowID] == null) { $("#workflow-status-table-body").append( makeWorkflowRow(j[i].workflowID, j[i].nextRun, j[i].lastRun, j[i].executionInterval, j[i].currentState, j[i].lastRunFinishState)); - workflows[j[i].workflowID] = {workflowDescription : j[i].workflowDescription, - lastRunDetails : j[i].lastRunDetails}; + workflows[j[i].workflowID] = { + workflowDescription: j[i].workflowDescription, + lastRunDetails: j[i].lastRunDetails + }; attachWorkflowInfoButton(j[i].workflowID, "workflowDescription"); attachWorkflowInfoButton(j[i].workflowID, "lastRunDetails"); } else { @@ -207,7 +211,7 @@

Modal header

function getPagingLimit(id, member) { var myID = id; var myMember = member; - return function() { + return function () { return pillars[myID][myMember]; } } @@ -217,7 +221,7 @@

Modal header

var myUrl = url; var myID = id; var myMember = member; - return function() { + return function () { pager = new Pager(getPagingLimit(myID, myMember), 20, myUrl, "#modalPager", "#modalPagerBody"); $("#modalPagerLabel").html(myTitle); $("#modalPagerBody").html("

Loading

"); @@ -229,35 +233,35 @@

Modal header

function getCellContext(id, type) { var context = {}; context.url = integrityServiceUrl + "/integrity/IntegrityService/"; - if(type == "Pillar Hostname") { + if (type == "Pillar Hostname") { context.element = id + "-pillarHostname"; context.title = type + " on " + id; context.member = "pillarHostname"; - } else if(type == "Pillar Type") { + } else if (type == "Pillar Type") { context.element = id + "-pillarType"; context.title = type + " on " + id; context.member = "pillarType"; - } else if(type == "Total files") { + } else if (type == "Total files") { context.element = id + "-totalFileCount"; context.title = type + " on " + id; context.member = "totalFileCount"; context.url += "getAllFileIDs/"; - } else if(type == "Missing files") { + } else if (type == "Missing files") { context.element = id + "-missingFiles"; context.title = type + " on " + id; context.member = "missingFilesCount"; context.url += "getMissingFileIDs/"; - } else if(type == "Missing checksums") { + } else if (type == "Missing checksums") { context.element = id + "-missingChecksums"; context.title = type + " on " + id; context.member = "missingChecksumsCount"; context.url += "getMissingChecksumsFileIDs/"; - } else if(type == "Obsolete checksums") { + } else if (type == "Obsolete checksums") { context.element = id + "-obsoleteChecksums"; context.title = type + " on " + id; context.member = "obsoleteChecksumsCount"; context.url += "getObsoleteChecksumsFileIDs/"; - } else if(type == "Inconsistent checksums") { + } else if (type == "Inconsistent checksums") { context.element = id + "-checksumErrors"; context.title = type + " on " + id; context.member = "checksumErrorCount"; @@ -299,7 +303,7 @@

Modal header

function updateIntCell(id, type, cellValue) { var context = getCellContext(id, type); - if(cellValue == 0) { + if (cellValue == 0) { var html = ""; $("#" + context.element).html(html); } else { @@ -313,20 +317,21 @@

Modal header

function getIntegrityStatus() { var url = integrityServiceUrl + "/integrity/IntegrityService/getIntegrityStatus/?collectionID=" + getCollectionID(); - $.getJSON(url, {}, function(j){ + $.getJSON(url, {}, function (j) { var htmlTable; for (var i = 0; i < j.length; i++) { - if(pillars[j[i].pillarID] == null) { + if (pillars[j[i].pillarID] == null) { $("#integrity-status-table-body").append(makePillarRow(j[i].pillarID)); } pillars[j[i].pillarID] = { - pillarHostname : j[i].pillarHostname, - pillarType : j[i].pillarType, - totalFileCount : j[i].totalFileCount, - missingFilesCount : j[i].missingFilesCount, - missingChecksumsCount : j[i].missingChecksumsCount, - obsoleteChecksumsCount : j[i].obsoleteChecksumsCount, - checksumErrorCount : j[i].checksumErrorCount}; + pillarHostname: j[i].pillarHostname, + pillarType: j[i].pillarType, + totalFileCount: j[i].totalFileCount, + missingFilesCount: j[i].missingFilesCount, + missingChecksumsCount: j[i].missingChecksumsCount, + obsoleteChecksumsCount: j[i].obsoleteChecksumsCount, + checksumErrorCount: j[i].checksumErrorCount + }; updateCells(j[i].pillarID); } }); @@ -335,14 +340,16 @@

Modal header

function startWorkflow() { var ID = $("#workflowSelector option:selected").val(); var url = integrityServiceUrl + '/integrity/IntegrityService/startWorkflow/'; - $('#formStatus').load(url, {workflowID: ID, - collectionID: getCollectionID() }).show().fadeOut({duration: 5000}); + $('#formStatus').load(url, { + workflowID: ID, + collectionID: getCollectionID() + }).show().fadeOut({duration: 5000}); } function getCollectionInformation() { var url = integrityServiceUrl + "/integrity/IntegrityService/getCollectionInformation/?collectionID=" + getCollectionID(); - $.getJSON(url, {}, function(j) { + $.getJSON(url, {}, function (j) { var infoHtml = " Latest ingest: " + j.lastIngest + "     "; infoHtml += " Size: " + j.collectionSize + "     "; infoHtml += " Number of files: " + formatInt(j.numberOfFiles) + ""; @@ -367,13 +374,13 @@

Modal header

} function initializePage() { - $.get('repo/urlservice/integrityService/', {}, function(url) { + $.get('repo/urlservice/integrityService/', {}, function (url) { integrityServiceUrl = url; - }, 'html').done(function() { - $.getJSON('repo/reposervice/getCollections/', {}, function(collections) { + }, 'html').done(function () { + $.getJSON('repo/reposervice/getCollections/', {}, function (collections) { nameMapper = new CollectionNameMapper(collections); var colls = nameMapper.getCollectionIDs(); - for(i in colls) { + for (i in colls) { $("#collectionChooser").append(''); } collectionChanged(); @@ -384,7 +391,7 @@

Modal header

function collectionChanged() { clearContent(); $("#integrityLegend").html("Integrity information for collection " + nameMapper.getName(getCollectionID())); - reportUrl = integrityServiceUrl + "/integrity/IntegrityService/getLatestIntegrityReport/"; + reportUrl = integrityServiceUrl + "/integrity/IntegrityService/getLatestIntegrityReport/"; reportUrl += "?collectionID=" + getCollectionID(); reportUrl += "&workflowID=" + "CompleteIntegrityCheck"; $("#integrityReportGetter").html("Get latest integrity report"); @@ -393,21 +400,29 @@

Modal header

getCollectionInformation(); getWorkflowStatuses(); getIntegrityStatus(); - update_page = setInterval(function() { + update_page = setInterval(function () { getWorkflowStatuses(); getIntegrityStatus(); getCollectionInformation(); }, 2500); } - $(document).ready(function(){ + $(document).ready(function () { // Load page content makeMenu("integrity-service.html", "#pageMenu"); initializePage(); // Setup event / click handling - $("#workflowStarter").click(function(event) { event.preventDefault(); startWorkflow(); }); - $("#collectionChooser").change(function(event) {event.preventDefault(); collectionChanged();}); + $("#workflowStarter").click(function (event) { + event.preventDefault(); + startWorkflow(); + }); + $("#collectionChooser").change(function (event) { + event.preventDefault(); + collectionChanged(); + }); + + closePopoverOnClick(); }); diff --git a/bitrepository-webclient/src/main/webapp/status-service.html b/bitrepository-webclient/src/main/webapp/status-service.html index b9e0e15da..c26b7d3b5 100644 --- a/bitrepository-webclient/src/main/webapp/status-service.html +++ b/bitrepository-webclient/src/main/webapp/status-service.html @@ -172,6 +172,7 @@ $(document).ready(function(){ makeMenu("status-service.html", "#pageMenu"); initPage(); + closePopoverOnClick(); }); diff --git a/bitrepository-webclient/src/main/webapp/utils.js b/bitrepository-webclient/src/main/webapp/utils.js index 7849205fc..2c63a6e4e 100644 --- a/bitrepository-webclient/src/main/webapp/utils.js +++ b/bitrepository-webclient/src/main/webapp/utils.js @@ -22,5 +22,15 @@ function nl2br(line) { - return line.replace(/\n/g, '
'); + return line.replace(/\n/g, '
'); } + +function closePopoverOnClick() { + $("html").on("mouseup", function (e) { + if (!$(e.target).closest(".popover").length) { + $(".popover").each(function () { + $(this.previousSibling).popover("hide"); + }); + } + }); +} \ No newline at end of file From cffb651b4e1e2ddc11d557752d8ff309de77a062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20S=C3=B8by?= Date: Wed, 29 Jun 2022 12:58:29 +0200 Subject: [PATCH 3/3] Dashboard collection name now links to its integrity url. --- .../dashboard_components/collectionStatus.js | 12 +++---- .../src/main/webapp/integrity-service.html | 33 ++++++++++++------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/bitrepository-webclient/src/main/webapp/dashboard_components/collectionStatus.js b/bitrepository-webclient/src/main/webapp/dashboard_components/collectionStatus.js index ed2de73ae..4a7a06940 100644 --- a/bitrepository-webclient/src/main/webapp/dashboard_components/collectionStatus.js +++ b/bitrepository-webclient/src/main/webapp/dashboard_components/collectionStatus.js @@ -19,7 +19,7 @@ for(var i = 0; i < collectionIDs.length; i++) { collections[collectionIDs[i].collectionID] = {collectionID: collectionIDs[i].collectionID, collectionName: collectionIDs[i].collectionName, - numFiles: '-', + numFiles: '-', latestIngest: "Fetching", collectionSize: '-', pillars: '-', @@ -72,7 +72,7 @@ } } - function updateCollectionStatistic(collection) { + function updateCollectionStatistic(collection) { if(scheduleUpdate(collection, "stats")) { url = integrityServiceUrl + "/integrity/IntegrityService/getIntegrityStatus/?collectionID=" + collection; var c = collection; @@ -88,7 +88,7 @@ collections[c].pillars = pillarCount; collections[c].numChecksumErrors = checksumErrors; collections[c].numMissingFiles = missingFiles; - }).done(function(){updateCollectionRow(collections[c])}).always(function() {finishUpdate(c, "stats");}); + }).done(function(){updateCollectionRow(collections[c])}).always(function() {finishUpdate(c, "stats");}); } } @@ -100,7 +100,7 @@ } } - function makeCollectionRow(collection) { + function makeCollectionRow(collection) { var id = collection.collectionID; var html = ""; html += ""; @@ -118,7 +118,7 @@ function updateCollectionRow(collection) { var id = collection.collectionID; - $("#" + id + "-name").html(collection.collectionName); + $("#" + id + "-name").html(`${collection.collectionName}`); $("#" + id + "-numFiles").html(numeral(collection.numFiles).format('0,0')); $("#" + id + "-latestIngest").html(collection.latestIngest); $("#" + id + "-collectionSize").html(collection.collectionSize); @@ -153,7 +153,7 @@ return false; } } - + function finishUpdate(collection, type) { return updateLock[collection][type] = true; } diff --git a/bitrepository-webclient/src/main/webapp/integrity-service.html b/bitrepository-webclient/src/main/webapp/integrity-service.html index c0e1dc62f..35f3dc21e 100644 --- a/bitrepository-webclient/src/main/webapp/integrity-service.html +++ b/bitrepository-webclient/src/main/webapp/integrity-service.html @@ -347,8 +347,8 @@

Modal header

} - function getCollectionInformation() { - var url = integrityServiceUrl + "/integrity/IntegrityService/getCollectionInformation/?collectionID=" + getCollectionID(); + function getCollectionInformation(collectionID) { + var url = integrityServiceUrl + "/integrity/IntegrityService/getCollectionInformation/?collectionID=" + collectionID; $.getJSON(url, {}, function (j) { var infoHtml = " Latest ingest: " + j.lastIngest + "     "; infoHtml += " Size: " + j.collectionSize + "     "; @@ -379,34 +379,43 @@

Modal header

}, 'html').done(function () { $.getJSON('repo/reposervice/getCollections/', {}, function (collections) { nameMapper = new CollectionNameMapper(collections); - var colls = nameMapper.getCollectionIDs(); - for (i in colls) { - $("#collectionChooser").append(''); + let cols = nameMapper.getCollectionIDs(); + for (let i in cols) { + $("#collectionChooser").append(''); + } + let collectionID = new URLSearchParams(window.location.search).get("collectionID"); + if (collectionID !== null && cols.includes(collectionID)) { + setCollection(collectionID); + } else { + collectionChanged(getCollectionID()); } - collectionChanged(); }); }); } - function collectionChanged() { + function collectionChanged(collectionID) { clearContent(); - $("#integrityLegend").html("Integrity information for collection " + nameMapper.getName(getCollectionID())); + $("#integrityLegend").html("Integrity information for collection " + nameMapper.getName(collectionID)); reportUrl = integrityServiceUrl + "/integrity/IntegrityService/getLatestIntegrityReport/"; - reportUrl += "?collectionID=" + getCollectionID(); + reportUrl += "?collectionID=" + collectionID; reportUrl += "&workflowID=" + "CompleteIntegrityCheck"; $("#integrityReportGetter").html("Get latest integrity report"); clearInterval(update_page); loadWorkflows(); - getCollectionInformation(); + getCollectionInformation(collectionID); getWorkflowStatuses(); getIntegrityStatus(); update_page = setInterval(function () { getWorkflowStatuses(); getIntegrityStatus(); - getCollectionInformation(); + getCollectionInformation(collectionID); }, 2500); } + function setCollection(collectionID) { + $("#collectionChooser").val(collectionID).change(); + } + $(document).ready(function () { // Load page content makeMenu("integrity-service.html", "#pageMenu"); @@ -419,7 +428,7 @@

Modal header

}); $("#collectionChooser").change(function (event) { event.preventDefault(); - collectionChanged(); + collectionChanged(getCollectionID()); }); closePopoverOnClick();