NIFI-6221 Adding 'Download' and 'View' content buttons to List Queue (#3440)

NIFI-6221 Adding 'Download' and 'View' content icon buttons to slick grid actions column to improve end user navigation.
This commit is contained in:
aeaversa 2019-04-19 18:25:15 -04:00 committed by Peter Wicks
parent cd2c3fd4e6
commit 512555dbb0
1 changed files with 45 additions and 22 deletions

View File

@ -204,32 +204,48 @@
});
}
// add an actions column when the user can access provenance
if (nfCommon.canAccessProvenance()) {
// function for formatting actions
var actionsFormatter = function () {
return '<div title="Provenance" class="pointer icon icon-provenance view-provenance"></div>';
};
// function for formatting actions column
var actionsFormatter = function (row,cell,value,columnDef,dataContext) {
var formatted = '';
var disabled = (dataContext.size > 0)?false:true;
formatted += '<div class="icon download-flowfile-content fa fa-download '+((disabled)?'disabled':'pointer')+'"'+
' title="'+((disabled)?'No content available to download':'Download content')+'" aria-hidden="true"></div>';
if(nfCommon.isContentViewConfigured()){
formatted += '<div class="icon view-flowfile-content fa fa-eye '+((disabled)?'disabled':'pointer')+'"'+
' title="'+((disabled)?'No content available to view':'View content')+'" aria-hidden="true"></div>';
}
if(nfCommon.canAccessProvenance()){
formatted += '<div title="Provenance" class="pointer icon icon-provenance view-provenance" aria-hidden="true"></div>';
}
return formatted;
};
// add an actions column to the column model
queueListingColumns.push({
id: 'actions',
name: '&nbsp;',
resizable: false,
formatter: actionsFormatter,
sortable: false,
width: 75,
maxWidth: 75
});
queueListingColumns.push({
id: 'actions',
name: '&nbsp;',
resizable: false,
formatter: actionsFormatter,
sortable: false,
width: 50,
maxWidth: 50
});
}
return queueListingColumns;
};
/**
* Downloads the content for the flowfile currently being viewed.
*
* @param flowFileSummary|{flowfile} (optional) - the flowfile summary
*/
var downloadContent = function () {
var dataUri = $('#flowfile-uri').text() + '/content';
var downloadContent = function (flowFileSummary) {
var dataUri = ((nfCommon.isDefinedAndNotNull(flowFileSummary.uri))?flowFileSummary.uri:$('#flowfile-uri').text())+ '/content';
// perform the request once we've received a token
nfCommon.getAccessToken(config.urls.downloadToken).done(function (downloadToken) {
@ -241,7 +257,7 @@
}
// conditionally include the cluster node id
var clusterNodeId = $('#flowfile-cluster-node-id').text();
var clusterNodeId = (nfCommon.isDefinedAndNotNull(flowFileSummary.clusterNodeId))?flowFileSummary.clusterNodeId:$('#flowfile-cluster-node-id').text();
if (!nfCommon.isBlank(clusterNodeId)) {
parameters['clusterNodeId'] = clusterNodeId;
}
@ -262,9 +278,12 @@
/**
* Views the content for the flowfile currently being viewed.
*
* @param flowFileSummary|{flowfile} (optional) - the flowfile summary
*/
var viewContent = function () {
var dataUri = $('#flowfile-uri').text() + '/content';
var viewContent = function (flowFileSummary) {
var dataUri = ((nfCommon.isDefinedAndNotNull(flowFileSummary.uri))?flowFileSummary.uri:$('#flowfile-uri').text())+ '/content';
// generate tokens as necessary
var getAccessTokens = $.Deferred(function (deferred) {
@ -301,7 +320,7 @@
var dataUriParameters = {};
// conditionally include the cluster node id
var clusterNodeId = $('#flowfile-cluster-node-id').text();
var clusterNodeId = (nfCommon.isDefinedAndNotNull(flowFileSummary.clusterNodeId))?flowFileSummary.clusterNodeId:$('#flowfile-cluster-node-id').text();
if (!nfCommon.isBlank(clusterNodeId)) {
dataUriParameters['clusterNodeId'] = clusterNodeId;
}
@ -675,6 +694,10 @@
nfShell.showPage('provenance?' + $.param({
flowFileUuid: item.uuid
}));
} else if (target.hasClass('download-flowfile-content') && !target.hasClass('disabled')) {
downloadContent(item);
} else if (target.hasClass('view-flowfile-content') && !target.hasClass('disabled')) {
viewContent(item);
}
}
});