Skip to content

Commit

Permalink
Inject the GUI version in the server
Browse files Browse the repository at this point in the history
Fixes #346
  • Loading branch information
qligier committed Feb 5, 2025
1 parent 9f84ae6 commit 9b013cb
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 61 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/angular_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- main
paths:
- "matchbox-frontend/**"
- "pom.xml" # Since we use the Maven version, also trigger the workflow when the version changes

jobs:
build-angular-and-commit:
Expand All @@ -31,27 +30,6 @@ jobs:
cache: npm
cache-dependency-path: matchbox-frontend/package-lock.json

- name: Setup Java
uses: actions/setup-java@v4
# https://github.com/actions/setup-java#usage
with:
java-version: 21
distribution: adopt

- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9

- name: Update the GUI version from the Maven project version
shell: bash
run: |
cd ..
VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
echo "The Maven project version is ${VERSION}"
cd ./matchbox-frontend
npm --no-git-tag-version --allow-same-version=true version "$VERSION"
- name: Install dependencies
# Use dependencies from the lock file, no unattended updates
run: npm ci
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased

- No more GUI version mismatch [#346](https://github.com/ahdis/matchbox/issues/346)

2025/02/05 Release 3.9.12

- Update org.hl7.fhir.core to 6.5.7
Expand Down
3 changes: 1 addition & 2 deletions matchbox-frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component } from '@angular/core';
import { FhirConfigService } from './fhirConfig.service';
import { TranslateService } from '@ngx-translate/core';
import packageJson from '../../package.json';
import {HashUrlRedirectionService} from "./util/hash-url-redirection-service";

@Component({
Expand All @@ -11,7 +10,7 @@ import {HashUrlRedirectionService} from "./util/hash-url-redirection-service";
standalone: false
})
export class AppComponent {
public version: string = packageJson.version;
public version: string = (window as any).MATCHBOX_VERSION;

constructor(readonly translateService: TranslateService,
readonly fhirConfigService: FhirConfigService,
Expand Down
3 changes: 1 addition & 2 deletions matchbox-frontend/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component } from '@angular/core';
import packageJson from '../../../package.json';

@Component({
selector: 'app-home',
Expand All @@ -8,5 +7,5 @@ import packageJson from '../../../package.json';
standalone: false
})
export class HomeComponent {
public version: string = packageJson.version;
public version: string = (window as any).MATCHBOX_VERSION;
}
3 changes: 1 addition & 2 deletions matchbox-frontend/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component } from '@angular/core';
import packageJson from '../../../package.json';

@Component({
selector: 'app-settings',
Expand All @@ -8,5 +7,5 @@ import packageJson from '../../../package.json';
standalone: false
})
export class SettingsComponent {
public version: string = packageJson.version;
public version: string = (window as any).MATCHBOX_VERSION;
}
3 changes: 2 additions & 1 deletion matchbox-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<meta charset="utf-8" />
<title>matchbox</title>
<script>
// The server will update this variable when it serves this file (see MatchboxStaticResourceConfig)
// The server will update these variables when it serves this file (see MatchboxStaticResourceConfig)
window.MATCHBOX_BASE_PATH = "/";
window.MATCHBOX_VERSION = "served-by-ng";
</script>

<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
1 change: 0 additions & 1 deletion matchbox-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"baseUrl": ".",
"module": "ES2022",
"esModuleInterop": true,
"resolveJsonModule": true,
"paths": {
"*": [
"node_modules/*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ch.ahdis.matchbox.config;

import ch.ahdis.matchbox.engine.cli.VersionUtil;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
Expand Down Expand Up @@ -97,8 +97,11 @@ public Resource transform(final HttpServletRequest request,
String content = classPathResource.getContentAsString(StandardCharsets.UTF_8);

// Replace the base path of the server
content = content.replace("MATCHBOX_BASE_PATH = \"/\"",
"MATCHBOX_BASE_PATH = \"%s\"".formatted(this.parent.baseServerPath));
content = content
.replace("MATCHBOX_BASE_PATH = \"/\"",
"MATCHBOX_BASE_PATH = \"%s\"".formatted(this.parent.baseServerPath))
.replace("MATCHBOX_VERSION = \"served-by-ng\"",
"MATCHBOX_VERSION = \"%s\"".formatted(VersionUtil.getVersion()));

return new TransformedResource(resource,
content.getBytes(StandardCharsets.UTF_8));
Expand Down
5 changes: 3 additions & 2 deletions matchbox-server/src/main/resources/static/browser/index.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 9b013cb

Please sign in to comment.