Skip to content

Commit

Permalink
GUI: add button to copy direct link to validation
Browse files Browse the repository at this point in the history
Fixes #296
  • Loading branch information
qligier authored and oliveregger committed Oct 16, 2024
1 parent 013cdf0 commit e8024a2
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 79 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Unreleased
- Upgrade hapifhir org.hl7.fhir.core to 6.3.32
- FML: Use FMLParser in StructureMapUtilities and support for identity transform [#289](https://github.com/ahdis/matchbox/issues/289)
- FML: FML transform performance tuning #264 (via @mrunibe)
- Validation: add button to copy a direct link to the validation [#296](https://github.com/ahdis/matchbox/issues/296)

2024/10/07 Release 3.9.3

Expand Down
6 changes: 5 additions & 1 deletion matchbox-frontend/src/app/validate/validate.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ <h2>Validation history</h2>
</ng-container>
</td>
<td class="actions mat-cell">
<mat-icon (click)="removeEntryFromHistory(entry)" aria-label="Remove" title="Remove from history">delete</mat-icon>
<mat-icon (click)="removeEntryFromHistory(entry)" aria-label="Remove" title="Remove from history" class="delete">delete</mat-icon>
<a [href]="getDirectLink(entry)" (click)="copyDirectLink($event, entry)" target="_blank" title="Copy a direct link to this validation">
<mat-icon aria-label="Copy" class="copy">content_copy</mat-icon>
</a>

</td>
</tr>
</table>
Expand Down
8 changes: 7 additions & 1 deletion matchbox-frontend/src/app/validate/validate.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ table {
td.actions {
mat-icon {
font-size: 24px;
color: $issue-error;
&.delete {
color: $issue-error;
margin-right: .2em;
}
&.copy {
color: #4ab183;
}
}
}
}
Expand Down
58 changes: 47 additions & 11 deletions matchbox-frontend/src/app/validate/validate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import untar from 'js-untar';
import { IDroppedBlob } from '../upload/upload.component';
import ace from 'ace-builds';
import { ValidationEntry } from './validation-entry';
import { ValidationParameter } from './validation-parameter';
import {ValidationParameter, ValidationParameterDefinition} from './validation-parameter';
import { ITarEntry } from './tar-entry';
import { Issue, OperationResult } from '../util/operation-result';
import { FormControl, Validators } from '@angular/forms';
Expand Down Expand Up @@ -34,7 +34,7 @@ export class ValidateComponent implements AfterViewInit {
capabilityStatement: fhir.r4.CapabilityStatement | null = null;
installedIgs: Set<string> = new Set<string>();
supportedProfiles: Map<string, StructureDefinition> = new Map<string, StructureDefinition>();
validatorSettings: Map<string, ValidationParameter> = new Map<string, ValidationParameter>();
validatorSettings: Map<string, ValidationParameterDefinition> = new Map<string, ValidationParameterDefinition>();

// The input form
filteredProfiles: Set<StructureDefinition> = new Set<StructureDefinition>();
Expand Down Expand Up @@ -140,7 +140,7 @@ export class ValidateComponent implements AfterViewInit {
let entry: ValidationEntry;
try {
// Try to parse the resource to extract information
entry = new ValidationEntry(filename, content, contentType, null);
entry = new ValidationEntry(filename, content, contentType, null, this.getCurrentValidationSettings());
this.currentResource = new UploadedFile(
filename,
contentType,
Expand Down Expand Up @@ -230,7 +230,7 @@ export class ValidateComponent implements AfterViewInit {
let res = JSON.parse(decoder.decode(extractedFile.buffer)) as fhir.r4.Resource;
let profiles = res.meta?.profile;
// maybe better add ig as a parmeter, we assume now that ig version is equal to canonical version
let entry = new ValidationEntry(name, JSON.stringify(res, null, 2), 'application/fhir+json', profiles);
let entry = new ValidationEntry(name, JSON.stringify(res, null, 2), 'application/fhir+json', profiles, this.getCurrentValidationSettings());
dataSource.push(entry);
}
}
Expand Down Expand Up @@ -282,10 +282,8 @@ export class ValidateComponent implements AfterViewInit {
}

// Validation options
for (const [_, setting] of this.validatorSettings) {
if (setting.formControl.value != null && setting.formControl.value.length > 0) {
searchParams.set(setting.param.name, setting.formControl.value);
}
for (const param of entry.validationParameters) {
searchParams.set(param.name, param.value);
}
entry.loading = true;
this.client
Expand Down Expand Up @@ -353,7 +351,8 @@ export class ValidateComponent implements AfterViewInit {
this.currentResource.filename,
this.currentResource.content,
this.currentResource.contentType,
[this.selectedProfile]
[this.selectedProfile],
this.getCurrentValidationSettings()
);
if (this.selectedIg != this.AUTO_IG_SELECTION) {
entry.ig = this.selectedIg;
Expand All @@ -376,7 +375,7 @@ export class ValidateComponent implements AfterViewInit {
*/
scrollToIssueLocation(issue: Issue): void {
if (issue.line && this.editorContent == CodeEditorContent.RESOURCE_CONTENT) {
// Scroll to the clicked issue, but only if the issue has a location and the resource is shown in the code editor
// Scroll to the clicked issue, but only if the issue has a location and the resource is shown in the code editor
// (scrolling in the OperationOutcome would be nonsense).
this.editor.scrollToIssueLocation(issue);
}
Expand All @@ -399,6 +398,33 @@ export class ValidateComponent implements AfterViewInit {
);
}

getDirectLink(entry: ValidationEntry): string {
const url = new URL(document.location.href);
url.searchParams.forEach((name: string) => {
url.searchParams.delete(name);
});

url.searchParams.set('resource', btoa(entry.resource));
url.searchParams.set('profile', entry.selectedProfile);
if (entry.ig) {
url.searchParams.set('ig', entry.ig);
}

for (const param of entry.validationParameters) {
url.searchParams.set(param.name, param.value);
}

return url.toString();
}

copyDirectLink(event: MouseEvent,entry: ValidationEntry) {
if ('clipboard' in navigator) {
event.preventDefault();
const url = this.getDirectLink(entry);
navigator.clipboard.writeText(url).then(() => {});
}
}

getExtensionStringValue(element: fhir.r4.Element, url: string): string {
return this.getExtension(element, url)?.valueString ?? '';
}
Expand All @@ -424,6 +450,16 @@ export class ValidateComponent implements AfterViewInit {
this.editor.updateCodeEditorContent(this.selectedEntry, this.editorContent);
}

private getCurrentValidationSettings(): ValidationParameter[] {
const parameters: ValidationParameter[] = [];
for (const [_, setting] of this.validatorSettings) {
if (setting.formControl.value != null && setting.formControl.value.length > 0) {
parameters.push(new ValidationParameter(setting.param.name, setting.formControl.value));
}
}
return parameters;
}

/**
* Show an error toast message.
* @param title the toast title.
Expand Down Expand Up @@ -467,7 +503,7 @@ export class ValidateComponent implements AfterViewInit {
od.parameter
.filter((f) => f.use == 'in' && f.name != 'resource' && f.name != 'profile' && f.name != 'ig')
.forEach((parameter: fhir.r4.OperationDefinitionParameter) => {
this.validatorSettings.set(parameter.name, new ValidationParameter(parameter));
this.validatorSettings.set(parameter.name, new ValidationParameterDefinition(parameter));
});
}

Expand Down
15 changes: 9 additions & 6 deletions matchbox-frontend/src/app/validate/validation-entry.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { IssueSeverity, OperationResult } from '../util/operation-result';
import {ValidationParameter, ValidationParameterDefinition} from "./validation-parameter";

export class ValidationEntry {
filename: string; // "package/package.json",
resource: string;
readonly filename: string; // "package/package.json",
readonly resource: string;
resourceType: string;
resourceId: string;
mimetype: string;
readonly mimetype: string;
result: OperationResult | undefined;
profiles: string[] = [];
readonly profiles: string[] = [];
selectedProfile: string;
ig?: string;
date: Date;
readonly date: Date;
readonly validationParameters: ValidationParameter[] = [];
public loading: boolean = false;

constructor(filename: string, resource: string, mimetype: string | null, profiles: string[] | null) {
constructor(filename: string, resource: string, mimetype: string | null, profiles: string[] | null, settings: ValidationParameter[] = []) {
this.filename = filename;
this.resource = resource;
this.validationParameters = settings;

if (mimetype) {
this.mimetype = mimetype;
Expand Down
7 changes: 6 additions & 1 deletion matchbox-frontend/src/app/validate/validation-parameter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {UntypedFormControl} from "@angular/forms";

export class ValidationParameter {
export class ValidationParameterDefinition {
param: fhir.r4.OperationDefinitionParameter;
formControl: UntypedFormControl;

Expand All @@ -9,3 +9,8 @@ export class ValidationParameter {
this.formControl = new UntypedFormControl();
}
}

export class ValidationParameter {
constructor(readonly name: string, readonly value: string) {
}
}
1 change: 1 addition & 0 deletions matchbox-server/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spring:
server:
servlet:
context-path: /matchboxv3
max-http-request-header-size: 40KB
management:
endpoint:
health:
Expand Down
36 changes: 18 additions & 18 deletions matchbox-server/src/main/resources/static/3rdpartylicenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,13 @@ SOFTWARE.
Package: angular-oauth2-oidc
License: "MIT"

Copyright (c) 2017 Manfred Steyer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2017 Manfred Steyer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------
Package: @angular/platform-browser
Expand Down Expand Up @@ -1003,17 +1003,17 @@ License: "Apache-2.0"
Package: tslib
License: "0BSD"

Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
Package: @angular/common
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
import{Ic as a,Jc as b}from"./chunk-PO3V6XUW.js";import"./chunk-TSRGIXR5.js";export{b as HighlightLineNumbers,a as activateLineNumbers};
import{Jc as a,Kc as b}from"./chunk-I546T47D.js";import"./chunk-TSRGIXR5.js";export{b as HighlightLineNumbers,a as activateLineNumbers};

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit e8024a2

Please sign in to comment.