Skip to content

Commit

Permalink
fix(acanio-viewer): Upgrade acanio-viewer to 1.1.0 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayselafsar authored Dec 24, 2024
1 parent 1133a80 commit 29fbda4
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "acanio-viewer"]
path = acanio-viewer
url=https://github.com/acanio/acanio-viewer.git
url = https://github.com/acanio/acanio-viewer.git
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,25 @@ On your Nextcloud, simply navigate to Apps > Multimedia > DICOM Viewer, and enab

You can build the source code with the following steps:

1. Clone this repository on `path-to-nextcloud/apps`
1. Clone this project on `path-to-nextcloud/apps`

2. Change into the directory you have cloned this repository
```
git clone https://github.com/ayselafsar/dicomviewer.git
```

3. Run `npm run build` command to build source code
2. Navigate to the cloned project's directory

3. Update the submodule for viewer

```
git submodule update --init --recursive
```

3. Build the project

```
npm run build
```

4. Enable the DICOM Viewer app in Nextcloud

Expand Down
2 changes: 1 addition & 1 deletion acanio-viewer
Submodule acanio-viewer updated 2419 files
2 changes: 2 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
['name' => 'display#showDICOMViewerModeJson', 'url' => '/ncviewer/viewer/dicomjson', 'verb' => 'GET'],
['name' => 'display#getDICOMViewerFile', 'url' => '/ncviewer/{filepath}', 'verb' => 'GET'],
['name' => 'display#getDICOMViewerAsset', 'url' => '/ncviewer/assets/{assetpath}', 'verb' => 'GET'],
['name' => 'display#getDICOMViewerAssetImages', 'url' => '/ncviewer/assets/images/{assetpath}', 'verb' => 'GET'],
['name' => 'display#getDICOMViewerAssetSub', 'url' => '/ncviewer/viewer/assets/{assetpath}', 'verb' => 'GET'],
['name' => 'display#getDICOMViewerAssetSubImages', 'url' => '/ncviewer/viewer/assets/images/{assetpath}', 'verb' => 'GET'],
['name' => 'display#getDICOMJson', 'url' => '/dicomjson', 'verb' => 'GET'],
['name' => 'display#getPublicDICOMJson', 'url' => '/publicdicomjson', 'verb' => 'GET'],
]];
42 changes: 42 additions & 0 deletions lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,48 @@ public function getDICOMViewerAssetSub(string $assetpath): StreamResponse {
$response->addHeader('Cross-Origin-Opener-Policy', 'same-origin');
$response->addHeader('Cross-Origin-Embedder-Policy', 'require-corp');

return $response;
}

/**
* @PublicPage
* @NoCSRFRequired
*
* @param string $assetpath
* @return StreamResponse
*/
public function getDICOMViewerAssetImages(string $assetpath): StreamResponse {
$filename = str_replace('viewer/', '', $assetpath);
$fullFilePath = $this->publicViewerAssetsFolderPath . '/images/' . $filename;

$response = new StreamResponse(fopen($fullFilePath, 'rb'));
$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurldecode($filename) . '"');
$response->addHeader('Content-Type', $this->mimeTypeDetector->detectPath($fullFilePath));
$response->setContentSecurityPolicy($this->getContentSecurityPolicy());
$response->addHeader('Cross-Origin-Opener-Policy', 'same-origin');
$response->addHeader('Cross-Origin-Embedder-Policy', 'require-corp');

return $response;
}

/**
* @PublicPage
* @NoCSRFRequired
*
* @param string $assetpath
* @return StreamResponse
*/
public function getDICOMViewerAssetSubImages(string $assetpath): StreamResponse {
$filename = str_replace('viewer/', '', $assetpath);
$fullFilePath = $this->publicViewerAssetsFolderPath . '/images/' . $filename;

$response = new StreamResponse(fopen($fullFilePath, 'rb'));
$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurldecode($filename) . '"');
$response->addHeader('Content-Type', $this->mimeTypeDetector->detectPath($fullFilePath));
$response->setContentSecurityPolicy($this->getContentSecurityPolicy());
$response->addHeader('Cross-Origin-Opener-Policy', 'same-origin');
$response->addHeader('Cross-Origin-Embedder-Policy', 'require-corp');

return $response;
}

Expand Down

0 comments on commit 29fbda4

Please sign in to comment.