Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: '-',
Expand Down Expand Up @@ -72,7 +72,7 @@
}
}

function updateCollectionStatistic(collection) {
function updateCollectionStatistic(collection) {
if(scheduleUpdate(collection, "stats")) {
url = integrityServiceUrl + "/integrity/IntegrityService/getIntegrityStatus/?collectionID=" + collection;
var c = collection;
Expand All @@ -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");});
}
}

Expand All @@ -100,7 +100,7 @@
}
}

function makeCollectionRow(collection) {
function makeCollectionRow(collection) {
var id = collection.collectionID;
var html = "";
html += "<tr id=\"" + id + "-row\">";
Expand All @@ -118,7 +118,7 @@

function updateCollectionRow(collection) {
var id = collection.collectionID;
$("#" + id + "-name").html(collection.collectionName);
$("#" + id + "-name").html(`<a href='integrity-service.html?collectionID=${collection.collectionID}'>${collection.collectionName}</a>`);
$("#" + id + "-numFiles").html(numeral(collection.numFiles).format('0,0'));
$("#" + id + "-latestIngest").html(collection.latestIngest);
$("#" + id + "-collectionSize").html(collection.collectionSize);
Expand Down Expand Up @@ -153,7 +153,7 @@
return false;
}
}

function finishUpdate(collection, type) {
return updateLock[collection][type] = true;
}
Expand Down
133 changes: 79 additions & 54 deletions bitrepository-webclient/src/main/webapp/integrity-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h3 id="modalPagerLabel">Modal header</h3>

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('<option value="' + j[i] + '">' + j[i] + '</option>');
}
Expand Down Expand Up @@ -157,40 +157,45 @@ <h3 id="modalPagerLabel">Modal header</h3>
function getStoredWorkflowInfo(id, type) {
var myID = id;
var myType = type;
return function() {
return function () {
return nl2br(workflows[myID][myType]);
}
}

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 {
Expand All @@ -206,7 +211,7 @@ <h3 id="modalPagerLabel">Modal header</h3>
function getPagingLimit(id, member) {
var myID = id;
var myMember = member;
return function() {
return function () {
return pillars[myID][myMember];
}
}
Expand All @@ -216,7 +221,7 @@ <h3 id="modalPagerLabel">Modal header</h3>
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("<p>Loading</p>");
Expand All @@ -228,35 +233,35 @@ <h3 id="modalPagerLabel">Modal header</h3>
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";
Expand Down Expand Up @@ -298,7 +303,7 @@ <h3 id="modalPagerLabel">Modal header</h3>

function updateIntCell(id, type, cellValue) {
var context = getCellContext(id, type);
if(cellValue == 0) {
if (cellValue == 0) {
var html = "<button class=\"btn btn-link\" disabled>" + formatInt(cellValue) + "</button>";
$("#" + context.element).html(html);
} else {
Expand All @@ -312,20 +317,21 @@ <h3 id="modalPagerLabel">Modal header</h3>
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);
}
});
Expand All @@ -334,14 +340,16 @@ <h3 id="modalPagerLabel">Modal header</h3>
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) {
function getCollectionInformation(collectionID) {
var url = integrityServiceUrl + "/integrity/IntegrityService/getCollectionInformation/?collectionID=" + collectionID;
$.getJSON(url, {}, function (j) {
var infoHtml = "<span><b> Latest ingest: " + j.lastIngest + " &nbsp; &nbsp; ";
infoHtml += " Size: " + j.collectionSize + " &nbsp; &nbsp; ";
infoHtml += " Number of files: " + formatInt(j.numberOfFiles) + "</b></span>";
Expand All @@ -366,47 +374,64 @@ <h3 id="modalPagerLabel">Modal header</h3>
}

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) {
$("#collectionChooser").append('<option value="' + colls[i] + '">' + nameMapper.getName(colls[i]) + '</option>');
let cols = nameMapper.getCollectionIDs();
for (let i in cols) {
$("#collectionChooser").append('<option value="' + cols[i] + '">' + nameMapper.getName(cols[i]) + '</option>');
}
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()));
reportUrl = integrityServiceUrl + "/integrity/IntegrityService/getLatestIntegrityReport/";
reportUrl += "?collectionID=" + getCollectionID();
$("#integrityLegend").html("Integrity information for collection " + nameMapper.getName(collectionID));
reportUrl = integrityServiceUrl + "/integrity/IntegrityService/getLatestIntegrityReport/";
reportUrl += "?collectionID=" + collectionID;
reportUrl += "&workflowID=" + "CompleteIntegrityCheck";
$("#integrityReportGetter").html("<a class=\"btn btn-link\" href=\"" + reportUrl + "\" target=\"_blank\">Get latest integrity report</a>");
clearInterval(update_page);
loadWorkflows();
getCollectionInformation();
getCollectionInformation(collectionID);
getWorkflowStatuses();
getIntegrityStatus();
update_page = setInterval(function() {
update_page = setInterval(function () {
getWorkflowStatuses();
getIntegrityStatus();
getCollectionInformation();
getCollectionInformation(collectionID);
}, 2500);
}

$(document).ready(function(){
function setCollection(collectionID) {
$("#collectionChooser").val(collectionID).change();
}

$(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(getCollectionID());
});

closePopoverOnClick();
});

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
$(document).ready(function(){
makeMenu("status-service.html", "#pageMenu");
initPage();
closePopoverOnClick();
});

</script>
Expand Down
12 changes: 11 additions & 1 deletion bitrepository-webclient/src/main/webapp/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@


function nl2br(line) {
return line.replace(/\n/g, '<br />');
return line.replace(/\n/g, '<br />');
}

function closePopoverOnClick() {
$("html").on("mouseup", function (e) {
if (!$(e.target).closest(".popover").length) {
$(".popover").each(function () {
$(this.previousSibling).popover("hide");
});
}
});
}