Skip to content

Commit

Permalink
NIFI-13743: Ensuring the mime type is set when navigating to the cont…
Browse files Browse the repository at this point in the history
…ent viewer from Provenance. (apache#9262)

- Adding a trailing slash when loading the external viewer to eliminate an unneeded redirection.

This closes apache#9262
  • Loading branch information
mcgilman authored Sep 12, 2024
1 parent 6e5a276 commit 6e308f2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ExternalViewer implements OnDestroy {
queryParams = queryParams.set('clientId', this.request.clientId);
}

const urlWithParams = `${this.request.url}?${queryParams.toString()}`;
const urlWithParams = `${this.request.url}/?${queryParams.toString()}`;

const sanitizedUrl = this.domSanitizer.sanitize(SecurityContext.URL, urlWithParams);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3673,7 +3673,9 @@ export class FlowEffects {
switchMap((versionControlInfo: VersionControlInformationEntity) => {
const vci = versionControlInfo.versionControlInformation;
if (vci) {
return from(this.registryService.getFlowVersions(vci.registryId, vci.bucketId, vci.flowId, vci.branch)).pipe(
return from(
this.registryService.getFlowVersions(vci.registryId, vci.bucketId, vci.flowId, vci.branch)
).pipe(
map((versions) =>
FlowActions.openChangeVersionDialog({
request: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export class ProvenanceService {
contentViewerUrl: string,
eventId: number,
direction: string,
clusterNodeId?: string
clusterNodeId?: string,
mimeType?: string
): void {
// build the uri to the data
let dataUri = `${nifiUrl}provenance-events/${encodeURIComponent(eventId)}/content/${encodeURIComponent(
Expand Down Expand Up @@ -126,6 +127,10 @@ export class ProvenanceService {
clientId: this.client.getClientId()
};

if (mimeType) {
contentViewerParameters['mimeType'] = mimeType;
}

// open the content viewer
const contentViewerQuery: string = new URLSearchParams(contentViewerParameters).toString();
window.open(`${contentViewer}${contentViewerQuery}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { isDefinedAndNotNull, NiFiCommon } from 'libs/shared/src';
import { selectClusterSummary } from '../../../../state/cluster-summary/cluster-summary.selectors';
import { ClusterService } from '../../../../service/cluster.service';
import { LARGE_DIALOG, MEDIUM_DIALOG } from 'libs/shared/src';
import { Attribute } from '../../../../state/shared';

@Injectable()
export class ProvenanceEventListingEffects {
Expand Down Expand Up @@ -358,12 +359,30 @@ export class ProvenanceEventListingEffects {
dialogReference.componentInstance.viewContent
.pipe(takeUntil(dialogReference.afterClosed()))
.subscribe((direction: string) => {
let mimeType: string | undefined;

if (response.provenanceEvent.attributes) {
const mimeTypeAttribute: Attribute | undefined =
response.provenanceEvent.attributes.find(
(attribute: Attribute) => attribute.name === 'mime.type'
);

if (mimeTypeAttribute) {
if (direction === 'input') {
mimeType = mimeTypeAttribute.previousValue;
} else if (direction === 'output') {
mimeType = mimeTypeAttribute.value;
}
}
}

this.provenanceService.viewContent(
about.uri,
about.contentViewerUrl,
request.eventId,
direction,
request.clusterNodeId
request.clusterNodeId,
mimeType
);
});
}
Expand Down

0 comments on commit 6e308f2

Please sign in to comment.