NIFI-13743: Ensuring the mime type is set when navigating to the content viewer from Provenance. (#9262)

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

This closes #9262
This commit is contained in:
Matt Gilman 2024-09-12 16:41:49 -04:00 committed by GitHub
parent 6e5a276cb2
commit 6e308f2cf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 4 deletions

View File

@ -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);

View File

@ -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: {

View File

@ -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(
@ -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}`);

View File

@ -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 {
@ -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
);
});
}