Adding 'Download' and 'View' content buttons to List Queue
Adding 'Download' and 'View' content icon buttons to slick grid actions column to improve end user navigation.
});
}
- // add an actions column when the user can access provenance
+ // 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()){
- // function for formatting actions
- var actionsFormatter = function () {
- return '<div title="Provenance" class="pointer icon icon-provenance view-provenance"></div>';
+ 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: 50,
- maxWidth: 50
+ width: 75,
+ maxWidth: 75
});
- }
+
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) {
}
// 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;
}
/**
* 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) {
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;
}
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);
}
}
});
