diff --git a/.gitmodules b/.gitmodules index d957373..3598054 100755 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index b10ab18..0803e22 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/acanio-viewer b/acanio-viewer index 7042319..ea9c6d5 160000 --- a/acanio-viewer +++ b/acanio-viewer @@ -1 +1 @@ -Subproject commit 7042319e2eb1f3d23219662e288783fb99d1a0f0 +Subproject commit ea9c6d50b581a82baad584ac9afbc27ef150cd43 diff --git a/appinfo/routes.php b/appinfo/routes.php index 4d5c159..f50d17b 100755 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -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'], ]]; diff --git a/lib/Controller/DisplayController.php b/lib/Controller/DisplayController.php index 47251fa..d388ff4 100755 --- a/lib/Controller/DisplayController.php +++ b/lib/Controller/DisplayController.php @@ -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; }